-
Notifications
You must be signed in to change notification settings - Fork 77
Expand file tree
/
Copy pathtest.cpp
More file actions
179 lines (147 loc) · 5.92 KB
/
test.cpp
File metadata and controls
179 lines (147 loc) · 5.92 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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
int g1; // external linkage
extern int g2; // external linkage from explicit specification
const int g3 = 0; // internal linkage
extern const int g4 = 0; // external linkage
static int g5; // internal linkage
namespace ns1 { // named namespace as external linkage
int l1; // inherits external linkage from enclosing namespace
void f1() {} // inherits external linkage from enclosing namespace
enum e1 { // inherits external linkage from enclosing namespace
E1_1, // inherits external linkage from enumeration
E1_2 // inherits external linkage from enumeration
};
typedef enum {
E2_1,
E2_2 // inherits external linkage from enumeration
} e2; // inherits external linkage from enclosing namespace
template <typename T>
void f2(T p1) {} // inherits external linkage from enclosing namespace
class C1 { // inherits external linkage from enclosing namespace
int m1;
static int m2; // inherits external linkage from class scope
void m3() {} // inherits external linkage from class scope
enum e1 { E1_1 }; // inherits external linkage from class scope
typedef enum { E2_1 } e2; // inherits external linkage from class scope
class C2 { // inherits external linkage from class scope
int m1;
static int m2; // inherits external linkage from class scope
void m3() {} // inherits external linkage from class scope
}; // inherits external linkage from class scope
typedef class {
int m1;
// static int m2 not allowed in anonymous class
void m3() {} // inherits external linkage from class scope
} C3; // inherits external linkage from class scope
class {
int m1;
// static int m2 not allowed in unnamed class
void m3() {} // inherits no linkage from class scope
} m4; // anonymous class outside typedef has no linkage
};
typedef class { // inherits external linkage from enclosing namespace
int m1;
// static int m2 not allowed in anonymous class
void m3() {} // inherits external linkage from class scope
class C2 { // inherits external linkage from enclosing class scope
int m1;
// static int m2 not allowed in anonymous class
void m3() {} // inherits external linkage from class scope
};
typedef class { // inherits external linkage from enclosing namespace
int m1;
// static int m2 not allowed in anonymous class
void m3() {} // inherits external linkage from class scope
} C3; // inherits external linkage from enclosing namespace
class {
int m1;
// static int m2 not allowed in unnamed class
void m3() {} // inherits no linkage from class scope
} m4; // anonymous class outside typedef has no linkage
} C2;
template <typename T>
class C3 { // inherits external linkage from enclosing namespace
T m1;
};
} // namespace ns1
namespace { // unnamed namespace has internal linkage
namespace ns2 { // inherits internal linkage from unnamed namespace
int l1; // inherits internal linkage from enclosing namespace
void f1() {} // inherits internal linkage from enclosing namespace
enum e1 { // inherits internal linkage from enclosing namespace
E1_1, // inherits internal linkage from enumeration
E1_2 // inherits internal linkage from enumeration
};
typedef enum {
E2_1,
E2_2 // inherits internal linkage from enumeration
} e2; // inherits internal linkage from enclosing namespace
template <typename T>
void f2(T p1) {} // inherits internal linkage from enclosing namespace
class C1 { // inherits internal linkage from enclosing namespace
int m1;
static int m2; // inherits internal linkage from class scope
void m3() {} // inherits internal linkage from class scope
class C2 {
int m1;
static int m2; // inherits internal linkage from class scope
void m3() {} // inherits internal linkage from class scope
}; // inherits internal linkage from class scope
typedef struct {
int m1;
// static int m2 not allowed in anonymous class
void m3() {} // inherits internal linkage from class scope
} C3; // inherits internal linkage from class scope
class {
int m1;
// static int m2 not allowed in unnamed class
void m3() {} // inherits no linkage from class scope
} m4; // anonymous class outside typedef has no linkage
};
typedef class { // inherits internal linkage from enclosing namespace
int m1;
// static int m2 not allowed in anonymous class
void m3() {} // inherits internal linkage from class scope
class C2 {
int m1;
// static int m2 not allowed in anonymous class
void m3() {} // inherits internal linkage from class scope
}; // inherits internal linkage from class scope
typedef class { // inherits internal linkage from enclosing namespace
int m1;
// static int m2 not allowed in anonymous class
void m3() {} // inherits internal linkage from class scope
} C3; // inherits internal linkage from enclosing namespace
class {
int m1;
// static int m2 not allowed in unnamed class
void m3() {} // inherits no linkage from class scope
} m4; // anonymous class outside typedef has no linkage
} C2;
template <typename T>
class C3 { // inherits internal linkage from enclosing namespace
T m1;
};
} // namespace ns2
} // namespace
// The following example is from N3797 and represent a block scope case that is
// not supported.
static void f();
static int i; // internal linkage from static storage duration in global scope
void g() {
extern void f(); // internal linkage
int i; // object with automatic storage duration and no linkage inherited from
// block scope
{
extern int i; // object with static storage duration and external linkage
}
}
void block_scope() {
struct S { // No linkage, block scope
int m1;
void member() {} // No linkage, block scope
};
typedef struct { // No linkage, block scope
int m1;
void member() {} // No linkage, block scope
} S2;
}