summaryrefslogtreecommitdiff
path: root/clang/test/CXX/conv
diff options
context:
space:
mode:
authorZancanaro; Carlo <czan8762@plang3.cs.usyd.edu.au>2012-09-24 09:58:17 +1000
committerZancanaro; Carlo <czan8762@plang3.cs.usyd.edu.au>2012-09-24 09:58:17 +1000
commit222e2a7620e6520ffaf4fc4e69d79c18da31542e (patch)
tree7bfbc05bfa3b41c8f9d2e56d53a0bc3e310df239 /clang/test/CXX/conv
parent3d206f03985b50beacae843d880bccdc91a9f424 (diff)
Add the clang library to the repo (with some of my changes, too).
Diffstat (limited to 'clang/test/CXX/conv')
-rw-r--r--clang/test/CXX/conv/conv.mem/p4.cpp65
-rw-r--r--clang/test/CXX/conv/conv.prom/p2.cpp16
-rw-r--r--clang/test/CXX/conv/conv.prom/p4.cpp9
-rw-r--r--clang/test/CXX/conv/conv.ptr/p2.cpp6
-rw-r--r--clang/test/CXX/conv/conv.qual/pr6089.cpp18
5 files changed, 114 insertions, 0 deletions
diff --git a/clang/test/CXX/conv/conv.mem/p4.cpp b/clang/test/CXX/conv/conv.mem/p4.cpp
new file mode 100644
index 0000000..e0748d8
--- /dev/null
+++ b/clang/test/CXX/conv/conv.mem/p4.cpp
@@ -0,0 +1,65 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+struct Base {
+ int data;
+ int method();
+};
+int (Base::*data_ptr) = &Base::data;
+int (Base::*method_ptr)() = &Base::method;
+
+namespace test0 {
+ struct Derived : Base {};
+ void test() {
+ int (Derived::*d) = data_ptr;
+ int (Derived::*m)() = method_ptr;
+ }
+}
+
+// Can't be inaccessible.
+namespace test1 {
+ struct Derived : private Base {}; // expected-note 2 {{declared private here}}
+ void test() {
+ int (Derived::*d) = data_ptr; // expected-error {{cannot cast private base class 'Base' to 'test1::Derived'}}
+ int (Derived::*m)() = method_ptr; // expected-error {{cannot cast private base class 'Base' to 'test1::Derived'}}
+ }
+};
+
+// Can't be ambiguous.
+namespace test2 {
+ struct A : Base {};
+ struct B : Base {};
+ struct Derived : A, B {};
+ void test() {
+ int (Derived::*d) = data_ptr; // expected-error {{ambiguous conversion from pointer to member of base class 'Base' to pointer to member of derived class 'test2::Derived':}}
+ int (Derived::*m)() = method_ptr; // expected-error {{ambiguous conversion from pointer to member of base class 'Base' to pointer to member of derived class 'test2::Derived':}}
+ }
+}
+
+// Can't be virtual.
+namespace test3 {
+ struct Derived : virtual Base {};
+ void test() {
+ int (Derived::*d) = data_ptr; // expected-error {{conversion from pointer to member of class 'Base' to pointer to member of class 'test3::Derived' via virtual base 'Base' is not allowed}}
+ int (Derived::*m)() = method_ptr; // expected-error {{conversion from pointer to member of class 'Base' to pointer to member of class 'test3::Derived' via virtual base 'Base' is not allowed}}
+ }
+}
+
+// Can't be virtual even if there's a non-virtual path.
+namespace test4 {
+ struct A : Base {};
+ struct Derived : Base, virtual A {};
+ void test() {
+ int (Derived::*d) = data_ptr; // expected-error {{ambiguous conversion from pointer to member of base class 'Base' to pointer to member of derived class 'test4::Derived':}}
+ int (Derived::*m)() = method_ptr; // expected-error {{ambiguous conversion from pointer to member of base class 'Base' to pointer to member of derived class 'test4::Derived':}}
+ }
+}
+
+// PR6254: don't get thrown off by a virtual base.
+namespace test5 {
+ struct A {};
+ struct Derived : Base, virtual A {};
+ void test() {
+ int (Derived::*d) = data_ptr;
+ int (Derived::*m)() = method_ptr;
+ }
+}
diff --git a/clang/test/CXX/conv/conv.prom/p2.cpp b/clang/test/CXX/conv/conv.prom/p2.cpp
new file mode 100644
index 0000000..8d75419
--- /dev/null
+++ b/clang/test/CXX/conv/conv.prom/p2.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++0x -ffreestanding %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++0x -fshort-wchar -ffreestanding %s
+
+#include <stdint.h>
+
+// In theory, the promoted types vary by platform; however, in reality they
+// are quite consistent across all platforms where clang runs.
+
+extern int promoted_wchar;
+extern decltype(+L'a') promoted_wchar;
+
+extern int promoted_char16;
+extern decltype(+u'a') promoted_char16;
+
+extern unsigned promoted_char32;
+extern decltype(+U'a') promoted_char32;
diff --git a/clang/test/CXX/conv/conv.prom/p4.cpp b/clang/test/CXX/conv/conv.prom/p4.cpp
new file mode 100644
index 0000000..02a91cd
--- /dev/null
+++ b/clang/test/CXX/conv/conv.prom/p4.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++0x %s
+
+enum X : short { A, B };
+extern decltype(+A) x;
+extern int x;
+
+enum Y : long { C, D };
+extern decltype(+C) y;
+extern long y;
diff --git a/clang/test/CXX/conv/conv.ptr/p2.cpp b/clang/test/CXX/conv/conv.ptr/p2.cpp
new file mode 100644
index 0000000..8808d20
--- /dev/null
+++ b/clang/test/CXX/conv/conv.ptr/p2.cpp
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+namespace pr7801 {
+ extern void* x[];
+ void* dummy[] = { &x };
+}
diff --git a/clang/test/CXX/conv/conv.qual/pr6089.cpp b/clang/test/CXX/conv/conv.qual/pr6089.cpp
new file mode 100644
index 0000000..ae75ec4
--- /dev/null
+++ b/clang/test/CXX/conv/conv.qual/pr6089.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+bool is_char_ptr( const char* );
+
+template< class T >
+ long is_char_ptr( T /* r */ );
+
+// Note: the const here does not lead to a qualification conversion
+template< class T >
+ void make_range( T* const r, bool );
+
+template< class T >
+ void make_range( T& r, long );
+
+void first_finder( const char*& Search )
+{
+ make_range( Search, is_char_ptr(Search) );
+}