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