1 // RUN: %clang_cc1 -fsyntax-only -verify -std=gnu++11 %s
2 // RUN: %clang_cc1 -fsyntax-only -verify -Wno-c++11-extensions -Wno-local-type-template-args %s
3 // RUN: %clang_cc1 -fsyntax-only -verify -Wno-c++11-extensions -Wno-local-type-template-args -fmodules %s
6 int x; // expected-note {{previous definition is here}}
8 void f() {} // expected-note {{previous definition is here}}
11 extern int x; // expected-error {{declaration of 'x' has a different language linkage}}
12 extern int y; // OK, has internal linkage, so no language linkage.
13 void f(); // expected-error {{declaration of 'f' has a different language linkage}}
17 // This is OK. Both test2_f don't have language linkage since they have
20 static void test2_f() {
22 static void test2_f(int x) {
59 class __attribute__ ((__visibility__("default"))) shared_future;
62 template <class> friend class shared_future;
63 shared_future<_Rp> share();
65 template <class _Rp> future<_Rp>
68 struct shared_future<_Rp&> {
69 shared_future(future<_Rp&>&& __f);
75 shared_future<int&> f1 = get_future<int&>();
79 // This is OK. The variables have internal linkage and therefore no language
93 extern "C" { typedef int test7_F(); static test7_F test7_f; }
94 extern "C++" { extern test7_F test7_f; }
96 // FIXME: This should be invalid. The function has no language linkage, but
97 // the function type has, so this is redeclaring the function with a different
100 static void test8_f();
103 extern void test8_f();
106 static void test8_g();
109 extern void test8_g();
113 void __attribute__((overloadable)) test9_f(int c); // expected-note {{previous declaration is here}}
116 void __attribute__((overloadable)) test9_f(int c); // expected-error {{declaration of 'test9_f' has a different language linkage}}
120 void __attribute__((overloadable)) test10_f(int);
121 void __attribute__((overloadable)) test10_f(double);
126 void __attribute__((overloadable)) test11_g(int);
127 void __attribute__((overloadable)) test11_g(double);
142 static void a(void) {}
147 void a(void); // expected-note {{previous declaration is here}}
148 static void a(void) {} // expected-error {{static declaration of 'a' follows non-static declaration}}
153 const int a = 5; // expected-note {{previous definition is here}}
154 static const int a; // expected-error {{redefinition of 'a'}}
161 friend int bar(Foo *y);
174 template <typename T1, typename T2> void foo() {}
175 template <typename T, T x> void bar() {} // expected-note {{candidate function}}
179 // foo<L, I>'s linkage should be the merge of UniqueExternalLinkage (or
180 // InternalLinkage in c++11) and VisibleNoLinkage. The correct answer is
181 // NoLinkage in both cases. This means that using foo<L, I> as a template
182 // argument should fail.
183 return reinterpret_cast<void*>(bar<typeof(foo<L, I>), foo<L, I> >); // expected-error {{reinterpret_cast cannot resolve overloaded function 'bar' to type 'void *}}
191 template <typename T> struct foo {
192 template <T *P> static void f() {}
193 static void *g() { return (void *)f<&x>; }
196 template <typename T> T foo<T>::x;
202 void *h() { return f(); }
205 extern "C" void pr16247_foo(int);
206 static void pr16247_foo(double);
207 void pr16247_foo(int) {}
208 void pr16247_foo(double) {}
211 extern "C" void pr16247_bar(int);
212 static void pr16247_bar(double);
213 void pr16247_bar(int) {}
214 void pr16247_bar(double) {}