blob: f65e290709575ad238e295bae97e87cbde2143e5 [file] [log] [blame]
Anders Carlssonabea9512011-02-28 00:40:07 +00001// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -fsyntax-only -verify -std=c++0x %s
Sean Huntbbd37c62009-11-21 08:43:09 +00002
3// Declaration syntax checks
4[[]] int before_attr;
5int after_attr [[]];
6int * [[]] ptr_attr;
7int 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;
11void fn_attr () [[]];
12class [[]] class_attr {};
13extern "C++" [[]] int extern_attr;
14template <typename T> [[]] void template_attr ();
15
16int comma_attr [[,]]; // expected-error {{expected identifier}}
17int scope_attr [[foo::]]; // expected-error {{expected identifier}}
18int & [[]] ref_attr = after_attr; // expected-error {{an attribute list cannot appear here}}
19class foo {
20 void after_const_attr () const [[]]; // expected-error {{expected expression}}
21};
22extern "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
Sean Huntbbd37c62009-11-21 08:43:09 +000032[[align]] int aligned_no_params; // expected-error {{C++0x attribute 'align' must have an argument list}}
33[[align(i)]] int aligned_nonconst; // expected-error {{'aligned' attribute requires integer constant}}
34
35// Statement tests
36void foo () {
37 [[]] ;
38 [[]] { }
39 [[]] if (0) { }
40 [[]] for (;;);
41 [[]] do {
42 [[]] continue;
43 } while (0);
44 [[]] while (0);
45
46 [[]] switch (i) {
47 [[]] case 0:
48 [[]] default:
49 [[]] break;
50 }
51
52 [[]] goto there;
53 [[]] there:
54
55 [[]] try {
56 } [[]] catch (...) { // expected-error {{an attribute list cannot appear here}}
57 }
58
59 [[]] return;
60}