1 // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fsyntax-only -verify -std=c++11 %s
3 static int test0
__attribute__((weak
)); // expected-error {{weak declaration cannot have internal linkage}}
4 static void test1() __attribute__((weak
)); // expected-error {{weak declaration cannot have internal linkage}}
6 namespace test2
__attribute__((weak
)) { // expected-warning {{'weak' attribute only applies to variables, functions, and classes}}
10 int test3
__attribute__((weak
)); // expected-error {{weak declaration cannot have internal linkage}}
11 void test4() __attribute__((weak
)); // expected-error {{weak declaration cannot have internal linkage}}
15 static void test5() __attribute__((weak
)); // no error
20 static void test6() __attribute__((weak
)); // expected-error {{weak declaration cannot have internal linkage}}
24 // GCC rejects the instantiation with the internal type, but some existing
25 // code expects it. It is also not that different from giving hidden visibility
26 // to parts of a template that have explicit default visibility, so we accept
28 template <class T
> struct Test7
{
29 void test7() __attribute__((weak
)) {}
30 static int var
__attribute__((weak
));
34 namespace { class Internal
{}; }
35 template struct Test7
<Internal
>;
36 template struct Test7
<int>;
38 class __attribute__((weak
)) Test8
{}; // OK
40 __attribute__((weak
)) auto Test9
= Internal(); // expected-error {{weak declaration cannot have internal linkage}}