Daniel Dunbar | a572887 | 2009-12-15 20:14:24 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -verify %s |
Ryan Flynn | 478fbc6 | 2009-07-25 22:29:44 +0000 | [diff] [blame] | 2 | |
| 3 | void foo(); |
| 4 | void foo() __attribute__((unused)); |
| 5 | void foo() __attribute__((unused)); |
| 6 | void foo(){} // expected-note {{previous definition is here}} |
| 7 | void foo() __attribute__((constructor)); // expected-warning {{must precede definition}} |
| 8 | void foo(); |
| 9 | |
| 10 | int bar; |
| 11 | extern int bar; |
| 12 | int bar; |
| 13 | int bar __attribute__((weak)); |
| 14 | int bar __attribute__((used)); |
| 15 | extern int bar __attribute__((weak)); |
| 16 | int bar = 0; // expected-note {{previous definition is here}} |
Rafael Espindola | d320ffc | 2012-07-15 01:33:40 +0000 | [diff] [blame] | 17 | int bar __attribute__((weak)); // no warning as it matches the existing |
| 18 | // attribute. |
| 19 | int bar __attribute__((used, |
| 20 | visibility("hidden"))); // expected-warning {{must precede definition}} |
Ryan Flynn | 478fbc6 | 2009-07-25 22:29:44 +0000 | [diff] [blame] | 21 | int bar; |
| 22 | |
Rafael Espindola | 3f66406 | 2012-05-18 01:47:00 +0000 | [diff] [blame] | 23 | struct zed { // expected-note {{previous definition is here}} |
| 24 | }; |
| 25 | struct __attribute__((visibility("hidden"))) zed; // expected-warning {{must precede definition}} |
Rafael Espindola | d320ffc | 2012-07-15 01:33:40 +0000 | [diff] [blame] | 26 | |
| 27 | struct __attribute__((visibility("hidden"))) zed2 { |
| 28 | }; |
| 29 | struct __attribute__((visibility("hidden"))) zed2; |
| 30 | |
| 31 | struct __attribute__((visibility("hidden"))) zed3 { // expected-note {{previous definition is here}} |
| 32 | }; |
| 33 | struct __attribute__((visibility("hidden"), |
| 34 | packed // expected-warning {{must precede definition}} |
| 35 | )) zed3; |
| 36 | |
| 37 | struct __attribute__((visibility("hidden"))) zed4 { // expected-note {{previous attribute is here}} |
| 38 | }; |
| 39 | struct __attribute__((visibility("default"))) zed4; // expected-error {{visibility does not match previous declaration}} |