• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
2 
3 int f() __attribute__((internal_linkage));
4 
5 class A;
6 class __attribute__((internal_linkage)) A {
7 public:
8   int x __attribute__((internal_linkage)); // expected-warning{{'internal_linkage' attribute only applies to variables, functions and classes}}
9   static int y __attribute__((internal_linkage));
10   void f1() __attribute__((internal_linkage));
f2()11   void f2() __attribute__((internal_linkage)) {}
f3()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}}
A()15   A() __attribute__((internal_linkage)) {}
~A()16   ~A() __attribute__((internal_linkage)) {}
operator =(const A &)17   A& operator=(const A&) __attribute__((internal_linkage)) { return *this; }
18   struct {
19     int z  __attribute__((internal_linkage)); // expected-warning{{'internal_linkage' attribute only applies to variables, functions and classes}}
20   };
21 };
22 
f4()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 
27 namespace Z __attribute__((internal_linkage)) { // expected-warning{{'internal_linkage' attribute only applies to variables, functions and classes}}
28 }
29 
g()30 __attribute__((internal_linkage("foo"))) int g() {} // expected-error{{'internal_linkage' attribute takes no arguments}}
31 
h()32 [[clang::internal_linkage]] int h() {}
33 
34 enum struct __attribute__((internal_linkage)) E { // expected-warning{{'internal_linkage' attribute only applies to variables, functions and classes}}
35   a = 1,
36   b = 2
37 };
38 
39 int A::y;
40 
f1()41 void A::f1() {
42 }
43 
g(int a)44 void 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 }
48