1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fsyntax-only -verify %s 2*f4a2713aSLionel Sambuc 3*f4a2713aSLionel Sambuc // GCC will accept anything as the argument of weakref. Should we 4*f4a2713aSLionel Sambuc // check for an existing decl? 5*f4a2713aSLionel Sambuc static int a1() __attribute__((weakref ("foo"))); 6*f4a2713aSLionel Sambuc static int a2() __attribute__((weakref, alias ("foo"))); 7*f4a2713aSLionel Sambuc 8*f4a2713aSLionel Sambuc static int a3 __attribute__((weakref ("foo"))); 9*f4a2713aSLionel Sambuc static int a4 __attribute__((weakref, alias ("foo"))); 10*f4a2713aSLionel Sambuc 11*f4a2713aSLionel Sambuc // gcc rejects, clang accepts 12*f4a2713aSLionel Sambuc static int a5 __attribute__((alias ("foo"), weakref)); 13*f4a2713aSLionel Sambuc 14*f4a2713aSLionel Sambuc // this is pointless, but accepted by gcc. We reject it. 15*f4a2713aSLionel Sambuc static int a6 __attribute__((weakref)); //expected-error {{weakref declaration of 'a6' must also have an alias attribute}} 16*f4a2713aSLionel Sambuc 17*f4a2713aSLionel Sambuc // gcc warns, clang rejects 18*f4a2713aSLionel Sambuc void f(void) { 19*f4a2713aSLionel Sambuc static int a __attribute__((weakref ("v2"))); // expected-error {{declaration of 'a' must be in a global context}} 20*f4a2713aSLionel Sambuc } 21*f4a2713aSLionel Sambuc 22*f4a2713aSLionel Sambuc // both gcc and clang reject 23*f4a2713aSLionel Sambuc class c { 24*f4a2713aSLionel Sambuc static int a __attribute__((weakref ("v2"))); // expected-error {{declaration of 'a' must be in a global context}} 25*f4a2713aSLionel Sambuc static int b() __attribute__((weakref ("f3"))); // expected-error {{declaration of 'b' must be in a global context}} 26*f4a2713aSLionel Sambuc }; 27*f4a2713aSLionel Sambuc int a7() __attribute__((weakref ("f1"))); // expected-error {{weakref declaration must have internal linkage}} 28*f4a2713aSLionel Sambuc int a8 __attribute__((weakref ("v1"))); // expected-error {{weakref declaration must have internal linkage}} 29*f4a2713aSLionel Sambuc 30*f4a2713aSLionel Sambuc // gcc accepts this 31*f4a2713aSLionel Sambuc int a9 __attribute__((weakref)); // expected-error {{weakref declaration of 'a9' must also have an alias attribute}} 32*f4a2713aSLionel Sambuc 33*f4a2713aSLionel Sambuc static int a10(); 34*f4a2713aSLionel Sambuc int a10() __attribute__((weakref ("foo"))); 35*f4a2713aSLionel Sambuc 36*f4a2713aSLionel Sambuc static int v __attribute__((weakref(a1), alias("foo"))); // expected-error {{'weakref' attribute requires a string}} 37