Daniel Dunbar | a572887 | 2009-12-15 20:14:24 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -verify -std=c++0x %s |
Sean Hunt | bbd37c6 | 2009-11-21 08:43:09 +0000 | [diff] [blame] | 2 | |
| 3 | int final_fail [[final]]; //expected-error {{'final' attribute only applies to virtual method or class types}} |
| 4 | |
John McCall | 7c2342d | 2010-03-10 11:27:22 +0000 | [diff] [blame] | 5 | struct [[final]] final_base { }; // expected-note {{'final_base' declared here}} |
Sean Hunt | bbd37c6 | 2009-11-21 08:43:09 +0000 | [diff] [blame] | 6 | struct final_child : final_base { }; // expected-error {{derivation from 'final' struct final_base}} |
| 7 | |
| 8 | struct final_member { virtual void quux [[final]] (); }; // expected-note {{overridden virtual function is here}} |
| 9 | struct final_override : final_member { virtual void quux (); }; // expected-error {{declaration of 'quux' overrides a 'final' function}} |
| 10 | |
| 11 | int align_illegal [[align(3)]]; //expected-error {{requested alignment is not a power of 2}} |
| 12 | char align_big [[align(int)]]; |
| 13 | int align_small [[align(1)]]; |
| 14 | int align_multiple [[align(1), align(8), align(1)]]; |
| 15 | |
| 16 | struct align_member { |
| 17 | int member [[align(8)]]; |
| 18 | }; |
| 19 | |
| 20 | static_assert(alignof(align_big) == alignof(int), "k's alignment is wrong"); |
| 21 | static_assert(alignof(align_small) == alignof(int), "j's alignment is wrong"); |
| 22 | static_assert(alignof(align_multiple) == 8, "l's alignment is wrong"); |
| 23 | static_assert(alignof(align_member) == 8, "quuux's alignment is wrong"); |
| 24 | static_assert(sizeof(align_member) == 8, "quuux's size is wrong"); |
Sean Hunt | 7725e67 | 2009-11-25 04:20:27 +0000 | [diff] [blame] | 25 | |
| 26 | int bc_fail [[base_check]]; // expected-error {{'base_check' attribute only applies to class types}} |
| 27 | int hiding_fail [[hiding]]; // expected-error {{'hiding' attribute only applies to member types}} |
| 28 | int override_fail [[override]]; // expected-error {{'override' attribute only applies to virtual method types}} |
| 29 | |
| 30 | struct base { |
| 31 | virtual void function(); |
| 32 | virtual void other_function(); |
| 33 | }; |
| 34 | |
| 35 | struct [[base_check, base_check]] bc : base { // expected-error {{'base_check' attribute cannot be repeated}} |
Douglas Gregor | 9af2f52 | 2009-12-01 16:58:18 +0000 | [diff] [blame] | 36 | }; |