summaryrefslogtreecommitdiff
path: root/test/Parser
diff options
context:
space:
mode:
Diffstat (limited to 'test/Parser')
-rw-r--r--test/Parser/MicrosoftExtensions.cpp29
-rw-r--r--test/Parser/cxx11-stmt-attributes.cpp54
-rw-r--r--test/Parser/objcxx11-attributes.mm8
3 files changed, 86 insertions, 5 deletions
diff --git a/test/Parser/MicrosoftExtensions.cpp b/test/Parser/MicrosoftExtensions.cpp
index 89394c303ca8..3a1ffea453ca 100644
--- a/test/Parser/MicrosoftExtensions.cpp
+++ b/test/Parser/MicrosoftExtensions.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -fsyntax-only -Wno-unused-value -Wmicrosoft -verify -fms-extensions -fdelayed-template-parsing
+// RUN: %clang_cc1 %s -std=c++11 -fsyntax-only -Wno-unused-value -Wmicrosoft -verify -fms-extensions -fms-compatibility -fdelayed-template-parsing
/* Microsoft attribute tests */
[repeatable][source_annotation_attribute( Parameter|ReturnValue )]
@@ -103,7 +103,7 @@ typedef COM_CLASS_TEMPLATE<struct_with_uuid> COM_TYPE_2;
template <class T, const GUID& g>
class COM_CLASS_TEMPLATE_REF { };
-typedef COM_CLASS_TEMPLATE<struct_with_uuid, __uuidof(struct_with_uuid)> COM_TYPE_REF;
+typedef COM_CLASS_TEMPLATE_REF<struct_with_uuid, __uuidof(struct_with_uuid)> COM_TYPE_REF;
struct late_defined_uuid;
template<typename T>
@@ -284,3 +284,28 @@ int main () {
missing_template_keyword<int>();
}
+
+
+
+namespace access_protected_PTM {
+
+class A {
+protected:
+ void f(); // expected-note {{must name member using the type of the current context 'access_protected_PTM::B'}}
+};
+
+class B : public A{
+public:
+ void test_access();
+ static void test_access_static();
+};
+
+void B::test_access() {
+ &A::f; // expected-error {{'f' is a protected member of 'access_protected_PTM::A'}}
+}
+
+void B::test_access_static() {
+ &A::f;
+}
+
+} \ No newline at end of file
diff --git a/test/Parser/cxx11-stmt-attributes.cpp b/test/Parser/cxx11-stmt-attributes.cpp
new file mode 100644
index 000000000000..fab56218eb84
--- /dev/null
+++ b/test/Parser/cxx11-stmt-attributes.cpp
@@ -0,0 +1,54 @@
+// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -fsyntax-only -verify -std=c++11 %s
+
+void foo(int i) {
+
+ [[unknown_attribute]] ;
+ [[unknown_attribute]] { }
+ [[unknown_attribute]] if (0) { }
+ [[unknown_attribute]] for (;;);
+ [[unknown_attribute]] do {
+ [[unknown_attribute]] continue;
+ } while (0);
+ [[unknown_attribute]] while (0);
+
+ [[unknown_attribute]] switch (i) {
+ [[unknown_attribute]] case 0:
+ [[unknown_attribute]] default:
+ [[unknown_attribute]] break;
+ }
+
+ [[unknown_attribute]] goto here;
+ [[unknown_attribute]] here:
+
+ [[unknown_attribute]] try {
+ } catch (...) {
+ }
+
+ [[unknown_attribute]] return;
+
+
+ alignas(8) ; // expected-warning {{attribute aligned cannot be specified on a statement}}
+ [[noreturn]] { } // expected-warning {{attribute noreturn cannot be specified on a statement}}
+ [[noreturn]] if (0) { } // expected-warning {{attribute noreturn cannot be specified on a statement}}
+ [[noreturn]] for (;;); // expected-warning {{attribute noreturn cannot be specified on a statement}}
+ [[noreturn]] do { // expected-warning {{attribute noreturn cannot be specified on a statement}}
+ [[unavailable]] continue; // TODO: only noreturn, alignas and carries_dependency are parsed in C++ 11 syntax at the moment, hence no warning here
+ } while (0);
+ [[unknown_attributqqq]] while (0); // TODO: remove 'qqq' part and enjoy 'empty loop body' warning here (DiagnoseEmptyLoopBody)
+ [[unknown_attribute]] while (0); // no warning here yet, just an unknown attribute
+
+ [[unused]] switch (i) { // TODO: only noreturn, alignas and carries_dependency are parsed in C++ 11 syntax at the moment, hence no warning here
+ [[uuid]] case 0: // TODO: only noreturn, alignas and carries_dependency are parsed in C++ 11 syntax at the moment, hence no warning here
+ [[visibility]] default: // TODO: only noreturn, alignas and carries_dependency are parsed in C++ 11 syntax at the moment, hence no warning here
+ [[carries_dependency]] break; // expected-warning {{attribute carries_dependency cannot be specified on a statement}}
+ }
+
+ [[fastcall]] goto there; // TODO: only noreturn, alignas and carries_dependency are parsed in C++ 11 syntax at the moment, hence no warning here
+ [[noinline]] there: // TODO: only noreturn, alignas and carries_dependency are parsed in C++ 11 syntax at the moment, hence no warning here
+
+ [[lock_returned]] try { // TODO: only noreturn, alignas and carries_dependency are parsed in C++ 11 syntax at the moment, hence no warning here
+ } catch (...) {
+ }
+
+ [[weakref]] return; // TODO: only noreturn, alignas and carries_dependency are parsed in C++ 11 syntax at the moment, hence no warning here
+}
diff --git a/test/Parser/objcxx11-attributes.mm b/test/Parser/objcxx11-attributes.mm
index 0875b66e2132..0c91392978af 100644
--- a/test/Parser/objcxx11-attributes.mm
+++ b/test/Parser/objcxx11-attributes.mm
@@ -31,15 +31,17 @@ void f(X *noreturn) {
// An attribute is OK.
[[]];
- [[int(), noreturn]];
+ [[int(), noreturn]]; // expected-warning {{attribute noreturn cannot be specified on a statement}}
[[class, test(foo 'x' bar),,,]];
- [[bitand, noreturn]];
+ [[bitand, noreturn]]; // expected-warning {{attribute noreturn cannot be specified on a statement}}
[[noreturn]]int(e)();
+ int e2(); // expected-warning {{interpreted as a function declaration}} expected-note{{}}
// A function taking a noreturn function.
- int(f)([[noreturn]] int());
+ int(f)([[noreturn]] int()); // expected-note {{here}}
f(e);
+ f(e2); // expected-error {{cannot initialize a parameter of type 'int (*)() __attribute__((noreturn))' with an lvalue of type 'int ()'}}
// Variables initialized by a message send.
int(g)([[noreturn getSelf] getSize]);