Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 76 additions & 2 deletions specs/language/declarations.tex
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@
\textit{template-declaration}\br
\textit{type-alias-declaration}\br
...

\define{special-declaration}\br
\textit{export-declaration-group}\br
\textit{cbuffer-declaration-group}\br
...

\define{empty-declaration} \terminal{;}

\end{grammar}

\Sec{Specifiers}{Decl.Spec}
Expand Down Expand Up @@ -56,6 +56,80 @@
\p If a function is declared with an \texttt{export} specifier then all redeclarations of the same function must also use the \texttt{export} specifier or be part of \textit{export-declaration-group} (\ref{Decl.Export}).

\Sec{Declarators}{Decl.Decl}

\begin{grammar}
\define{init-declarator-list}\br
\textit{init-declarator}\br
\textit{init-declarator-list} \terminal{,} \textit{init-declarator}\br

\define{init-declarator}\br
\textit{declarator} \opt{initializer}\br

\define{declarator}\br
\textit{declarator-id} \opt{attribute-specifier-seq}\br
\textit{declarator} \textit{parameters-and-qualifiers}\br
\textit{declarator} \terminal{[} \opt{constant-expression} \terminal{]} \opt{attribute-specifier-seq}\br

\define{parameters-and-qualifiers}\br
\terminal{(} \textit{parameter-declaration-clause} \terminal{)} \opt{cv-qualifier-seq} \opt{attribute-specifier-seq}\br

\define{cv-qualifier-seq}\br
\textit{cv-qualifier} \opt{cv-qualifier-seq}\br

\define{cv-qualifier}\br
\terminal{const}\br

\define{declarator-id}\br
\textit{id-expression}\br

\end{grammar}

\Sub{Arrays}{Decl.arrays}
% This might need to nest deeper as we flesh out the sections.

\p A declaration \textit{T D} where \textit{D} is of the form

\begin{grammar}
\textit{D`} \terminal{[} \textit{N} \terminal{]} \opt{attribute-specifier-seq}\br
\end{grammar}

declares an array of \textit{N} \textit{T`}, where \textit{N} is the
\textit{array bound}, and \textit{T`} is the derived type of the declarator
\textit{D`} and is called the \textit{contained type} of the array. \textit{N}
shall be a constant expression converted to unsigned integer type and shall have
a value greater than zero.

\p A declaration \textit{T D} where \textit{D} is of the form

\begin{grammar}
\textit{D`} \terminal{[} \terminal{]} \opt{attribute-specifier-seq}\br
\end{grammar}

declares an array of unknown bound, except when the bound is implicitly derived
as described below. A declaration may only declare an array of unknown bound for
global declarations of resource objects (\ref{Resources}).

\p Array declarations may be nested to form multidimensional arrays. When
declaring a multidimensional array, only the first (outermost) dimension may
have an unknown bound; all inner dimensions must have known bounds.

\begin{note}
For example the declaration \texttt{int A[3][4];} declares \texttt{A} as an
array of 3 elements, each of which is an array of 4 integers.

Applying this example to the above grammar, \texttt{T} is \texttt{int},
\texttt{D} is \texttt{A[3][4]}, \texttt{D'} is \texttt{A[3]}, \texttt{N} is 3,
and \texttt{T'} is \texttt{int[4]}.
\end{note}

\p The contained type of an array of any form shall be a complete type.

\p A declarator with an omitted array bound is valid when declaring an object of
array type which is not a non-static data member and is initialized with an
initializer that follows the declarator. In this case the array bound is implied
by the number of elements provided by the initializer list following the rules
described in \ref{Decl.Init}.

\Sec{Initializers}{Decl.Init}

\p The process of initialization described in this section applies to all
Expand Down
5 changes: 5 additions & 0 deletions specs/language/expressions.tex
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,11 @@
(\ref{Overload}).\footnote{HLSL does not support the base address of a subscript
operator being the expression inside the braces, which is valid in C and C++.}

\p If the base object is of array, vector or matrix type, the index expression
must be of integer type or of a type that implicitly converts to integer type.
If the index expression evaluates to a value that is out-of-range for the base
object, the behavior is undefined.

\Sec{Function Calls}{Expr.Post.Call}

\p A function call may be an \textit{ordinary function}, or a \textit{member
Expand Down