1// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -fsyntax-only -verify -std=c++11 %s 2 3// Declaration syntax checks 4[[]] int before_attr; 5int [[]] between_attr; 6int after_attr [[]]; 7int * [[]] ptr_attr; 8int array_attr [1] [[]]; 9alignas(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[[]] [[]] int [[]] [[]] multi_attr [[]] [[]]; 17 18int comma_attr [[,]]; // expected-error {{expected identifier}} 19int scope_attr [[foo::]]; // expected-error {{expected identifier}} 20unsigned [[]] int attr_in_decl_spec; // expected-error {{expected unqualified-id}} 21int & [[]] ref_attr = after_attr; // expected-error {{an attribute list cannot appear here}} 22class foo { 23 void after_const_attr () const [[]]; // expected-error {{expected body of lambda expression}} expected-error {{array has incomplete element type 'void'}} 24}; 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 35alignas int aligned_no_params; // expected-error {{expected '('}} 36alignas(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} 64