Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / SemaCXX / linkage-spec.cpp
blob4be4b3fc3e7705ec6ba4d2de8db613954a66c4f5
1 // RUN: %clang_cc1 -fsyntax-only -verify %s
2 // RUN: %clang_cc1 -fsyntax-only -verify -Wretained-language-linkage -DW_RETAINED_LANGUAGE_LINKAGE %s
3 extern "C" {
4 extern "C" void f(int);
7 extern "C++" {
8 extern "C++" int& g(int);
9 float& g();
11 double& g(double);
13 void test(int x, double d) {
14 f(x);
15 float &f1 = g();
16 int& i1 = g(x);
17 double& d1 = g(d);
20 extern "C" int foo;
21 extern "C" int foo;
23 extern "C" const int bar;
24 extern "C" int const bar;
26 extern "C" struct bar d;
27 extern struct bar e;
29 extern "C++" {
30 namespace N0 {
31 struct X0 {
32 int foo(int x) { return x; }
37 // PR5430
38 namespace pr5430 {
39 extern "C" void func(void);
41 using namespace pr5430;
42 extern "C" void pr5430::func(void) { }
44 // PR5405
45 int f2(char *)
47 return 0;
50 extern "C"
52 int f2(int)
54 return f2((char *)0);
58 namespace PR5405 {
59 int f2b(char *) {
60 return 0;
63 extern "C" {
64 int f2b(int) {
65 return f2b((char *)0); // ok
70 // PR6991
71 extern "C" typedef int (*PutcFunc_t)(int);
74 // PR7859
75 extern "C" void pr7859_a(int) {} // expected-note {{previous definition}}
76 extern "C" void pr7859_a(int) {} // expected-error {{redefinition}}
78 extern "C" void pr7859_b() {} // expected-note {{previous definition}}
79 extern "C" void pr7859_b(int) {} // expected-error {{conflicting}}
81 extern "C" void pr7859_c(short) {} // expected-note {{previous definition}}
82 extern "C" void pr7859_c(int) {} // expected-error {{conflicting}}
84 extern "C" {
85 struct s0 {
86 private:
87 s0();
88 s0(const s0 &);
92 //PR7754
93 extern "C++" template <class T> int pr7754(T param);
95 namespace N {
96 int value;
99 extern "C++" using N::value;
101 // PR7076
102 extern "C" const char *Version_string = "2.9";
104 extern "C" {
105 extern const char *Version_string2 = "2.9";
108 namespace PR9162 {
109 extern "C" {
110 typedef struct _ArtsSink ArtsSink;
111 struct _ArtsSink {
112 int sink;
115 int arts_sink_get_type()
117 return sizeof(ArtsSink);
121 namespace pr14958 {
122 namespace js { extern int ObjectClass; }
123 extern "C" {
124 namespace js {}
126 int js::ObjectClass;
129 extern "C" void PR16167; // expected-error {{variable has incomplete type 'void'}}
130 extern void PR16167_0; // expected-error {{variable has incomplete type 'void'}}
132 // PR7927
133 enum T_7927 {
134 E_7927
137 extern "C" void f_pr7927(int);
139 namespace {
140 extern "C" void f_pr7927(int);
142 void foo_pr7927() {
143 f_pr7927(E_7927);
144 f_pr7927(0);
145 ::f_pr7927(E_7927);
146 ::f_pr7927(0);
150 void bar_pr7927() {
151 f_pr7927(E_7927);
152 f_pr7927(0);
153 ::f_pr7927(E_7927);
154 ::f_pr7927(0);
157 namespace PR17337 {
158 extern "C++" {
159 class Foo;
160 extern "C" int bar3(Foo *y);
161 class Foo {
162 int x;
163 friend int bar3(Foo *y);
164 #ifdef W_RETAINED_LANGUAGE_LINKAGE
165 // expected-note@-5 {{previous declaration is here}}
166 // expected-warning@-3 {{retaining previous language linkage}}
167 #endif
169 extern "C" int bar3(Foo *y) {
170 return y->x;