1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -verify %s 2*f4a2713aSLionel Sambuc 3*f4a2713aSLionel Sambuc void foo(); 4*f4a2713aSLionel Sambuc void foo() __attribute__((unused)); 5*f4a2713aSLionel Sambuc void foo() __attribute__((unused)); foo()6*f4a2713aSLionel Sambucvoid foo(){} // expected-note {{previous definition is here}} 7*f4a2713aSLionel Sambuc void foo() __attribute__((constructor)); // expected-warning {{must precede definition}} 8*f4a2713aSLionel Sambuc void foo(); 9*f4a2713aSLionel Sambuc 10*f4a2713aSLionel Sambuc int bar; 11*f4a2713aSLionel Sambuc extern int bar; 12*f4a2713aSLionel Sambuc int bar; 13*f4a2713aSLionel Sambuc int bar __attribute__((weak)); 14*f4a2713aSLionel Sambuc int bar __attribute__((used)); 15*f4a2713aSLionel Sambuc extern int bar __attribute__((weak)); 16*f4a2713aSLionel Sambuc int bar = 0; // expected-note {{previous definition is here}} 17*f4a2713aSLionel Sambuc int bar __attribute__((weak)); // no warning as it matches the existing 18*f4a2713aSLionel Sambuc // attribute. 19*f4a2713aSLionel Sambuc int bar __attribute__((used, 20*f4a2713aSLionel Sambuc visibility("hidden"))); // expected-warning {{must precede definition}} 21*f4a2713aSLionel Sambuc int bar; 22*f4a2713aSLionel Sambuc 23*f4a2713aSLionel Sambuc struct zed { // expected-note {{previous definition is here}} 24*f4a2713aSLionel Sambuc }; 25*f4a2713aSLionel Sambuc struct __attribute__((visibility("hidden"))) zed; // expected-warning {{must precede definition}} 26*f4a2713aSLionel Sambuc 27*f4a2713aSLionel Sambuc struct __attribute__((visibility("hidden"))) zed2 { 28*f4a2713aSLionel Sambuc }; 29*f4a2713aSLionel Sambuc struct __attribute__((visibility("hidden"))) zed2; 30*f4a2713aSLionel Sambuc 31*f4a2713aSLionel Sambuc struct __attribute__((visibility("hidden"))) zed3 { // expected-note {{previous definition is here}} 32*f4a2713aSLionel Sambuc }; 33*f4a2713aSLionel Sambuc struct __attribute__((visibility("hidden"), 34*f4a2713aSLionel Sambuc packed // expected-warning {{must precede definition}} 35*f4a2713aSLionel Sambuc )) zed3; 36*f4a2713aSLionel Sambuc 37*f4a2713aSLionel Sambuc struct __attribute__((visibility("hidden"))) zed4 { // expected-note {{previous attribute is here}} 38*f4a2713aSLionel Sambuc }; 39*f4a2713aSLionel Sambuc struct __attribute__((visibility("default"))) zed4; // expected-error {{visibility does not match previous declaration}} 40