attr-weak.cpp revision 332bb2a2e3cd0a5af85758847a8050ae8ceee5f3
1// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fsyntax-only -verify %s 2 3static int test0 __attribute__((weak)); // expected-error {{weak declaration cannot have internal linkage}} 4static void test1() __attribute__((weak)); // expected-error {{weak declaration cannot have internal linkage}} 5 6namespace test2 __attribute__((weak)) { // expected-warning {{'weak' attribute only applies to variables and functions}} 7} 8 9namespace { 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}} 12} 13 14struct Test5 { 15 static void test5() __attribute__((weak)); // no error 16}; 17 18namespace { 19 struct Test6 { 20 static void test6() __attribute__((weak)); // expected-error {{weak declaration cannot have internal linkage}} 21 }; 22} 23 24template <class T> struct Test7 { 25 void test7() __attribute__((weak)) {} 26}; 27namespace { class Internal; } 28template struct Test7<Internal>; 29template struct Test7<int>; 30