diff options
author | Carlo Zancanaro <carlo@pc-4w14-0.cs.usyd.edu.au> | 2012-10-15 17:10:06 +1100 |
---|---|---|
committer | Carlo Zancanaro <carlo@pc-4w14-0.cs.usyd.edu.au> | 2012-10-15 17:10:06 +1100 |
commit | be1de4be954c80875ad4108e0a33e8e131b2f2c0 (patch) | |
tree | 1fbbecf276bf7c7bdcbb4dd446099d6d90eaa516 /clang/test/Parser/cxx0x-attributes.cpp | |
parent | c4626a62754862d20b41e8a46a3574264ea80e6d (diff) | |
parent | f1bd2e48c5324d3f7cda4090c87f8a5b6f463ce2 (diff) |
Merge branch 'master' of ssh://bitbucket.org/czan/honours
Diffstat (limited to 'clang/test/Parser/cxx0x-attributes.cpp')
-rw-r--r-- | clang/test/Parser/cxx0x-attributes.cpp | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/clang/test/Parser/cxx0x-attributes.cpp b/clang/test/Parser/cxx0x-attributes.cpp new file mode 100644 index 0000000..f97995e --- /dev/null +++ b/clang/test/Parser/cxx0x-attributes.cpp @@ -0,0 +1,83 @@ +// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -fsyntax-only -verify -std=c++11 %s + +// Declaration syntax checks +[[]] int before_attr; +int [[]] between_attr; +int after_attr [[]]; +int * [[]] ptr_attr; +int & [[]] ref_attr = after_attr; +int && [[]] rref_attr = 0; +int array_attr [1] [[]]; +alignas(8) int aligned_attr; +[[test::valid(for 42 [very] **** '+' symbols went on a trip; the end.)]] + int garbage_attr; +[[,,,static, class, namespace,, inline, constexpr, mutable,, bi\ +tand, bitor::compl(!.*_ Cx.!U^*R),,,]] int more_garbage_attr; +[[u8"invalid!"]] int invalid_string_attr; // expected-error {{expected ']'}} +void fn_attr () [[]]; +void noexcept_fn_attr () noexcept [[]]; +struct MemberFnOrder { + virtual void f() const volatile && noexcept [[]] final = 0; +}; +class [[]] class_attr {}; +extern "C++" [[]] int extern_attr; +template <typename T> [[]] void template_attr (); +[[]] [[]] int [[]] [[]] multi_attr [[]] [[]]; + +int comma_attr [[,]]; +int scope_attr [[foo::]]; // expected-error {{expected identifier}} +int (paren_attr) [[]]; // expected-error {{an attribute list cannot appear here}} +unsigned [[]] int attr_in_decl_spec; // expected-error {{expected unqualified-id}} +class foo { + void const_after_attr () [[]] const; // expected-error {{expected ';'}} +}; +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}} +[[]] namespace ns { int i; } // expected-error {{an attribute list cannot appear here}} expected-note {{declared here}} +[[]] 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 +alignas int aligned_no_params; // expected-error {{expected '('}} +alignas(i) int aligned_nonconst; // expected-error {{'aligned' attribute requires integer constant}} expected-note {{read of non-const variable 'i'}} + +// 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}} + } + struct S { int arr[2]; } s; + (void)s.arr[ [] { return 0; }() ]; // expected-error {{C++11 only allows consecutive left square brackets when introducing an attribute}} + int n = __builtin_offsetof(S, arr[ [] { return 0; }() ]); // expected-error {{C++11 only allows consecutive left square brackets when introducing an attribute}} + + void bar [[noreturn]] ([[]] int i, [[]] int j); + using FuncType = void ([[]] int); + void baz([[]]...); // expected-error {{expected parameter declarator}} + + [[]] return; +} + +template<typename...Ts> void variadic() { + void bar [[noreturn...]] (); // expected-error {{attribute 'noreturn' cannot be used as an attribute pack}} +} |