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
72 changes: 70 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,74 @@
\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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is the relationship between T and T'?

\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 The contained type of an array of either form shall be a complete type.

\begin{note}
An array of arrays may be declared with infinite nesting of array declarators
as long as either all array bounds are known, or only the outermost array
bound is unknown. This is codified in the spec above with the requirement that
the contained type of an array be a complete type.
\end{note}

\p A declarator with an omitted array bound is valid if the when declaring an
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove 'if the' before when? or remove 'the when' after if?

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
Copy link
Collaborator

@spall spall Oct 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this only allowed for global declarations of resource objects? or for all array declarations?

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
Loading