2011-10-14 06:29:44 +08:00
|
|
|
// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -fsyntax-only -verify -std=c++11 %s
|
2009-11-21 16:43:09 +08:00
|
|
|
|
|
|
|
// Declaration syntax checks
|
|
|
|
[[]] int before_attr;
|
2011-09-30 02:03:57 +08:00
|
|
|
int [[]] between_attr;
|
2009-11-21 16:43:09 +08:00
|
|
|
int after_attr [[]];
|
|
|
|
int * [[]] ptr_attr;
|
|
|
|
int array_attr [1] [[]];
|
2011-09-30 02:04:28 +08:00
|
|
|
alignas(8) int aligned_attr;
|
2009-11-21 16:43:09 +08:00
|
|
|
[[test::valid(for 42 [very] **** '+' symbols went on a trip; the end.)]]
|
|
|
|
int garbage_attr;
|
|
|
|
void fn_attr () [[]];
|
|
|
|
class [[]] class_attr {};
|
|
|
|
extern "C++" [[]] int extern_attr;
|
|
|
|
template <typename T> [[]] void template_attr ();
|
2011-09-30 02:04:05 +08:00
|
|
|
[[]] [[]] int [[]] [[]] multi_attr [[]] [[]];
|
2009-11-21 16:43:09 +08:00
|
|
|
|
|
|
|
int comma_attr [[,]]; // expected-error {{expected identifier}}
|
|
|
|
int scope_attr [[foo::]]; // expected-error {{expected identifier}}
|
2011-09-30 02:03:57 +08:00
|
|
|
unsigned [[]] int attr_in_decl_spec; // expected-error {{expected unqualified-id}}
|
2009-11-21 16:43:09 +08:00
|
|
|
int & [[]] ref_attr = after_attr; // expected-error {{an attribute list cannot appear here}}
|
|
|
|
class foo {
|
2012-01-04 10:40:39 +08:00
|
|
|
void after_const_attr () const [[]]; // expected-error {{expected body of lambda expression}}
|
2009-11-21 16:43:09 +08:00
|
|
|
};
|
|
|
|
extern "C++" [[]] { } // expected-error {{an attribute list cannot appear here}}
|
|
|
|
[[]] template <typename T> void before_template_attr (); // expected-error {{an attribute list cannot appear here}}
|
2012-02-04 17:53:13 +08:00
|
|
|
[[]] namespace ns { int i; } // expected-error {{an attribute list cannot appear here}} expected-note {{declared here}}
|
2009-11-21 16:43:09 +08:00
|
|
|
[[]] static_assert(true, ""); //expected-error {{an attribute list cannot appear here}}
|
|
|
|
[[]] asm(""); // expected-error {{an attribute list cannot appear here}}
|
|
|
|
|
|
|
|
[[]] using ns::i; // expected-error {{an attribute list cannot appear here}}
|
|
|
|
[[]] using namespace ns;
|
|
|
|
|
|
|
|
// Argument tests
|
2011-09-30 02:04:28 +08:00
|
|
|
alignas int aligned_no_params; // expected-error {{expected '('}}
|
2012-02-04 17:53:13 +08:00
|
|
|
alignas(i) int aligned_nonconst; // expected-error {{'aligned' attribute requires integer constant}} expected-note {{read of non-const variable 'i'}}
|
2009-11-21 16:43:09 +08:00
|
|
|
|
|
|
|
// Statement tests
|
|
|
|
void foo () {
|
|
|
|
[[]] ;
|
|
|
|
[[]] { }
|
|
|
|
[[]] if (0) { }
|
|
|
|
[[]] for (;;);
|
|
|
|
[[]] do {
|
|
|
|
[[]] continue;
|
|
|
|
} while (0);
|
|
|
|
[[]] while (0);
|
|
|
|
|
|
|
|
[[]] switch (i) {
|
|
|
|
[[]] case 0:
|
|
|
|
[[]] default:
|
|
|
|
[[]] break;
|
|
|
|
}
|
|
|
|
|
|
|
|
[[]] goto there;
|
|
|
|
[[]] there:
|
|
|
|
|
|
|
|
[[]] try {
|
|
|
|
} [[]] catch (...) { // expected-error {{an attribute list cannot appear here}}
|
|
|
|
}
|
|
|
|
|
|
|
|
[[]] return;
|
|
|
|
}
|