-
Notifications
You must be signed in to change notification settings - Fork 51
Array accesses and bounds #634
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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} | ||
|
@@ -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 | ||
\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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
There was a problem hiding this comment.
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'?