blob: 0b6413cfb2772e522d2f87eed965f9f4a80fa0cb [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 ();
Peter Collingbourne3497fdf2011-09-29 18:04:05 +000016[[]] [[]] int [[]] [[]] multi_attr [[]] [[]];
Sean Huntbbd37c62009-11-21 08:43:09 +000017
18int comma_attr [[,]]; // expected-error {{expected identifier}}
19int scope_attr [[foo::]]; // expected-error {{expected identifier}}
Peter Collingbournef1907682011-09-29 18:03:57 +000020unsigned [[]] int attr_in_decl_spec; // expected-error {{expected unqualified-id}}
Sean Huntbbd37c62009-11-21 08:43:09 +000021int & [[]] ref_attr = after_attr; // expected-error {{an attribute list cannot appear here}}
22class foo {
Douglas Gregorae7902c2011-08-04 15:30:47 +000023 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 +000024};
25extern "C++" [[]] { } // expected-error {{an attribute list cannot appear here}}
26[[]] template <typename T> void before_template_attr (); // expected-error {{an attribute list cannot appear here}}
27[[]] namespace ns { int i; } // expected-error {{an attribute list cannot appear here}}
28[[]] static_assert(true, ""); //expected-error {{an attribute list cannot appear here}}
29[[]] asm(""); // expected-error {{an attribute list cannot appear here}}
30
31[[]] using ns::i; // expected-error {{an attribute list cannot appear here}}
32[[]] using namespace ns;
33
34// Argument tests
Sean Huntbbd37c62009-11-21 08:43:09 +000035[[align]] int aligned_no_params; // expected-error {{C++0x attribute 'align' must have an argument list}}
36[[align(i)]] int aligned_nonconst; // expected-error {{'aligned' attribute requires integer constant}}
37
38// Statement tests
39void foo () {
40 [[]] ;
41 [[]] { }
42 [[]] if (0) { }
43 [[]] for (;;);
44 [[]] do {
45 [[]] continue;
46 } while (0);
47 [[]] while (0);
48
49 [[]] switch (i) {
50 [[]] case 0:
51 [[]] default:
52 [[]] break;
53 }
54
55 [[]] goto there;
56 [[]] there:
57
58 [[]] try {
59 } [[]] catch (...) { // expected-error {{an attribute list cannot appear here}}
60 }
61
62 [[]] return;
63}