summaryrefslogtreecommitdiffstats
path: root/clang/test/Parser/cxx0x-attributes.cpp
diff options
context:
space:
mode:
authorAlexis Hunt <alercah@gmail.com>2009-11-21 08:43:09 +0000
committerAlexis Hunt <alercah@gmail.com>2009-11-21 08:43:09 +0000
commit96d5c76498b26bdf6e6ded4f166085a11c1738a4 (patch)
tree780685d28c9cf8c2e472913f98b85ff4a941bbc4 /clang/test/Parser/cxx0x-attributes.cpp
parenta33fc86be3855165bc41e355378fb27acb327930 (diff)
downloadbcm5719-llvm-96d5c76498b26bdf6e6ded4f166085a11c1738a4.tar.gz
bcm5719-llvm-96d5c76498b26bdf6e6ded4f166085a11c1738a4.zip
Added rudimentary C++0x attribute support.
The following attributes are currently supported in C++0x attribute lists (and in GNU ones as well): - align() - semantics believed to be conformant to n3000, except for redeclarations and what entities it may apply to - final - semantics believed to be conformant to CWG issue 817's proposed wording, except for redeclarations - noreturn - semantics believed to be conformant to n3000, except for redeclarations - carries_dependency - currently ignored (this is an optimization hint) llvm-svn: 89543
Diffstat (limited to 'clang/test/Parser/cxx0x-attributes.cpp')
-rw-r--r--clang/test/Parser/cxx0x-attributes.cpp61
1 files changed, 61 insertions, 0 deletions
diff --git a/clang/test/Parser/cxx0x-attributes.cpp b/clang/test/Parser/cxx0x-attributes.cpp
new file mode 100644
index 00000000000..a66e3e05976
--- /dev/null
+++ b/clang/test/Parser/cxx0x-attributes.cpp
@@ -0,0 +1,61 @@
+// RUN: clang-cc -fsyntax-only -verify -std=c++0x %s
+
+// Declaration syntax checks
+[[]] int before_attr;
+int after_attr [[]];
+int * [[]] ptr_attr;
+int array_attr [1] [[]];
+[[align(8)]] int aligned_attr;
+[[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 ();
+
+int comma_attr [[,]]; // expected-error {{expected identifier}}
+int scope_attr [[foo::]]; // expected-error {{expected identifier}}
+int & [[]] ref_attr = after_attr; // expected-error {{an attribute list cannot appear here}}
+class foo {
+ void after_const_attr () const [[]]; // expected-error {{expected expression}}
+};
+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}}
+[[]] 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
+[[final()]] int final_params; // expected-error {{C++0x attribute 'final' cannot have an argument list}}
+[[align]] int aligned_no_params; // expected-error {{C++0x attribute 'align' must have an argument list}}
+[[align(i)]] int aligned_nonconst; // expected-error {{'aligned' attribute requires integer constant}}
+
+// 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;
+}
OpenPOWER on IntegriCloud