11
11
// RUN: %clang_cc1 -fsyntax-only -verify -pedantic %s -DTEST11
12
12
// RUN: %clang_cc1 -fsyntax-only -verify -pedantic %s -DTEST12
13
13
// RUN: %clang_cc1 -fsyntax-only -verify -pedantic %s -DTEST13
14
+ // RUN: %clang_cc1 -fsyntax-only -verify -pedantic %s -DTEST14
15
+ // RUN: %clang_cc1 -triple x86_64-linux -emit-llvm-only -verify -pedantic %s -DTEST15
14
16
15
17
#if TEST1
16
18
int main; // expected-error{{main cannot be declared as a variable in the global scope}}
@@ -78,12 +80,14 @@ namespace ns {
78
80
extern " C" struct A { int main (); }; // ok
79
81
80
82
namespace c {
81
- extern " C" void main (); // expected-warning {{'main' should not be 'extern "C"'}}
83
+ extern " C" void main (); // expected-error {{'main' must return 'int'}} \
84
+ // expected-warning {{'main' should not be 'extern "C"'}}
82
85
}
83
86
84
87
extern " C" {
85
88
namespace Z {
86
- void main (); // expected-warning {{'main' should not be 'extern "C"'}}
89
+ void main (); // expected-error {{'main' must return 'int'}} \
90
+ // expected-warning {{'main' should not be 'extern "C"'}}
87
91
}
88
92
}
89
93
@@ -102,11 +106,6 @@ extern "C++" {
102
106
int main (); // expected-warning {{'main' should not be 'extern "C++"'}}
103
107
}
104
108
105
- extern " C" {
106
- int main (); // expected-warning {{'main' should not be 'extern "C"'}}
107
- }
108
-
109
- extern " C" int main (); // expected-warning {{'main' should not be 'extern "C"'}}
110
109
extern " C++" int main (); // expected-warning {{'main' should not be 'extern "C++"'}}
111
110
112
111
namespace ns1 {
@@ -122,6 +121,21 @@ namespace ns2 {
122
121
extern " C++" void main () {} // ok
123
122
}
124
123
124
+ #elif TEST14
125
+ extern " C" {
126
+ int main (); // expected-warning {{'main' should not be 'extern "C"'}}
127
+ }
128
+
129
+ extern " C" int main (); // expected-warning {{'main' should not be 'extern "C"'}}
130
+
131
+ #elif TEST15
132
+ extern " C" __attribute__((visibility(" default" ))) __attribute__((weak))
133
+ int main (); // expected-warning {{'main' should not be 'extern "C"'}}
134
+
135
+ unsigned long g () {
136
+ return reinterpret_cast <unsigned long >(&main); // expected-warning {{referring to 'main' within an expression is a Clang extension}}
137
+ }
138
+
125
139
#else
126
140
#error Unknown Test
127
141
#endif
0 commit comments