blob: 75f23c657c6a397a2e0121765134f181104e2acd [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;
Peter Collingbournef1907682011-09-29 18:03:57 +00005int [[]] between_attr;
Sean Huntbbd37c62009-11-21 08:43:09 +00006int after_attr [[]];
7int * [[]] ptr_attr;
8int array_attr [1] [[]];
9[[align(8)]] int aligned_attr;
10[[test::valid(for 42 [very] **** '+' symbols went on a trip; the end.)]]
11 int garbage_attr;
12void fn_attr () [[]];
13class [[]] class_attr {};
14extern "C++" [[]] int extern_attr;
15template <typename T> [[]] void template_attr ();
16
17int comma_attr [[,]]; // expected-error {{expected identifier}}
18int scope_attr [[foo::]]; // expected-error {{expected identifier}}
Peter Collingbournef1907682011-09-29 18:03:57 +000019unsigned [[]] int attr_in_decl_spec; // expected-error {{expected unqualified-id}}
Sean Huntbbd37c62009-11-21 08:43:09 +000020int & [[]] ref_attr = after_attr; // expected-error {{an attribute list cannot appear here}}
21class foo {
Douglas Gregorae7902c2011-08-04 15:30:47 +000022 void after_const_attr () const [[]]; // expected-error {{expected body of lambda expression}} expected-error {{array has incomplete element type 'void'}}
Sean Huntbbd37c62009-11-21 08:43:09 +000023};
24extern "C++" [[]] { } // expected-error {{an attribute list cannot appear here}}
25[[]] template <typename T> void before_template_attr (); // expected-error {{an attribute list cannot appear here}}
26[[]] namespace ns { int i; } // expected-error {{an attribute list cannot appear here}}
27[[]] static_assert(true, ""); //expected-error {{an attribute list cannot appear here}}
28[[]] asm(""); // expected-error {{an attribute list cannot appear here}}
29
30[[]] using ns::i; // expected-error {{an attribute list cannot appear here}}
31[[]] using namespace ns;
32
33// Argument tests
Sean Huntbbd37c62009-11-21 08:43:09 +000034[[align]] int aligned_no_params; // expected-error {{C++0x attribute 'align' must have an argument list}}
35[[align(i)]] int aligned_nonconst; // expected-error {{'aligned' attribute requires integer constant}}
36
37// Statement tests
38void foo () {
39 [[]] ;
40 [[]] { }
41 [[]] if (0) { }
42 [[]] for (;;);
43 [[]] do {
44 [[]] continue;
45 } while (0);
46 [[]] while (0);
47
48 [[]] switch (i) {
49 [[]] case 0:
50 [[]] default:
51 [[]] break;
52 }
53
54 [[]] goto there;
55 [[]] there:
56
57 [[]] try {
58 } [[]] catch (...) { // expected-error {{an attribute list cannot appear here}}
59 }
60
61 [[]] return;
62}