summaryrefslogtreecommitdiffstats
path: root/test/Parser
diff options
context:
space:
mode:
Diffstat (limited to 'test/Parser')
-rw-r--r--test/Parser/MicrosoftExtensions.cpp100
-rw-r--r--test/Parser/cxx-default-delete.cpp15
-rw-r--r--test/Parser/cxx-ext-delete-default.cpp11
-rw-r--r--test/Parser/cxx-friend.cpp6
-rw-r--r--test/Parser/cxx0x-member-initializers.cpp15
-rw-r--r--test/Parser/nested-namespaces-recovery.cpp24
-rw-r--r--test/Parser/opencl-astype.cl20
7 files changed, 181 insertions, 10 deletions
diff --git a/test/Parser/MicrosoftExtensions.cpp b/test/Parser/MicrosoftExtensions.cpp
index 32ed375..3a72ea0 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
+// RUN: %clang_cc1 %s -fsyntax-only -Wno-unused-value -Wmicrosoft -verify -fms-extensions -fdelayed-template-parsing
/* Microsoft attribute tests */
[repeatable][source_annotation_attribute( Parameter|ReturnValue )]
@@ -105,6 +105,13 @@ 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;
+ struct late_defined_uuid;
+ template<typename T>
+ void test_late_defined_uuid() {
+ __uuidof(late_defined_uuid);
+ }
+ struct __declspec(uuid("000000A0-0000-0000-C000-000000000049")) late_defined_uuid;
+
class CtorCall {
public:
@@ -136,7 +143,7 @@ class C2 {
};
template <class T>
-void f(){
+void missing_template_keyword(){
typename C1<T>:: /*template*/ Iterator<0> Mypos; // expected-warning {{use 'template' keyword to treat 'Iterator' as a dependent template name}}
}
@@ -151,11 +158,6 @@ void redundant_typename() {
t = 3;
}
-int main() {
- redundant_typename<int>();
- f<int>();
-}
-
__interface MicrosoftInterface;
__interface MicrosoftInterface {
@@ -164,3 +166,87 @@ __interface MicrosoftInterface {
};
__int64 x7 = __int64(0);
+
+
+namespace If_exists_test {
+
+class IF_EXISTS {
+private:
+ typedef int Type;
+};
+
+int __if_exists_test() {
+ int b=0;
+ __if_exists(IF_EXISTS::Type) {
+ b++;
+ b++;
+ }
+ __if_exists(IF_EXISTS::Type_not) {
+ this wont compile.
+ }
+ __if_not_exists(IF_EXISTS::Type) {
+ this wont compile.
+ }
+ __if_not_exists(IF_EXISTS::Type_not) {
+ b++;
+ b++;
+ }
+}
+
+
+__if_exists(IF_EXISTS::Type) {
+ int var23;
+}
+
+__if_exists(IF_EXISTS::Type_not) {
+ this wont compile.
+}
+
+__if_not_exists(IF_EXISTS::Type) {
+ this wont compile.
+}
+
+__if_not_exists(IF_EXISTS::Type_not) {
+ int var244;
+}
+
+class IF_EXISTS_CLASS_TEST {
+ __if_exists(IF_EXISTS::Type) {
+ // __if_exists, __if_not_exists can nest
+ __if_not_exists(IF_EXISTS::Type_not) {
+ int var123;
+ }
+ int var23;
+ }
+
+ __if_exists(IF_EXISTS::Type_not) {
+ this wont compile.
+ }
+
+ __if_not_exists(IF_EXISTS::Type) {
+ this wont compile.
+ }
+
+ __if_not_exists(IF_EXISTS::Type_not) {
+ int var244;
+ }
+};
+
+}
+
+
+int __identifier(generic) = 3;
+
+class inline_definition_pure_spec {
+ virtual int f() = 0 { return 0; }// expected-warning {{function definition with pure-specifier is a Microsoft extension}}
+ virtual int f2() = 0;
+};
+
+
+int main () {
+ // Necessary to force instantiation in -fdelayed-template-parsing mode.
+ test_late_defined_uuid<int>();
+ redundant_typename<int>();
+ missing_template_keyword<int>();
+}
+
diff --git a/test/Parser/cxx-default-delete.cpp b/test/Parser/cxx-default-delete.cpp
new file mode 100644
index 0000000..a3d5b2c
--- /dev/null
+++ b/test/Parser/cxx-default-delete.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -std=c++0x -fsyntax-only -verify %s
+
+int i = delete; // expected-error{{only functions}}
+int j = default; // expected-error{{special member functions}}
+
+int f() = delete, g; // expected-error{{standalone}}
+int o, p() = delete; // expected-error{{standalone}}
+
+struct foo {
+ foo() = default;
+ ~foo() = delete;
+ void bar() = delete;
+};
+
+void baz() = delete;
diff --git a/test/Parser/cxx-ext-delete-default.cpp b/test/Parser/cxx-ext-delete-default.cpp
new file mode 100644
index 0000000..0627238
--- /dev/null
+++ b/test/Parser/cxx-ext-delete-default.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
+
+struct A {
+ A(const A&) = delete; // expected-warning {{accepted as a C++0x extension}}
+ A& operator=(const A&) = delete; // expected-warning {{accepted as a C++0x extension}}
+ A() = default; // expected-warning {{accepted as a C++0x extension}}
+ ~A();
+};
+
+void f() = delete; // expected-warning {{accepted as a C++0x extension}}
+A::~A() = default; //expected-warning {{accepted as a C++0x extension}}
diff --git a/test/Parser/cxx-friend.cpp b/test/Parser/cxx-friend.cpp
index 59350b5..a13e7ba 100644
--- a/test/Parser/cxx-friend.cpp
+++ b/test/Parser/cxx-friend.cpp
@@ -21,9 +21,9 @@ class B {
// 'A' here should refer to the declaration above.
friend class A;
- friend C; // expected-warning {{must specify 'class' to befriend}}
- friend U; // expected-warning {{must specify 'union' to befriend}}
- friend int; // expected-warning {{non-class type 'int' cannot be a friend}}
+ friend C; // expected-warning {{specify 'class' to befriend}}
+ friend U; // expected-warning {{specify 'union' to befriend}}
+ friend int; // expected-warning {{non-class friend type 'int'}}
friend void myfunc();
diff --git a/test/Parser/cxx0x-member-initializers.cpp b/test/Parser/cxx0x-member-initializers.cpp
new file mode 100644
index 0000000..6c3492e
--- /dev/null
+++ b/test/Parser/cxx0x-member-initializers.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++0x %s
+
+// Make sure we don't run off the end of the stream when parsing a deferred
+// initializer.
+int a; // expected-note {{previous}}
+struct S {
+ int n = 4 + ; // expected-error {{expected expression}}
+} a; // expected-error {{redefinition}}
+
+// Make sure we use all of the tokens.
+struct T {
+ int a = 1 // expected-error {{expected ';' at end of declaration list}}
+ int b = 2;
+ int c = b; // expected-error {{undeclared identifier}}
+};
diff --git a/test/Parser/nested-namespaces-recovery.cpp b/test/Parser/nested-namespaces-recovery.cpp
new file mode 100644
index 0000000..d45938b
--- /dev/null
+++ b/test/Parser/nested-namespaces-recovery.cpp
@@ -0,0 +1,24 @@
+// RUN: cp %s %t
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: not %clang_cc1 -x c++ -fixit %t
+// RUN: %clang_cc1 -x c++ %t
+
+namespace foo1::foo2::foo3 { // expected-error {{nested namespace definition must define each namespace separately}}
+ int foo(int x) { return x; }
+}
+
+int foo(int x) {
+ return foo1::foo2::foo3::foo(x);
+}
+
+namespace bar1 {
+ namespace bar2 {
+ namespace bar3 {
+ int bar(int x) { return x; }
+ }
+ }
+}
+
+int bar(int x) {
+ return bar1::bar2::bar3::bar(x);
+}
diff --git a/test/Parser/opencl-astype.cl b/test/Parser/opencl-astype.cl
new file mode 100644
index 0000000..d4c547e
--- /dev/null
+++ b/test/Parser/opencl-astype.cl
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+#pragma OPENCL EXTENSION cl_khr_fp64 : enable
+
+void test_astype() {
+ float f = 1.0f;
+ unsigned int i = __builtin_astype(f, unsigned int);
+
+ typedef __attribute__(( ext_vector_type(4) )) int int4;
+ typedef __attribute__(( ext_vector_type(3) )) float float3;
+ typedef __attribute__(( ext_vector_type(4) )) float float4;
+ typedef __attribute__(( ext_vector_type(4) )) double double4;
+
+ float4 f4;
+ double4 d4 = __builtin_astype(f4, double4); // expected-error{{invalid reinterpretation: sizes of 'double4' and 'float4' must match}}
+
+ // Verify int4->float3, float3->int4 works.
+ int4 i4;
+ float3 f3 = __builtin_astype(i4, float3);
+ i4 = __builtin_astype(f3, int4);
+}
OpenPOWER on IntegriCloud