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