blob: 198da778cd0edeb1b3f95c2b504464f522d50f6d [file] [log] [blame]
Richard Smith762bb9d2011-10-13 22:29:44 +00001// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -fsyntax-only -verify -std=c++11 %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] [[]];
Peter Collingbourne82d0b0a2011-09-29 18:04:28 +00009alignas(8) int aligned_attr;
Sean Huntbbd37c62009-11-21 08:43:09 +000010[[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 {
Eli Friedmandc3b7232012-01-04 02:40:39 +000023 void after_const_attr () const [[]]; // expected-error {{expected body of lambda expression}}
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}}
Richard Smith282e7e62012-02-04 09:53:13 +000027[[]] namespace ns { int i; } // expected-error {{an attribute list cannot appear here}} expected-note {{declared here}}
Sean Huntbbd37c62009-11-21 08:43:09 +000028[[]] 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
Peter Collingbourne82d0b0a2011-09-29 18:04:28 +000035alignas int aligned_no_params; // expected-error {{expected '('}}
Richard Smith282e7e62012-02-04 09:53:13 +000036alignas(i) int aligned_nonconst; // expected-error {{'aligned' attribute requires integer constant}} expected-note {{read of non-const variable 'i'}}
Sean Huntbbd37c62009-11-21 08:43:09 +000037
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}