blob: 921a90ab4a41afc2b205dec0a79c7d2b0f74bfee [file] [log] [blame]
Evgeniy Stepanovae6ebd32015-11-10 21:28:44 +00001// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
2
3int f() __attribute__((internal_linkage));
4
5class A;
6class __attribute__((internal_linkage)) A {
7public:
Aaron Ballmanadf66b62017-11-26 20:01:12 +00008 int x __attribute__((internal_linkage)); // expected-warning{{'internal_linkage' attribute only applies to variables, functions, and classes}}
Evgeniy Stepanovae6ebd32015-11-10 21:28:44 +00009 static int y __attribute__((internal_linkage));
10 void f1() __attribute__((internal_linkage));
11 void f2() __attribute__((internal_linkage)) {}
12 static void f3() __attribute__((internal_linkage)) {}
13 void f4(); // expected-note{{previous definition is here}}
14 static int zz; // expected-note{{previous definition is here}}
15 A() __attribute__((internal_linkage)) {}
16 ~A() __attribute__((internal_linkage)) {}
17 A& operator=(const A&) __attribute__((internal_linkage)) { return *this; }
18 struct {
Aaron Ballmanadf66b62017-11-26 20:01:12 +000019 int z __attribute__((internal_linkage)); // expected-warning{{'internal_linkage' attribute only applies to}}
Evgeniy Stepanovae6ebd32015-11-10 21:28:44 +000020 };
21};
22
23__attribute__((internal_linkage)) void A::f4() {} // expected-error{{'internal_linkage' attribute does not appear on the first declaration of 'f4'}}
24
25__attribute__((internal_linkage)) int A::zz; // expected-error{{'internal_linkage' attribute does not appear on the first declaration of 'zz'}}
26
Aaron Ballmanadf66b62017-11-26 20:01:12 +000027namespace Z __attribute__((internal_linkage)) { // expected-warning{{'internal_linkage' attribute only applies to}}
Evgeniy Stepanovae6ebd32015-11-10 21:28:44 +000028}
29
30__attribute__((internal_linkage("foo"))) int g() {} // expected-error{{'internal_linkage' attribute takes no arguments}}
31
32[[clang::internal_linkage]] int h() {}
33
Aaron Ballmanadf66b62017-11-26 20:01:12 +000034enum struct __attribute__((internal_linkage)) E { // expected-warning{{'internal_linkage' attribute only applies to}}
Evgeniy Stepanovae6ebd32015-11-10 21:28:44 +000035 a = 1,
36 b = 2
37};
38
39int A::y;
40
41void A::f1() {
42}
43
44void g(int a [[clang::internal_linkage]]) { // expected-warning{{'internal_linkage' attribute only applies to variables, functions and classes}}
45 int x [[clang::internal_linkage]]; // expected-warning{{'internal_linkage' attribute on a non-static local variable is ignored}}
46 static int y [[clang::internal_linkage]];
47}