|
2519 | 2519 | both the \grammarterm{decl-specifier-seq} and its \grammarterm{declarator}.
|
2520 | 2520 |
|
2521 | 2521 | \pnum
|
2522 |
| -Thus, a declaration of a particular identifier has the form |
2523 |
| -\tcode{T} \tcode{D} where \tcode{T} |
2524 |
| -is of the form \opt{\grammarterm{attribute-specifier-seq}} |
2525 |
| -\grammarterm{decl-specifier-seq} |
2526 |
| -and \tcode{D} is a declarator. |
2527 |
| -Following is a recursive procedure for determining |
2528 |
| -the type specified for the contained |
2529 |
| -\grammarterm{declarator-id} |
2530 |
| -by such a declaration. |
| 2522 | +Thus, a declaration of a particular \grammarterm{declarator-id} has the form |
| 2523 | +\opt{\grammarterm{attribute-specifier-seq}} \grammarterm{decl-specifier-seq} |
| 2524 | +\grammarterm{declarator}. The optional \grammarterm{attribute-specifier-seq} |
| 2525 | +appertains to the declared entity. Following is a recursive procedure for |
| 2526 | +determining the type of the \grammarterm{declarator-id} and the entity which it declares. |
2531 | 2527 |
|
2532 | 2528 | \pnum
|
2533 |
| -First, the type \tcode{T} is determined. |
2534 |
| -In a declaration of the form |
2535 |
| -\begin{ncsimplebnf} |
2536 |
| -\opt{attribute-specifier-seq} decl-specifier-seq \terminal{D} |
2537 |
| -\end{ncsimplebnf} |
2538 |
| -the \grammarterm{decl-specifier-seq} determines the type \tcode{T}. |
2539 |
| -The optional \grammarterm{attribute-specifier-seq} appertains |
2540 |
| -to the entity declared by \tcode{D}. |
| 2529 | +First, a type \tcode{T} is determined from |
| 2530 | +the \grammarterm{decl-specifier-seq}. |
2541 | 2531 | \begin{example}
|
2542 | 2532 | In the declaration
|
2543 | 2533 | \begin{codeblock}
|
|
2551 | 2541 | \end{example}
|
2552 | 2542 |
|
2553 | 2543 | \pnum
|
2554 |
| -In a declaration \tcode{T} \tcode{D} |
2555 |
| -where \tcode{D} has the form |
| 2544 | +A \grammarterm{declarator} of the form |
2556 | 2545 | \begin{ncsimplebnf}
|
2557 | 2546 | declarator-id \opt{attribute-specifier-seq}
|
2558 | 2547 | \end{ncsimplebnf}
|
2559 |
| -the type of the \grammarterm{declarator-id} |
2560 |
| -in \tcode{D} is ``\tcode{T}''. |
| 2548 | +determines the type of its |
| 2549 | +\grammarterm{declarator-id} to be ``\tcode{T}''. |
2561 | 2550 | The optional \grammarterm{attribute-specifier-seq}
|
2562 |
| -appertains to the entity declared by \tcode{D}. |
| 2551 | +appertains to the declared entity. |
2563 | 2552 |
|
2564 | 2553 | \pnum
|
2565 |
| -In a declaration |
2566 |
| -\tcode{T} \tcode{D} where |
2567 |
| -\tcode{D} has the form |
2568 |
| -\begin{ncsimplebnf} |
2569 |
| -\terminal{(} \terminal{D1} \terminal{)} |
2570 |
| -\end{ncsimplebnf} |
2571 |
| -the type of the \grammarterm{declarator-id} |
2572 |
| -in \tcode{D} is the same as that of the |
2573 |
| -contained \grammarterm{declarator-id} |
2574 |
| -in the declaration \tcode{T} \tcode{D1}. |
| 2554 | +A \grammarterm{declarator} of the form \tcode{(D)} |
| 2555 | +determines the type of its \grammarterm{declarator-id} |
| 2556 | +to be that of the \grammarterm{declarator-id} |
| 2557 | +in the declaration \tcode{T} \tcode{D}. |
2575 | 2558 | \indextext{declaration!parentheses in}%
|
2576 | 2559 | \begin{note}
|
2577 | 2560 | Parentheses do not alter the type of the embedded
|
|
2583 | 2566 | \indextext{declarator!pointer}%
|
2584 | 2567 |
|
2585 | 2568 | \pnum
|
2586 |
| -In a declaration |
2587 |
| -\tcode{T} |
2588 |
| -\tcode{D} |
2589 |
| -where |
2590 |
| -\tcode{D} |
2591 |
| -has the form |
| 2569 | +A \grammarterm{declarator} of the form |
2592 | 2570 | \begin{ncsimplebnf}
|
2593 |
| -\terminal{*} \opt{attribute-specifier-seq} \opt{cv-qualifier-seq} \terminal{D1} |
| 2571 | +\terminal{*} \opt{attribute-specifier-seq} \opt{cv-qualifier-seq} \terminal{D} |
2594 | 2572 | \end{ncsimplebnf}
|
2595 |
| -and the type of the contained |
2596 |
| -\grammarterm{declarator-id} |
2597 |
| -in the declaration |
2598 |
| -\tcode{T} |
2599 |
| -\tcode{D1} |
2600 |
| -is ``\placeholder{derived-declarator-type-list} |
2601 |
| -\tcode{T}'', |
2602 |
| -then the type of the |
2603 |
| -\grammarterm{declarator-id} |
2604 |
| -in |
2605 |
| -\tcode{D} |
2606 |
| -is ``\placeholder{derived-declarator-type-list} \grammarterm{cv-qualifier-seq} pointer to |
2607 |
| -\tcode{T}''. |
| 2573 | +determines the type of its \grammarterm{declarator-id} to be |
| 2574 | +that of the \grammarterm{declarator-id} in the declaration |
| 2575 | +\tcode{U} \tcode{D}, where \tcode{U} is a \grammarterm{type-specifier} denoting |
| 2576 | +the type ``\grammarterm{cv-qualifier-seq} pointer to \tcode{T}''. |
2608 | 2577 | \indextext{declaration!pointer}%
|
2609 | 2578 | \indextext{declaration!constant pointer}%
|
2610 |
| -The |
2611 |
| -\grammarterm{cv-qualifier}{s} |
2612 |
| -apply to the pointer and not to the object pointed to. |
2613 |
| -Similarly, the optional \grammarterm{attribute-specifier-seq}\iref{dcl.attr.grammar} appertains to the pointer and not to the object pointed to. |
| 2579 | +The \grammarterm{cv-qualifier}{s} apply to the pointer |
| 2580 | +and not to the object pointed to. |
| 2581 | +Similarly, the optional \grammarterm{attribute-specifier-seq}\iref{dcl.attr.grammar} |
| 2582 | +appertains to the pointer and not to the object pointed to. |
2614 | 2583 |
|
2615 | 2584 | \pnum
|
2616 | 2585 | \begin{example}
|
|
2692 | 2661 | \indextext{declarator!reference}
|
2693 | 2662 |
|
2694 | 2663 | \pnum
|
2695 |
| -In a declaration |
2696 |
| -\tcode{T} |
2697 |
| -\tcode{D} |
2698 |
| -where |
2699 |
| -\tcode{D} |
2700 |
| -has either of the forms |
| 2664 | +A \grammarterm{declarator} having either of the forms |
2701 | 2665 | \begin{ncsimplebnf}
|
2702 |
| -\terminal{\&} \opt{attribute-specifier-seq} \terminal{D1}\br |
2703 |
| -\terminal{\&\&} \opt{attribute-specifier-seq} \terminal{D1} |
| 2666 | +\terminal{\&} \opt{attribute-specifier-seq} \terminal{D}\br |
| 2667 | +\terminal{\&\&} \opt{attribute-specifier-seq} \terminal{D} |
2704 | 2668 | \end{ncsimplebnf}
|
2705 |
| -and the type of the contained |
2706 |
| -\grammarterm{declarator-id} |
2707 |
| -in the declaration |
2708 |
| -\tcode{T} |
2709 |
| -\tcode{D1} |
2710 |
| -is ``\placeholder{derived-declarator-type-list} |
2711 |
| -\tcode{T}'', |
2712 |
| -then the type of the |
2713 |
| -\grammarterm{declarator-id} |
2714 |
| -in |
2715 |
| -\tcode{D} |
2716 |
| -is ``\placeholder{derived-declarator-type-list} reference to |
2717 |
| -\tcode{T}''. |
| 2669 | +determines the type of its \grammarterm{declarator-id} to be |
| 2670 | +that of the \grammarterm{declarator-id} in the declaration |
| 2671 | +\tcode{U} \tcode{D}, where \tcode{U} is a \grammarterm{type-specifier} |
| 2672 | +denoting the type ``reference to \tcode{T}''. |
2718 | 2673 | The optional \grammarterm{attribute-specifier-seq} appertains to the reference type.
|
2719 | 2674 | Cv-qualified references are ill-formed except when the cv-qualifiers
|
2720 | 2675 | are introduced through the use of a
|
|
2883 | 2838 | \indextext{pointer to member}%
|
2884 | 2839 |
|
2885 | 2840 | \pnum
|
2886 |
| -In a declaration |
2887 |
| -\tcode{T} |
2888 |
| -\tcode{D} |
2889 |
| -where |
2890 |
| -\tcode{D} |
2891 |
| -has the form |
| 2841 | +A \grammarterm{declarator} of the form |
2892 | 2842 | \begin{ncsimplebnf}
|
2893 |
| -nested-name-specifier \terminal{*} \opt{attribute-specifier-seq} \opt{cv-qualifier-seq} \terminal{D1} |
| 2843 | +nested-name-specifier \terminal{*} \opt{attribute-specifier-seq} \opt{cv-qualifier-seq} \terminal{D} |
2894 | 2844 | \end{ncsimplebnf}
|
2895 |
| -and the |
2896 |
| -\grammarterm{nested-name-specifier} |
2897 |
| -denotes a class, |
2898 |
| -and the type of the contained |
2899 |
| -\grammarterm{declarator-id} |
2900 |
| -in the declaration |
2901 |
| -\tcode{T} |
2902 |
| -\tcode{D1} |
2903 |
| -is ``\placeholder{derived-declarator-type-list} |
2904 |
| -\tcode{T}'', |
2905 |
| -then the type of the |
2906 |
| -\grammarterm{declarator-id} |
2907 |
| -in |
2908 |
| -\tcode{D} |
2909 |
| -is ``\placeholder{derived-declarator-type-list} \grammarterm{cv-qualifier-seq} pointer to member of class |
2910 |
| -\grammarterm{nested-name-specifier} of type |
2911 |
| -\tcode{T}''. |
2912 |
| -The optional \grammarterm{attribute-specifier-seq}\iref{dcl.attr.grammar} appertains to the |
2913 |
| -pointer-to-member. |
| 2845 | +where the \grammarterm{nested-name-specifier} denotes a class type |
| 2846 | +determines the type of its \grammarterm{declarator-id} to be |
| 2847 | +that of the \grammarterm{declarator-id} in the declaration |
| 2848 | +\tcode{U} \tcode{D}, where \tcode{U} is a \grammarterm{type-specifier} |
| 2849 | +denoting the type ``\grammarterm{cv-qualifier-seq} pointer to member of class |
| 2850 | +\grammarterm{nested-name-specifier} of type \tcode{T}''. |
| 2851 | +The optional \grammarterm{attribute-specifier-seq}\iref{dcl.attr.grammar} |
| 2852 | +appertains to the pointer-to-member. |
2914 | 2853 |
|
2915 | 2854 | \pnum
|
2916 | 2855 | \begin{example}
|
|
2992 | 2931 | \indextext{declarator!array}
|
2993 | 2932 |
|
2994 | 2933 | \pnum
|
2995 |
| -In a declaration \tcode{T} \tcode{D} where \tcode{D} has the form |
| 2934 | +A \grammarterm{declarator} of the form |
2996 | 2935 | \begin{ncsimplebnf}
|
2997 |
| -\terminal{D1} \terminal{[} \opt{constant-expression} \terminal{]} \opt{attribute-specifier-seq} |
| 2936 | +\terminal{D} \terminal{[} constant-expression \terminal{]} \opt{attribute-specifier-seq} |
2998 | 2937 | \end{ncsimplebnf}
|
2999 |
| -and the type of the contained \grammarterm{declarator-id} |
3000 |
| -in the declaration \tcode{T} \tcode{D1} |
3001 |
| -is ``\placeholder{derived-declarator-type-list} \tcode{T}'', |
3002 |
| -the type of the \grammarterm{declarator-id} in \tcode{D} is |
3003 |
| -``\placeholder{derived-declarator-type-list} array of \tcode{N} \tcode{T}''. |
3004 |
| -The \grammarterm{constant-expression} |
3005 |
| -shall be a converted constant expression of type \tcode{std::size_t}\iref{expr.const}. |
| 2938 | +where the \grammarterm{constant-expression} is a converted constant expression |
| 2939 | +of type \tcode{std::size_t}\iref{expr.const} |
| 2940 | +determines the type of its \grammarterm{declarator-id} to be |
| 2941 | +that of the \grammarterm{declarator-id} in the declaration |
| 2942 | +\tcode{U} \tcode{D}, where \tcode{U} is a \grammarterm{type-specifier} |
| 2943 | +denoting the type ``array of \tcode{N} \tcode{T}'' and \tcode{N} is the |
| 2944 | +value of the \grammarterm{constant-expression}. |
3006 | 2945 | \indextext{bound, of array}%
|
3007 |
| -Its value \tcode{N} specifies the \defnx{array bound}{array!bound}, |
3008 |
| -i.e., the number of elements in the array; |
3009 |
| -\tcode{N} shall be greater than zero. |
| 2946 | +The \defnx{array bound}{array!bound} \tcode{N} shall be greater than zero. |
| 2947 | +The optional \grammarterm{attribute-specifier-seq} |
| 2948 | +appertains to the array type. |
3010 | 2949 |
|
3011 | 2950 | \pnum
|
3012 |
| -In a declaration \tcode{T} \tcode{D} where \tcode{D} has the form |
| 2951 | +A \grammarterm{declarator} of the form |
3013 | 2952 | \begin{ncsimplebnf}
|
3014 |
| -\terminal{D1 [ ]} \opt{attribute-specifier-seq} |
| 2953 | +\terminal{D [ ]} \opt{attribute-specifier-seq} |
3015 | 2954 | \end{ncsimplebnf}
|
3016 |
| -and the type of the contained \grammarterm{declarator-id} |
3017 |
| -in the declaration \tcode{T} \tcode{D1} |
3018 |
| -is ``\placeholder{derived-declarator-type-list} \tcode{T}'', |
3019 |
| -the type of the \grammarterm{declarator-id} in \tcode{D} is |
3020 |
| -``\placeholder{derived-declarator-type-list} array of unknown bound of \tcode{T}'', except as specified below. |
| 2955 | +determines the type of its \grammarterm{declarator-id} to be |
| 2956 | +that of the \grammarterm{declarator-id} in the declaration |
| 2957 | +\tcode{U} \tcode{D}, where \tcode{U} is a \grammarterm{type-specifier} |
| 2958 | +denoting the type ``array of unknown bound of \tcode{T}'', except as specified below. |
| 2959 | +The optional \grammarterm{attribute-specifier-seq} appertains to the array type. |
3021 | 2960 |
|
3022 | 2961 | \pnum
|
3023 | 2962 | \indextext{declaration!array}%
|
3024 |
| -A type of the form ``array of \tcode{N} \tcode{U}'' or |
3025 |
| -``array of unknown bound of \tcode{U}'' is an \defn{array type}. |
3026 |
| -The optional \grammarterm{attribute-specifier-seq} |
3027 |
| -appertains to the array type. |
3028 |
| - |
3029 |
| -\pnum |
3030 |
| -\tcode{U} is called the array \defn{element type}; |
| 2963 | +A type of the form ``array of \tcode{N} \tcode{E}'' or |
| 2964 | +``array of unknown bound of \tcode{E}'' is an \defn{array type}. |
| 2965 | +\tcode{E} is called the array \defn{element type}; |
3031 | 2966 | this type shall not be
|
3032 | 2967 | a placeholder type\iref{dcl.spec.auto},
|
3033 | 2968 | a reference type,
|
|
3053 | 2988 |
|
3054 | 2989 | \pnum
|
3055 | 2990 | Any type of the form
|
3056 |
| -``\grammarterm{cv-qualifier-seq} array of \tcode{N} \tcode{U}'' |
| 2991 | +``\grammarterm{cv-qualifier-seq} array of \tcode{N} \tcode{E}'' |
3057 | 2992 | is adjusted to
|
3058 |
| -``array of \tcode{N} \grammarterm{cv-qualifier-seq} \tcode{U}'', |
3059 |
| -and similarly for ``array of unknown bound of \tcode{U}''. |
| 2993 | +``array of \tcode{N} \grammarterm{cv-qualifier-seq} \tcode{E}'', |
| 2994 | +and similarly for ``array of unknown bound of \tcode{E}''. |
3060 | 2995 | \begin{example}
|
3061 | 2996 | \begin{codeblock}
|
3062 | 2997 | typedef int A[5], AA[2][3];
|
|
3065 | 3000 | \end{codeblock}
|
3066 | 3001 | \end{example}
|
3067 | 3002 | \begin{note}
|
3068 |
| -An ``array of \tcode{N} \grammarterm{cv-qualifier-seq} \tcode{U}'' |
| 3003 | +An ``array of \tcode{N} \grammarterm{cv-qualifier-seq} \tcode{E}'' |
3069 | 3004 | has cv-qualified type; see~\ref{basic.type.qualifier}.
|
3070 | 3005 | \end{note}
|
3071 | 3006 |
|
3072 | 3007 | \pnum
|
3073 |
| -An object of type ``array of \tcode{N} \tcode{U}'' contains |
| 3008 | +An object of type ``array of \tcode{N} \tcode{E}'' contains |
3074 | 3009 | a contiguously allocated non-empty set
|
3075 |
| -of \tcode{N} subobjects of type \tcode{U}, |
| 3010 | +of \tcode{N} subobjects of type \tcode{E}, |
3076 | 3011 | known as the \defnx{elements}{array!element} of the array,
|
3077 | 3012 | and numbered \tcode{0} to \tcode{N-1}.
|
3078 | 3013 |
|
|
3088 | 3023 | In these cases, the array bound is calculated
|
3089 | 3024 | from the number of initial elements (say, \tcode{N})
|
3090 | 3025 | supplied\iref{dcl.init.aggr},
|
3091 |
| -and the type of the array is ``array of \tcode{N} \tcode{U}''. |
| 3026 | +and the type of the array is ``array of \tcode{N} \tcode{E}''. |
3092 | 3027 |
|
3093 | 3028 | \pnum
|
3094 | 3029 | Furthermore, if there is a preceding declaration of the entity in the same
|
|
3194 | 3129 |
|
3195 | 3130 | \pnum
|
3196 | 3131 | \indextext{type!function}%
|
3197 |
| -In a declaration |
3198 |
| -\tcode{T} |
3199 |
| -\tcode{D} |
3200 |
| -where |
3201 |
| -\tcode{D} |
3202 |
| -has the form |
| 3132 | +A \grammarterm{declarator} of the form |
3203 | 3133 | \begin{ncsimplebnf}
|
3204 |
| -\terminal{D1} \terminal{(} parameter-declaration-clause \terminal{)} \opt{cv-qualifier-seq}\br |
| 3134 | +\terminal{D} \terminal{(} parameter-declaration-clause \terminal{)} \opt{cv-qualifier-seq}\br |
3205 | 3135 | \bnfindent\opt{ref-qualifier} \opt{noexcept-specifier} \opt{attribute-specifier-seq}
|
3206 | 3136 | \end{ncsimplebnf}
|
3207 |
| -and the type of the contained |
3208 |
| -\grammarterm{declarator-id} |
3209 |
| -in the declaration |
3210 |
| -\tcode{T} |
3211 |
| -\tcode{D1} |
3212 |
| -is |
3213 |
| -``\placeholder{derived-declarator-type-list} |
3214 |
| -\tcode{T}'', |
3215 |
| -the type of the |
3216 |
| -\grammarterm{declarator-id} |
3217 |
| -in |
3218 |
| -\tcode{D} |
3219 |
| -is |
3220 |
| -``\placeholder{derived-declarator-type-list} |
3221 |
| -\opt{\tcode{noexcept}} |
3222 |
| -function of parameter-type-list |
| 3137 | +determines the type of its \grammarterm{declarator-id} to be |
| 3138 | +that of the \grammarterm{declarator-id} in the declaration |
| 3139 | +\tcode{U} \tcode{D}, where \tcode{U} is a \grammarterm{type-specifier} |
| 3140 | +denoting the type ``\opt{\tcode{noexcept}} function of parameter-type-list |
3223 | 3141 | \opt{\grammarterm{cv-qualifier-seq}} \opt{\grammarterm{ref-qualifier}}
|
3224 |
| -returning \tcode{T}'', where |
| 3142 | +returning \tcode{T}'', and |
3225 | 3143 | \begin{itemize}
|
3226 | 3144 | \item
|
3227 | 3145 | the parameter-type-list is derived from
|
|
3231 | 3149 | the exception specification\iref{except.spec} is non-throwing.
|
3232 | 3150 | \end{itemize}
|
3233 | 3151 | The optional \grammarterm{attribute-specifier-seq}
|
3234 |
| -appertains to the function type. |
| 3152 | +appertains to the function type. |
3235 | 3153 |
|
3236 | 3154 | \pnum
|
3237 |
| -In a declaration |
3238 |
| -\tcode{T} |
3239 |
| -\tcode{D} |
3240 |
| -where |
3241 |
| -\tcode{D} |
3242 |
| -has the form |
| 3155 | +A \grammarterm{declarator} of the form |
3243 | 3156 | \begin{ncsimplebnf}
|
3244 |
| -\terminal{D1} \terminal{(} parameter-declaration-clause \terminal{)} \opt{cv-qualifier-seq}\br |
| 3157 | +\terminal{D} \terminal{(} parameter-declaration-clause \terminal{)} \opt{cv-qualifier-seq}\br |
3245 | 3158 | \bnfindent\opt{ref-qualifier} \opt{noexcept-specifier} \opt{attribute-specifier-seq} trailing-return-type
|
3246 | 3159 | \end{ncsimplebnf}
|
3247 |
| -and the type of the contained |
3248 |
| -\grammarterm{declarator-id} |
3249 |
| -in the declaration |
3250 |
| -\tcode{T} |
3251 |
| -\tcode{D1} |
3252 |
| -is |
3253 |
| -``\placeholder{derived-declarator-type-list} \tcode{T}'', |
3254 |
| -\tcode{T} shall be the single \grammarterm{type-specifier} \tcode{auto}. |
3255 |
| -The type of the |
3256 |
| -\grammarterm{declarator-id} |
3257 |
| -in |
3258 |
| -\tcode{D} |
3259 |
| -is |
3260 |
| -``\placeholder{derived-declarator-type-list} |
3261 |
| -\opt{\tcode{noexcept}} |
3262 |
| -function of parameter-type-list |
| 3160 | +where \tcode{T} has the form ``\placeholder{type-list} \tcode{auto}'', |
| 3161 | +the type of its \grammarterm{declarator-id} is determined to be |
| 3162 | +that of the \grammarterm{declarator-id} in the declaration |
| 3163 | +\tcode{U} \tcode{D}, where \tcode{U} is a \grammarterm{type-specifier} |
| 3164 | +denoting the type ``\opt{\tcode{noexcept}} function of parameter-type-list |
3263 | 3165 | \opt{\grammarterm{cv-qualifier-seq}} \opt{\grammarterm{ref-qualifier}}
|
3264 |
| -returning \tcode{U}'', where |
| 3166 | +returning \tcode{V}'', and |
3265 | 3167 | \begin{itemize}
|
3266 | 3168 | \item
|
3267 | 3169 | the parameter-type-list is derived from
|
3268 | 3170 | the \grammarterm{parameter-declaration-clause} as described below,
|
3269 | 3171 | \item
|
3270 |
| -\tcode{U} is the type specified by the \grammarterm{trailing-return-type}, and |
| 3172 | +\tcode{V} is the type specified by the \grammarterm{trailing-return-type}, and |
3271 | 3173 | \item
|
3272 | 3174 | the optional \tcode{noexcept} is present if and only if
|
3273 | 3175 | the exception specification is non-throwing.
|
|
0 commit comments