-
Notifications
You must be signed in to change notification settings - Fork 56
Expand file tree
/
Copy pathdeclarations.tex
More file actions
124 lines (92 loc) · 4.71 KB
/
declarations.tex
File metadata and controls
124 lines (92 loc) · 4.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
\Ch{Declarations}{Decl}
\Sec{Preamble}{Decl.Pre}
\p Declarations generally specify how names are to be interpreted. Declarations have the form
\begin{grammar}
\define{declaration-seq}\br
\textit{declaration}\br
\textit{declaration-seq declaration}
\define{declaration}\br
\textit{name-declaration}\br
\textit{special-declaration}
\define{name-declaration}\br
...
\define{special-declaration}\br
\textit{export-declaration-group}\br
...
\end{grammar}
\Sec{Specifiers}{Decl.Spec}
\Sub{General}{Decl.Spec.General}
\p The specifiers that can be used in a declaration are
\begin{grammar}
\define{decl-specifier}\br
\textit{function-specifier}\br
...
\end{grammar}
\Sub{Function specifiers}{Decl.Spec.Fct}
\p A \textit{function-specifier} can be used only in a function declaration.
\begin{grammar}
\define{function-specifier}\br
\texttt{export}\br
\end{grammar}
\p The \texttt{export} specifier denotes that the function has program linkage (\ref{Basic.Linkage.Program}).
\p The \texttt{export} specifier cannot be used on functions directly or indirectly within an unnamed namespace.
\p Functions with program linkage can also be specified in \textit{export-declaration-group} (\ref{Decl.Export}).
\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}
\Sec{Initializers}{Decl.Init}
\p The process of initialization described in this section applies to all
initializers regardless of the context.
\begin{grammar}
\define{initializer}\br
brace-or-equal-initializer\br
\terminal{(} expression-list \terminal{)}\br
\define{brace-or-equal-initializer}\br
\terminal{=} initializer-clause\br
braced-init-list\br
\define{initializer-clause}\br
assignment-expression\br
braced-init-list\br
\define{braced-init-list}\br
\terminal{\{} initializer-list \opt{\terminal{,}} \terminal{\}}\br
\terminal{\{} \terminal{\}}\br
\define{initializer-list}\br
initializer-clause\br
initializer-list \terminal{,} initializer-clause\br
\end{grammar}
\Sub{Aggregate Initialization}{Decl.Init.Agg}
\p An \textit{aggregate} is a vector, matrix, array, or class that does not have
explicit constructors (\ref{Classes.Special}) or non-public data members
(\ref{Classes.Access}). An aggregate may contain non-aggregate members as long
as the non-aggregate members have default constructors and copy constructors
defined.
\p Each \textit{braced initializer list} is comprised of zero or more
\textit{initializer-clause} expressions, which is either another braced
initializer list or an expression which generates a value that either is or can
be implicitly converted to an rvalue. Each assignment-expression is an object,
which may be a scalar or aggregate type. A \textit{element-wise initializer
sequence} is constructed by concatenating the scalar element ordering
(\ref{Intro.Object.SubOrdering}) of each initializer-clause.
\p An initializer-list is a valid initializer if for each element \(E_n\) in the
target object's scalar element ordering there is a corresponding initializer
\(I_n\) in the element-wise initializer sequence which can be implicitly
converted to the element's type.
\p An initializer-list is invalid if the element-wise initializer sequence
contains more or fewer elements than the target object's scalar element
ordering, or if any initializer \(I_n\) cannot be implicitly converted to the
corresponding element \(E_n\)'s type.
\Sec{Function Definitions}{Decl.Function}
\Sec{Attributes}{Decl.Attr}
\Sub{Semantic Annotations}{Decl.Attr.Semantic}
\Sub{Entry Attributes}{Decl.Attr.Entry}
\Sec{Export Declarations}{Decl.Export}
\p One or more functions with \textit{external linkage} can be also specified in the form of
\begin{grammar}
\define{export-declaration-group}\br
\texttt{export} \terminal{\{} \opt{function-declaration-seq} \terminal{\}}\br
\define{function-declaration-seq}\br
\textit{function-declaration} \opt{function-declaration-seq}
\end{grammar}
\p The \texttt{export} specifier denotes that every \textit{function-declaration} included in \textit{function-declaration-seq} has \textit{external linkage} (\ref{Basic.Linkage.External}).
\p The \textit{export-declaration-group} declaration cannot appear directly or indirectly within an unnamed namespace.
\p Functions with \textit{external linkage} can also be declared with an \texttt{export} specifier (\ref{Decl.Spec.Fct}).
\p If a function is part of an \textit{export-declaration-group} then all redeclarations of the same function must also be part on a \textit{export-declaration-group} or be declared with an \texttt{export} specifier (\ref{Decl.Spec.Fct}).