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 | // Declaration syntax checks |
| 4 | [[]] int before_attr; |
| 5 | int after_attr [[]]; |
| 6 | int * [[]] ptr_attr; |
| 7 | int array_attr [1] [[]]; |
| 8 | [[align(8)]] int aligned_attr; |
| 9 | [[test::valid(for 42 [very] **** '+' symbols went on a trip; the end.)]] |
| 10 | int garbage_attr; |
| 11 | void fn_attr () [[]]; |
| 12 | class [[]] class_attr {}; |
| 13 | extern "C++" [[]] int extern_attr; |
| 14 | template <typename T> [[]] void template_attr (); |
| 15 | |
| 16 | int comma_attr [[,]]; // expected-error {{expected identifier}} |
| 17 | int scope_attr [[foo::]]; // expected-error {{expected identifier}} |
| 18 | int & [[]] ref_attr = after_attr; // expected-error {{an attribute list cannot appear here}} |
| 19 | class foo { |
| 20 | void after_const_attr () const [[]]; // expected-error {{expected expression}} |
| 21 | }; |
| 22 | extern "C++" [[]] { } // expected-error {{an attribute list cannot appear here}} |
| 23 | [[]] template <typename T> void before_template_attr (); // expected-error {{an attribute list cannot appear here}} |
| 24 | [[]] namespace ns { int i; } // expected-error {{an attribute list cannot appear here}} |
| 25 | [[]] static_assert(true, ""); //expected-error {{an attribute list cannot appear here}} |
| 26 | [[]] asm(""); // expected-error {{an attribute list cannot appear here}} |
| 27 | |
| 28 | [[]] using ns::i; // expected-error {{an attribute list cannot appear here}} |
| 29 | [[]] using namespace ns; |
| 30 | |
| 31 | // Argument tests |
| 32 | [[final()]] int final_params; // expected-error {{C++0x attribute 'final' cannot have an argument list}} |
| 33 | [[align]] int aligned_no_params; // expected-error {{C++0x attribute 'align' must have an argument list}} |
| 34 | [[align(i)]] int aligned_nonconst; // expected-error {{'aligned' attribute requires integer constant}} |
| 35 | |
| 36 | // Statement tests |
| 37 | void foo () { |
| 38 | [[]] ; |
| 39 | [[]] { } |
| 40 | [[]] if (0) { } |
| 41 | [[]] for (;;); |
| 42 | [[]] do { |
| 43 | [[]] continue; |
| 44 | } while (0); |
| 45 | [[]] while (0); |
| 46 | |
| 47 | [[]] switch (i) { |
| 48 | [[]] case 0: |
| 49 | [[]] default: |
| 50 | [[]] break; |
| 51 | } |
| 52 | |
| 53 | [[]] goto there; |
| 54 | [[]] there: |
| 55 | |
| 56 | [[]] try { |
| 57 | } [[]] catch (...) { // expected-error {{an attribute list cannot appear here}} |
| 58 | } |
| 59 | |
| 60 | [[]] return; |
| 61 | } |