summaryrefslogtreecommitdiffstats
path: root/test/SemaCXX
diff options
context:
space:
mode:
authordim <dim@FreeBSD.org>2011-05-02 19:39:53 +0000
committerdim <dim@FreeBSD.org>2011-05-02 19:39:53 +0000
commit110eaaceddcec790f7e6a5e3bf1261c9aa1e73ab (patch)
tree64a10f4c4154739d4a8191d7e1b52ce497f4ebd6 /test/SemaCXX
parenta0fb00f9837bd0d2e5948f16f6a6b82a7a628f51 (diff)
downloadFreeBSD-src-110eaaceddcec790f7e6a5e3bf1261c9aa1e73ab.zip
FreeBSD-src-110eaaceddcec790f7e6a5e3bf1261c9aa1e73ab.tar.gz
Vendor import of clang trunk r130700:
http://llvm.org/svn/llvm-project/cfe/trunk@130700
Diffstat (limited to 'test/SemaCXX')
-rw-r--r--test/SemaCXX/MicrosoftExtensions.cpp86
-rw-r--r--test/SemaCXX/PR9459.cpp7
-rw-r--r--test/SemaCXX/PR9460.cpp19
-rw-r--r--test/SemaCXX/PR9461.cpp32
-rw-r--r--test/SemaCXX/PR9572.cpp15
-rw-r--r--test/SemaCXX/__try.cpp58
-rw-r--r--test/SemaCXX/addr-of-overloaded-function.cpp7
-rw-r--r--test/SemaCXX/address-space-conversion.cpp197
-rw-r--r--test/SemaCXX/address-space-newdelete.cpp24
-rw-r--r--test/SemaCXX/address-space-references.cpp19
-rw-r--r--test/SemaCXX/alignof-sizeof-reference.cpp6
-rw-r--r--test/SemaCXX/altivec.cpp30
-rw-r--r--test/SemaCXX/array-bounds.cpp53
-rw-r--r--test/SemaCXX/attr-nonnull.cpp6
-rw-r--r--test/SemaCXX/attr-unavailable.cpp2
-rw-r--r--test/SemaCXX/auto-subst-failure.cpp15
-rw-r--r--test/SemaCXX/conditional-expr.cpp2
-rw-r--r--test/SemaCXX/conversion-function.cpp25
-rw-r--r--test/SemaCXX/cxx0x-constexpr-const.cpp10
-rw-r--r--test/SemaCXX/cxx0x-delegating-ctors.cpp36
-rw-r--r--test/SemaCXX/cxx0x-return-init-list.cpp18
-rw-r--r--test/SemaCXX/decltype-98.cpp3
-rw-r--r--test/SemaCXX/decltype-overloaded-functions.cpp13
-rw-r--r--test/SemaCXX/destructor.cpp13
-rw-r--r--test/SemaCXX/enum-scoped.cpp6
-rw-r--r--test/SemaCXX/exception-spec-no-exceptions.cpp7
-rw-r--r--test/SemaCXX/exception-spec.cpp193
-rw-r--r--test/SemaCXX/exceptions.cpp2
-rw-r--r--test/SemaCXX/expression-traits.cpp620
-rw-r--r--test/SemaCXX/flexible-array-test.cpp16
-rw-r--r--test/SemaCXX/for-range-examples.cpp150
-rw-r--r--test/SemaCXX/for-range-no-std.cpp37
-rw-r--r--test/SemaCXX/friend.cpp4
-rw-r--r--test/SemaCXX/generic-selection.cpp46
-rw-r--r--test/SemaCXX/goto.cpp105
-rw-r--r--test/SemaCXX/goto2.cpp47
-rw-r--r--test/SemaCXX/init-priority-attr.cpp2
-rw-r--r--test/SemaCXX/libstdcxx_is_pod_hack.cpp16
-rw-r--r--test/SemaCXX/literal-type.cpp63
-rw-r--r--test/SemaCXX/member-expr.cpp5
-rw-r--r--test/SemaCXX/member-pointers-2.cpp15
-rw-r--r--test/SemaCXX/neon-vector-types.cpp27
-rw-r--r--test/SemaCXX/nested-name-spec-locations.cpp94
-rw-r--r--test/SemaCXX/nullptr.cpp2
-rw-r--r--test/SemaCXX/operator-arrow-temporary.cpp19
-rw-r--r--test/SemaCXX/overloaded-name.cpp12
-rw-r--r--test/SemaCXX/overloaded-operator.cpp15
-rw-r--r--test/SemaCXX/pascal-strings.cpp6
-rw-r--r--test/SemaCXX/pseudo-destructors.cpp7
-rw-r--r--test/SemaCXX/ptrtomember.cpp5
-rw-r--r--test/SemaCXX/reinterpret-cast.cpp16
-rw-r--r--test/SemaCXX/return-noreturn.cpp73
-rw-r--r--test/SemaCXX/return.cpp14
-rw-r--r--test/SemaCXX/rval-references.cpp2
-rw-r--r--test/SemaCXX/scope-check.cpp20
-rw-r--r--test/SemaCXX/short-enums.cpp17
-rw-r--r--test/SemaCXX/short-wchar-sign.cpp6
-rw-r--r--test/SemaCXX/sourceranges.cpp6
-rw-r--r--test/SemaCXX/static-cast.cpp6
-rw-r--r--test/SemaCXX/storage-class.cpp3
-rw-r--r--test/SemaCXX/type-traits.cpp1598
-rw-r--r--test/SemaCXX/uninit-variables-conditional.cpp23
-rw-r--r--test/SemaCXX/uninit-variables.cpp66
-rw-r--r--test/SemaCXX/uninitialized.cpp53
-rw-r--r--test/SemaCXX/unknown-anytype.cpp36
-rw-r--r--test/SemaCXX/unreachable-catch-clauses.cpp2
-rw-r--r--test/SemaCXX/unreachable-code.cpp2
-rw-r--r--test/SemaCXX/unused-functions.cpp4
-rw-r--r--test/SemaCXX/vtable-instantiation.cc26
-rw-r--r--test/SemaCXX/warn-assignment-condition.cpp13
-rw-r--r--test/SemaCXX/warn-bool-conversion.cpp24
-rw-r--r--test/SemaCXX/warn-deprecated-header.cpp6
-rw-r--r--test/SemaCXX/warn-exit-time-destructors.cpp27
-rw-r--r--test/SemaCXX/warn-global-constructors.cpp4
-rw-r--r--test/SemaCXX/warn-literal-conversion.cpp15
-rw-r--r--test/SemaCXX/warn-missing-prototypes.cpp6
-rw-r--r--test/SemaCXX/warn-non-pod-memset.cpp63
-rw-r--r--test/SemaCXX/warn-overloaded-virtual.cpp12
-rw-r--r--test/SemaCXX/warn-shadow.cpp11
-rw-r--r--test/SemaCXX/warn-unreachable.cpp2
-rw-r--r--test/SemaCXX/warn-unused-filescoped.cpp9
-rw-r--r--test/SemaCXX/warn-using-namespace-in-header.cpp54
-rw-r--r--test/SemaCXX/warn-using-namespace-in-header.h50
-rw-r--r--test/SemaCXX/warn_false_to_pointer.cpp10
-rw-r--r--test/SemaCXX/writable-strings-deprecated.cpp2
85 files changed, 3865 insertions, 633 deletions
diff --git a/test/SemaCXX/MicrosoftExtensions.cpp b/test/SemaCXX/MicrosoftExtensions.cpp
index 30ad4d0..2d620b6 100644
--- a/test/SemaCXX/MicrosoftExtensions.cpp
+++ b/test/SemaCXX/MicrosoftExtensions.cpp
@@ -1,24 +1,16 @@
-// RUN: %clang_cc1 %s -fsyntax-only -Wmicrosoft -verify -fms-extensions -fexceptions
+// RUN: %clang_cc1 %s -triple i686-pc-win32 -fsyntax-only -Wmicrosoft -verify -fms-extensions -fexceptions -fcxx-exceptions
// ::type_info is predeclared with forward class declartion
void f(const type_info &a);
-// The following three are all equivalent when ms-extensions are on
-void foo() throw(int);
-void foo() throw(int, long);
-void foo() throw(...);
-void foo(); // expected-note {{previous declaration}}
-
-// Only nothrow specification is treated specially.
-void foo() throw(); // expected-error {{exception specification in declaration does not match previous declaration}}
-// throw(...)
-void r3();
-void r3() throw(...);
+// Microsoft doesn't validate exception specification.
+void foo(); // expected-note {{previous declaration}}
+void foo() throw(); // expected-warning {{exception specification in declaration does not match previous declaration}}
-void r6() throw(...);
-void r6() throw(int); // okay
+void r6() throw(...); // expected-note {{previous declaration}}
+void r6() throw(int); // expected-warning {{exception specification in declaration does not match previous declaration}}
struct Base {
virtual void f2();
@@ -122,3 +114,69 @@ struct X0 {
enum : long long { // expected-warning{{enumeration types with a fixed underlying type are a Microsoft extension}}
SomeValue = 0x100000000
};
+
+
+class AAA {
+__declspec(dllimport) void f(void) { }
+void f2(void);
+};
+
+__declspec(dllimport) void AAA::f2(void) { // expected-error {{dllimport attribute can be applied only to symbol}}
+
+}
+
+
+
+template <class T>
+class BB {
+public:
+ void f(int g = 10 ); // expected-note {{previous definition is here}}
+};
+
+template <class T>
+void BB<T>::f(int g = 0) { } // expected-warning {{redefinition of default argument}}
+
+
+namespace MissingTypename {
+
+template<class T> class A {
+public:
+ typedef int TYPE;
+};
+
+template<class T> class B {
+public:
+ typedef int TYPE;
+};
+
+
+template<class T, class U>
+class C : private A<T>, public B<U> {
+public:
+ typedef A<T> Base1;
+ typedef B<U> Base2;
+ typedef A<U> Base3;
+
+ A<T>::TYPE a1; // expected-warning {{missing 'typename' prior to dependent type name}}
+ Base1::TYPE a2; // expected-warning {{missing 'typename' prior to dependent type name}}
+
+ B<U>::TYPE a3; // expected-warning {{missing 'typename' prior to dependent type name}}
+ Base2::TYPE a4; // expected-warning {{missing 'typename' prior to dependent type name}}
+
+ A<U>::TYPE a5; // expected-error {{missing 'typename' prior to dependent type name}}
+ Base3::TYPE a6; // expected-error {{missing 'typename' prior to dependent type name}}
+ };
+
+}
+
+
+
+
+extern void static_func();
+void static_func(); // expected-note {{previous declaration is here}}
+
+
+static void static_func() // expected-warning {{static declaration of 'static_func' follows non-static declaration}}
+{
+
+} \ No newline at end of file
diff --git a/test/SemaCXX/PR9459.cpp b/test/SemaCXX/PR9459.cpp
new file mode 100644
index 0000000..dfb242d
--- /dev/null
+++ b/test/SemaCXX/PR9459.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// Don't crash.
+
+template<typename>struct ae_same;
+template<typename>struct ts{}ap()
+{ts<a>::ap<ae_same<int>::&ae_same<>>::p(a); }; // expected-error {{use of undeclared identifier 'a'}}
diff --git a/test/SemaCXX/PR9460.cpp b/test/SemaCXX/PR9460.cpp
new file mode 100644
index 0000000..2cc435e
--- /dev/null
+++ b/test/SemaCXX/PR9460.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// Don't crash.
+
+template<typename aT>
+struct basic_string{
+ a; // expected-error {{requires a type specifier}}
+ basic_string(aT*);
+};
+
+struct runtime_error{ // expected-note {{candidate constructor}}
+ runtime_error( // expected-note {{candidate constructor}}
+basic_string<char> struct{ // expected-error {{cannot combine with previous 'type-name' declaration specifier}}
+a(){ // expected-error {{requires a type specifier}}
+ runtime_error(0); // expected-error {{no matching conversion}}
+}
+}
+);
+};
diff --git a/test/SemaCXX/PR9461.cpp b/test/SemaCXX/PR9461.cpp
new file mode 100644
index 0000000..ce17931
--- /dev/null
+++ b/test/SemaCXX/PR9461.cpp
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// Don't crash.
+
+template<typename,typename=int,typename=int>struct basic_string;
+
+typedef basic_string<char> string;
+
+
+
+template<typename aT,typename,typename oc>
+struct basic_string
+{
+int us;
+basic_string(const aT*,const oc&a=int());
+
+int _S_construct();
+
+int _S_construct(int);
+
+_S_construct(); // expected-error {{requires}}
+};
+
+template<typename _CharT,typename _Traits,typename _Alloc>
+basic_string<_CharT,_Traits,_Alloc>::basic_string(const _CharT*,const _Alloc&)
+:us(_S_construct)
+{string a;}
+
+struct runtime_error{runtime_error(string);}; // expected-note 2 {{candidate constructor}}
+
+struct system_error:runtime_error{ // expected-note {{to match}} expected-note {{specified here}}
+system_error():time_error("" // expected-error 4 {{expected}} expected-error {{initializer}} expected-note {{to match}} expected-error {{no matching constructor}}
diff --git a/test/SemaCXX/PR9572.cpp b/test/SemaCXX/PR9572.cpp
new file mode 100644
index 0000000..d1b7077
--- /dev/null
+++ b/test/SemaCXX/PR9572.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+class Base {
+ virtual ~Base();
+};
+struct Foo : public Base {
+ const int kBlah = 3; // expected-error{{fields can only be initialized in constructors}}
+ Foo();
+};
+struct Bar : public Foo {
+ Bar() { }
+};
+struct Baz {
+ Foo f;
+ Baz() { }
+};
diff --git a/test/SemaCXX/__try.cpp b/test/SemaCXX/__try.cpp
new file mode 100644
index 0000000..cb5d38a
--- /dev/null
+++ b/test/SemaCXX/__try.cpp
@@ -0,0 +1,58 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -fborland-extensions -fcxx-exceptions %s
+
+// This test is from http://docwiki.embarcadero.com/RADStudio/en/Try
+
+int puts(const char *);
+
+template<typename T>
+int printf(const char *, T);
+
+const char * strdup(const char *);
+
+void free(const void *);
+
+#define EXCEPTION_EXECUTE_HANDLER 1
+
+class Exception
+{
+public:
+ Exception(const char* s = "Unknown"){what = strdup(s); }
+ Exception(const Exception& e ){what = strdup(e.what); }
+ ~Exception() {free(what); }
+ const char* msg() const {return what; }
+private:
+ const char* what;
+};
+
+int main()
+{
+ float e, f, g;
+ try
+ {
+ try
+ {
+ f = 1.0;
+ g = 0.0;
+ try
+ {
+ puts("Another exception:");
+
+ e = f / g;
+ }
+ __except(EXCEPTION_EXECUTE_HANDLER)
+ {
+ puts("Caught a C-based exception.");
+ throw(Exception("Hardware error: Divide by 0"));
+ }
+ }
+ catch(const Exception& e)
+ {
+ printf("Caught C++ Exception: %s :\n", e.msg());
+ }
+ }
+ __finally
+ {
+ puts("C++ allows __finally too!");
+ }
+ return e;
+}
diff --git a/test/SemaCXX/addr-of-overloaded-function.cpp b/test/SemaCXX/addr-of-overloaded-function.cpp
index a1079ff..a36fd58 100644
--- a/test/SemaCXX/addr-of-overloaded-function.cpp
+++ b/test/SemaCXX/addr-of-overloaded-function.cpp
@@ -57,11 +57,12 @@ struct B
struct C {
C &getC() {
- return makeAC; // expected-error{{address of overloaded function 'makeAC'}}
+ // FIXME: this error message is terrible
+ return makeAC; // expected-error{{cannot bind to a value of unrelated type}}
}
- C &makeAC(); //expected-note{{candidate function}}
- const C &makeAC() const; //expected-note{{candidate function}}
+ C &makeAC();
+ const C &makeAC() const;
static void f(); // expected-note{{candidate function}}
static void f(int); // expected-note{{candidate function}}
diff --git a/test/SemaCXX/address-space-conversion.cpp b/test/SemaCXX/address-space-conversion.cpp
new file mode 100644
index 0000000..d21d419
--- /dev/null
+++ b/test/SemaCXX/address-space-conversion.cpp
@@ -0,0 +1,197 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// This test checks for the various conversions and casting operations
+// with address-space-qualified pointers.
+
+struct A { virtual ~A() {} };
+struct B : A { };
+
+typedef void *void_ptr;
+typedef void __attribute__((address_space(1))) *void_ptr_1;
+typedef void __attribute__((address_space(2))) *void_ptr_2;
+
+typedef int *int_ptr;
+typedef int __attribute__((address_space(1))) *int_ptr_1;
+typedef int __attribute__((address_space(2))) *int_ptr_2;
+
+typedef A *A_ptr;
+typedef A __attribute__((address_space(1))) *A_ptr_1;
+typedef A __attribute__((address_space(2))) *A_ptr_2;
+
+typedef B *B_ptr;
+typedef B __attribute__((address_space(1))) *B_ptr_1;
+typedef B __attribute__((address_space(2))) *B_ptr_2;
+
+void test_const_cast(int_ptr ip, int_ptr_1 ip1, int_ptr_2 ip2,
+ A_ptr ap, A_ptr_1 ap1, A_ptr_2 ap2,
+ const int *cip,
+ const int __attribute__((address_space(1))) *cip1) {
+ // Cannot use const_cast to cast between address spaces, add an
+ // address space, or remove an address space.
+ (void)const_cast<int_ptr>(ip1); // expected-error{{is not allowed}}
+ (void)const_cast<int_ptr>(ip2); // expected-error{{is not allowed}}
+ (void)const_cast<int_ptr_1>(ip); // expected-error{{is not allowed}}
+ (void)const_cast<int_ptr_1>(ip2); // expected-error{{is not allowed}}
+ (void)const_cast<int_ptr_2>(ip); // expected-error{{is not allowed}}
+ (void)const_cast<int_ptr_2>(ip1); // expected-error{{is not allowed}}
+
+ (void)const_cast<A_ptr>(ap1); // expected-error{{is not allowed}}
+ (void)const_cast<A_ptr>(ap2); // expected-error{{is not allowed}}
+ (void)const_cast<A_ptr_1>(ap); // expected-error{{is not allowed}}
+ (void)const_cast<A_ptr_1>(ap2); // expected-error{{is not allowed}}
+ (void)const_cast<A_ptr_2>(ap); // expected-error{{is not allowed}}
+ (void)const_cast<A_ptr_2>(ap1); // expected-error{{is not allowed}}
+
+ // It's acceptable to cast away constness.
+ (void)const_cast<int_ptr>(cip);
+ (void)const_cast<int_ptr_1>(cip1);
+}
+
+void test_static_cast(void_ptr vp, void_ptr_1 vp1, void_ptr_2 vp2,
+ A_ptr ap, A_ptr_1 ap1, A_ptr_2 ap2,
+ B_ptr bp, B_ptr_1 bp1, B_ptr_2 bp2) {
+ // Well-formed upcast
+ (void)static_cast<A_ptr>(bp);
+ (void)static_cast<A_ptr_1>(bp1);
+ (void)static_cast<A_ptr_2>(bp2);
+
+ // Well-formed downcast
+ (void)static_cast<B_ptr>(ap);
+ (void)static_cast<B_ptr_1>(ap1);
+ (void)static_cast<B_ptr_2>(ap2);
+
+ // Well-formed cast to/from void
+ (void)static_cast<void_ptr>(ap);
+ (void)static_cast<void_ptr_1>(ap1);
+ (void)static_cast<void_ptr_2>(ap2);
+ (void)static_cast<A_ptr>(vp);
+ (void)static_cast<A_ptr_1>(vp1);
+ (void)static_cast<A_ptr_2>(vp2);
+
+ // Ill-formed upcasts
+ (void)static_cast<A_ptr>(bp1); // expected-error{{is not allowed}}
+ (void)static_cast<A_ptr>(bp2); // expected-error{{is not allowed}}
+ (void)static_cast<A_ptr_1>(bp); // expected-error{{is not allowed}}
+ (void)static_cast<A_ptr_1>(bp2); // expected-error{{is not allowed}}
+ (void)static_cast<A_ptr_2>(bp); // expected-error{{is not allowed}}
+ (void)static_cast<A_ptr_2>(bp1); // expected-error{{is not allowed}}
+
+ // Ill-formed downcasts
+ (void)static_cast<B_ptr>(ap1); // expected-error{{casts away qualifiers}}
+ (void)static_cast<B_ptr>(ap2); // expected-error{{casts away qualifiers}}
+ (void)static_cast<B_ptr_1>(ap); // expected-error{{casts away qualifiers}}
+ (void)static_cast<B_ptr_1>(ap2); // expected-error{{casts away qualifiers}}
+ (void)static_cast<B_ptr_2>(ap); // expected-error{{casts away qualifiers}}
+ (void)static_cast<B_ptr_2>(ap1); // expected-error{{casts away qualifiers}}
+
+ // Ill-formed cast to/from void
+ (void)static_cast<void_ptr>(ap1); // expected-error{{is not allowed}}
+ (void)static_cast<void_ptr>(ap2); // expected-error{{is not allowed}}
+ (void)static_cast<void_ptr_1>(ap); // expected-error{{is not allowed}}
+ (void)static_cast<void_ptr_1>(ap2); // expected-error{{is not allowed}}
+ (void)static_cast<void_ptr_2>(ap); // expected-error{{is not allowed}}
+ (void)static_cast<void_ptr_2>(ap1); // expected-error{{is not allowed}}
+ (void)static_cast<A_ptr>(vp1); // expected-error{{casts away qualifiers}}
+ (void)static_cast<A_ptr>(vp2); // expected-error{{casts away qualifiers}}
+ (void)static_cast<A_ptr_1>(vp); // expected-error{{casts away qualifiers}}
+ (void)static_cast<A_ptr_1>(vp2); // expected-error{{casts away qualifiers}}
+ (void)static_cast<A_ptr_2>(vp); // expected-error{{casts away qualifiers}}
+ (void)static_cast<A_ptr_2>(vp1); // expected-error{{casts away qualifiers}}
+}
+
+void test_dynamic_cast(A_ptr ap, A_ptr_1 ap1, A_ptr_2 ap2,
+ B_ptr bp, B_ptr_1 bp1, B_ptr_2 bp2) {
+ // Well-formed upcast
+ (void)dynamic_cast<A_ptr>(bp);
+ (void)dynamic_cast<A_ptr_1>(bp1);
+ (void)dynamic_cast<A_ptr_2>(bp2);
+
+ // Well-formed downcast
+ (void)dynamic_cast<B_ptr>(ap);
+ (void)dynamic_cast<B_ptr_1>(ap1);
+ (void)dynamic_cast<B_ptr_2>(ap2);
+
+ // Ill-formed upcasts
+ (void)dynamic_cast<A_ptr>(bp1); // expected-error{{casts away qualifiers}}
+ (void)dynamic_cast<A_ptr>(bp2); // expected-error{{casts away qualifiers}}
+ (void)dynamic_cast<A_ptr_1>(bp); // expected-error{{casts away qualifiers}}
+ (void)dynamic_cast<A_ptr_1>(bp2); // expected-error{{casts away qualifiers}}
+ (void)dynamic_cast<A_ptr_2>(bp); // expected-error{{casts away qualifiers}}
+ (void)dynamic_cast<A_ptr_2>(bp1); // expected-error{{casts away qualifiers}}
+
+ // Ill-formed downcasts
+ (void)dynamic_cast<B_ptr>(ap1); // expected-error{{casts away qualifiers}}
+ (void)dynamic_cast<B_ptr>(ap2); // expected-error{{casts away qualifiers}}
+ (void)dynamic_cast<B_ptr_1>(ap); // expected-error{{casts away qualifiers}}
+ (void)dynamic_cast<B_ptr_1>(ap2); // expected-error{{casts away qualifiers}}
+ (void)dynamic_cast<B_ptr_2>(ap); // expected-error{{casts away qualifiers}}
+ (void)dynamic_cast<B_ptr_2>(ap1); // expected-error{{casts away qualifiers}}
+}
+
+void test_reinterpret_cast(void_ptr vp, void_ptr_1 vp1, void_ptr_2 vp2,
+ A_ptr ap, A_ptr_1 ap1, A_ptr_2 ap2,
+ B_ptr bp, B_ptr_1 bp1, B_ptr_2 bp2,
+ const void __attribute__((address_space(1))) *cvp1) {
+ // reinterpret_cast can be used to cast to a different address space.
+ (void)reinterpret_cast<A_ptr>(ap1);
+ (void)reinterpret_cast<A_ptr>(ap2);
+ (void)reinterpret_cast<A_ptr>(bp);
+ (void)reinterpret_cast<A_ptr>(bp1);
+ (void)reinterpret_cast<A_ptr>(bp2);
+ (void)reinterpret_cast<A_ptr>(vp);
+ (void)reinterpret_cast<A_ptr>(vp1);
+ (void)reinterpret_cast<A_ptr>(vp2);
+ (void)reinterpret_cast<A_ptr_1>(ap);
+ (void)reinterpret_cast<A_ptr_1>(ap2);
+ (void)reinterpret_cast<A_ptr_1>(bp);
+ (void)reinterpret_cast<A_ptr_1>(bp1);
+ (void)reinterpret_cast<A_ptr_1>(bp2);
+ (void)reinterpret_cast<A_ptr_1>(vp);
+ (void)reinterpret_cast<A_ptr_1>(vp1);
+ (void)reinterpret_cast<A_ptr_1>(vp2);
+
+ // ... but don't try to cast away constness!
+ (void)reinterpret_cast<A_ptr_2>(cvp1); // expected-error{{casts away qualifiers}}
+}
+
+void test_cstyle_cast(void_ptr vp, void_ptr_1 vp1, void_ptr_2 vp2,
+ A_ptr ap, A_ptr_1 ap1, A_ptr_2 ap2,
+ B_ptr bp, B_ptr_1 bp1, B_ptr_2 bp2,
+ const void __attribute__((address_space(1))) *cvp1) {
+ // C-style casts are the wild west of casts.
+ (void)(A_ptr)(ap1);
+ (void)(A_ptr)(ap2);
+ (void)(A_ptr)(bp);
+ (void)(A_ptr)(bp1);
+ (void)(A_ptr)(bp2);
+ (void)(A_ptr)(vp);
+ (void)(A_ptr)(vp1);
+ (void)(A_ptr)(vp2);
+ (void)(A_ptr_1)(ap);
+ (void)(A_ptr_1)(ap2);
+ (void)(A_ptr_1)(bp);
+ (void)(A_ptr_1)(bp1);
+ (void)(A_ptr_1)(bp2);
+ (void)(A_ptr_1)(vp);
+ (void)(A_ptr_1)(vp1);
+ (void)(A_ptr_1)(vp2);
+ (void)(A_ptr_2)(cvp1);
+}
+
+void test_implicit_conversion(void_ptr vp, void_ptr_1 vp1, void_ptr_2 vp2,
+ A_ptr ap, A_ptr_1 ap1, A_ptr_2 ap2,
+ B_ptr bp, B_ptr_1 bp1, B_ptr_2 bp2) {
+ // Well-formed conversions
+ void_ptr vpA = ap;
+ void_ptr_1 vp_1A = ap1;
+ void_ptr_2 vp_2A = ap2;
+ A_ptr ap_A = bp;
+ A_ptr_1 ap_A1 = bp1;
+ A_ptr_2 ap_A2 = bp2;
+
+ // Ill-formed conversions
+ void_ptr vpB = ap1; // expected-error{{cannot initialize a variable of type}}
+ void_ptr_1 vp_1B = ap2; // expected-error{{cannot initialize a variable of type}}
+ A_ptr ap_B = bp1; // expected-error{{cannot initialize a variable of type}}
+ A_ptr_1 ap_B1 = bp2; // expected-error{{cannot initialize a variable of type}}
+}
diff --git a/test/SemaCXX/address-space-newdelete.cpp b/test/SemaCXX/address-space-newdelete.cpp
new file mode 100644
index 0000000..b809cd3
--- /dev/null
+++ b/test/SemaCXX/address-space-newdelete.cpp
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+void* operator new (__SIZE_TYPE__ size, void* ptr);
+void* operator new[](__SIZE_TYPE__ size, void* ptr);
+
+typedef int __attribute__((address_space(1))) int_1;
+
+void test_new(void *p) {
+ (void)new int_1; // expected-error{{'new' cannot allocate objects of type 'int' in address space '1'}}
+ (void)new __attribute__((address_space(1))) int; // expected-error{{'new' cannot allocate objects of type 'int' in address space '1'}}
+ (void)new int_1 [5]; // expected-error{{'new' cannot allocate objects of type 'int' in address space '1'}}
+ (void)new __attribute__((address_space(1))) int [5]; // expected-error{{'new' cannot allocate objects of type 'int' in address space '1'}}
+
+ // Placement new
+ (void)new (p) int_1; // expected-error{{'new' cannot allocate objects of type 'int' in address space '1'}}
+ (void)new (p) __attribute__((address_space(1))) int; // expected-error{{'new' cannot allocate objects of type 'int' in address space '1'}}
+ (void)new (p) int_1 [5]; // expected-error{{'new' cannot allocate objects of type 'int' in address space '1'}}
+ (void)new (p) __attribute__((address_space(1))) int [5]; // expected-error{{'new' cannot allocate objects of type 'int' in address space '1'}}
+}
+
+void test_delete(int_1 *ip1) {
+ delete ip1; // expected-error{{'delete' cannot delete objects of type 'int' in address space '1'}}
+ delete [] ip1; // expected-error{{'delete' cannot delete objects of type 'int' in address space '1'}}
+}
diff --git a/test/SemaCXX/address-space-references.cpp b/test/SemaCXX/address-space-references.cpp
new file mode 100644
index 0000000..f5a63d2
--- /dev/null
+++ b/test/SemaCXX/address-space-references.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+typedef int __attribute__((address_space(1))) int_1;
+typedef int __attribute__((address_space(2))) int_2;
+
+void f0(int_1 &); // expected-note{{candidate function not viable: 1st argument ('int') is in address space 0, but parameter must be in address space 1}} \
+// expected-note{{candidate function not viable: 1st argument ('int_2' (aka '__attribute__((address_space(2))) int')) is in address space 2, but parameter must be in address space 1}}
+void f0(const int_1 &); // expected-note{{candidate function not viable: 1st argument ('int') is in address space 0, but parameter must be in address space 1}} \
+// expected-note{{candidate function not viable: 1st argument ('int_2' (aka '__attribute__((address_space(2))) int')) is in address space 2, but parameter must be in address space 1}}
+
+void test_f0() {
+ int i;
+ static int_1 i1;
+ static int_2 i2;
+
+ f0(i); // expected-error{{no matching function for call to 'f0'}}
+ f0(i1);
+ f0(i2); // expected-error{{no matching function for call to 'f0'}}
+}
diff --git a/test/SemaCXX/alignof-sizeof-reference.cpp b/test/SemaCXX/alignof-sizeof-reference.cpp
index 761edfc..b517e43 100644
--- a/test/SemaCXX/alignof-sizeof-reference.cpp
+++ b/test/SemaCXX/alignof-sizeof-reference.cpp
@@ -8,8 +8,8 @@ void test() {
static_assert(sizeof(r) == 1, "bad size");
}
-void f();
-void f(int);
+void f(); // expected-note{{candidate function}}
+void f(int); // expected-note{{candidate function}}
void g() {
- sizeof(&f); // expected-error{{cannot resolve overloaded function from context}}
+ sizeof(&f); // expected-error{{cannot resolve overloaded function 'f' from context}}
}
diff --git a/test/SemaCXX/altivec.cpp b/test/SemaCXX/altivec.cpp
index 921bb73..504eb1b 100644
--- a/test/SemaCXX/altivec.cpp
+++ b/test/SemaCXX/altivec.cpp
@@ -2,6 +2,36 @@
typedef int V4i __attribute__((vector_size(16)));
+void test_vec_step(vector short arg1) {
+ vector bool char vbc;
+ vector signed char vsc;
+ vector unsigned char vuc;
+ vector bool short vbs;
+ vector short vs;
+ vector unsigned short vus;
+ vector pixel vp;
+ vector bool int vbi;
+ vector int vi;
+ vector unsigned int vui;
+ vector float vf;
+
+ vector int *pvi;
+
+ int res1[vec_step(arg1) == 8 ? 1 : -1];
+ int res2[vec_step(vbc) == 16 ? 1 : -1];
+ int res3[vec_step(vsc) == 16 ? 1 : -1];
+ int res4[vec_step(vuc) == 16 ? 1 : -1];
+ int res5[vec_step(vbs) == 8 ? 1 : -1];
+ int res6[vec_step(vs) == 8 ? 1 : -1];
+ int res7[vec_step(vus) == 8 ? 1 : -1];
+ int res8[vec_step(vp) == 8 ? 1 : -1];
+ int res9[vec_step(vbi) == 4 ? 1 : -1];
+ int res10[vec_step(vi) == 4 ? 1 : -1];
+ int res11[vec_step(vui) == 4 ? 1 : -1];
+ int res12[vec_step(vf) == 4 ? 1 : -1];
+ int res13[vec_step(*pvi) == 4 ? 1 : -1];
+}
+
void f(V4i a)
{
}
diff --git a/test/SemaCXX/array-bounds.cpp b/test/SemaCXX/array-bounds.cpp
index 80646c7..3bd6c354 100644
--- a/test/SemaCXX/array-bounds.cpp
+++ b/test/SemaCXX/array-bounds.cpp
@@ -120,3 +120,56 @@ int test_pr9296() {
return array[true]; // no-warning
}
+int test_sizeof_as_condition(int flag) {
+ int arr[2] = { 0, 0 }; // expected-note {{array 'arr' declared here}}
+ if (flag)
+ return sizeof(char) != sizeof(char) ? arr[2] : arr[1];
+ return sizeof(char) == sizeof(char) ? arr[2] : arr[1]; // expected-warning {{array index of '2' indexes past the end of an array (that contains 2 elements)}}
+}
+
+void test_switch() {
+ switch (4) {
+ case 1: {
+ int arr[2];
+ arr[2] = 1; // no-warning
+ break;
+ }
+ case 4: {
+ int arr[2]; // expected-note {{array 'arr' declared here}}
+ arr[2] = 1; // expected-warning {{array index of '2' indexes past the end of an array (that contains 2 elements)}}
+ break;
+ }
+ default: {
+ int arr[2];
+ arr[2] = 1; // no-warning
+ break;
+ }
+ }
+}
+
+// Test nested switch statements.
+enum enumA { enumA_A, enumA_B, enumA_C, enumA_D, enumA_E };
+enum enumB { enumB_X, enumB_Y, enumB_Z };
+static enum enumB myVal = enumB_X;
+void test_nested_switch()
+{
+ switch (enumA_E) { // expected-warning {{no case matching constant}}
+ switch (myVal) { // expected-warning {{enumeration values 'enumB_X' and 'enumB_Z' not handled in switch}}
+ case enumB_Y: ;
+ }
+ }
+}
+
+// Test that if all the values of an enum covered, that the 'default' branch
+// is unreachable.
+enum Values { A, B, C, D };
+void test_all_enums_covered(enum Values v) {
+ int x[2];
+ switch (v) {
+ case A: return;
+ case B: return;
+ case C: return;
+ case D: return;
+ }
+ x[2] = 0; // no-warning
+}
diff --git a/test/SemaCXX/attr-nonnull.cpp b/test/SemaCXX/attr-nonnull.cpp
index 19d6642..09c054c1 100644
--- a/test/SemaCXX/attr-nonnull.cpp
+++ b/test/SemaCXX/attr-nonnull.cpp
@@ -1,5 +1,7 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
struct S {
+ S(const char *) __attribute__((nonnull(2)));
+
static void f(const char*, const char*) __attribute__((nonnull(1)));
// GCC has a hidden 'this' argument in member functions, so the middle
@@ -10,7 +12,9 @@ struct S {
expected-error{{invalid for the implicit this argument}}
};
-void test(S s) {
+void test() {
+ S s(0); // expected-warning{{null passed}}
+
s.f(0, ""); // expected-warning{{null passed}}
s.f("", 0);
s.g("", 0, ""); // expected-warning{{null passed}}
diff --git a/test/SemaCXX/attr-unavailable.cpp b/test/SemaCXX/attr-unavailable.cpp
index fe3e8b1..5f34ed9 100644
--- a/test/SemaCXX/attr-unavailable.cpp
+++ b/test/SemaCXX/attr-unavailable.cpp
@@ -25,6 +25,6 @@ namespace radar9046492 {
void foo() FOO; // expected-note {{candidate function has been explicitly made unavailable}}
void bar() {
- foo(); // expected-error {{call to unavailable function 'foo' not available - replaced}}
+ foo(); // expected-error {{call to unavailable function 'foo': not available - replaced}}
}
}
diff --git a/test/SemaCXX/auto-subst-failure.cpp b/test/SemaCXX/auto-subst-failure.cpp
new file mode 100644
index 0000000..442c7e8
--- /dev/null
+++ b/test/SemaCXX/auto-subst-failure.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++0x
+
+void f() {
+ auto a = f(); // expected-error {{variable has incomplete type 'void'}}
+ auto &b = f(); // expected-error {{cannot form a reference to 'void'}}
+ auto *c = f(); // expected-error {{incompatible initializer of type 'void'}}
+
+ auto d(f()); // expected-error {{variable has incomplete type 'void'}}
+ auto &&e(f()); // expected-error {{cannot form a reference to 'void'}}
+ auto *g(f()); // expected-error {{incompatible initializer of type 'void'}}
+
+ (void)new auto(f()); // expected-error {{allocation of incomplete type 'void'}}
+ (void)new auto&(f()); // expected-error {{cannot form a reference to 'void'}}
+ (void)new auto*(f()); // expected-error {{incompatible constructor argument of type 'void'}}
+}
diff --git a/test/SemaCXX/conditional-expr.cpp b/test/SemaCXX/conditional-expr.cpp
index 1da9a17..b95700e 100644
--- a/test/SemaCXX/conditional-expr.cpp
+++ b/test/SemaCXX/conditional-expr.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fexceptions -fsyntax-only -verify -std=c++0x -Wsign-compare %s
+// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -fsyntax-only -verify -std=c++0x -Wsign-compare %s
// C++ rules for ?: are a lot stricter than C rules, and have to take into
// account more conversion options.
diff --git a/test/SemaCXX/conversion-function.cpp b/test/SemaCXX/conversion-function.cpp
index 61c8ada..aa47ae0 100644
--- a/test/SemaCXX/conversion-function.cpp
+++ b/test/SemaCXX/conversion-function.cpp
@@ -353,3 +353,28 @@ namespace PR8034 {
};
int x = C().operator int();
}
+
+namespace PR9336 {
+ template<class T>
+ struct generic_list
+ {
+ template<class Container>
+ operator Container()
+ {
+ Container ar;
+ T* i;
+ ar[0]=*i;
+ return ar;
+ }
+ };
+
+ template<class T>
+ struct array
+ {
+ T& operator[](int);
+ const T& operator[](int)const;
+ };
+
+ generic_list<generic_list<int> > l;
+ array<array<int> > a = l;
+}
diff --git a/test/SemaCXX/cxx0x-constexpr-const.cpp b/test/SemaCXX/cxx0x-constexpr-const.cpp
new file mode 100644
index 0000000..79e6dda
--- /dev/null
+++ b/test/SemaCXX/cxx0x-constexpr-const.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -std=c++0x -fsyntax-only -verify %s
+
+constexpr int x = 1;
+constexpr int id(int x) { return x; }
+
+void foo(void) {
+ x = 2; // expected-error {{read-only variable is not assignable}}
+ int (*idp)(int) = id;
+}
+
diff --git a/test/SemaCXX/cxx0x-delegating-ctors.cpp b/test/SemaCXX/cxx0x-delegating-ctors.cpp
new file mode 100644
index 0000000..b211cb1
--- /dev/null
+++ b/test/SemaCXX/cxx0x-delegating-ctors.cpp
@@ -0,0 +1,36 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++0x -verify %s
+
+struct foo {
+ int i;
+ foo();
+ foo(int);
+ foo(int, int);
+ foo(bool);
+ foo(char);
+ foo(float*);
+ foo(float&);
+};
+
+// Good
+foo::foo (int i) : i(i) {
+}
+// Good
+foo::foo () : foo(-1) {
+}
+// Good
+foo::foo (int, int) : foo() {
+}
+
+foo::foo (bool) : foo(true) { // expected-error{{delegates to itself}}
+}
+
+// Good
+foo::foo (float* f) : foo(*f) {
+}
+
+// FIXME: This should error
+foo::foo (float &f) : foo(&f) {
+}
+
+foo::foo (char) : i(3), foo(3) { // expected-error{{must appear alone}}
+}
diff --git a/test/SemaCXX/cxx0x-return-init-list.cpp b/test/SemaCXX/cxx0x-return-init-list.cpp
new file mode 100644
index 0000000..2005a7f
--- /dev/null
+++ b/test/SemaCXX/cxx0x-return-init-list.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// This test checks for a teeny tiny subset of the functionality in
+// the C++0x generalized initializer lists feature, which happens to
+// be used in libstdc++ 4.5. We accept only this syntax so that Clang
+// can handle the libstdc++ 4.5 headers.
+
+int test0(int i) {
+ return { i }; // expected-warning{{generalized initializer lists are a C++0x extension unsupported in Clang}}
+}
+
+template<typename T, typename U>
+T test1(U u) {
+ return { u }; // expected-warning{{generalized initializer lists are a C++0x extension unsupported in Clang}}
+}
+
+template int test1(char);
+template long test1(int);
diff --git a/test/SemaCXX/decltype-98.cpp b/test/SemaCXX/decltype-98.cpp
new file mode 100644
index 0000000..db52565
--- /dev/null
+++ b/test/SemaCXX/decltype-98.cpp
@@ -0,0 +1,3 @@
+// RUN: %clang_cc1 -std=c++98 -fsyntax-only -verify %s
+extern int x;
+__decltype(1) x = 3;
diff --git a/test/SemaCXX/decltype-overloaded-functions.cpp b/test/SemaCXX/decltype-overloaded-functions.cpp
index c11a47e..f4aacd6 100644
--- a/test/SemaCXX/decltype-overloaded-functions.cpp
+++ b/test/SemaCXX/decltype-overloaded-functions.cpp
@@ -1,12 +1,15 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++0x
-void f();
-void f(int);
-decltype(f) a; // expected-error{{cannot resolve overloaded function from context}}
+void f(); // expected-note{{candidate function}}
+void f(int); // expected-note{{candidate function}}
+decltype(f) a; // expected-error{{cannot resolve overloaded function 'f' from context}}
template<typename T> struct S {
- decltype(T::f) * f; // expected-error{{cannot resolve overloaded function from context}}
+ decltype(T::f) * f; // expected-error{{cannot resolve overloaded function 'f' from context}}
};
-struct K { void f(); void f(int); };
+struct K {
+ void f(); // expected-note{{candidate function}}
+ void f(int); // expected-note{{candidate function}}
+};
S<K> b; // expected-note{{in instantiation of template class 'S<K>' requested here}}
diff --git a/test/SemaCXX/destructor.cpp b/test/SemaCXX/destructor.cpp
index 14a4fb8..01f21de 100644
--- a/test/SemaCXX/destructor.cpp
+++ b/test/SemaCXX/destructor.cpp
@@ -177,3 +177,16 @@ namespace PR9238 {
class B { public: ~B(); };
class C : virtual B { public: ~C() { } };
}
+
+namespace PR7900 {
+ struct A { // expected-note 2{{type 'PR7900::A' is declared here}}
+ };
+ struct B : public A {
+ };
+ void foo() {
+ B b;
+ b.~B();
+ b.~A(); // expected-error{{destructor type 'PR7900::A' in object destruction expression does not match the type 'PR7900::B' of the object being destroyed}}
+ (&b)->~A(); // expected-error{{destructor type 'PR7900::A' in object destruction expression does not match the type 'PR7900::B' of the object being destroyed}}
+ }
+}
diff --git a/test/SemaCXX/enum-scoped.cpp b/test/SemaCXX/enum-scoped.cpp
index cf579e1..8c4bfe7 100644
--- a/test/SemaCXX/enum-scoped.cpp
+++ b/test/SemaCXX/enum-scoped.cpp
@@ -103,3 +103,9 @@ enum : long {
enum : long x; // expected-error{{unnamed enumeration must be a definition}} \
// expected-warning{{declaration does not declare anything}}
+
+void PR9333() {
+ enum class scoped_enum { yes, no, maybe };
+ scoped_enum e = scoped_enum::yes;
+ if (e == scoped_enum::no) { }
+}
diff --git a/test/SemaCXX/exception-spec-no-exceptions.cpp b/test/SemaCXX/exception-spec-no-exceptions.cpp
index 1fe45b0..2e18070 100644
--- a/test/SemaCXX/exception-spec-no-exceptions.cpp
+++ b/test/SemaCXX/exception-spec-no-exceptions.cpp
@@ -1,7 +1,8 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -fexceptions -fobjc-exceptions %s
-// Note: this is intentionally -fno-exceptions, not just accidentally
-// so because that's the current -cc1 default.
+// Note that we're specifically excluding -fcxx-exceptions in the command line above.
+
+// That this should work even with -fobjc-exceptions is PR9358
// PR7243: redeclarations
namespace test0 {
diff --git a/test/SemaCXX/exception-spec.cpp b/test/SemaCXX/exception-spec.cpp
deleted file mode 100644
index b4bc78a..0000000
--- a/test/SemaCXX/exception-spec.cpp
+++ /dev/null
@@ -1,193 +0,0 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -fexceptions %s
-
-// Straight from the standard:
-// Plain function with spec
-void f() throw(int);
-// Pointer to function with spec
-void (*fp)() throw (int);
-// Function taking reference to function with spec
-void g(void pfa() throw(int));
-// Typedef for pointer to function with spec
-typedef int (*pf)() throw(int); // expected-error {{specifications are not allowed in typedefs}}
-
-// Some more:
-// Function returning function with spec
-void (*h())() throw(int);
-// Ultimate parser thrill: function with spec returning function with spec and
-// taking pointer to function with spec.
-// The actual function throws int, the return type double, the argument float.
-void (*i() throw(int))(void (*)() throw(float)) throw(double);
-// Pointer to pointer to function taking function with spec
-void (**k)(void pfa() throw(int)); // no-error
-// Pointer to pointer to function with spec
-void (**j)() throw(int); // expected-error {{not allowed beyond a single}}
-// Pointer to function returning pointer to pointer to function with spec
-void (**(*h())())() throw(int); // expected-error {{not allowed beyond a single}}
-
-struct Incomplete; // expected-note 3 {{forward declaration}}
-
-// Exception spec must not have incomplete types, or pointers to them, except
-// void.
-void ic1() throw(void); // expected-error {{incomplete type 'void' is not allowed in exception specification}}
-void ic2() throw(Incomplete); // expected-error {{incomplete type 'Incomplete' is not allowed in exception specification}}
-void ic3() throw(void*);
-void ic4() throw(Incomplete*); // expected-error {{pointer to incomplete type 'Incomplete' is not allowed in exception specification}}
-void ic5() throw(Incomplete&); // expected-error {{reference to incomplete type 'Incomplete' is not allowed in exception specification}}
-
-// Redeclarations
-typedef int INT;
-void r1() throw(int);
-void r1() throw(int);
-
-void r2() throw(int);
-void r2() throw(INT);
-
-// throw-any spec and no spec at all are semantically equivalent
-void r4() throw(int, float);
-void r4() throw(float, int);
-
-void r5() throw(int); // expected-note {{previous declaration}}
-void r5(); // expected-warning {{missing exception specification}}
-
-void r7() throw(int); // expected-note {{previous declaration}}
-void r7() throw(float); // expected-error {{exception specification in declaration does not match}}
-
-// Top-level const doesn't matter.
-void r8() throw(int);
-void r8() throw(const int);
-
-// Multiple appearances don't matter.
-void r9() throw(int, int);
-void r9() throw(int, int);
-
-struct A
-{
-};
-
-struct B1 : A
-{
-};
-
-struct B2 : A
-{
-};
-
-struct D : B1, B2
-{
-};
-
-struct P : private A
-{
-};
-
-struct Base
-{
- virtual void f1() throw();
- virtual void f4() throw(int, float);
-
- virtual void f5() throw(int, float);
- virtual void f6() throw(A);
- virtual void f7() throw(A, int, float);
- virtual void f8();
-
- virtual void g1() throw(); // expected-note {{overridden virtual function is here}}
- virtual void g2() throw(int); // expected-note {{overridden virtual function is here}}
- virtual void g3() throw(A); // expected-note {{overridden virtual function is here}}
- virtual void g4() throw(B1); // expected-note {{overridden virtual function is here}}
- virtual void g5() throw(A); // expected-note {{overridden virtual function is here}}
-};
-struct Derived : Base
-{
- virtual void f1() throw();
- virtual void f4() throw(float, int);
-
- virtual void f5() throw(float);
- virtual void f6() throw(B1);
- virtual void f7() throw(B1, B2, int);
- virtual void f8() throw(B2, B2, int, float, char, double, bool);
-
- virtual void g1() throw(int); // expected-error {{exception specification of overriding function is more lax}}
- virtual void g2(); // expected-error {{exception specification of overriding function is more lax}}
- virtual void g3() throw(D); // expected-error {{exception specification of overriding function is more lax}}
- virtual void g4() throw(A); // expected-error {{exception specification of overriding function is more lax}}
- virtual void g5() throw(P); // expected-error {{exception specification of overriding function is more lax}}
-};
-
-// Some functions to play with below.
-void s1() throw();
-void s2() throw(int);
-void s3() throw(A);
-void s4() throw(B1);
-void s5() throw(D);
-void s6();
-void s7() throw(int, float);
-void (*s8())() throw(B1); // s8 returns a pointer to function with spec
-void s9(void (*)() throw(B1)); // s9 takes pointer to function with spec
-
-void fnptrs()
-{
- // Assignment and initialization of function pointers.
- void (*t1)() throw() = &s1; // valid
- t1 = &s2; // expected-error {{not superset}} expected-error {{incompatible type}}
- t1 = &s3; // expected-error {{not superset}} expected-error {{incompatible type}}
- void (&t2)() throw() = s2; // expected-error {{not superset}}
- void (*t3)() throw(int) = &s2; // valid
- void (*t4)() throw(A) = &s1; // valid
- t4 = &s3; // valid
- t4 = &s4; // valid
- t4 = &s5; // expected-error {{not superset}} expected-error {{incompatible type}}
- void (*t5)() = &s1; // valid
- t5 = &s2; // valid
- t5 = &s6; // valid
- t5 = &s7; // valid
- t1 = t3; // expected-error {{not superset}} expected-error {{incompatible type}}
- t3 = t1; // valid
- void (*t6)() throw(B1);
- t6 = t4; // expected-error {{not superset}} expected-error {{incompatible type}}
- t4 = t6; // valid
- t5 = t1; // valid
- t1 = t5; // expected-error {{not superset}} expected-error {{incompatible type}}
-
- // return types and arguments must match exactly, no inheritance allowed
- void (*(*t7)())() throw(B1) = &s8; // valid
- void (*(*t8)())() throw(A) = &s8; // expected-error {{return types differ}}
- void (*(*t9)())() throw(D) = &s8; // expected-error {{return types differ}}
- void (*t10)(void (*)() throw(B1)) = &s9; // valid expected-warning{{disambiguated}}
- void (*t11)(void (*)() throw(A)) = &s9; // expected-error {{argument types differ}} expected-warning{{disambiguated}}
- void (*t12)(void (*)() throw(D)) = &s9; // expected-error {{argument types differ}} expected-warning{{disambiguated}}
-}
-
-// Member function stuff
-
-struct Str1 { void f() throw(int); }; // expected-note {{previous declaration}}
-void Str1::f() // expected-warning {{missing exception specification}}
-{
-}
-
-void mfnptr()
-{
- void (Str1::*pfn1)() throw(int) = &Str1::f; // valid
- void (Str1::*pfn2)() = &Str1::f; // valid
- void (Str1::*pfn3)() throw() = &Str1::f; // expected-error {{not superset}}
-}
-
-// Don't suppress errors in template instantiation.
-template <typename T> struct TEx; // expected-note {{template is declared here}}
-
-void tf() throw(TEx<int>); // expected-error {{implicit instantiation of undefined template}}
-
-// DR 437, class throws itself.
-struct DR437 {
- void f() throw(DR437);
- void g() throw(DR437*);
- void h() throw(DR437&);
-};
-
-// DR 437 within a nested class
-struct DR437_out {
- struct DR437_in {
- void f() throw(DR437_out);
- void g() throw(DR437_out*);
- void h() throw(DR437_out&);
- };
-};
diff --git a/test/SemaCXX/exceptions.cpp b/test/SemaCXX/exceptions.cpp
index bda4a3d..e2bfe18 100644
--- a/test/SemaCXX/exceptions.cpp
+++ b/test/SemaCXX/exceptions.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fexceptions -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -fsyntax-only -verify %s
struct A; // expected-note 4 {{forward declaration of 'A'}}
diff --git a/test/SemaCXX/expression-traits.cpp b/test/SemaCXX/expression-traits.cpp
new file mode 100644
index 0000000..4555192
--- /dev/null
+++ b/test/SemaCXX/expression-traits.cpp
@@ -0,0 +1,620 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -fcxx-exceptions %s
+
+//
+// Tests for "expression traits" intrinsics such as __is_lvalue_expr.
+//
+// For the time being, these tests are written against the 2003 C++
+// standard (ISO/IEC 14882:2003 -- see draft at
+// http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2001/n1316/).
+//
+// C++0x has its own, more-refined, idea of lvalues and rvalues.
+// If/when we need to support those, we'll need to track both
+// standard documents.
+
+#if !__has_feature(cxx_static_assert)
+# define CONCAT_(X_, Y_) CONCAT1_(X_, Y_)
+# define CONCAT1_(X_, Y_) X_ ## Y_
+
+// This emulation can be used multiple times on one line (and thus in
+// a macro), except at class scope
+# define static_assert(b_, m_) \
+ typedef int CONCAT_(sa_, __LINE__)[b_ ? 1 : -1]
+#endif
+
+// Tests are broken down according to section of the C++03 standard
+// (ISO/IEC 14882:2003(E))
+
+// Assertion macros encoding the following two paragraphs
+//
+// basic.lval/1 Every expression is either an lvalue or an rvalue.
+//
+// expr.prim/5 A parenthesized expression is a primary expression whose type
+// and value are identical to those of the enclosed expression. The
+// presence of parentheses does not affect whether the expression is
+// an lvalue.
+//
+// Note: these asserts cannot be made at class scope in C++03. Put
+// them in a member function instead.
+#define ASSERT_LVALUE(expr) \
+ static_assert(__is_lvalue_expr(expr), "should be an lvalue"); \
+ static_assert(__is_lvalue_expr((expr)), \
+ "the presence of parentheses should have" \
+ " no effect on lvalueness (expr.prim/5)"); \
+ static_assert(!__is_rvalue_expr(expr), "should be an lvalue"); \
+ static_assert(!__is_rvalue_expr((expr)), \
+ "the presence of parentheses should have" \
+ " no effect on lvalueness (expr.prim/5)")
+
+#define ASSERT_RVALUE(expr); \
+ static_assert(__is_rvalue_expr(expr), "should be an rvalue"); \
+ static_assert(__is_rvalue_expr((expr)), \
+ "the presence of parentheses should have" \
+ " no effect on lvalueness (expr.prim/5)"); \
+ static_assert(!__is_lvalue_expr(expr), "should be an rvalue"); \
+ static_assert(!__is_lvalue_expr((expr)), \
+ "the presence of parentheses should have" \
+ " no effect on lvalueness (expr.prim/5)")
+
+enum Enum { Enumerator };
+
+int ReturnInt();
+void ReturnVoid();
+Enum ReturnEnum();
+
+void basic_lval_5()
+{
+ // basic.lval/5: The result of calling a function that does not return
+ // a reference is an rvalue.
+ ASSERT_RVALUE(ReturnInt());
+ ASSERT_RVALUE(ReturnVoid());
+ ASSERT_RVALUE(ReturnEnum());
+}
+
+int& ReturnIntReference();
+extern Enum& ReturnEnumReference();
+
+void basic_lval_6()
+{
+ // basic.lval/6: An expression which holds a temporary object resulting
+ // from a cast to a nonreference type is an rvalue (this includes
+ // the explicit creation of an object using functional notation
+ struct IntClass
+ {
+ explicit IntClass(int = 0);
+ IntClass(char const*);
+ operator int() const;
+ };
+
+ struct ConvertibleToIntClass
+ {
+ operator IntClass() const;
+ };
+
+ ConvertibleToIntClass b;
+
+ // Make sure even trivial conversions are not detected as lvalues
+ int intLvalue = 0;
+ ASSERT_RVALUE((int)intLvalue);
+ ASSERT_RVALUE((short)intLvalue);
+ ASSERT_RVALUE((long)intLvalue);
+
+ // Same tests with function-call notation
+ ASSERT_RVALUE(int(intLvalue));
+ ASSERT_RVALUE(short(intLvalue));
+ ASSERT_RVALUE(long(intLvalue));
+
+ char charLValue = 'x';
+ ASSERT_RVALUE((signed char)charLValue);
+ ASSERT_RVALUE((unsigned char)charLValue);
+
+ ASSERT_RVALUE(static_cast<int>(IntClass()));
+ IntClass intClassLValue;
+ ASSERT_RVALUE(static_cast<int>(intClassLValue));
+ ASSERT_RVALUE(static_cast<IntClass>(ConvertibleToIntClass()));
+ ConvertibleToIntClass convertibleToIntClassLValue;
+ ASSERT_RVALUE(static_cast<IntClass>(convertibleToIntClassLValue));
+
+
+ typedef signed char signed_char;
+ typedef unsigned char unsigned_char;
+ ASSERT_RVALUE(signed_char(charLValue));
+ ASSERT_RVALUE(unsigned_char(charLValue));
+
+ ASSERT_RVALUE(int(IntClass()));
+ ASSERT_RVALUE(int(intClassLValue));
+ ASSERT_RVALUE(IntClass(ConvertibleToIntClass()));
+ ASSERT_RVALUE(IntClass(convertibleToIntClassLValue));
+}
+
+void conv_ptr_1()
+{
+ // conv.ptr/1: A null pointer constant is an integral constant
+ // expression (5.19) rvalue of integer type that evaluates to
+ // zero.
+ ASSERT_RVALUE(0);
+}
+
+void expr_6()
+{
+ // expr/6: If an expression initially has the type “reference to T”
+ // (8.3.2, 8.5.3), ... the expression is an lvalue.
+ int x = 0;
+ int& referenceToInt = x;
+ ASSERT_LVALUE(referenceToInt);
+ ASSERT_LVALUE(ReturnIntReference());
+}
+
+void expr_prim_2()
+{
+ // 5.1/2 A string literal is an lvalue; all other
+ // literals are rvalues.
+ ASSERT_LVALUE("foo");
+ ASSERT_RVALUE(1);
+ ASSERT_RVALUE(1.2);
+ ASSERT_RVALUE(10UL);
+}
+
+void expr_prim_3()
+{
+ // 5.1/3: The keyword "this" names a pointer to the object for
+ // which a nonstatic member function (9.3.2) is invoked. ...The
+ // expression is an rvalue.
+ struct ThisTest
+ {
+ void f() { ASSERT_RVALUE(this); }
+ };
+}
+
+extern int variable;
+void Function();
+
+struct BaseClass
+{
+ virtual ~BaseClass();
+
+ int BaseNonstaticMemberFunction();
+ static int BaseStaticMemberFunction();
+ int baseDataMember;
+};
+
+struct Class : BaseClass
+{
+ static void function();
+ static int variable;
+
+ template <class T>
+ struct NestedClassTemplate {};
+
+ template <class T>
+ static int& NestedFuncTemplate() { return variable; } // expected-note{{candidate function}}
+
+ template <class T>
+ int& NestedMemfunTemplate() { return variable; }
+
+ int operator*() const;
+
+ template <class T>
+ int operator+(T) const;
+
+ int NonstaticMemberFunction();
+ static int StaticMemberFunction();
+ int dataMember;
+
+ int& referenceDataMember;
+ static int& staticReferenceDataMember;
+ static int staticNonreferenceDataMember;
+
+ enum Enum { Enumerator };
+
+ operator long() const;
+
+ Class();
+ Class(int,int);
+
+ void expr_prim_4()
+ {
+ // 5.1/4: The operator :: followed by an identifier, a
+ // qualified-id, or an operator-function-id is a primary-
+ // expression. ...The result is an lvalue if the entity is
+ // a function or variable.
+ ASSERT_LVALUE(::Function); // identifier: function
+ ASSERT_LVALUE(::variable); // identifier: variable
+
+ // the only qualified-id form that can start without "::" (and thus
+ // be legal after "::" ) is
+ //
+ // ::<sub>opt</sub> nested-name-specifier template<sub>opt</sub> unqualified-id
+ ASSERT_LVALUE(::Class::function); // qualified-id: function
+ ASSERT_LVALUE(::Class::variable); // qualified-id: variable
+
+ // The standard doesn't give a clear answer about whether these
+ // should really be lvalues or rvalues without some surrounding
+ // context that forces them to be interpreted as naming a
+ // particular function template specialization (that situation
+ // doesn't come up in legal pure C++ programs). This language
+ // extension simply rejects them as requiring additional context
+ __is_lvalue_expr(::Class::NestedFuncTemplate); // qualified-id: template \
+ // expected-error{{cannot resolve overloaded function 'NestedFuncTemplate' from context}}
+
+ __is_lvalue_expr(::Class::NestedMemfunTemplate); // qualified-id: template \
+ // expected-error{{a bound member function may only be called}}
+
+ __is_lvalue_expr(::Class::operator+); // operator-function-id: template \
+ // expected-error{{a bound member function may only be called}}
+
+ //ASSERT_RVALUE(::Class::operator*); // operator-function-id: member function
+ }
+
+ void expr_prim_7()
+ {
+ // expr.prim/7 An identifier is an id-expression provided it has been
+ // suitably declared (clause 7). [Note: ... ] The type of the
+ // expression is the type of the identifier. The result is the
+ // entity denoted by the identifier. The result is an lvalue if
+ // the entity is a function, variable, or data member... (cont'd)
+ ASSERT_LVALUE(Function); // identifier: function
+ ASSERT_LVALUE(StaticMemberFunction); // identifier: function
+ ASSERT_LVALUE(variable); // identifier: variable
+ ASSERT_LVALUE(dataMember); // identifier: data member
+ //ASSERT_RVALUE(NonstaticMemberFunction); // identifier: member function
+
+ // (cont'd)...A nested-name-specifier that names a class,
+ // optionally followed by the keyword template (14.2), and then
+ // followed by the name of a member of either that class (9.2) or
+ // one of its base classes... is a qualified-id... The result is
+ // the member. The type of the result is the type of the
+ // member. The result is an lvalue if the member is a static
+ // member function or a data member.
+ ASSERT_LVALUE(Class::dataMember);
+ ASSERT_LVALUE(Class::StaticMemberFunction);
+ //ASSERT_RVALUE(Class::NonstaticMemberFunction); // identifier: member function
+
+ ASSERT_LVALUE(Class::baseDataMember);
+ ASSERT_LVALUE(Class::BaseStaticMemberFunction);
+ //ASSERT_RVALUE(Class::BaseNonstaticMemberFunction); // identifier: member function
+ }
+};
+
+void expr_call_10()
+{
+ // expr.call/10: A function call is an lvalue if and only if the
+ // result type is a reference. This statement is partially
+ // redundant with basic.lval/5
+ basic_lval_5();
+
+ ASSERT_LVALUE(ReturnIntReference());
+ ASSERT_LVALUE(ReturnEnumReference());
+}
+
+namespace Namespace
+{
+ int x;
+ void function();
+}
+
+void expr_prim_8()
+{
+ // expr.prim/8 A nested-name-specifier that names a namespace
+ // (7.3), followed by the name of a member of that namespace (or
+ // the name of a member of a namespace made visible by a
+ // using-directive ) is a qualified-id; 3.4.3.2 describes name
+ // lookup for namespace members that appear in qualified-ids. The
+ // result is the member. The type of the result is the type of the
+ // member. The result is an lvalue if the member is a function or
+ // a variable.
+ ASSERT_LVALUE(Namespace::x);
+ ASSERT_LVALUE(Namespace::function);
+}
+
+void expr_sub_1(int* pointer)
+{
+ // expr.sub/1 A postfix expression followed by an expression in
+ // square brackets is a postfix expression. One of the expressions
+ // shall have the type “pointer to T” and the other shall have
+ // enumeration or integral type. The result is an lvalue of type
+ // “T.”
+ ASSERT_LVALUE(pointer[1]);
+
+ // The expression E1[E2] is identical (by definition) to *((E1)+(E2)).
+ ASSERT_LVALUE(*(pointer+1));
+}
+
+void expr_type_conv_1()
+{
+ // expr.type.conv/1 A simple-type-specifier (7.1.5) followed by a
+ // parenthesized expression-list constructs a value of the specified
+ // type given the expression list. ... If the expression list
+ // specifies more than a single value, the type shall be a class with
+ // a suitably declared constructor (8.5, 12.1), and the expression
+ // T(x1, x2, ...) is equivalent in effect to the declaration T t(x1,
+ // x2, ...); for some invented temporary variable t, with the result
+ // being the value of t as an rvalue.
+ ASSERT_RVALUE(Class(2,2));
+}
+
+void expr_type_conv_2()
+{
+ // expr.type.conv/2 The expression T(), where T is a
+ // simple-type-specifier (7.1.5.2) for a non-array complete object
+ // type or the (possibly cv-qualified) void type, creates an
+ // rvalue of the specified type,
+ ASSERT_RVALUE(int());
+ ASSERT_RVALUE(Class());
+ ASSERT_RVALUE(void());
+}
+
+
+void expr_ref_4()
+{
+ // Applies to expressions of the form E1.E2
+
+ // If E2 is declared to have type “reference to T”, then E1.E2 is
+ // an lvalue;.... Otherwise, one of the following rules applies.
+ ASSERT_LVALUE(Class().staticReferenceDataMember);
+ ASSERT_LVALUE(Class().referenceDataMember);
+
+ // — If E2 is a static data member, and the type of E2 is T, then
+ // E1.E2 is an lvalue; ...
+ ASSERT_LVALUE(Class().staticNonreferenceDataMember);
+ ASSERT_LVALUE(Class().staticReferenceDataMember);
+
+
+ // — If E2 is a non-static data member, ... If E1 is an lvalue,
+ // then E1.E2 is an lvalue...
+ Class lvalue;
+ ASSERT_LVALUE(lvalue.dataMember);
+ ASSERT_RVALUE(Class().dataMember);
+
+ // — If E1.E2 refers to a static member function, ... then E1.E2
+ // is an lvalue
+ ASSERT_LVALUE(Class().StaticMemberFunction);
+
+ // — Otherwise, if E1.E2 refers to a non-static member function,
+ // then E1.E2 is not an lvalue.
+ //ASSERT_RVALUE(Class().NonstaticMemberFunction);
+
+ // — If E2 is a member enumerator, and the type of E2 is T, the
+ // expression E1.E2 is not an lvalue. The type of E1.E2 is T.
+ ASSERT_RVALUE(Class().Enumerator);
+ ASSERT_RVALUE(lvalue.Enumerator);
+}
+
+
+void expr_post_incr_1(int x)
+{
+ // expr.post.incr/1 The value obtained by applying a postfix ++ is
+ // the value that the operand had before applying the
+ // operator... The result is an rvalue.
+ ASSERT_RVALUE(x++);
+}
+
+void expr_dynamic_cast_2()
+{
+ // expr.dynamic.cast/2: If T is a pointer type, v shall be an
+ // rvalue of a pointer to complete class type, and the result is
+ // an rvalue of type T.
+ Class instance;
+ ASSERT_RVALUE(dynamic_cast<Class*>(&instance));
+
+ // If T is a reference type, v shall be an
+ // lvalue of a complete class type, and the result is an lvalue of
+ // the type referred to by T.
+ ASSERT_LVALUE(dynamic_cast<Class&>(instance));
+}
+
+void expr_dynamic_cast_5()
+{
+ // expr.dynamic.cast/5: If T is “reference to cv1 B” and v has type
+ // “cv2 D” such that B is a base class of D, the result is an
+ // lvalue for the unique B sub-object of the D object referred
+ // to by v.
+ typedef BaseClass B;
+ typedef Class D;
+ D object;
+ ASSERT_LVALUE(dynamic_cast<B&>(object));
+}
+
+// expr.dynamic.cast/8: The run-time check logically executes as follows:
+//
+// — If, in the most derived object pointed (referred) to by v, v
+// points (refers) to a public base class subobject of a T object, and
+// if only one object of type T is derived from the sub-object pointed
+// (referred) to by v, the result is a pointer (an lvalue referring)
+// to that T object.
+//
+// — Otherwise, if v points (refers) to a public base class sub-object
+// of the most derived object, and the type of the most derived object
+// has a base class, of type T, that is unambiguous and public, the
+// result is a pointer (an lvalue referring) to the T sub-object of
+// the most derived object.
+//
+// The mention of "lvalue" in the text above appears to be a
+// defect that is being corrected by the response to UK65 (see
+// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2009/n2841.html).
+
+#if 0
+void expr_typeid_1()
+{
+ // expr.typeid/1: The result of a typeid expression is an lvalue...
+ ASSERT_LVALUE(typeid(1));
+}
+#endif
+
+void expr_static_cast_1(int x)
+{
+ // expr.static.cast/1: The result of the expression
+ // static_cast<T>(v) is the result of converting the expression v
+ // to type T. If T is a reference type, the result is an lvalue;
+ // otherwise, the result is an rvalue.
+ ASSERT_LVALUE(static_cast<int&>(x));
+ ASSERT_RVALUE(static_cast<int>(x));
+}
+
+void expr_reinterpret_cast_1()
+{
+ // expr.reinterpret.cast/1: The result of the expression
+ // reinterpret_cast<T>(v) is the result of converting the
+ // expression v to type T. If T is a reference type, the result is
+ // an lvalue; otherwise, the result is an rvalue
+ ASSERT_RVALUE(reinterpret_cast<int*>(0));
+ char const v = 0;
+ ASSERT_LVALUE(reinterpret_cast<char const&>(v));
+}
+
+void expr_unary_op_1(int* pointer, struct incomplete* pointerToIncompleteType)
+{
+ // expr.unary.op/1: The unary * operator performs indirection: the
+ // expression to which it is applied shall be a pointer to an
+ // object type, or a pointer to a function type and the result is
+ // an lvalue referring to the object or function to which the
+ // expression points.
+ ASSERT_LVALUE(*pointer);
+ ASSERT_LVALUE(*Function);
+
+ // [Note: a pointer to an incomplete type
+ // (other than cv void ) can be dereferenced. ]
+ ASSERT_LVALUE(*pointerToIncompleteType);
+}
+
+void expr_pre_incr_1(int operand)
+{
+ // expr.pre.incr/1: The operand of prefix ++ ... shall be a
+ // modifiable lvalue.... The value is the new value of the
+ // operand; it is an lvalue.
+ ASSERT_LVALUE(++operand);
+}
+
+void expr_cast_1(int x)
+{
+ // expr.cast/1: The result of the expression (T) cast-expression
+ // is of type T. The result is an lvalue if T is a reference type,
+ // otherwise the result is an rvalue.
+ ASSERT_LVALUE((void(&)())expr_cast_1);
+ ASSERT_LVALUE((int&)x);
+ ASSERT_RVALUE((void(*)())expr_cast_1);
+ ASSERT_RVALUE((int)x);
+}
+
+void expr_mptr_oper()
+{
+ // expr.mptr.oper/6: The result of a .* expression is an lvalue
+ // only if its first operand is an lvalue and its second operand
+ // is a pointer to data member... (cont'd)
+ typedef Class MakeRValue;
+ ASSERT_RVALUE(MakeRValue().*(&Class::dataMember));
+ //ASSERT_RVALUE(MakeRValue().*(&Class::NonstaticMemberFunction));
+ Class lvalue;
+ ASSERT_LVALUE(lvalue.*(&Class::dataMember));
+ //ASSERT_RVALUE(lvalue.*(&Class::NonstaticMemberFunction));
+
+ // (cont'd)...The result of an ->* expression is an lvalue only
+ // if its second operand is a pointer to data member. If the
+ // second operand is the null pointer to member value (4.11), the
+ // behavior is undefined.
+ ASSERT_LVALUE((&lvalue)->*(&Class::dataMember));
+ //ASSERT_RVALUE((&lvalue)->*(&Class::NonstaticMemberFunction));
+}
+
+void expr_cond(bool cond)
+{
+ // 5.16 Conditional operator [expr.cond]
+ //
+ // 2 If either the second or the third operand has type (possibly
+ // cv-qualified) void, then the lvalue-to-rvalue (4.1),
+ // array-to-pointer (4.2), and function-to-pointer (4.3) standard
+ // conversions are performed on the second and third operands, and one
+ // of the following shall hold:
+ //
+ // — The second or the third operand (but not both) is a
+ // throw-expression (15.1); the result is of the type of the other and
+ // is an rvalue.
+
+ Class classLvalue;
+ ASSERT_RVALUE(cond ? throw 1 : (void)0);
+ ASSERT_RVALUE(cond ? (void)0 : throw 1);
+ ASSERT_RVALUE(cond ? throw 1 : classLvalue);
+ ASSERT_RVALUE(cond ? classLvalue : throw 1);
+
+ // — Both the second and the third operands have type void; the result
+ // is of type void and is an rvalue. [Note: this includes the case
+ // where both operands are throw-expressions. ]
+ ASSERT_RVALUE(cond ? (void)1 : (void)0);
+ ASSERT_RVALUE(cond ? throw 1 : throw 0);
+
+ // expr.cond/4: If the second and third operands are lvalues and
+ // have the same type, the result is of that type and is an
+ // lvalue.
+ ASSERT_LVALUE(cond ? classLvalue : classLvalue);
+ int intLvalue = 0;
+ ASSERT_LVALUE(cond ? intLvalue : intLvalue);
+
+ // expr.cond/5:Otherwise, the result is an rvalue.
+ typedef Class MakeRValue;
+ ASSERT_RVALUE(cond ? MakeRValue() : classLvalue);
+ ASSERT_RVALUE(cond ? classLvalue : MakeRValue());
+ ASSERT_RVALUE(cond ? MakeRValue() : MakeRValue());
+ ASSERT_RVALUE(cond ? classLvalue : intLvalue);
+ ASSERT_RVALUE(cond ? intLvalue : int());
+}
+
+void expr_ass_1(int x)
+{
+ // expr.ass/1: There are several assignment operators, all of
+ // which group right-to-left. All require a modifiable lvalue as
+ // their left operand, and the type of an assignment expression is
+ // that of its left operand. The result of the assignment
+ // operation is the value stored in the left operand after the
+ // assignment has taken place; the result is an lvalue.
+ ASSERT_LVALUE(x = 1);
+ ASSERT_LVALUE(x += 1);
+ ASSERT_LVALUE(x -= 1);
+ ASSERT_LVALUE(x *= 1);
+ ASSERT_LVALUE(x /= 1);
+ ASSERT_LVALUE(x %= 1);
+ ASSERT_LVALUE(x ^= 1);
+ ASSERT_LVALUE(x &= 1);
+ ASSERT_LVALUE(x |= 1);
+}
+
+void expr_comma(int x)
+{
+ // expr.comma: A pair of expressions separated by a comma is
+ // evaluated left-to-right and the value of the left expression is
+ // discarded... result is an lvalue if its right operand is.
+
+ // Can't use the ASSERT_XXXX macros without adding parens around
+ // the comma expression.
+ static_assert(__is_lvalue_expr(x,x), "expected an lvalue");
+ static_assert(__is_rvalue_expr(x,1), "expected an rvalue");
+ static_assert(__is_lvalue_expr(1,x), "expected an lvalue");
+ static_assert(__is_rvalue_expr(1,1), "expected an rvalue");
+}
+
+#if 0
+template<typename T> void f();
+
+// FIXME These currently fail
+void expr_fun_lvalue()
+{
+ ASSERT_LVALUE(&f<int>);
+}
+
+void expr_fun_rvalue()
+{
+ ASSERT_RVALUE(f<int>);
+}
+#endif
+
+template <int NonTypeNonReferenceParameter, int& NonTypeReferenceParameter>
+void check_temp_param_6()
+{
+ ASSERT_RVALUE(NonTypeNonReferenceParameter);
+ ASSERT_LVALUE(NonTypeReferenceParameter);
+}
+
+int AnInt = 0;
+
+void temp_param_6()
+{
+ check_temp_param_6<3,AnInt>();
+}
diff --git a/test/SemaCXX/flexible-array-test.cpp b/test/SemaCXX/flexible-array-test.cpp
index 95d8bb1..e6c3132 100644
--- a/test/SemaCXX/flexible-array-test.cpp
+++ b/test/SemaCXX/flexible-array-test.cpp
@@ -51,5 +51,19 @@ class A {
union B {
int s;
- char c[]; // expected-error {{field has incomplete type 'char []'}}
+ char c[];
+};
+
+namespace rdar9065507 {
+
+struct StorageBase {
+ long ref_count;
+ unsigned size;
+ unsigned capacity;
};
+
+struct Storage : StorageBase {
+ int data[];
+};
+
+}
diff --git a/test/SemaCXX/for-range-examples.cpp b/test/SemaCXX/for-range-examples.cpp
new file mode 100644
index 0000000..810f1de
--- /dev/null
+++ b/test/SemaCXX/for-range-examples.cpp
@@ -0,0 +1,150 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++0x
+
+namespace value_range_detail {
+ template<typename T>
+ class value_range_iter {
+ T t;
+ public:
+ value_range_iter(const T &t) : t(t) {}
+ T operator*() const { return t; }
+ bool operator!=(const value_range_iter &o) const { return t != o.t; }
+ value_range_iter &operator++() { ++t; return *this; }
+ };
+
+ template<typename T>
+ struct value_range {
+ value_range(const T &a, const T &b) : begin_(a), end_(b) {}
+ value_range_iter<T> begin_, end_;
+ };
+
+ template<typename T>
+ value_range_iter<T> begin(const value_range<T> &r) { return r.begin_; }
+ template<typename T>
+ value_range_iter<T> end(const value_range<T> &r) { return r.end_; }
+
+
+ struct end_t {};
+
+ template<typename T>
+ class value_range_step_iter {
+ T it, step;
+ public:
+ value_range_step_iter(const T &it, const T &step) : it(it), step(step) {}
+ T operator*() const { return it; }
+ bool operator!=(value_range_step_iter end) const { return it != end.it; }
+ value_range_step_iter &operator++() { it += step; return *this; }
+ };
+
+ template<typename T>
+ class value_range_step {
+ T it, step, end_;
+ public:
+ value_range_step(const T &it, const T &end, const T &step) :
+ it(it), end_(end), step(step) {}
+ typedef value_range_step_iter<T> iterator;
+ iterator begin() const { return iterator(it, step); }
+ iterator end() const { return iterator(end_, step); }
+ };
+}
+
+template<typename T>
+value_range_detail::value_range<T> range(const T &a, const T &b) { return value_range_detail::value_range<T>(a, b); }
+
+template<typename T>
+value_range_detail::value_range_step<T> range(const T &a, const T &b, const T &step) { return value_range_detail::value_range_step<T>(a, b, step); }
+
+
+namespace map_range {
+ template<typename T>
+ class vector {
+ T storage[100];
+ decltype(sizeof(char)) size;
+ public:
+ vector() : size() {}
+ void push_back(T t) { storage[size++] = t; }
+ T *begin() { return storage; }
+ T *end() { return storage + size; }
+ };
+
+ template<typename T> struct tuple_elem {
+ T t;
+ tuple_elem() {}
+ tuple_elem(T t) : t(t) {}
+ };
+ template<typename... A>
+ struct tuple : tuple_elem<A>... {
+ tuple() : tuple_elem<A>()... {}
+ tuple(A... a) : tuple_elem<A>(a)... {}
+ template<typename B> B &get() { return tuple_elem<B>::t; }
+ };
+
+ template<typename F, typename I>
+ class map_iter {
+ F f;
+ I i;
+ public:
+ map_iter(F f, I i) : f(f), i(i) {}
+ auto operator*() const -> decltype(f(*i)) { return f(*i); }
+ bool operator!=(const map_iter &o) const { return i != o.i; }
+ map_iter &operator++() { ++i; return *this; }
+ };
+
+ template<typename T>
+ struct iter_pair {
+ T begin_, end_;
+ iter_pair(T begin, T end) : begin_(begin), end_(end) {}
+ };
+ template<typename T> T begin(iter_pair<T> p) { return p.begin_; }
+ template<typename T> T end(iter_pair<T> p) { return p.end_; }
+
+ template<typename...> class mem_fun_impl;
+ template<typename R, typename T, typename... A>
+ class mem_fun_impl<R (T::*)(A...)> {
+ typedef R (T::*F)(A...);
+ F f;
+ public:
+ mem_fun_impl(F f) : f(f) {}
+ R operator()(T &t, A &&...a) const { return (t.*f)(static_cast<A&&>(a)...); }
+ };
+ template<typename F> mem_fun_impl<F> mem_fun(F f) { return mem_fun_impl<F>(f); }
+
+ template<typename F, typename T>
+ auto map(const F &f, T &t) -> iter_pair<map_iter<F, decltype(t.begin())>> {
+ typedef map_iter<F, decltype(t.begin())> iter;
+ return iter_pair<iter>(iter(f, t.begin()), iter(f, t.end()));
+ }
+}
+
+#define assert(b) if (!b) { return 1; }
+int main() {
+ int total = 0;
+
+ for (auto n : range(1, 5)) {
+ total += n;
+ }
+ assert(total == 10);
+
+ for (auto n : range(10, 100, 10)) {
+ total += n;
+ }
+ assert(total == 460);
+
+ map_range::vector<char> chars;
+ chars.push_back('a');
+ chars.push_back('b');
+ chars.push_back('c');
+ for (char c : chars) {
+ ++total;
+ }
+ assert(total == 463);
+
+ typedef map_range::tuple<int, double> T;
+ map_range::vector<T> pairs;
+ pairs.push_back(T(42, 12.9));
+ pairs.push_back(T(6, 4.2));
+ pairs.push_back(T(9, 1.1));
+ for (auto a : map(map_range::mem_fun(&T::get<int>), pairs)) {
+ total += a;
+ }
+ assert(total == 500);
+}
diff --git a/test/SemaCXX/for-range-no-std.cpp b/test/SemaCXX/for-range-no-std.cpp
new file mode 100644
index 0000000..8cc71e5
--- /dev/null
+++ b/test/SemaCXX/for-range-no-std.cpp
@@ -0,0 +1,37 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++0x
+
+struct S {
+ int *begin();
+ int *end();
+};
+
+struct T {
+};
+
+struct Range {};
+int begin(Range); // expected-note {{not viable}}
+int end(Range);
+
+namespace NS {
+ struct ADL {};
+ struct iter {
+ int operator*();
+ bool operator!=(iter);
+ void operator++();
+ };
+ iter begin(ADL); // expected-note {{not viable}}
+ iter end(ADL);
+
+ struct NoADL {};
+}
+NS::iter begin(NS::NoADL); // expected-note {{not viable}}
+NS::iter end(NS::NoADL);
+
+void f() {
+ int a[] = {1, 2, 3};
+ for (auto b : S()) {} // ok
+ for (auto b : T()) {} // expected-error {{no matching function for call to 'begin'}} expected-note {{range has type}}
+ for (auto b : a) {} // ok
+ for (int b : NS::ADL()) {} // ok
+ for (int b : NS::NoADL()) {} // expected-error {{no matching function for call to 'begin'}} expected-note {{range has type}}
+}
diff --git a/test/SemaCXX/friend.cpp b/test/SemaCXX/friend.cpp
index 1222dd0..b1ef220 100644
--- a/test/SemaCXX/friend.cpp
+++ b/test/SemaCXX/friend.cpp
@@ -64,11 +64,11 @@ namespace test4 {
}
namespace rdar8529993 {
-struct A { ~A(); }; // expected-note {{nearly matches}}
+struct A { ~A(); };
struct B : A
{
- template<int> friend A::~A(); // expected-error {{does not match}}
+ template<int> friend A::~A(); // expected-error {{destructor cannot be declared as a template}}
};
}
diff --git a/test/SemaCXX/generic-selection.cpp b/test/SemaCXX/generic-selection.cpp
new file mode 100644
index 0000000..b171fce
--- /dev/null
+++ b/test/SemaCXX/generic-selection.cpp
@@ -0,0 +1,46 @@
+// RUN: %clang_cc1 -std=c++0x -fsyntax-only -verify %s
+
+template <typename T, typename U = void*>
+struct A {
+ enum {
+ id = _Generic(T(), // expected-error {{controlling expression type 'char' not compatible with any generic association type}}
+ int: 1, // expected-note {{compatible type 'int' specified here}}
+ float: 2,
+ U: 3) // expected-error {{type 'int' in generic association compatible with previously specified type 'int'}}
+ };
+};
+
+static_assert(A<int>::id == 1, "fail");
+static_assert(A<float>::id == 2, "fail");
+static_assert(A<double, double>::id == 3, "fail");
+
+A<char> a1; // expected-note {{in instantiation of template class 'A<char, void *>' requested here}}
+A<short, int> a2; // expected-note {{in instantiation of template class 'A<short, int>' requested here}}
+
+template <typename T, typename U>
+struct B {
+ enum {
+ id = _Generic(T(),
+ int: 1, // expected-note {{compatible type 'int' specified here}}
+ int: 2, // expected-error {{type 'int' in generic association compatible with previously specified type 'int'}}
+ U: 3)
+ };
+};
+
+template <unsigned Arg, unsigned... Args> struct Or {
+ enum { result = Arg | Or<Args...>::result };
+};
+
+template <unsigned Arg> struct Or<Arg> {
+ enum { result = Arg };
+};
+
+template <class... Args> struct TypeMask {
+ enum {
+ result = Or<_Generic(Args(), int: 1, long: 2, short: 4, float: 8)...>::result
+ };
+};
+
+static_assert(TypeMask<int, long, short>::result == 7, "fail");
+static_assert(TypeMask<float, short>::result == 12, "fail");
+static_assert(TypeMask<int, float, float>::result == 9, "fail");
diff --git a/test/SemaCXX/goto.cpp b/test/SemaCXX/goto.cpp
new file mode 100644
index 0000000..d8d5ec5
--- /dev/null
+++ b/test/SemaCXX/goto.cpp
@@ -0,0 +1,105 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wall -fblocks %s
+
+// PR9463
+double *end;
+void f(bool b1, bool b2) {
+ {
+ do {
+ int end = 0;
+ if (b2) {
+ do {
+ goto end;
+ } while (b2);
+ }
+ end = 1;
+ } while (b1);
+ }
+
+ end:
+ return;
+}
+
+namespace N {
+ float* end;
+ void f(bool b1, bool b2) {
+ {
+ do {
+ int end = 0;
+ if (b2) {
+ do {
+ goto end;
+ } while (b2);
+ }
+ end = 1;
+ } while (b1);
+ }
+
+ end:
+ return;
+ }
+}
+
+void g() {
+ end = 1; // expected-error{{assigning to 'double *' from incompatible type 'int'}}
+}
+
+void h(int end) {
+ {
+ goto end; // expected-error{{use of undeclared label 'end'}}
+ }
+}
+
+void h2(int end) {
+ {
+ __label__ end;
+ goto end;
+
+ end:
+ ::end = 0;
+ }
+ end: // expected-warning{{unused label 'end'}}
+ end = 1;
+}
+
+class X {
+public:
+ X();
+};
+
+void rdar9135994()
+{
+X:
+ goto X;
+}
+
+namespace PR9495 {
+ struct NonPOD { NonPOD(); ~NonPOD(); };
+
+ void f(bool b) {
+ NonPOD np;
+ if (b) {
+ goto undeclared; // expected-error{{use of undeclared label 'undeclared'}}
+ }
+ }
+
+ void g() {
+ (void)^(bool b){
+ NonPOD np;
+ if (b) {
+ goto undeclared; // expected-error{{use of undeclared label 'undeclared'}}
+ }
+ };
+ }
+}
+
+extern "C" {
+ void exit(int);
+}
+
+void f() {
+ {
+ goto exit;
+ }
+ exit:
+ return;
+}
diff --git a/test/SemaCXX/goto2.cpp b/test/SemaCXX/goto2.cpp
new file mode 100644
index 0000000..01ea031
--- /dev/null
+++ b/test/SemaCXX/goto2.cpp
@@ -0,0 +1,47 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+//PR9463
+int subfun(const char *text) {
+ const char *tmp = text;
+ return 0;
+}
+
+void fun(const char* text) {
+ int count = 0;
+ bool check = true;
+
+ if (check)
+ {
+ const char *end = text;
+
+ if (check)
+ {
+ do
+ {
+ if (check)
+ {
+ count = subfun(end);
+ goto end;
+ }
+
+ check = !check;
+ }
+ while (check);
+ }
+ // also works, after commenting following line of source code
+ int e = subfun(end);
+ }
+ end:
+ if (check)
+ ++count;
+}
+
+const char *text = "some text";
+
+int main() {
+ const char *ptr = text;
+
+ fun(ptr);
+
+ return 0;
+}
diff --git a/test/SemaCXX/init-priority-attr.cpp b/test/SemaCXX/init-priority-attr.cpp
index 7605ee6..6facebf 100644
--- a/test/SemaCXX/init-priority-attr.cpp
+++ b/test/SemaCXX/init-priority-attr.cpp
@@ -19,7 +19,7 @@ extern Two koo[];
Two foo __attribute__((init_priority(101))) ( 5, 6 );
-Two goo __attribute__((init_priority(2,3))) ( 5, 6 ); // expected-error {{attribute requires 1 argument(s)}}
+Two goo __attribute__((init_priority(2,3))) ( 5, 6 ); // expected-error {{attribute takes one argument}}
Two coo[2] __attribute__((init_priority(3))); // expected-error {{init_priority attribute requires integer constant between 101 and 65535 inclusive}}
diff --git a/test/SemaCXX/libstdcxx_is_pod_hack.cpp b/test/SemaCXX/libstdcxx_is_pod_hack.cpp
index 2e92032..3581c79 100644
--- a/test/SemaCXX/libstdcxx_is_pod_hack.cpp
+++ b/test/SemaCXX/libstdcxx_is_pod_hack.cpp
@@ -11,3 +11,19 @@ struct __is_pod {
};
__is_pod<int> ipi;
+
+// Ditto for __is_same.
+template<typename T>
+struct __is_same {
+};
+
+__is_same<int> isi;
+
+// Another, similar egregious hack for __is_signed, which is a type
+// trait in Embarcadero's compiler but is used as an identifier in
+// libstdc++.
+struct test_is_signed {
+ static const bool __is_signed = true;
+};
+
+bool check_signed = test_is_signed::__is_signed;
diff --git a/test/SemaCXX/literal-type.cpp b/test/SemaCXX/literal-type.cpp
index 142dd75..6a61823 100644
--- a/test/SemaCXX/literal-type.cpp
+++ b/test/SemaCXX/literal-type.cpp
@@ -1,10 +1,71 @@
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++0x %s
static_assert(__is_literal(int), "fail");
+static_assert(__is_literal_type(int), "fail"); // alternate spelling for GCC
static_assert(__is_literal(void*), "fail");
enum E { E1 };
static_assert(__is_literal(E), "fail");
static_assert(__is_literal(decltype(E1)), "fail");
typedef int IAR[10];
static_assert(__is_literal(IAR), "fail");
-// FIXME: Records
+typedef int Vector __attribute__((vector_size(16)));
+typedef int VectorExt __attribute__((ext_vector_type(4)));
+static_assert(__is_literal(Vector), "fail");
+static_assert(__is_literal(VectorExt), "fail");
+
+// C++0x [basic.types]p10:
+// A type is a literal type if it is:
+// [...]
+// -- a class type that has all of the following properties:
+// -- it has a trivial destructor
+// -- every constructor call and full-expression in the
+// brace-or-equal-initializers for non-static data members (if an) is
+// a constant expression,
+// -- it is an aggregate type or has at least one constexpr constructor
+// or constructor template that is not a copy or move constructor, and
+// -- it has all non-static data members and base classes of literal
+// types
+struct Empty {};
+struct LiteralType {
+ int x;
+ E e;
+ IAR arr;
+ Empty empty;
+ int method();
+};
+struct HasDtor { ~HasDtor(); };
+
+class NonAggregate { int x; };
+struct HasNonLiteralBase : NonAggregate {};
+struct HasNonLiteralMember { HasDtor x; };
+
+static_assert(__is_literal(Empty), "fail");
+static_assert(__is_literal(LiteralType), "fail");
+static_assert(!__is_literal(HasDtor), "fail");
+static_assert(!__is_literal(NonAggregate), "fail");
+static_assert(!__is_literal(HasNonLiteralBase), "fail");
+static_assert(!__is_literal(HasNonLiteralMember), "fail");
+
+// FIXME: Test constexpr constructors and non-static members with initializers
+// when Clang supports them:
+#if 0
+extern int f();
+struct HasNonConstExprMemInit {
+ int x = f();
+ constexpr HasNonConstExprMemInit(int y) {}
+};
+static_assert(!__is_literal(HasNonConstExprMemInit), "fail");
+
+class HasConstExprCtor {
+ int x;
+public:
+ constexpr HasConstExprCtor(int x) : x(x) {}
+};
+template <typename T> class HasConstExprCtorTemplate {
+ T x;
+public:
+ template <typename U> constexpr HasConstExprCtorTemplate(U y) : x(y) {}
+};
+static_assert(__is_literal(HasConstExprCtor), "fail");
+static_assert(__is_literal(HasConstExprCtorTemplate), "fail");
+#endif
diff --git a/test/SemaCXX/member-expr.cpp b/test/SemaCXX/member-expr.cpp
index 3c3eb04..68af415 100644
--- a/test/SemaCXX/member-expr.cpp
+++ b/test/SemaCXX/member-expr.cpp
@@ -135,4 +135,9 @@ namespace PR9025 {
int g3() {
return fun3.x; // expected-error{{base of member reference is an overloaded function; perhaps you meant to call it with no arguments?}}
}
+
+ template <typename T> S fun4();
+ int g4() {
+ return fun4.x; // expected-error{{base of member reference is a function; perhaps you meant to call it?}}
+ }
}
diff --git a/test/SemaCXX/member-pointers-2.cpp b/test/SemaCXX/member-pointers-2.cpp
index 4b3b82c..6c39282 100644
--- a/test/SemaCXX/member-pointers-2.cpp
+++ b/test/SemaCXX/member-pointers-2.cpp
@@ -34,3 +34,18 @@ void test0() {
Test0 mytest;
mytest.test();
}
+
+namespace rdar9065289 {
+ typedef void (*FuncPtr)();
+ struct X0 { };
+
+ struct X1
+ {
+ X0* x0;
+ FuncPtr X0::*fptr;
+ };
+
+ void f(X1 p) {
+ (p.x0->*(p.fptr))();
+ }
+}
diff --git a/test/SemaCXX/neon-vector-types.cpp b/test/SemaCXX/neon-vector-types.cpp
new file mode 100644
index 0000000..aa82b11
--- /dev/null
+++ b/test/SemaCXX/neon-vector-types.cpp
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// rdar://9208404
+
+typedef int MP4Err;
+typedef float Float32;
+typedef float float32_t;
+typedef __attribute__((neon_vector_type(4))) float32_t float32x4_t;
+typedef float vFloat __attribute__((__vector_size__(16)));
+typedef vFloat VFLOAT;
+typedef unsigned long UInt32;
+
+extern int bar (float32x4_t const *p);
+
+int foo (const Float32 *realBufPtr) {
+ float32x4_t const *vRealPtr = (VFLOAT *)&realBufPtr[0];
+ return bar(vRealPtr);
+}
+
+MP4Err autoCorrelation2nd_Neon(Float32 *alphar, Float32 *alphai,
+ const Float32 *realBufPtr,
+ const Float32 *imagBufPtr,
+ const UInt32 len)
+{
+ float32x4_t const *vRealPtr = (VFLOAT *)&realBufPtr[0];
+ return 0;
+}
+
diff --git a/test/SemaCXX/nested-name-spec-locations.cpp b/test/SemaCXX/nested-name-spec-locations.cpp
index 25914df..048d4ba 100644
--- a/test/SemaCXX/nested-name-spec-locations.cpp
+++ b/test/SemaCXX/nested-name-spec-locations.cpp
@@ -65,6 +65,98 @@ void PseudoDestructorExprCheck(
template<typename T>
struct DependentScopedDeclRefExpr {
void f() {
- outer_alias::inner::X0<T>::value = 17;
+ outer_alias::inner::X0<typename add_reference<T>::type
+ * // expected-error{{as a pointer to a reference of type}}
+ >::value = 17;
}
};
+
+void DependentScopedDeclRefExprCheck(DependentScopedDeclRefExpr<int> t) {
+ t.f(); // expected-note{{in instantiation of member function}}
+}
+
+
+template<typename T>
+struct TypenameTypeTester {
+ typedef typename outer::inner::X0<
+ typename add_reference<T>::type
+ * // expected-error{{declared as a pointer to a reference of type}}
+ >::type type;
+};
+
+TypenameTypeTester<int> TypenameTypeCheck; // expected-note{{in instantiation of template class}}
+
+template<typename T, typename U>
+struct DependentTemplateSpecializationTypeTester {
+ typedef typename T::template apply<typename add_reference<U>::type
+ * // expected-error{{declared as a pointer to a reference of type}}
+ >::type type;
+};
+
+struct HasApply {
+ template<typename T>
+ struct apply {
+ typedef T type;
+ };
+};
+
+DependentTemplateSpecializationTypeTester<HasApply, int> DTSTCheck; // expected-note{{in instantiation of template class}}
+
+template<typename T, typename U>
+struct DependentTemplateSpecializationTypeTester2 {
+ typedef typename T::template apply<typename add_reference<U>::type
+ * // expected-error{{declared as a pointer to a reference of type}}
+ > type;
+};
+
+DependentTemplateSpecializationTypeTester2<HasApply, int> DTSTCheck2; // expected-note{{in instantiation of template class}}
+
+template<typename T, typename U>
+struct DependentTemplateSpecializationTypeTester3 :
+ T::template apply<typename add_reference<U>::type
+ * // expected-error{{declared as a pointer to a reference of type}}
+ >
+{};
+
+DependentTemplateSpecializationTypeTester3<HasApply, int> DTSTCheck3; // expected-note{{in instantiation of template class}}
+
+template<typename T, typename U>
+struct DependentTemplateSpecializationTypeTester4 {
+ typedef class T::template apply<typename add_reference<U>::type
+ * // expected-error{{declared as a pointer to a reference of type}}
+ > type;
+};
+
+DependentTemplateSpecializationTypeTester4<HasApply, int> DTSTCheck4; // expected-note{{in instantiation of template class}}
+
+template<template<class T> class TTP>
+struct AcceptedTemplateTemplateParameter {
+};
+
+template<typename T, typename U>
+struct DependentTemplateTemplateArgumentTester {
+ typedef AcceptedTemplateTemplateParameter<
+ T::
+ template apply<
+ typename add_reference<U>::type
+ * // expected-error{{declared as a pointer to a reference of type}}
+ >::
+ template X>
+ type;
+};
+
+DependentTemplateTemplateArgumentTester<HasApply, int> DTTACheck; // expected-note{{in instantiation of template class}}
+
+namespace PR9388 {
+ namespace std {
+ template<typename T> class vector {
+ };
+ }
+ template<typename T> static void foo(std::vector<T*> &V) {
+ __PRETTY_FUNCTION__; // expected-warning{{expression result unused}}
+ }
+ void bar(std::vector<int*> &Blocks) {
+ foo(Blocks); // expected-note{{in instantiation of}}
+ }
+
+}
diff --git a/test/SemaCXX/nullptr.cpp b/test/SemaCXX/nullptr.cpp
index 01f3d93..84c80aa 100644
--- a/test/SemaCXX/nullptr.cpp
+++ b/test/SemaCXX/nullptr.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fexceptions -fsyntax-only -verify -std=c++0x -ffreestanding %s
+// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -fsyntax-only -verify -std=c++0x -ffreestanding %s
#include <stdint.h>
typedef decltype(nullptr) nullptr_t;
diff --git a/test/SemaCXX/operator-arrow-temporary.cpp b/test/SemaCXX/operator-arrow-temporary.cpp
new file mode 100644
index 0000000..8e79609
--- /dev/null
+++ b/test/SemaCXX/operator-arrow-temporary.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// PR9615
+
+struct Resource {
+ void doit();
+};
+
+template<int x> struct Lock {
+ ~Lock() { int a[x]; } // expected-error {{declared as an array with a negative size}}
+ Resource* operator->() { return 0; }
+};
+
+struct Accessor {
+ Lock<-1> operator->();
+};
+
+// Make sure we try to instantiate the destructor for Lock here
+void f() { Accessor acc; acc->doit(); } // expected-note {{requested here}}
+
diff --git a/test/SemaCXX/overloaded-name.cpp b/test/SemaCXX/overloaded-name.cpp
index 289d5c9..5a87cc8 100644
--- a/test/SemaCXX/overloaded-name.cpp
+++ b/test/SemaCXX/overloaded-name.cpp
@@ -1,14 +1,14 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
-int ovl(int);
-float ovl(float);
+int ovl(int); // expected-note 3{{candidate function}}
+float ovl(float); // expected-note 3{{candidate function}}
-template<typename T> T ovl(T);
+template<typename T> T ovl(T); // expected-note 3{{candidate function}}
void test(bool b) {
- (void)((void)0, ovl); // expected-error{{cannot resolve overloaded function from context}}
+ (void)((void)0, ovl); // expected-error{{cannot resolve overloaded function 'ovl' from context}}
// PR7863
- (void)(b? ovl : &ovl); // expected-error{{cannot resolve overloaded function from context}}
- (void)(b? ovl<float> : &ovl); // expected-error{{cannot resolve overloaded function from context}}
+ (void)(b? ovl : &ovl); // expected-error{{cannot resolve overloaded function 'ovl' from context}}
+ (void)(b? ovl<float> : &ovl); // expected-error{{cannot resolve overloaded function 'ovl' from context}}
(void)(b? ovl<float> : ovl<float>);
}
diff --git a/test/SemaCXX/overloaded-operator.cpp b/test/SemaCXX/overloaded-operator.cpp
index 4399a02..44d013f 100644
--- a/test/SemaCXX/overloaded-operator.cpp
+++ b/test/SemaCXX/overloaded-operator.cpp
@@ -384,3 +384,18 @@ void test_lookup_through_using() {
N::X2 x;
x << 17;
}
+
+namespace rdar9136502 {
+ struct X {
+ int i();
+ int i(int);
+ };
+
+ struct Y {
+ Y &operator<<(int); // expected-note{{candidate function not viable: no known conversion from '<bound member function type>' to 'int'}}
+ };
+
+ void f(X x, Y y) {
+ y << x.i; // expected-error{{a bound member function may only be called}}
+ }
+}
diff --git a/test/SemaCXX/pascal-strings.cpp b/test/SemaCXX/pascal-strings.cpp
new file mode 100644
index 0000000..89194b5
--- /dev/null
+++ b/test/SemaCXX/pascal-strings.cpp
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -fpascal-strings
+const wchar_t *pascalString = L"\pThis is a Pascal string";
+
+unsigned char a[3] = "\pa";
+unsigned char b[3] = "\pab";
+unsigned char c[3] = "\pabc"; // expected-error {{initializer-string for char array is too long}}
diff --git a/test/SemaCXX/pseudo-destructors.cpp b/test/SemaCXX/pseudo-destructors.cpp
index 30d9faa..d71304e 100644
--- a/test/SemaCXX/pseudo-destructors.cpp
+++ b/test/SemaCXX/pseudo-destructors.cpp
@@ -2,7 +2,7 @@
struct A {};
enum Foo { F };
-typedef Foo Bar;
+typedef Foo Bar; // expected-note{{type 'Bar' (aka 'Foo') is declared here}}
typedef int Integer;
typedef double Double;
@@ -23,10 +23,9 @@ void f(A* a, Foo *f, int *i, double *d) {
a->~A();
a->A::~A();
- a->~foo(); // expected-error{{identifier 'foo' in pseudo-destructor expression does not name a type}}
+ a->~foo(); // expected-error{{identifier 'foo' in object destruction expression does not name a type}}
- // FIXME: the diagnostic below isn't wonderful
- a->~Bar(); // expected-error{{does not name a type}}
+ a->~Bar(); // expected-error{{destructor type 'Bar' (aka 'Foo') in object destruction expression does not match the type 'A' of the object being destroyed}}
f->~Bar();
f->~Foo();
diff --git a/test/SemaCXX/ptrtomember.cpp b/test/SemaCXX/ptrtomember.cpp
index 1038de9..c391733 100644
--- a/test/SemaCXX/ptrtomember.cpp
+++ b/test/SemaCXX/ptrtomember.cpp
@@ -27,6 +27,7 @@ void f3(S3* p, void (S3::*m)()) {
(void)(void*)(p->*m); // expected-error {{a bound member function may only be called}}
(void)reinterpret_cast<void*>(p->*m); // expected-error {{a bound member function may only be called}}
if (p->*m) {} // expected-error {{a bound member function may only be called}}
-
- p->m; // expected-error {{a bound member function may only be called}}
+ if (!(p->*m)) {} // expected-error {{a bound member function may only be called}}
+ if (p->m) {}; // expected-error {{a bound member function may only be called}}
+ if (!p->m) {}; // expected-error {{a bound member function may only be called}}
}
diff --git a/test/SemaCXX/reinterpret-cast.cpp b/test/SemaCXX/reinterpret-cast.cpp
index 74dbc01..f526249 100644
--- a/test/SemaCXX/reinterpret-cast.cpp
+++ b/test/SemaCXX/reinterpret-cast.cpp
@@ -45,9 +45,9 @@ void constness()
// Valid: T1* -> T2 const*
int const *icp = reinterpret_cast<int const*>(ipppc);
// Invalid: T1 const* -> T2*
- (void)reinterpret_cast<int*>(icp); // expected-error {{reinterpret_cast from 'const int *' to 'int *' casts away constness}}
+ (void)reinterpret_cast<int*>(icp); // expected-error {{reinterpret_cast from 'const int *' to 'int *' casts away qualifiers}}
// Invalid: T1*** -> T2 const* const**
- int const *const **icpcpp = reinterpret_cast<int const* const**>(ipppc); // expected-error {{reinterpret_cast from 'int ***' to 'const int *const **' casts away constness}}
+ int const *const **icpcpp = reinterpret_cast<int const* const**>(ipppc); // expected-error {{reinterpret_cast from 'int ***' to 'const int *const **' casts away qualifiers}}
// Valid: T1* -> T2*
int *ip = reinterpret_cast<int*>(icpcpp);
// Valid: T* -> T const*
@@ -77,7 +77,7 @@ void memptrs()
{
const int structure::*psi = 0;
(void)reinterpret_cast<const float structure::*>(psi);
- (void)reinterpret_cast<int structure::*>(psi); // expected-error {{reinterpret_cast from 'const int structure::*' to 'int structure::*' casts away constness}}
+ (void)reinterpret_cast<int structure::*>(psi); // expected-error {{reinterpret_cast from 'const int structure::*' to 'int structure::*' casts away qualifiers}}
void (structure::*psf)() = 0;
(void)reinterpret_cast<int (structure::*)()>(psf);
@@ -105,6 +105,14 @@ void const_arrays() {
const STRING *s;
const char *c;
- (void)reinterpret_cast<char *>(s); // expected-error {{reinterpret_cast from 'const STRING *' (aka 'char const (*)[10]') to 'char *' casts away constness}}
+ (void)reinterpret_cast<char *>(s); // expected-error {{reinterpret_cast from 'const STRING *' (aka 'char const (*)[10]') to 'char *' casts away qualifiers}}
(void)reinterpret_cast<const STRING *>(c);
}
+
+namespace PR9564 {
+ struct a { int a : 10; }; a x;
+ int *y = &reinterpret_cast<int&>(x.a); // expected-error {{not allowed}}
+
+ __attribute((ext_vector_type(4))) typedef float v4;
+ float& w(v4 &a) { return reinterpret_cast<float&>(a[1]); } // expected-error {{not allowed}}
+}
diff --git a/test/SemaCXX/return-noreturn.cpp b/test/SemaCXX/return-noreturn.cpp
index 7e0a69c..53ed0d7 100644
--- a/test/SemaCXX/return-noreturn.cpp
+++ b/test/SemaCXX/return-noreturn.cpp
@@ -1,18 +1,69 @@
// RUN: %clang_cc1 %s -fsyntax-only -verify -Wreturn-type -Wmissing-noreturn -Wno-unreachable-code
-// XFAIL: *
// A destructor may be marked noreturn and should still influence the CFG.
-namespace PR6884 {
- struct abort_struct {
- abort_struct() {} // Make this non-POD so the destructor is invoked.
- ~abort_struct() __attribute__((noreturn));
- };
-
- int f() {
- abort_struct();
+void pr6884_abort() __attribute__((noreturn));
+
+struct pr6884_abort_struct {
+ pr6884_abort_struct() {}
+ ~pr6884_abort_struct() __attribute__((noreturn)) { pr6884_abort(); }
+};
+
+int pr6884_f(int x) {
+ switch (x) { default: pr6884_abort(); }
+}
+
+int pr6884_g(int x) {
+ switch (x) { default: pr6884_abort_struct(); }
+}
+
+int pr6884_g_positive(int x) {
+ switch (x) { default: ; }
+} // expected-warning {{control reaches end of non-void function}}
+
+int pr6884_h(int x) {
+ switch (x) {
+ default: {
+ pr6884_abort_struct a;
+ }
}
+}
- int f2() {
- abort_struct s;
+// PR9380
+struct PR9380 {
+ ~PR9380();
+};
+struct PR9380_B : public PR9380 {
+ PR9380_B( const PR9380& str );
+};
+void test_PR9380(const PR9380& aKey) {
+ const PR9380& flatKey = PR9380_B(aKey);
+}
+
+// Array of objects with destructors. This is purely a coverage test case.
+void test_array() {
+ PR9380 a[2];
+}
+
+// Test classes wrapped in typedefs. This is purely a coverage test case
+// for CFGImplictDtor::getDestructorDecl().
+void test_typedefs() {
+ typedef PR9380 PR9380_Ty;
+ PR9380_Ty test;
+ PR9380_Ty test2[20];
+}
+
+// PR9412 - Handle CFG traversal with null successors.
+enum PR9412_MatchType { PR9412_Exact };
+
+template <PR9412_MatchType type> int PR9412_t() {
+ switch (type) {
+ case PR9412_Exact:
+ default:
+ break;
}
+} // expected-warning {{control reaches end of non-void function}}
+
+void PR9412_f() {
+ PR9412_t<PR9412_Exact>(); // expected-note {{in instantiation of function template specialization 'PR9412_t<0>' requested here}}
}
+
diff --git a/test/SemaCXX/return.cpp b/test/SemaCXX/return.cpp
index 46524fc..af7f50c 100644
--- a/test/SemaCXX/return.cpp
+++ b/test/SemaCXX/return.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -fexceptions -fsyntax-only -Wignored-qualifiers -verify
+// RUN: %clang_cc1 %s -fcxx-exceptions -fexceptions -fsyntax-only -Wignored-qualifiers -verify
int test1() {
throw;
@@ -41,3 +41,15 @@ char* volatile i(); // expected-warning{{'volatile' type qualifier on return typ
const volatile int scalar_cv(); // expected-warning{{'const volatile' type qualifiers on return type have no effect}}
}
+
+namespace PR9328 {
+ typedef char *PCHAR;
+ class Test
+ {
+ const PCHAR GetName() { return 0; } // expected-warning{{'const' type qualifier on return type has no effect}}
+ };
+}
+
+class foo {
+ operator int * const ();
+};
diff --git a/test/SemaCXX/rval-references.cpp b/test/SemaCXX/rval-references.cpp
index 11187cb..74afdbe 100644
--- a/test/SemaCXX/rval-references.cpp
+++ b/test/SemaCXX/rval-references.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fexceptions -fsyntax-only -verify -std=c++0x %s
+// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -fsyntax-only -verify -std=c++0x %s
typedef int&& irr;
typedef irr& ilr_c1; // Collapses to int&
diff --git a/test/SemaCXX/scope-check.cpp b/test/SemaCXX/scope-check.cpp
index d462af0..3a90cc0 100644
--- a/test/SemaCXX/scope-check.cpp
+++ b/test/SemaCXX/scope-check.cpp
@@ -1,4 +1,5 @@
// RUN: %clang_cc1 -fsyntax-only -verify -fblocks %s -Wno-unreachable-code
+// RUN: %clang_cc1 -fsyntax-only -verify -fblocks -std=gnu++0x %s -Wno-unreachable-code
namespace test0 {
struct D { ~D(); };
@@ -151,3 +152,22 @@ namespace test8 {
l2: x++;
}
}
+
+namespace test9 {
+ struct S { int i; };
+ void test1() {
+ goto foo;
+ S s;
+ foo:
+ return;
+ }
+ unsigned test2(unsigned x, unsigned y) {
+ switch (x) {
+ case 2:
+ S s;
+ if (y > 42) return x + y;
+ default:
+ return x - 2;
+ }
+ }
+}
diff --git a/test/SemaCXX/short-enums.cpp b/test/SemaCXX/short-enums.cpp
new file mode 100644
index 0000000..ca713b7
--- /dev/null
+++ b/test/SemaCXX/short-enums.cpp
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -fshort-enums -fsyntax-only %s
+
+// This shouldn't crash: PR9474
+
+enum E { VALUE_1 };
+
+template <typename T>
+struct A {};
+
+template <E Enum>
+struct B : A<B<Enum> > {};
+
+void bar(int x) {
+ switch (x) {
+ case sizeof(B<VALUE_1>): ;
+ }
+} \ No newline at end of file
diff --git a/test/SemaCXX/short-wchar-sign.cpp b/test/SemaCXX/short-wchar-sign.cpp
new file mode 100644
index 0000000..9a177c0
--- /dev/null
+++ b/test/SemaCXX/short-wchar-sign.cpp
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -triple i386-mingw32 -fsyntax-only -pedantic -verify %s
+// RUN: %clang_cc1 -fshort-wchar -fsyntax-only -pedantic -verify %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -pedantic -verify %s
+
+// Check that short wchar_t is unsigned, and that regular wchar_t is not.
+int test[(wchar_t(-1)<wchar_t(0)) == (sizeof(wchar_t) == 4) ?1:-1];
diff --git a/test/SemaCXX/sourceranges.cpp b/test/SemaCXX/sourceranges.cpp
index 602d76b..0537aa2 100644
--- a/test/SemaCXX/sourceranges.cpp
+++ b/test/SemaCXX/sourceranges.cpp
@@ -13,15 +13,15 @@ typedef int C;
}
int main() {
- // CHECK: CXXNewExpr {{0x[0-9a-fA-F]+}} <col:19, col:28> 'foo::class A *'
+ // CHECK: CXXNewExpr {{0x[0-9a-fA-F]+}} <col:19, col:28> 'foo::A *'
P<foo::A> p14 = new foo::A;
- // CHECK: CXXNewExpr {{0x[0-9a-fA-F]+}} <col:19, col:28> 'foo::enum B *'
+ // CHECK: CXXNewExpr {{0x[0-9a-fA-F]+}} <col:19, col:28> 'foo::B *'
P<foo::B> p24 = new foo::B;
// CHECK: CXXNewExpr {{0x[0-9a-fA-F]+}} <col:19, col:28> 'foo::C *'
P<foo::C> pr4 = new foo::C;
}
foo::A getName() {
- // CHECK: CXXConstructExpr {{0x[0-9a-fA-F]+}} <col:10, col:17> 'foo::class A'
+ // CHECK: CXXConstructExpr {{0x[0-9a-fA-F]+}} <col:10, col:17> 'foo::A'
return foo::A();
}
diff --git a/test/SemaCXX/static-cast.cpp b/test/SemaCXX/static-cast.cpp
index 46c6eee..7fb016e 100644
--- a/test/SemaCXX/static-cast.cpp
+++ b/test/SemaCXX/static-cast.cpp
@@ -84,8 +84,8 @@ void t_529_5_8()
(void)static_cast<C1&>(*((A*)0)); // expected-error {{cannot cast 'A' to 'C1 &' via virtual base 'B'}}
(void)static_cast<D*>((A*)0); // expected-error {{cannot cast 'A *' to 'D *' via virtual base 'B'}}
(void)static_cast<D&>(*((A*)0)); // expected-error {{cannot cast 'A' to 'D &' via virtual base 'B'}}
- (void)static_cast<B*>((const A*)0); // expected-error {{static_cast from 'const A *' to 'B *' casts away constness}}
- (void)static_cast<B&>(*((const A*)0)); // expected-error {{static_cast from 'const A' to 'B &' casts away constness}}
+ (void)static_cast<B*>((const A*)0); // expected-error {{static_cast from 'const A *' to 'B *' casts away qualifiers}}
+ (void)static_cast<B&>(*((const A*)0)); // expected-error {{static_cast from 'const A' to 'B &' casts away qualifiers}}
(void)static_cast<E*>((A*)0); // expected-error {{cannot cast private base class 'A' to 'E'}}
(void)static_cast<E&>(*((A*)0)); // expected-error {{cannot cast private base class 'A' to 'E'}}
(void)static_cast<H*>((A*)0); // expected-error {{ambiguous cast from base 'A' to derived 'H':\n struct A -> struct B -> struct G1 -> struct H\n struct A -> struct B -> struct G2 -> struct H}}
@@ -119,7 +119,7 @@ void t_529_10()
// Bad code below
- (void)static_cast<int*>((const void*)0); // expected-error {{static_cast from 'const void *' to 'int *' casts away constness}}
+ (void)static_cast<int*>((const void*)0); // expected-error {{static_cast from 'const void *' to 'int *' casts away qualifiers}}
(void)static_cast<void (*)()>((void*)0); // expected-error {{static_cast from 'void *' to 'void (*)()' is not allowed}}
}
diff --git a/test/SemaCXX/storage-class.cpp b/test/SemaCXX/storage-class.cpp
index a2e2063..01cfbfc 100644
--- a/test/SemaCXX/storage-class.cpp
+++ b/test/SemaCXX/storage-class.cpp
@@ -2,3 +2,6 @@
extern const int PR6495a = 42;
extern int PR6495b = 42; // expected-warning{{'extern' variable has an initializer}}
extern const int PR6495c[] = {42,43,44};
+
+extern struct Test1 {}; // expected-warning {{'extern' ignored on this declaration}}
+extern "C" struct Test0 {}; // no warning
diff --git a/test/SemaCXX/type-traits.cpp b/test/SemaCXX/type-traits.cpp
index ff9a6bf..96e9696 100644
--- a/test/SemaCXX/type-traits.cpp
+++ b/test/SemaCXX/type-traits.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify %s
#define T(b) (b) ? 1 : -1
#define F(b) (b) ? -1 : 1
@@ -27,22 +27,37 @@ struct HasAnonymousUnion {
};
};
+typedef int Vector __attribute__((vector_size(16)));
+typedef int VectorExt __attribute__((ext_vector_type(4)));
+
// Not PODs
typedef const void cvoid;
struct Derives : POD {};
+typedef Derives DerivesAr[10];
+typedef Derives DerivesArNB[];
struct DerivesEmpty : Empty {};
struct HasCons { HasCons(int); };
struct HasCopyAssign { HasCopyAssign operator =(const HasCopyAssign&); };
+struct HasMoveAssign { HasMoveAssign operator =(const HasMoveAssign&&); }; // \
+ // expected-warning {{rvalue references}}
struct HasDest { ~HasDest(); };
class HasPriv { int priv; };
class HasProt { protected: int prot; };
struct HasRef { int i; int& ref; HasRef() : i(0), ref(i) {} };
struct HasNonPOD { NonPOD np; };
struct HasVirt { virtual void Virt() {}; };
-typedef Derives NonPODAr[10];
+typedef NonPOD NonPODAr[10];
typedef HasVirt VirtAr[10];
-typedef HasCons NonPODArNB[];
+typedef NonPOD NonPODArNB[];
union NonPODUnion { int i; Derives n; };
+struct DerivesHasCons : HasCons {};
+struct DerivesHasCopyAssign : HasCopyAssign {};
+struct DerivesHasMoveAssign : HasMoveAssign {};
+struct DerivesHasDest : HasDest {};
+struct DerivesHasPriv : HasPriv {};
+struct DerivesHasProt : HasProt {};
+struct DerivesHasRef : HasRef {};
+struct DerivesHasVirt : HasVirt {};
struct HasNoThrowCopyAssign {
void operator =(const HasNoThrowCopyAssign&) throw();
@@ -77,37 +92,51 @@ typedef HasVirtDest VirtDestAr[1];
void is_pod()
{
- int t01[T(__is_pod(int))];
- int t02[T(__is_pod(Enum))];
- int t03[T(__is_pod(POD))];
- int t04[T(__is_pod(Int))];
- int t05[T(__is_pod(IntAr))];
- int t06[T(__is_pod(Statics))];
- int t07[T(__is_pod(Empty))];
- int t08[T(__is_pod(EmptyUnion))];
- int t09[T(__is_pod(Union))];
- int t10[T(__is_pod(HasFunc))];
- int t11[T(__is_pod(HasOp))];
- int t12[T(__is_pod(HasConv))];
- int t13[T(__is_pod(HasAssign))];
- int t14[T(__is_pod(IntArNB))];
- int t15[T(__is_pod(HasAnonymousUnion))];
-
- int t21[F(__is_pod(Derives))];
- int t22[F(__is_pod(HasCons))];
- int t23[F(__is_pod(HasCopyAssign))];
- int t24[F(__is_pod(HasDest))];
- int t25[F(__is_pod(HasPriv))];
- int t26[F(__is_pod(HasProt))];
- int t27[F(__is_pod(HasRef))];
- int t28[F(__is_pod(HasNonPOD))];
- int t29[F(__is_pod(HasVirt))];
- int t30[F(__is_pod(NonPODAr))];
- int t31[F(__is_pod(DerivesEmpty))];
- int t32[F(__is_pod(void))];
- int t33[F(__is_pod(cvoid))];
- int t34[F(__is_pod(NonPODArNB))];
- // int t32[F(__is_pod(NonPODUnion))];
+ { int arr[T(__is_pod(int))]; }
+ { int arr[T(__is_pod(Enum))]; }
+ { int arr[T(__is_pod(POD))]; }
+ { int arr[T(__is_pod(Int))]; }
+ { int arr[T(__is_pod(IntAr))]; }
+ { int arr[T(__is_pod(Statics))]; }
+ { int arr[T(__is_pod(Empty))]; }
+ { int arr[T(__is_pod(EmptyUnion))]; }
+ { int arr[T(__is_pod(Union))]; }
+ { int arr[T(__is_pod(HasFunc))]; }
+ { int arr[T(__is_pod(HasOp))]; }
+ { int arr[T(__is_pod(HasConv))]; }
+ { int arr[T(__is_pod(HasAssign))]; }
+ { int arr[T(__is_pod(IntArNB))]; }
+ { int arr[T(__is_pod(HasAnonymousUnion))]; }
+ { int arr[T(__is_pod(Vector))]; }
+ { int arr[T(__is_pod(VectorExt))]; }
+
+ { int arr[F(__is_pod(Derives))]; }
+ { int arr[F(__is_pod(DerivesAr))]; }
+ { int arr[F(__is_pod(DerivesArNB))]; }
+ { int arr[F(__is_pod(DerivesEmpty))]; }
+ { int arr[F(__is_pod(HasCons))]; }
+ { int arr[F(__is_pod(HasCopyAssign))]; }
+ { int arr[F(__is_pod(HasMoveAssign))]; }
+ { int arr[F(__is_pod(HasDest))]; }
+ { int arr[F(__is_pod(HasPriv))]; }
+ { int arr[F(__is_pod(HasProt))]; }
+ { int arr[F(__is_pod(HasRef))]; }
+ { int arr[F(__is_pod(HasVirt))]; }
+ { int arr[F(__is_pod(DerivesHasCons))]; }
+ { int arr[F(__is_pod(DerivesHasCopyAssign))]; }
+ { int arr[F(__is_pod(DerivesHasMoveAssign))]; }
+ { int arr[F(__is_pod(DerivesHasDest))]; }
+ { int arr[F(__is_pod(DerivesHasPriv))]; }
+ { int arr[F(__is_pod(DerivesHasProt))]; }
+ { int arr[F(__is_pod(DerivesHasRef))]; }
+ { int arr[F(__is_pod(DerivesHasVirt))]; }
+ { int arr[F(__is_pod(NonPOD))]; }
+ { int arr[F(__is_pod(HasNonPOD))]; }
+ { int arr[F(__is_pod(NonPODAr))]; }
+ { int arr[F(__is_pod(NonPODArNB))]; }
+ { int arr[F(__is_pod(void))]; }
+ { int arr[F(__is_pod(cvoid))]; }
+// { int arr[F(__is_pod(NonPODUnion))]; }
}
typedef Empty EmptyAr[10];
@@ -118,48 +147,49 @@ struct BitOnly { int x : 3; };
void is_empty()
{
- int t01[T(__is_empty(Empty))];
- int t02[T(__is_empty(DerivesEmpty))];
- int t03[T(__is_empty(HasCons))];
- int t04[T(__is_empty(HasCopyAssign))];
- int t05[T(__is_empty(HasDest))];
- int t06[T(__is_empty(HasFunc))];
- int t07[T(__is_empty(HasOp))];
- int t08[T(__is_empty(HasConv))];
- int t09[T(__is_empty(HasAssign))];
- int t10[T(__is_empty(Bit0))];
- int t11[T(__is_empty(Bit0Cons))];
-
- int t21[F(__is_empty(Int))];
- int t22[F(__is_empty(POD))];
- int t23[F(__is_empty(EmptyUnion))];
- int t24[F(__is_empty(EmptyAr))];
- int t25[F(__is_empty(HasRef))];
- int t26[F(__is_empty(HasVirt))];
- int t27[F(__is_empty(BitOnly))];
- int t28[F(__is_empty(void))];
- int t29[F(__is_empty(IntArNB))];
- int t30[F(__is_empty(HasAnonymousUnion))];
-// int t27[F(__is_empty(DerivesVirt))];
+ { int arr[T(__is_empty(Empty))]; }
+ { int arr[T(__is_empty(DerivesEmpty))]; }
+ { int arr[T(__is_empty(HasCons))]; }
+ { int arr[T(__is_empty(HasCopyAssign))]; }
+ { int arr[T(__is_empty(HasMoveAssign))]; }
+ { int arr[T(__is_empty(HasDest))]; }
+ { int arr[T(__is_empty(HasFunc))]; }
+ { int arr[T(__is_empty(HasOp))]; }
+ { int arr[T(__is_empty(HasConv))]; }
+ { int arr[T(__is_empty(HasAssign))]; }
+ { int arr[T(__is_empty(Bit0))]; }
+ { int arr[T(__is_empty(Bit0Cons))]; }
+
+ { int arr[F(__is_empty(Int))]; }
+ { int arr[F(__is_empty(POD))]; }
+ { int arr[F(__is_empty(EmptyUnion))]; }
+ { int arr[F(__is_empty(EmptyAr))]; }
+ { int arr[F(__is_empty(HasRef))]; }
+ { int arr[F(__is_empty(HasVirt))]; }
+ { int arr[F(__is_empty(BitOnly))]; }
+ { int arr[F(__is_empty(void))]; }
+ { int arr[F(__is_empty(IntArNB))]; }
+ { int arr[F(__is_empty(HasAnonymousUnion))]; }
+// { int arr[F(__is_empty(DerivesVirt))]; }
}
typedef Derives ClassType;
void is_class()
{
- int t01[T(__is_class(Derives))];
- int t02[T(__is_class(HasPriv))];
- int t03[T(__is_class(ClassType))];
- int t04[T(__is_class(HasAnonymousUnion))];
+ { int arr[T(__is_class(Derives))]; }
+ { int arr[T(__is_class(HasPriv))]; }
+ { int arr[T(__is_class(ClassType))]; }
+ { int arr[T(__is_class(HasAnonymousUnion))]; }
- int t11[F(__is_class(int))];
- int t12[F(__is_class(Enum))];
- int t13[F(__is_class(Int))];
- int t14[F(__is_class(IntAr))];
- int t15[F(__is_class(NonPODAr))];
- int t16[F(__is_class(Union))];
- int t17[F(__is_class(cvoid))];
- int t18[F(__is_class(IntArNB))];
+ { int arr[F(__is_class(int))]; }
+ { int arr[F(__is_class(Enum))]; }
+ { int arr[F(__is_class(Int))]; }
+ { int arr[F(__is_class(IntAr))]; }
+ { int arr[F(__is_class(DerivesAr))]; }
+ { int arr[F(__is_class(Union))]; }
+ { int arr[F(__is_class(cvoid))]; }
+ { int arr[F(__is_class(IntArNB))]; }
}
typedef Union UnionAr[10];
@@ -167,36 +197,36 @@ typedef Union UnionType;
void is_union()
{
- int t01[T(__is_union(Union))];
- int t02[T(__is_union(UnionType))];
+ { int arr[T(__is_union(Union))]; }
+ { int arr[T(__is_union(UnionType))]; }
- int t11[F(__is_union(int))];
- int t12[F(__is_union(Enum))];
- int t13[F(__is_union(Int))];
- int t14[F(__is_union(IntAr))];
- int t15[F(__is_union(UnionAr))];
- int t16[F(__is_union(cvoid))];
- int t17[F(__is_union(IntArNB))];
- int t18[F(__is_union(HasAnonymousUnion))];
+ { int arr[F(__is_union(int))]; }
+ { int arr[F(__is_union(Enum))]; }
+ { int arr[F(__is_union(Int))]; }
+ { int arr[F(__is_union(IntAr))]; }
+ { int arr[F(__is_union(UnionAr))]; }
+ { int arr[F(__is_union(cvoid))]; }
+ { int arr[F(__is_union(IntArNB))]; }
+ { int arr[F(__is_union(HasAnonymousUnion))]; }
}
typedef Enum EnumType;
void is_enum()
{
- int t01[T(__is_enum(Enum))];
- int t02[T(__is_enum(EnumType))];
+ { int arr[T(__is_enum(Enum))]; }
+ { int arr[T(__is_enum(EnumType))]; }
- int t11[F(__is_enum(int))];
- int t12[F(__is_enum(Union))];
- int t13[F(__is_enum(Int))];
- int t14[F(__is_enum(IntAr))];
- int t15[F(__is_enum(UnionAr))];
- int t16[F(__is_enum(Derives))];
- int t17[F(__is_enum(ClassType))];
- int t18[F(__is_enum(cvoid))];
- int t19[F(__is_enum(IntArNB))];
- int t20[F(__is_enum(HasAnonymousUnion))];
+ { int arr[F(__is_enum(int))]; }
+ { int arr[F(__is_enum(Union))]; }
+ { int arr[F(__is_enum(Int))]; }
+ { int arr[F(__is_enum(IntAr))]; }
+ { int arr[F(__is_enum(UnionAr))]; }
+ { int arr[F(__is_enum(Derives))]; }
+ { int arr[F(__is_enum(ClassType))]; }
+ { int arr[F(__is_enum(cvoid))]; }
+ { int arr[F(__is_enum(IntArNB))]; }
+ { int arr[F(__is_enum(HasAnonymousUnion))]; }
}
typedef HasVirt Polymorph;
@@ -204,19 +234,788 @@ struct InheritPolymorph : Polymorph {};
void is_polymorphic()
{
- int t01[T(__is_polymorphic(Polymorph))];
- int t02[T(__is_polymorphic(InheritPolymorph))];
+ { int arr[T(__is_polymorphic(Polymorph))]; }
+ { int arr[T(__is_polymorphic(InheritPolymorph))]; }
+
+ { int arr[F(__is_polymorphic(int))]; }
+ { int arr[F(__is_polymorphic(Union))]; }
+ { int arr[F(__is_polymorphic(Int))]; }
+ { int arr[F(__is_polymorphic(IntAr))]; }
+ { int arr[F(__is_polymorphic(UnionAr))]; }
+ { int arr[F(__is_polymorphic(Derives))]; }
+ { int arr[F(__is_polymorphic(ClassType))]; }
+ { int arr[F(__is_polymorphic(Enum))]; }
+ { int arr[F(__is_polymorphic(cvoid))]; }
+ { int arr[F(__is_polymorphic(IntArNB))]; }
+}
+
+void is_integral()
+{
+ int t01[T(__is_integral(bool))];
+ int t02[T(__is_integral(char))];
+ int t03[T(__is_integral(signed char))];
+ int t04[T(__is_integral(unsigned char))];
+ //int t05[T(__is_integral(char16_t))];
+ //int t06[T(__is_integral(char32_t))];
+ int t07[T(__is_integral(wchar_t))];
+ int t08[T(__is_integral(short))];
+ int t09[T(__is_integral(unsigned short))];
+ int t10[T(__is_integral(int))];
+ int t11[T(__is_integral(unsigned int))];
+ int t12[T(__is_integral(long))];
+ int t13[T(__is_integral(unsigned long))];
+
+ int t21[F(__is_integral(float))];
+ int t22[F(__is_integral(double))];
+ int t23[F(__is_integral(long double))];
+ int t24[F(__is_integral(Union))];
+ int t25[F(__is_integral(UnionAr))];
+ int t26[F(__is_integral(Derives))];
+ int t27[F(__is_integral(ClassType))];
+ int t28[F(__is_integral(Enum))];
+ int t29[F(__is_integral(void))];
+ int t30[F(__is_integral(cvoid))];
+ int t31[F(__is_integral(IntArNB))];
+}
+
+void is_floating_point()
+{
+ int t01[T(__is_floating_point(float))];
+ int t02[T(__is_floating_point(double))];
+ int t03[T(__is_floating_point(long double))];
+
+ int t11[F(__is_floating_point(bool))];
+ int t12[F(__is_floating_point(char))];
+ int t13[F(__is_floating_point(signed char))];
+ int t14[F(__is_floating_point(unsigned char))];
+ //int t15[F(__is_floating_point(char16_t))];
+ //int t16[F(__is_floating_point(char32_t))];
+ int t17[F(__is_floating_point(wchar_t))];
+ int t18[F(__is_floating_point(short))];
+ int t19[F(__is_floating_point(unsigned short))];
+ int t20[F(__is_floating_point(int))];
+ int t21[F(__is_floating_point(unsigned int))];
+ int t22[F(__is_floating_point(long))];
+ int t23[F(__is_floating_point(unsigned long))];
+ int t24[F(__is_floating_point(Union))];
+ int t25[F(__is_floating_point(UnionAr))];
+ int t26[F(__is_floating_point(Derives))];
+ int t27[F(__is_floating_point(ClassType))];
+ int t28[F(__is_floating_point(Enum))];
+ int t29[F(__is_floating_point(void))];
+ int t30[F(__is_floating_point(cvoid))];
+ int t31[F(__is_floating_point(IntArNB))];
+}
+
+void is_arithmetic()
+{
+ int t01[T(__is_arithmetic(float))];
+ int t02[T(__is_arithmetic(double))];
+ int t03[T(__is_arithmetic(long double))];
+ int t11[T(__is_arithmetic(bool))];
+ int t12[T(__is_arithmetic(char))];
+ int t13[T(__is_arithmetic(signed char))];
+ int t14[T(__is_arithmetic(unsigned char))];
+ //int t15[T(__is_arithmetic(char16_t))];
+ //int t16[T(__is_arithmetic(char32_t))];
+ int t17[T(__is_arithmetic(wchar_t))];
+ int t18[T(__is_arithmetic(short))];
+ int t19[T(__is_arithmetic(unsigned short))];
+ int t20[T(__is_arithmetic(int))];
+ int t21[T(__is_arithmetic(unsigned int))];
+ int t22[T(__is_arithmetic(long))];
+ int t23[T(__is_arithmetic(unsigned long))];
+
+ int t24[F(__is_arithmetic(Union))];
+ int t25[F(__is_arithmetic(UnionAr))];
+ int t26[F(__is_arithmetic(Derives))];
+ int t27[F(__is_arithmetic(ClassType))];
+ int t28[F(__is_arithmetic(Enum))];
+ int t29[F(__is_arithmetic(void))];
+ int t30[F(__is_arithmetic(cvoid))];
+ int t31[F(__is_arithmetic(IntArNB))];
+}
+
+struct ACompleteType {};
+struct AnIncompleteType;
+
+void is_complete_type()
+{
+ int t01[T(__is_complete_type(float))];
+ int t02[T(__is_complete_type(double))];
+ int t03[T(__is_complete_type(long double))];
+ int t11[T(__is_complete_type(bool))];
+ int t12[T(__is_complete_type(char))];
+ int t13[T(__is_complete_type(signed char))];
+ int t14[T(__is_complete_type(unsigned char))];
+ //int t15[T(__is_complete_type(char16_t))];
+ //int t16[T(__is_complete_type(char32_t))];
+ int t17[T(__is_complete_type(wchar_t))];
+ int t18[T(__is_complete_type(short))];
+ int t19[T(__is_complete_type(unsigned short))];
+ int t20[T(__is_complete_type(int))];
+ int t21[T(__is_complete_type(unsigned int))];
+ int t22[T(__is_complete_type(long))];
+ int t23[T(__is_complete_type(unsigned long))];
+ int t24[T(__is_complete_type(ACompleteType))];
+
+ int t30[F(__is_complete_type(AnIncompleteType))];
+}
+
+void is_void()
+{
+ int t01[T(__is_void(void))];
+ int t02[T(__is_void(cvoid))];
+
+ int t10[F(__is_void(float))];
+ int t11[F(__is_void(double))];
+ int t12[F(__is_void(long double))];
+ int t13[F(__is_void(bool))];
+ int t14[F(__is_void(char))];
+ int t15[F(__is_void(signed char))];
+ int t16[F(__is_void(unsigned char))];
+ int t17[F(__is_void(wchar_t))];
+ int t18[F(__is_void(short))];
+ int t19[F(__is_void(unsigned short))];
+ int t20[F(__is_void(int))];
+ int t21[F(__is_void(unsigned int))];
+ int t22[F(__is_void(long))];
+ int t23[F(__is_void(unsigned long))];
+ int t24[F(__is_void(Union))];
+ int t25[F(__is_void(UnionAr))];
+ int t26[F(__is_void(Derives))];
+ int t27[F(__is_void(ClassType))];
+ int t28[F(__is_void(Enum))];
+ int t29[F(__is_void(IntArNB))];
+ int t30[F(__is_void(void*))];
+ int t31[F(__is_void(cvoid*))];
+}
+
+void is_array()
+{
+ int t01[T(__is_array(IntAr))];
+ int t02[T(__is_array(IntArNB))];
+ int t03[T(__is_array(UnionAr))];
+
+ int t10[F(__is_array(void))];
+ int t11[F(__is_array(cvoid))];
+ int t12[F(__is_array(float))];
+ int t13[F(__is_array(double))];
+ int t14[F(__is_array(long double))];
+ int t15[F(__is_array(bool))];
+ int t16[F(__is_array(char))];
+ int t17[F(__is_array(signed char))];
+ int t18[F(__is_array(unsigned char))];
+ int t19[F(__is_array(wchar_t))];
+ int t20[F(__is_array(short))];
+ int t21[F(__is_array(unsigned short))];
+ int t22[F(__is_array(int))];
+ int t23[F(__is_array(unsigned int))];
+ int t24[F(__is_array(long))];
+ int t25[F(__is_array(unsigned long))];
+ int t26[F(__is_array(Union))];
+ int t27[F(__is_array(Derives))];
+ int t28[F(__is_array(ClassType))];
+ int t29[F(__is_array(Enum))];
+ int t30[F(__is_array(void*))];
+ int t31[F(__is_array(cvoid*))];
+}
+
+template <typename T> void tmpl_func(T&) {}
+
+template <typename T> struct type_wrapper {
+ typedef T type;
+ typedef T* ptrtype;
+ typedef T& reftype;
+};
+
+void is_function()
+{
+ int t01[T(__is_function(type_wrapper<void(void)>::type))];
+ int t02[T(__is_function(typeof(tmpl_func<int>)))];
+
+ typedef void (*ptr_to_func_type)(void);
+
+ int t10[F(__is_function(void))];
+ int t11[F(__is_function(cvoid))];
+ int t12[F(__is_function(float))];
+ int t13[F(__is_function(double))];
+ int t14[F(__is_function(long double))];
+ int t15[F(__is_function(bool))];
+ int t16[F(__is_function(char))];
+ int t17[F(__is_function(signed char))];
+ int t18[F(__is_function(unsigned char))];
+ int t19[F(__is_function(wchar_t))];
+ int t20[F(__is_function(short))];
+ int t21[F(__is_function(unsigned short))];
+ int t22[F(__is_function(int))];
+ int t23[F(__is_function(unsigned int))];
+ int t24[F(__is_function(long))];
+ int t25[F(__is_function(unsigned long))];
+ int t26[F(__is_function(Union))];
+ int t27[F(__is_function(Derives))];
+ int t28[F(__is_function(ClassType))];
+ int t29[F(__is_function(Enum))];
+ int t30[F(__is_function(void*))];
+ int t31[F(__is_function(cvoid*))];
+ int t32[F(__is_function(void(*)()))];
+ int t33[F(__is_function(ptr_to_func_type))];
+ int t34[F(__is_function(type_wrapper<void(void)>::ptrtype))];
+ int t35[F(__is_function(type_wrapper<void(void)>::reftype))];
+}
+
+void is_reference()
+{
+ int t01[T(__is_reference(int&))];
+ int t02[T(__is_reference(const int&))];
+ int t03[T(__is_reference(void *&))];
+
+ int t10[F(__is_reference(int))];
+ int t11[F(__is_reference(const int))];
+ int t12[F(__is_reference(void *))];
+}
+
+void is_lvalue_reference()
+{
+ int t01[T(__is_lvalue_reference(int&))];
+ int t02[T(__is_lvalue_reference(void *&))];
+ int t03[T(__is_lvalue_reference(const int&))];
+ int t04[T(__is_lvalue_reference(void * const &))];
+
+ int t10[F(__is_lvalue_reference(int))];
+ int t11[F(__is_lvalue_reference(const int))];
+ int t12[F(__is_lvalue_reference(void *))];
+}
+
+#if __has_feature(cxx_rvalue_references)
+
+void is_rvalue_reference()
+{
+ int t01[T(__is_rvalue_reference(const int&&))];
+ int t02[T(__is_rvalue_reference(void * const &&))];
+
+ int t10[F(__is_rvalue_reference(int&))];
+ int t11[F(__is_rvalue_reference(void *&))];
+ int t12[F(__is_rvalue_reference(const int&))];
+ int t13[F(__is_rvalue_reference(void * const &))];
+ int t14[F(__is_rvalue_reference(int))];
+ int t15[F(__is_rvalue_reference(const int))];
+ int t16[F(__is_rvalue_reference(void *))];
+}
+
+#endif
+
+void is_fundamental()
+{
+ int t01[T(__is_fundamental(float))];
+ int t02[T(__is_fundamental(double))];
+ int t03[T(__is_fundamental(long double))];
+ int t11[T(__is_fundamental(bool))];
+ int t12[T(__is_fundamental(char))];
+ int t13[T(__is_fundamental(signed char))];
+ int t14[T(__is_fundamental(unsigned char))];
+ //int t15[T(__is_fundamental(char16_t))];
+ //int t16[T(__is_fundamental(char32_t))];
+ int t17[T(__is_fundamental(wchar_t))];
+ int t18[T(__is_fundamental(short))];
+ int t19[T(__is_fundamental(unsigned short))];
+ int t20[T(__is_fundamental(int))];
+ int t21[T(__is_fundamental(unsigned int))];
+ int t22[T(__is_fundamental(long))];
+ int t23[T(__is_fundamental(unsigned long))];
+ int t24[T(__is_fundamental(void))];
+ int t25[T(__is_fundamental(cvoid))];
+
+ int t30[F(__is_fundamental(Union))];
+ int t31[F(__is_fundamental(UnionAr))];
+ int t32[F(__is_fundamental(Derives))];
+ int t33[F(__is_fundamental(ClassType))];
+ int t34[F(__is_fundamental(Enum))];
+ int t35[F(__is_fundamental(IntArNB))];
+}
+
+void is_object()
+{
+ int t01[T(__is_object(int))];
+ int t02[T(__is_object(int *))];
+ int t03[T(__is_object(void *))];
+ int t04[T(__is_object(Union))];
+ int t05[T(__is_object(UnionAr))];
+ int t06[T(__is_object(ClassType))];
+ int t07[T(__is_object(Enum))];
+
+ int t10[F(__is_object(type_wrapper<void(void)>::type))];
+ int t11[F(__is_object(int&))];
+ int t12[F(__is_object(void))];
+}
+
+void is_scalar()
+{
+ int t01[T(__is_scalar(float))];
+ int t02[T(__is_scalar(double))];
+ int t03[T(__is_scalar(long double))];
+ int t04[T(__is_scalar(bool))];
+ int t05[T(__is_scalar(char))];
+ int t06[T(__is_scalar(signed char))];
+ int t07[T(__is_scalar(unsigned char))];
+ int t08[T(__is_scalar(wchar_t))];
+ int t09[T(__is_scalar(short))];
+ int t10[T(__is_scalar(unsigned short))];
+ int t11[T(__is_scalar(int))];
+ int t12[T(__is_scalar(unsigned int))];
+ int t13[T(__is_scalar(long))];
+ int t14[T(__is_scalar(unsigned long))];
+ int t15[T(__is_scalar(Enum))];
+ int t16[T(__is_scalar(void*))];
+ int t17[T(__is_scalar(cvoid*))];
+
+ int t20[F(__is_scalar(void))];
+ int t21[F(__is_scalar(cvoid))];
+ int t22[F(__is_scalar(Union))];
+ int t23[F(__is_scalar(UnionAr))];
+ int t24[F(__is_scalar(Derives))];
+ int t25[F(__is_scalar(ClassType))];
+ int t26[F(__is_scalar(IntArNB))];
+}
+
+struct StructWithMembers {
+ int member;
+ void method() {}
+};
+
+void is_compound()
+{
+ int t01[T(__is_compound(void*))];
+ int t02[T(__is_compound(cvoid*))];
+ int t03[T(__is_compound(void (*)()))];
+ int t04[T(__is_compound(int StructWithMembers::*))];
+ int t05[T(__is_compound(void (StructWithMembers::*)()))];
+ int t06[T(__is_compound(int&))];
+ int t07[T(__is_compound(Union))];
+ int t08[T(__is_compound(UnionAr))];
+ int t09[T(__is_compound(Derives))];
+ int t10[T(__is_compound(ClassType))];
+ int t11[T(__is_compound(IntArNB))];
+ int t12[T(__is_compound(Enum))];
+
+ int t20[F(__is_compound(float))];
+ int t21[F(__is_compound(double))];
+ int t22[F(__is_compound(long double))];
+ int t23[F(__is_compound(bool))];
+ int t24[F(__is_compound(char))];
+ int t25[F(__is_compound(signed char))];
+ int t26[F(__is_compound(unsigned char))];
+ int t27[F(__is_compound(wchar_t))];
+ int t28[F(__is_compound(short))];
+ int t29[F(__is_compound(unsigned short))];
+ int t30[F(__is_compound(int))];
+ int t31[F(__is_compound(unsigned int))];
+ int t32[F(__is_compound(long))];
+ int t33[F(__is_compound(unsigned long))];
+ int t34[F(__is_compound(void))];
+ int t35[F(__is_compound(cvoid))];
+}
+
+void is_pointer()
+{
+ StructWithMembers x;
+
+ int t01[T(__is_pointer(void*))];
+ int t02[T(__is_pointer(cvoid*))];
+ int t03[T(__is_pointer(cvoid*))];
+ int t04[T(__is_pointer(char*))];
+ int t05[T(__is_pointer(int*))];
+ int t06[T(__is_pointer(int**))];
+ int t07[T(__is_pointer(ClassType*))];
+ int t08[T(__is_pointer(Derives*))];
+ int t09[T(__is_pointer(Enum*))];
+ int t10[T(__is_pointer(IntArNB*))];
+ int t11[T(__is_pointer(Union*))];
+ int t12[T(__is_pointer(UnionAr*))];
+ int t13[T(__is_pointer(StructWithMembers*))];
+ int t14[T(__is_pointer(void (*)()))];
+
+ int t20[F(__is_pointer(void))];
+ int t21[F(__is_pointer(cvoid))];
+ int t22[F(__is_pointer(cvoid))];
+ int t23[F(__is_pointer(char))];
+ int t24[F(__is_pointer(int))];
+ int t25[F(__is_pointer(int))];
+ int t26[F(__is_pointer(ClassType))];
+ int t27[F(__is_pointer(Derives))];
+ int t28[F(__is_pointer(Enum))];
+ int t29[F(__is_pointer(IntArNB))];
+ int t30[F(__is_pointer(Union))];
+ int t31[F(__is_pointer(UnionAr))];
+ int t32[F(__is_pointer(StructWithMembers))];
+ int t33[F(__is_pointer(int StructWithMembers::*))];
+ int t34[F(__is_pointer(void (StructWithMembers::*) ()))];
+}
+
+void is_member_object_pointer()
+{
+ StructWithMembers x;
+
+ int t01[T(__is_member_object_pointer(int StructWithMembers::*))];
+
+ int t10[F(__is_member_object_pointer(void (StructWithMembers::*) ()))];
+ int t11[F(__is_member_object_pointer(void*))];
+ int t12[F(__is_member_object_pointer(cvoid*))];
+ int t13[F(__is_member_object_pointer(cvoid*))];
+ int t14[F(__is_member_object_pointer(char*))];
+ int t15[F(__is_member_object_pointer(int*))];
+ int t16[F(__is_member_object_pointer(int**))];
+ int t17[F(__is_member_object_pointer(ClassType*))];
+ int t18[F(__is_member_object_pointer(Derives*))];
+ int t19[F(__is_member_object_pointer(Enum*))];
+ int t20[F(__is_member_object_pointer(IntArNB*))];
+ int t21[F(__is_member_object_pointer(Union*))];
+ int t22[F(__is_member_object_pointer(UnionAr*))];
+ int t23[F(__is_member_object_pointer(StructWithMembers*))];
+ int t24[F(__is_member_object_pointer(void))];
+ int t25[F(__is_member_object_pointer(cvoid))];
+ int t26[F(__is_member_object_pointer(cvoid))];
+ int t27[F(__is_member_object_pointer(char))];
+ int t28[F(__is_member_object_pointer(int))];
+ int t29[F(__is_member_object_pointer(int))];
+ int t30[F(__is_member_object_pointer(ClassType))];
+ int t31[F(__is_member_object_pointer(Derives))];
+ int t32[F(__is_member_object_pointer(Enum))];
+ int t33[F(__is_member_object_pointer(IntArNB))];
+ int t34[F(__is_member_object_pointer(Union))];
+ int t35[F(__is_member_object_pointer(UnionAr))];
+ int t36[F(__is_member_object_pointer(StructWithMembers))];
+ int t37[F(__is_member_object_pointer(void (*)()))];
+}
+
+void is_member_function_pointer()
+{
+ StructWithMembers x;
- int t11[F(__is_polymorphic(int))];
- int t12[F(__is_polymorphic(Union))];
- int t13[F(__is_polymorphic(Int))];
- int t14[F(__is_polymorphic(IntAr))];
- int t15[F(__is_polymorphic(UnionAr))];
- int t16[F(__is_polymorphic(Derives))];
- int t17[F(__is_polymorphic(ClassType))];
- int t18[F(__is_polymorphic(Enum))];
- int t19[F(__is_polymorphic(cvoid))];
- int t20[F(__is_polymorphic(IntArNB))];
+ int t01[T(__is_member_function_pointer(void (StructWithMembers::*) ()))];
+
+ int t10[F(__is_member_function_pointer(int StructWithMembers::*))];
+ int t11[F(__is_member_function_pointer(void*))];
+ int t12[F(__is_member_function_pointer(cvoid*))];
+ int t13[F(__is_member_function_pointer(cvoid*))];
+ int t14[F(__is_member_function_pointer(char*))];
+ int t15[F(__is_member_function_pointer(int*))];
+ int t16[F(__is_member_function_pointer(int**))];
+ int t17[F(__is_member_function_pointer(ClassType*))];
+ int t18[F(__is_member_function_pointer(Derives*))];
+ int t19[F(__is_member_function_pointer(Enum*))];
+ int t20[F(__is_member_function_pointer(IntArNB*))];
+ int t21[F(__is_member_function_pointer(Union*))];
+ int t22[F(__is_member_function_pointer(UnionAr*))];
+ int t23[F(__is_member_function_pointer(StructWithMembers*))];
+ int t24[F(__is_member_function_pointer(void))];
+ int t25[F(__is_member_function_pointer(cvoid))];
+ int t26[F(__is_member_function_pointer(cvoid))];
+ int t27[F(__is_member_function_pointer(char))];
+ int t28[F(__is_member_function_pointer(int))];
+ int t29[F(__is_member_function_pointer(int))];
+ int t30[F(__is_member_function_pointer(ClassType))];
+ int t31[F(__is_member_function_pointer(Derives))];
+ int t32[F(__is_member_function_pointer(Enum))];
+ int t33[F(__is_member_function_pointer(IntArNB))];
+ int t34[F(__is_member_function_pointer(Union))];
+ int t35[F(__is_member_function_pointer(UnionAr))];
+ int t36[F(__is_member_function_pointer(StructWithMembers))];
+ int t37[F(__is_member_function_pointer(void (*)()))];
+}
+
+void is_member_pointer()
+{
+ StructWithMembers x;
+
+ int t01[T(__is_member_pointer(int StructWithMembers::*))];
+ int t02[T(__is_member_pointer(void (StructWithMembers::*) ()))];
+
+ int t10[F(__is_member_pointer(void*))];
+ int t11[F(__is_member_pointer(cvoid*))];
+ int t12[F(__is_member_pointer(cvoid*))];
+ int t13[F(__is_member_pointer(char*))];
+ int t14[F(__is_member_pointer(int*))];
+ int t15[F(__is_member_pointer(int**))];
+ int t16[F(__is_member_pointer(ClassType*))];
+ int t17[F(__is_member_pointer(Derives*))];
+ int t18[F(__is_member_pointer(Enum*))];
+ int t19[F(__is_member_pointer(IntArNB*))];
+ int t20[F(__is_member_pointer(Union*))];
+ int t21[F(__is_member_pointer(UnionAr*))];
+ int t22[F(__is_member_pointer(StructWithMembers*))];
+ int t23[F(__is_member_pointer(void))];
+ int t24[F(__is_member_pointer(cvoid))];
+ int t25[F(__is_member_pointer(cvoid))];
+ int t26[F(__is_member_pointer(char))];
+ int t27[F(__is_member_pointer(int))];
+ int t28[F(__is_member_pointer(int))];
+ int t29[F(__is_member_pointer(ClassType))];
+ int t30[F(__is_member_pointer(Derives))];
+ int t31[F(__is_member_pointer(Enum))];
+ int t32[F(__is_member_pointer(IntArNB))];
+ int t33[F(__is_member_pointer(Union))];
+ int t34[F(__is_member_pointer(UnionAr))];
+ int t35[F(__is_member_pointer(StructWithMembers))];
+ int t36[F(__is_member_pointer(void (*)()))];
+}
+
+void is_const()
+{
+ int t01[T(__is_const(cvoid))];
+ int t02[T(__is_const(const char))];
+ int t03[T(__is_const(const int))];
+ int t04[T(__is_const(const long))];
+ int t05[T(__is_const(const short))];
+ int t06[T(__is_const(const signed char))];
+ int t07[T(__is_const(const wchar_t))];
+ int t08[T(__is_const(const bool))];
+ int t09[T(__is_const(const float))];
+ int t10[T(__is_const(const double))];
+ int t11[T(__is_const(const long double))];
+ int t12[T(__is_const(const unsigned char))];
+ int t13[T(__is_const(const unsigned int))];
+ int t14[T(__is_const(const unsigned long long))];
+ int t15[T(__is_const(const unsigned long))];
+ int t16[T(__is_const(const unsigned short))];
+ int t17[T(__is_const(const void))];
+ int t18[T(__is_const(const ClassType))];
+ int t19[T(__is_const(const Derives))];
+ int t20[T(__is_const(const Enum))];
+ int t21[T(__is_const(const IntArNB))];
+ int t22[T(__is_const(const Union))];
+ int t23[T(__is_const(const UnionAr))];
+
+ int t30[F(__is_const(char))];
+ int t31[F(__is_const(int))];
+ int t32[F(__is_const(long))];
+ int t33[F(__is_const(short))];
+ int t34[F(__is_const(signed char))];
+ int t35[F(__is_const(wchar_t))];
+ int t36[F(__is_const(bool))];
+ int t37[F(__is_const(float))];
+ int t38[F(__is_const(double))];
+ int t39[F(__is_const(long double))];
+ int t40[F(__is_const(unsigned char))];
+ int t41[F(__is_const(unsigned int))];
+ int t42[F(__is_const(unsigned long long))];
+ int t43[F(__is_const(unsigned long))];
+ int t44[F(__is_const(unsigned short))];
+ int t45[F(__is_const(void))];
+ int t46[F(__is_const(ClassType))];
+ int t47[F(__is_const(Derives))];
+ int t48[F(__is_const(Enum))];
+ int t49[F(__is_const(IntArNB))];
+ int t50[F(__is_const(Union))];
+ int t51[F(__is_const(UnionAr))];
+}
+
+void is_volatile()
+{
+ int t02[T(__is_volatile(volatile char))];
+ int t03[T(__is_volatile(volatile int))];
+ int t04[T(__is_volatile(volatile long))];
+ int t05[T(__is_volatile(volatile short))];
+ int t06[T(__is_volatile(volatile signed char))];
+ int t07[T(__is_volatile(volatile wchar_t))];
+ int t08[T(__is_volatile(volatile bool))];
+ int t09[T(__is_volatile(volatile float))];
+ int t10[T(__is_volatile(volatile double))];
+ int t11[T(__is_volatile(volatile long double))];
+ int t12[T(__is_volatile(volatile unsigned char))];
+ int t13[T(__is_volatile(volatile unsigned int))];
+ int t14[T(__is_volatile(volatile unsigned long long))];
+ int t15[T(__is_volatile(volatile unsigned long))];
+ int t16[T(__is_volatile(volatile unsigned short))];
+ int t17[T(__is_volatile(volatile void))];
+ int t18[T(__is_volatile(volatile ClassType))];
+ int t19[T(__is_volatile(volatile Derives))];
+ int t20[T(__is_volatile(volatile Enum))];
+ int t21[T(__is_volatile(volatile IntArNB))];
+ int t22[T(__is_volatile(volatile Union))];
+ int t23[T(__is_volatile(volatile UnionAr))];
+
+ int t30[F(__is_volatile(char))];
+ int t31[F(__is_volatile(int))];
+ int t32[F(__is_volatile(long))];
+ int t33[F(__is_volatile(short))];
+ int t34[F(__is_volatile(signed char))];
+ int t35[F(__is_volatile(wchar_t))];
+ int t36[F(__is_volatile(bool))];
+ int t37[F(__is_volatile(float))];
+ int t38[F(__is_volatile(double))];
+ int t39[F(__is_volatile(long double))];
+ int t40[F(__is_volatile(unsigned char))];
+ int t41[F(__is_volatile(unsigned int))];
+ int t42[F(__is_volatile(unsigned long long))];
+ int t43[F(__is_volatile(unsigned long))];
+ int t44[F(__is_volatile(unsigned short))];
+ int t45[F(__is_volatile(void))];
+ int t46[F(__is_volatile(ClassType))];
+ int t47[F(__is_volatile(Derives))];
+ int t48[F(__is_volatile(Enum))];
+ int t49[F(__is_volatile(IntArNB))];
+ int t50[F(__is_volatile(Union))];
+ int t51[F(__is_volatile(UnionAr))];
+}
+
+struct TrivialStruct {
+ int member;
+};
+
+struct NonTrivialStruct {
+ int member;
+ NonTrivialStruct() {
+ member = 0;
+ }
+};
+
+void is_trivial2()
+{
+ int t01[T(__is_trivial(char))];
+ int t02[T(__is_trivial(int))];
+ int t03[T(__is_trivial(long))];
+ int t04[T(__is_trivial(short))];
+ int t05[T(__is_trivial(signed char))];
+ int t06[T(__is_trivial(wchar_t))];
+ int t07[T(__is_trivial(bool))];
+ int t08[T(__is_trivial(float))];
+ int t09[T(__is_trivial(double))];
+ int t10[T(__is_trivial(long double))];
+ int t11[T(__is_trivial(unsigned char))];
+ int t12[T(__is_trivial(unsigned int))];
+ int t13[T(__is_trivial(unsigned long long))];
+ int t14[T(__is_trivial(unsigned long))];
+ int t15[T(__is_trivial(unsigned short))];
+ int t16[T(__is_trivial(ClassType))];
+ int t17[T(__is_trivial(Derives))];
+ int t18[T(__is_trivial(Enum))];
+ int t19[T(__is_trivial(IntAr))];
+ int t20[T(__is_trivial(Union))];
+ int t21[T(__is_trivial(UnionAr))];
+ int t22[T(__is_trivial(TrivialStruct))];
+
+ int t30[F(__is_trivial(void))];
+ int t31[F(__is_trivial(NonTrivialStruct))];
+}
+
+struct CStruct {
+ int one;
+ int two;
+};
+
+struct CEmptyStruct {};
+
+struct CppEmptyStruct : CStruct {};
+struct CppStructStandard : CEmptyStruct {
+ int three;
+ int four;
+};
+struct CppStructNonStandardByBase : CStruct {
+ int three;
+ int four;
+};
+struct CppStructNonStandardByVirt : CStruct {
+ virtual void method() {}
+};
+struct CppStructNonStandardByMemb : CStruct {
+ CppStructNonStandardByVirt member;
+};
+struct CppStructNonStandardByProt : CStruct {
+ int five;
+protected:
+ int six;
+};
+struct CppStructNonStandardByVirtBase : virtual CStruct {
+};
+struct CppStructNonStandardBySameBase : CEmptyStruct {
+ CEmptyStruct member;
+};
+struct CppStructNonStandardBy2ndVirtBase : CEmptyStruct {
+ CEmptyStruct member;
+};
+
+void is_standard_layout()
+{
+ typedef const int ConstInt;
+ typedef ConstInt ConstIntAr[4];
+ typedef CppStructStandard CppStructStandardAr[4];
+
+ int t01[T(__is_standard_layout(int))];
+ int t02[T(__is_standard_layout(ConstInt))];
+ int t03[T(__is_standard_layout(ConstIntAr))];
+ int t04[T(__is_standard_layout(CStruct))];
+ int t05[T(__is_standard_layout(CppStructStandard))];
+ int t06[T(__is_standard_layout(CppStructStandardAr))];
+ int t07[T(__is_standard_layout(Vector))];
+ int t08[T(__is_standard_layout(VectorExt))];
+
+ typedef CppStructNonStandardByBase CppStructNonStandardByBaseAr[4];
+
+ int t10[F(__is_standard_layout(CppStructNonStandardByVirt))];
+ int t11[F(__is_standard_layout(CppStructNonStandardByMemb))];
+ int t12[F(__is_standard_layout(CppStructNonStandardByProt))];
+ int t13[F(__is_standard_layout(CppStructNonStandardByVirtBase))];
+ int t14[F(__is_standard_layout(CppStructNonStandardByBase))];
+ int t15[F(__is_standard_layout(CppStructNonStandardByBaseAr))];
+ int t16[F(__is_standard_layout(CppStructNonStandardBySameBase))];
+ int t17[F(__is_standard_layout(CppStructNonStandardBy2ndVirtBase))];
+}
+
+void is_signed()
+{
+ //int t01[T(__is_signed(char))];
+ int t02[T(__is_signed(int))];
+ int t03[T(__is_signed(long))];
+ int t04[T(__is_signed(short))];
+ int t05[T(__is_signed(signed char))];
+ int t06[T(__is_signed(wchar_t))];
+
+ int t10[F(__is_signed(bool))];
+ int t11[F(__is_signed(cvoid))];
+ int t12[F(__is_signed(float))];
+ int t13[F(__is_signed(double))];
+ int t14[F(__is_signed(long double))];
+ int t15[F(__is_signed(unsigned char))];
+ int t16[F(__is_signed(unsigned int))];
+ int t17[F(__is_signed(unsigned long long))];
+ int t18[F(__is_signed(unsigned long))];
+ int t19[F(__is_signed(unsigned short))];
+ int t20[F(__is_signed(void))];
+ int t21[F(__is_signed(ClassType))];
+ int t22[F(__is_signed(Derives))];
+ int t23[F(__is_signed(Enum))];
+ int t24[F(__is_signed(IntArNB))];
+ int t25[F(__is_signed(Union))];
+ int t26[F(__is_signed(UnionAr))];
+}
+
+void is_unsigned()
+{
+ int t01[T(__is_unsigned(bool))];
+ int t02[T(__is_unsigned(unsigned char))];
+ int t03[T(__is_unsigned(unsigned short))];
+ int t04[T(__is_unsigned(unsigned int))];
+ int t05[T(__is_unsigned(unsigned long))];
+ int t06[T(__is_unsigned(unsigned long long))];
+ int t07[T(__is_unsigned(Enum))];
+
+ int t10[F(__is_unsigned(void))];
+ int t11[F(__is_unsigned(cvoid))];
+ int t12[F(__is_unsigned(float))];
+ int t13[F(__is_unsigned(double))];
+ int t14[F(__is_unsigned(long double))];
+ int t16[F(__is_unsigned(char))];
+ int t17[F(__is_unsigned(signed char))];
+ int t18[F(__is_unsigned(wchar_t))];
+ int t19[F(__is_unsigned(short))];
+ int t20[F(__is_unsigned(int))];
+ int t21[F(__is_unsigned(long))];
+ int t22[F(__is_unsigned(Union))];
+ int t23[F(__is_unsigned(UnionAr))];
+ int t24[F(__is_unsigned(Derives))];
+ int t25[F(__is_unsigned(ClassType))];
+ int t26[F(__is_unsigned(IntArNB))];
}
typedef Int& IntRef;
@@ -227,6 +1026,10 @@ struct HasCopy {
HasCopy(HasCopy& cp);
};
+struct HasMove {
+ HasMove(HasMove&& cp); // expected-warning {{rvalue references}}
+};
+
struct HasTemplateCons {
HasVirt Annoying;
@@ -235,216 +1038,235 @@ struct HasTemplateCons {
};
void has_trivial_default_constructor() {
- int t01[T(__has_trivial_constructor(Int))];
- int t02[T(__has_trivial_constructor(IntAr))];
- int t03[T(__has_trivial_constructor(Union))];
- int t04[T(__has_trivial_constructor(UnionAr))];
- int t05[T(__has_trivial_constructor(POD))];
- int t06[T(__has_trivial_constructor(Derives))];
- int t07[T(__has_trivial_constructor(ConstIntAr))];
- int t08[T(__has_trivial_constructor(ConstIntArAr))];
- int t09[T(__has_trivial_constructor(HasDest))];
- int t10[T(__has_trivial_constructor(HasPriv))];
- int t11[F(__has_trivial_constructor(HasCons))];
- int t12[F(__has_trivial_constructor(HasRef))];
- int t13[F(__has_trivial_constructor(HasCopy))];
- int t14[F(__has_trivial_constructor(IntRef))];
- int t15[T(__has_trivial_constructor(HasCopyAssign))];
- int t16[T(__has_trivial_constructor(const Int))];
- int t17[T(__has_trivial_constructor(NonPODAr))];
- int t18[F(__has_trivial_constructor(VirtAr))];
- int t19[F(__has_trivial_constructor(void))];
- int t20[F(__has_trivial_constructor(cvoid))];
- int t21[F(__has_trivial_constructor(HasTemplateCons))];
+ { int arr[T(__has_trivial_constructor(Int))]; }
+ { int arr[T(__has_trivial_constructor(IntAr))]; }
+ { int arr[T(__has_trivial_constructor(Union))]; }
+ { int arr[T(__has_trivial_constructor(UnionAr))]; }
+ { int arr[T(__has_trivial_constructor(POD))]; }
+ { int arr[T(__has_trivial_constructor(Derives))]; }
+ { int arr[T(__has_trivial_constructor(DerivesAr))]; }
+ { int arr[T(__has_trivial_constructor(ConstIntAr))]; }
+ { int arr[T(__has_trivial_constructor(ConstIntArAr))]; }
+ { int arr[T(__has_trivial_constructor(HasDest))]; }
+ { int arr[T(__has_trivial_constructor(HasPriv))]; }
+ { int arr[T(__has_trivial_constructor(HasCopyAssign))]; }
+ { int arr[T(__has_trivial_constructor(HasMoveAssign))]; }
+ { int arr[T(__has_trivial_constructor(const Int))]; }
+
+ { int arr[F(__has_trivial_constructor(HasCons))]; }
+ { int arr[F(__has_trivial_constructor(HasRef))]; }
+ { int arr[F(__has_trivial_constructor(HasCopy))]; }
+ { int arr[F(__has_trivial_constructor(IntRef))]; }
+ { int arr[F(__has_trivial_constructor(VirtAr))]; }
+ { int arr[F(__has_trivial_constructor(void))]; }
+ { int arr[F(__has_trivial_constructor(cvoid))]; }
+ { int arr[F(__has_trivial_constructor(HasTemplateCons))]; }
}
void has_trivial_copy_constructor() {
- int t01[T(__has_trivial_copy(Int))];
- int t02[T(__has_trivial_copy(IntAr))];
- int t03[T(__has_trivial_copy(Union))];
- int t04[T(__has_trivial_copy(UnionAr))];
- int t05[T(__has_trivial_copy(POD))];
- int t06[T(__has_trivial_copy(Derives))];
- int t07[T(__has_trivial_copy(ConstIntAr))];
- int t08[T(__has_trivial_copy(ConstIntArAr))];
- int t09[T(__has_trivial_copy(HasDest))];
- int t10[T(__has_trivial_copy(HasPriv))];
- int t11[T(__has_trivial_copy(HasCons))];
- int t12[T(__has_trivial_copy(HasRef))];
- int t13[F(__has_trivial_copy(HasCopy))];
- int t14[T(__has_trivial_copy(IntRef))];
- int t15[T(__has_trivial_copy(HasCopyAssign))];
- int t16[T(__has_trivial_copy(const Int))];
- int t17[F(__has_trivial_copy(NonPODAr))];
- int t18[F(__has_trivial_copy(VirtAr))];
- int t19[F(__has_trivial_copy(void))];
- int t20[F(__has_trivial_copy(cvoid))];
- int t21[F(__has_trivial_copy(HasTemplateCons))];
+ { int arr[T(__has_trivial_copy(Int))]; }
+ { int arr[T(__has_trivial_copy(IntAr))]; }
+ { int arr[T(__has_trivial_copy(Union))]; }
+ { int arr[T(__has_trivial_copy(UnionAr))]; }
+ { int arr[T(__has_trivial_copy(POD))]; }
+ { int arr[T(__has_trivial_copy(Derives))]; }
+ { int arr[T(__has_trivial_copy(ConstIntAr))]; }
+ { int arr[T(__has_trivial_copy(ConstIntArAr))]; }
+ { int arr[T(__has_trivial_copy(HasDest))]; }
+ { int arr[T(__has_trivial_copy(HasPriv))]; }
+ { int arr[T(__has_trivial_copy(HasCons))]; }
+ { int arr[T(__has_trivial_copy(HasRef))]; }
+ { int arr[T(__has_trivial_copy(HasMove))]; }
+ { int arr[T(__has_trivial_copy(IntRef))]; }
+ { int arr[T(__has_trivial_copy(HasCopyAssign))]; }
+ { int arr[T(__has_trivial_copy(HasMoveAssign))]; }
+ { int arr[T(__has_trivial_copy(const Int))]; }
+
+ { int arr[F(__has_trivial_copy(HasCopy))]; }
+ { int arr[F(__has_trivial_copy(HasTemplateCons))]; }
+ { int arr[F(__has_trivial_copy(DerivesAr))]; }
+ { int arr[F(__has_trivial_copy(VirtAr))]; }
+ { int arr[F(__has_trivial_copy(void))]; }
+ { int arr[F(__has_trivial_copy(cvoid))]; }
}
void has_trivial_copy_assignment() {
- int t01[T(__has_trivial_assign(Int))];
- int t02[T(__has_trivial_assign(IntAr))];
- int t03[T(__has_trivial_assign(Union))];
- int t04[T(__has_trivial_assign(UnionAr))];
- int t05[T(__has_trivial_assign(POD))];
- int t06[T(__has_trivial_assign(Derives))];
- int t07[F(__has_trivial_assign(ConstIntAr))];
- int t08[F(__has_trivial_assign(ConstIntArAr))];
- int t09[T(__has_trivial_assign(HasDest))];
- int t10[T(__has_trivial_assign(HasPriv))];
- int t11[T(__has_trivial_assign(HasCons))];
- int t12[T(__has_trivial_assign(HasRef))];
- int t13[T(__has_trivial_assign(HasCopy))];
- int t14[F(__has_trivial_assign(IntRef))];
- int t15[F(__has_trivial_assign(HasCopyAssign))];
- int t16[F(__has_trivial_assign(const Int))];
- int t17[F(__has_trivial_assign(NonPODAr))];
- int t18[F(__has_trivial_assign(VirtAr))];
- int t19[F(__has_trivial_assign(void))];
- int t20[F(__has_trivial_assign(cvoid))];
+ { int arr[T(__has_trivial_assign(Int))]; }
+ { int arr[T(__has_trivial_assign(IntAr))]; }
+ { int arr[T(__has_trivial_assign(Union))]; }
+ { int arr[T(__has_trivial_assign(UnionAr))]; }
+ { int arr[T(__has_trivial_assign(POD))]; }
+ { int arr[T(__has_trivial_assign(Derives))]; }
+ { int arr[T(__has_trivial_assign(HasDest))]; }
+ { int arr[T(__has_trivial_assign(HasPriv))]; }
+ { int arr[T(__has_trivial_assign(HasCons))]; }
+ { int arr[T(__has_trivial_assign(HasRef))]; }
+ { int arr[T(__has_trivial_assign(HasCopy))]; }
+ { int arr[T(__has_trivial_assign(HasMove))]; }
+ { int arr[T(__has_trivial_assign(HasMoveAssign))]; }
+
+ { int arr[F(__has_trivial_assign(IntRef))]; }
+ { int arr[F(__has_trivial_assign(HasCopyAssign))]; }
+ { int arr[F(__has_trivial_assign(const Int))]; }
+ { int arr[F(__has_trivial_assign(ConstIntAr))]; }
+ { int arr[F(__has_trivial_assign(ConstIntArAr))]; }
+ { int arr[F(__has_trivial_assign(DerivesAr))]; }
+ { int arr[F(__has_trivial_assign(VirtAr))]; }
+ { int arr[F(__has_trivial_assign(void))]; }
+ { int arr[F(__has_trivial_assign(cvoid))]; }
}
void has_trivial_destructor() {
- int t01[T(__has_trivial_destructor(Int))];
- int t02[T(__has_trivial_destructor(IntAr))];
- int t03[T(__has_trivial_destructor(Union))];
- int t04[T(__has_trivial_destructor(UnionAr))];
- int t05[T(__has_trivial_destructor(POD))];
- int t06[T(__has_trivial_destructor(Derives))];
- int t07[T(__has_trivial_destructor(ConstIntAr))];
- int t08[T(__has_trivial_destructor(ConstIntArAr))];
- int t09[F(__has_trivial_destructor(HasDest))];
- int t10[T(__has_trivial_destructor(HasPriv))];
- int t11[T(__has_trivial_destructor(HasCons))];
- int t12[T(__has_trivial_destructor(HasRef))];
- int t13[T(__has_trivial_destructor(HasCopy))];
- int t14[T(__has_trivial_destructor(IntRef))];
- int t15[T(__has_trivial_destructor(HasCopyAssign))];
- int t16[T(__has_trivial_destructor(const Int))];
- int t17[T(__has_trivial_destructor(NonPODAr))];
- int t18[T(__has_trivial_destructor(VirtAr))];
- int t19[F(__has_trivial_destructor(void))];
- int t20[F(__has_trivial_destructor(cvoid))];
+ { int arr[T(__has_trivial_destructor(Int))]; }
+ { int arr[T(__has_trivial_destructor(IntAr))]; }
+ { int arr[T(__has_trivial_destructor(Union))]; }
+ { int arr[T(__has_trivial_destructor(UnionAr))]; }
+ { int arr[T(__has_trivial_destructor(POD))]; }
+ { int arr[T(__has_trivial_destructor(Derives))]; }
+ { int arr[T(__has_trivial_destructor(ConstIntAr))]; }
+ { int arr[T(__has_trivial_destructor(ConstIntArAr))]; }
+ { int arr[T(__has_trivial_destructor(HasPriv))]; }
+ { int arr[T(__has_trivial_destructor(HasCons))]; }
+ { int arr[T(__has_trivial_destructor(HasRef))]; }
+ { int arr[T(__has_trivial_destructor(HasCopy))]; }
+ { int arr[T(__has_trivial_destructor(HasMove))]; }
+ { int arr[T(__has_trivial_destructor(IntRef))]; }
+ { int arr[T(__has_trivial_destructor(HasCopyAssign))]; }
+ { int arr[T(__has_trivial_destructor(HasMoveAssign))]; }
+ { int arr[T(__has_trivial_destructor(const Int))]; }
+ { int arr[T(__has_trivial_destructor(DerivesAr))]; }
+ { int arr[T(__has_trivial_destructor(VirtAr))]; }
+
+ { int arr[F(__has_trivial_destructor(HasDest))]; }
+ { int arr[F(__has_trivial_destructor(void))]; }
+ { int arr[F(__has_trivial_destructor(cvoid))]; }
}
struct A { ~A() {} };
template<typename> struct B : A { };
void f() {
- int t01[F(__has_trivial_destructor(A))];
- int t02[F(__has_trivial_destructor(B<int>))];
+ { int arr[F(__has_trivial_destructor(A))]; }
+ { int arr[F(__has_trivial_destructor(B<int>))]; }
}
void has_nothrow_assign() {
- int t01[T(__has_nothrow_assign(Int))];
- int t02[T(__has_nothrow_assign(IntAr))];
- int t03[T(__has_nothrow_assign(Union))];
- int t04[T(__has_nothrow_assign(UnionAr))];
- int t05[T(__has_nothrow_assign(POD))];
- int t06[T(__has_nothrow_assign(Derives))];
- int t07[F(__has_nothrow_assign(ConstIntAr))];
- int t08[F(__has_nothrow_assign(ConstIntArAr))];
- int t09[T(__has_nothrow_assign(HasDest))];
- int t10[T(__has_nothrow_assign(HasPriv))];
- int t11[T(__has_nothrow_assign(HasCons))];
- int t12[T(__has_nothrow_assign(HasRef))];
- int t13[T(__has_nothrow_assign(HasCopy))];
- int t14[F(__has_nothrow_assign(IntRef))];
- int t15[F(__has_nothrow_assign(HasCopyAssign))];
- int t16[F(__has_nothrow_assign(const Int))];
- int t17[F(__has_nothrow_assign(NonPODAr))];
- int t18[F(__has_nothrow_assign(VirtAr))];
- int t19[T(__has_nothrow_assign(HasNoThrowCopyAssign))];
- int t20[F(__has_nothrow_assign(HasMultipleCopyAssign))];
- int t21[T(__has_nothrow_assign(HasMultipleNoThrowCopyAssign))];
- int t22[F(__has_nothrow_assign(void))];
- int t23[F(__has_nothrow_assign(cvoid))];
- int t24[T(__has_nothrow_assign(HasVirtDest))];
+ { int arr[T(__has_nothrow_assign(Int))]; }
+ { int arr[T(__has_nothrow_assign(IntAr))]; }
+ { int arr[T(__has_nothrow_assign(Union))]; }
+ { int arr[T(__has_nothrow_assign(UnionAr))]; }
+ { int arr[T(__has_nothrow_assign(POD))]; }
+ { int arr[T(__has_nothrow_assign(Derives))]; }
+ { int arr[T(__has_nothrow_assign(HasDest))]; }
+ { int arr[T(__has_nothrow_assign(HasPriv))]; }
+ { int arr[T(__has_nothrow_assign(HasCons))]; }
+ { int arr[T(__has_nothrow_assign(HasRef))]; }
+ { int arr[T(__has_nothrow_assign(HasCopy))]; }
+ { int arr[T(__has_nothrow_assign(HasMove))]; }
+ { int arr[T(__has_nothrow_assign(HasMoveAssign))]; }
+ { int arr[T(__has_nothrow_assign(HasNoThrowCopyAssign))]; }
+ { int arr[T(__has_nothrow_assign(HasMultipleNoThrowCopyAssign))]; }
+ { int arr[T(__has_nothrow_assign(HasVirtDest))]; }
+
+ { int arr[F(__has_nothrow_assign(IntRef))]; }
+ { int arr[F(__has_nothrow_assign(HasCopyAssign))]; }
+ { int arr[F(__has_nothrow_assign(HasMultipleCopyAssign))]; }
+ { int arr[F(__has_nothrow_assign(const Int))]; }
+ { int arr[F(__has_nothrow_assign(ConstIntAr))]; }
+ { int arr[F(__has_nothrow_assign(ConstIntArAr))]; }
+ { int arr[F(__has_nothrow_assign(DerivesAr))]; }
+ { int arr[F(__has_nothrow_assign(VirtAr))]; }
+ { int arr[F(__has_nothrow_assign(void))]; }
+ { int arr[F(__has_nothrow_assign(cvoid))]; }
}
void has_nothrow_copy() {
- int t01[T(__has_nothrow_copy(Int))];
- int t02[T(__has_nothrow_copy(IntAr))];
- int t03[T(__has_nothrow_copy(Union))];
- int t04[T(__has_nothrow_copy(UnionAr))];
- int t05[T(__has_nothrow_copy(POD))];
- int t06[T(__has_nothrow_copy(Derives))];
- int t07[T(__has_nothrow_copy(ConstIntAr))];
- int t08[T(__has_nothrow_copy(ConstIntArAr))];
- int t09[T(__has_nothrow_copy(HasDest))];
- int t10[T(__has_nothrow_copy(HasPriv))];
- int t11[T(__has_nothrow_copy(HasCons))];
- int t12[T(__has_nothrow_copy(HasRef))];
- int t13[F(__has_nothrow_copy(HasCopy))];
- int t14[T(__has_nothrow_copy(IntRef))];
- int t15[T(__has_nothrow_copy(HasCopyAssign))];
- int t16[T(__has_nothrow_copy(const Int))];
- int t17[F(__has_nothrow_copy(NonPODAr))];
- int t18[F(__has_nothrow_copy(VirtAr))];
-
- int t19[T(__has_nothrow_copy(HasNoThrowCopy))];
- int t20[F(__has_nothrow_copy(HasMultipleCopy))];
- int t21[T(__has_nothrow_copy(HasMultipleNoThrowCopy))];
- int t22[F(__has_nothrow_copy(void))];
- int t23[F(__has_nothrow_copy(cvoid))];
- int t24[T(__has_nothrow_copy(HasVirtDest))];
- int t25[T(__has_nothrow_copy(HasTemplateCons))];
+ { int arr[T(__has_nothrow_copy(Int))]; }
+ { int arr[T(__has_nothrow_copy(IntAr))]; }
+ { int arr[T(__has_nothrow_copy(Union))]; }
+ { int arr[T(__has_nothrow_copy(UnionAr))]; }
+ { int arr[T(__has_nothrow_copy(POD))]; }
+ { int arr[T(__has_nothrow_copy(const Int))]; }
+ { int arr[T(__has_nothrow_copy(ConstIntAr))]; }
+ { int arr[T(__has_nothrow_copy(ConstIntArAr))]; }
+ { int arr[T(__has_nothrow_copy(Derives))]; }
+ { int arr[T(__has_nothrow_copy(IntRef))]; }
+ { int arr[T(__has_nothrow_copy(HasDest))]; }
+ { int arr[T(__has_nothrow_copy(HasPriv))]; }
+ { int arr[T(__has_nothrow_copy(HasCons))]; }
+ { int arr[T(__has_nothrow_copy(HasRef))]; }
+ { int arr[T(__has_nothrow_copy(HasMove))]; }
+ { int arr[T(__has_nothrow_copy(HasCopyAssign))]; }
+ { int arr[T(__has_nothrow_copy(HasMoveAssign))]; }
+ { int arr[T(__has_nothrow_copy(HasNoThrowCopy))]; }
+ { int arr[T(__has_nothrow_copy(HasMultipleNoThrowCopy))]; }
+ { int arr[T(__has_nothrow_copy(HasVirtDest))]; }
+ { int arr[T(__has_nothrow_copy(HasTemplateCons))]; }
+
+ { int arr[F(__has_nothrow_copy(HasCopy))]; }
+ { int arr[F(__has_nothrow_copy(HasMultipleCopy))]; }
+ { int arr[F(__has_nothrow_copy(DerivesAr))]; }
+ { int arr[F(__has_nothrow_copy(VirtAr))]; }
+ { int arr[F(__has_nothrow_copy(void))]; }
+ { int arr[F(__has_nothrow_copy(cvoid))]; }
}
void has_nothrow_constructor() {
- int t01[T(__has_nothrow_constructor(Int))];
- int t02[T(__has_nothrow_constructor(IntAr))];
- int t03[T(__has_nothrow_constructor(Union))];
- int t04[T(__has_nothrow_constructor(UnionAr))];
- int t05[T(__has_nothrow_constructor(POD))];
- int t06[T(__has_nothrow_constructor(Derives))];
- int t07[T(__has_nothrow_constructor(ConstIntAr))];
- int t08[T(__has_nothrow_constructor(ConstIntArAr))];
- int t09[T(__has_nothrow_constructor(HasDest))];
- int t10[T(__has_nothrow_constructor(HasPriv))];
- int t11[F(__has_nothrow_constructor(HasCons))];
- int t12[F(__has_nothrow_constructor(HasRef))];
- int t13[F(__has_nothrow_constructor(HasCopy))];
- int t14[F(__has_nothrow_constructor(IntRef))];
- int t15[T(__has_nothrow_constructor(HasCopyAssign))];
- int t16[T(__has_nothrow_constructor(const Int))];
- int t17[T(__has_nothrow_constructor(NonPODAr))];
- // int t18[T(__has_nothrow_constructor(VirtAr))]; // not implemented
-
- int t19[T(__has_nothrow_constructor(HasNoThrowConstructor))];
- int t20[F(__has_nothrow_constructor(HasNoThrowConstructorWithArgs))];
- int t21[F(__has_nothrow_constructor(void))];
- int t22[F(__has_nothrow_constructor(cvoid))];
- int t23[T(__has_nothrow_constructor(HasVirtDest))];
- int t24[F(__has_nothrow_constructor(HasTemplateCons))];
+ { int arr[T(__has_nothrow_constructor(Int))]; }
+ { int arr[T(__has_nothrow_constructor(IntAr))]; }
+ { int arr[T(__has_nothrow_constructor(Union))]; }
+ { int arr[T(__has_nothrow_constructor(UnionAr))]; }
+ { int arr[T(__has_nothrow_constructor(POD))]; }
+ { int arr[T(__has_nothrow_constructor(Derives))]; }
+ { int arr[T(__has_nothrow_constructor(DerivesAr))]; }
+ { int arr[T(__has_nothrow_constructor(ConstIntAr))]; }
+ { int arr[T(__has_nothrow_constructor(ConstIntArAr))]; }
+ { int arr[T(__has_nothrow_constructor(HasDest))]; }
+ { int arr[T(__has_nothrow_constructor(HasPriv))]; }
+ { int arr[T(__has_nothrow_constructor(HasCopyAssign))]; }
+ { int arr[T(__has_nothrow_constructor(const Int))]; }
+ { int arr[T(__has_nothrow_constructor(HasNoThrowConstructor))]; }
+ { int arr[T(__has_nothrow_constructor(HasVirtDest))]; }
+ // { int arr[T(__has_nothrow_constructor(VirtAr))]; } // not implemented
+
+ { int arr[F(__has_nothrow_constructor(HasCons))]; }
+ { int arr[F(__has_nothrow_constructor(HasRef))]; }
+ { int arr[F(__has_nothrow_constructor(HasCopy))]; }
+ { int arr[F(__has_nothrow_constructor(HasMove))]; }
+ { int arr[F(__has_nothrow_constructor(HasNoThrowConstructorWithArgs))]; }
+ { int arr[F(__has_nothrow_constructor(IntRef))]; }
+ { int arr[F(__has_nothrow_constructor(void))]; }
+ { int arr[F(__has_nothrow_constructor(cvoid))]; }
+ { int arr[F(__has_nothrow_constructor(HasTemplateCons))]; }
}
void has_virtual_destructor() {
- int t01[F(__has_virtual_destructor(Int))];
- int t02[F(__has_virtual_destructor(IntAr))];
- int t03[F(__has_virtual_destructor(Union))];
- int t04[F(__has_virtual_destructor(UnionAr))];
- int t05[F(__has_virtual_destructor(POD))];
- int t06[F(__has_virtual_destructor(Derives))];
- int t07[F(__has_virtual_destructor(ConstIntAr))];
- int t08[F(__has_virtual_destructor(ConstIntArAr))];
- int t09[F(__has_virtual_destructor(HasDest))];
- int t10[F(__has_virtual_destructor(HasPriv))];
- int t11[F(__has_virtual_destructor(HasCons))];
- int t12[F(__has_virtual_destructor(HasRef))];
- int t13[F(__has_virtual_destructor(HasCopy))];
- int t14[F(__has_virtual_destructor(IntRef))];
- int t15[F(__has_virtual_destructor(HasCopyAssign))];
- int t16[F(__has_virtual_destructor(const Int))];
- int t17[F(__has_virtual_destructor(NonPODAr))];
- int t18[F(__has_virtual_destructor(VirtAr))];
-
- int t19[T(__has_virtual_destructor(HasVirtDest))];
- int t20[T(__has_virtual_destructor(DerivedVirtDest))];
- int t21[F(__has_virtual_destructor(VirtDestAr))];
- int t22[F(__has_virtual_destructor(void))];
- int t23[F(__has_virtual_destructor(cvoid))];
+ { int arr[F(__has_virtual_destructor(Int))]; }
+ { int arr[F(__has_virtual_destructor(IntAr))]; }
+ { int arr[F(__has_virtual_destructor(Union))]; }
+ { int arr[F(__has_virtual_destructor(UnionAr))]; }
+ { int arr[F(__has_virtual_destructor(POD))]; }
+ { int arr[F(__has_virtual_destructor(Derives))]; }
+ { int arr[F(__has_virtual_destructor(DerivesAr))]; }
+ { int arr[F(__has_virtual_destructor(const Int))]; }
+ { int arr[F(__has_virtual_destructor(ConstIntAr))]; }
+ { int arr[F(__has_virtual_destructor(ConstIntArAr))]; }
+ { int arr[F(__has_virtual_destructor(HasDest))]; }
+ { int arr[F(__has_virtual_destructor(HasPriv))]; }
+ { int arr[F(__has_virtual_destructor(HasCons))]; }
+ { int arr[F(__has_virtual_destructor(HasRef))]; }
+ { int arr[F(__has_virtual_destructor(HasCopy))]; }
+ { int arr[F(__has_virtual_destructor(HasMove))]; }
+ { int arr[F(__has_virtual_destructor(HasCopyAssign))]; }
+ { int arr[F(__has_virtual_destructor(HasMoveAssign))]; }
+ { int arr[F(__has_virtual_destructor(IntRef))]; }
+ { int arr[F(__has_virtual_destructor(VirtAr))]; }
+
+ { int arr[T(__has_virtual_destructor(HasVirtDest))]; }
+ { int arr[T(__has_virtual_destructor(DerivedVirtDest))]; }
+ { int arr[F(__has_virtual_destructor(VirtDestAr))]; }
+ { int arr[F(__has_virtual_destructor(void))]; }
+ { int arr[F(__has_virtual_destructor(cvoid))]; }
}
@@ -474,29 +1296,29 @@ template <class T> class NonderivedTemp {};
template <class T> class UndefinedTemp; // expected-note {{declared here}}
void is_base_of() {
- int t01[T(__is_base_of(Base, Derived))];
- int t02[T(__is_base_of(const Base, Derived))];
- int t03[F(__is_base_of(Derived, Base))];
- int t04[F(__is_base_of(Derived, int))];
- int t05[T(__is_base_of(Base, Base))];
- int t06[T(__is_base_of(Base, Derived3))];
- int t07[T(__is_base_of(Derived, Derived3))];
- int t08[T(__is_base_of(Derived2b, Derived3))];
- int t09[T(__is_base_of(Derived2a, Derived3))];
- int t10[T(__is_base_of(BaseA<int>, DerivedB<int>))];
- int t11[F(__is_base_of(DerivedB<int>, BaseA<int>))];
- int t12[T(__is_base_of(Base, CrazyDerived<Base>))];
- int t13[F(__is_base_of(Union, Union))];
- int t14[T(__is_base_of(Empty, Empty))];
- int t15[T(__is_base_of(class_forward, class_forward))];
- int t16[F(__is_base_of(Empty, class_forward))]; // expected-error {{incomplete type 'class_forward' used in type trait expression}}
- int t17[F(__is_base_of(Base&, Derived&))];
+ { int arr[T(__is_base_of(Base, Derived))]; }
+ { int arr[T(__is_base_of(const Base, Derived))]; }
+ { int arr[F(__is_base_of(Derived, Base))]; }
+ { int arr[F(__is_base_of(Derived, int))]; }
+ { int arr[T(__is_base_of(Base, Base))]; }
+ { int arr[T(__is_base_of(Base, Derived3))]; }
+ { int arr[T(__is_base_of(Derived, Derived3))]; }
+ { int arr[T(__is_base_of(Derived2b, Derived3))]; }
+ { int arr[T(__is_base_of(Derived2a, Derived3))]; }
+ { int arr[T(__is_base_of(BaseA<int>, DerivedB<int>))]; }
+ { int arr[F(__is_base_of(DerivedB<int>, BaseA<int>))]; }
+ { int arr[T(__is_base_of(Base, CrazyDerived<Base>))]; }
+ { int arr[F(__is_base_of(Union, Union))]; }
+ { int arr[T(__is_base_of(Empty, Empty))]; }
+ { int arr[T(__is_base_of(class_forward, class_forward))]; }
+ { int arr[F(__is_base_of(Empty, class_forward))]; } // expected-error {{incomplete type 'class_forward' used in type trait expression}}
+ { int arr[F(__is_base_of(Base&, Derived&))]; }
int t18[F(__is_base_of(Base[10], Derived[10]))];
- int t19[F(__is_base_of(int, int))];
- int t20[F(__is_base_of(long, int))];
- int t21[T(__is_base_of(Base, DerivedTemp<int>))];
- int t22[F(__is_base_of(Base, NonderivedTemp<int>))];
- int t23[F(__is_base_of(Base, UndefinedTemp<int>))]; // expected-error {{implicit instantiation of undefined template 'UndefinedTemp<int>'}}
+ { int arr[F(__is_base_of(int, int))]; }
+ { int arr[F(__is_base_of(long, int))]; }
+ { int arr[T(__is_base_of(Base, DerivedTemp<int>))]; }
+ { int arr[F(__is_base_of(Base, NonderivedTemp<int>))]; }
+ { int arr[F(__is_base_of(Base, UndefinedTemp<int>))]; } // expected-error {{implicit instantiation of undefined template 'UndefinedTemp<int>'}}
isBaseOfT<Base, Derived>();
isBaseOfF<Derived, Base>();
@@ -508,6 +1330,64 @@ void is_base_of() {
isBaseOfF<DerivedB<int>, BaseA<int> >();
}
+#if 0
+template<class T, class U>
+class TemplateClass {};
+
+template<class T>
+using TemplateAlias = TemplateClass<T, int>;
+#endif
+
+typedef class Base BaseTypedef;
+
+void is_same()
+{
+ int t01[T(__is_same(Base, Base))];
+ int t02[T(__is_same(Base, BaseTypedef))];
+#if 0
+ int t03[T(__is_same(TemplateClass<int, int>, TemplateAlias<int>))];
+#endif
+
+ int t10[F(__is_same(Base, const Base))];
+ int t11[F(__is_same(Base, Base&))];
+ int t12[F(__is_same(Base, Derived))];
+}
+
+struct IntWrapper
+{
+ int value;
+ IntWrapper(int _value) : value(_value) {}
+ operator int() const {
+ return value;
+ }
+};
+
+struct FloatWrapper
+{
+ float value;
+ FloatWrapper(float _value) : value(_value) {}
+ FloatWrapper(const IntWrapper& obj)
+ : value(static_cast<float>(obj.value)) {}
+ operator float() const {
+ return value;
+ }
+ operator IntWrapper() const {
+ return IntWrapper(static_cast<int>(value));
+ }
+};
+
+void is_convertible()
+{
+ int t01[T(__is_convertible(IntWrapper, IntWrapper))];
+ int t02[T(__is_convertible(IntWrapper, const IntWrapper))];
+ int t03[T(__is_convertible(IntWrapper, int))];
+ int t04[T(__is_convertible(int, IntWrapper))];
+ int t05[T(__is_convertible(IntWrapper, FloatWrapper))];
+ int t06[T(__is_convertible(FloatWrapper, IntWrapper))];
+ int t07[T(__is_convertible(FloatWrapper, float))];
+ int t08[T(__is_convertible(float, FloatWrapper))];
+}
+
struct FromInt { FromInt(int); };
struct ToInt { operator int(); };
typedef void Function();
@@ -524,27 +1404,83 @@ struct X0 {
};
void is_convertible_to() {
- int t01[T(__is_convertible_to(Int, Int))];
- int t02[F(__is_convertible_to(Int, IntAr))];
- int t03[F(__is_convertible_to(IntAr, IntAr))];
- int t04[T(__is_convertible_to(void, void))];
- int t05[T(__is_convertible_to(cvoid, void))];
- int t06[T(__is_convertible_to(void, cvoid))];
- int t07[T(__is_convertible_to(cvoid, cvoid))];
- int t08[T(__is_convertible_to(int, FromInt))];
- int t09[T(__is_convertible_to(long, FromInt))];
- int t10[T(__is_convertible_to(double, FromInt))];
- int t11[T(__is_convertible_to(const int, FromInt))];
- int t12[T(__is_convertible_to(const int&, FromInt))];
- int t13[T(__is_convertible_to(ToInt, int))];
- int t14[T(__is_convertible_to(ToInt, const int&))];
- int t15[T(__is_convertible_to(ToInt, long))];
- int t16[F(__is_convertible_to(ToInt, int&))];
- int t17[F(__is_convertible_to(ToInt, FromInt))];
- int t18[T(__is_convertible_to(IntAr&, IntAr&))];
- int t19[T(__is_convertible_to(IntAr&, const IntAr&))];
- int t20[F(__is_convertible_to(const IntAr&, IntAr&))];
- int t21[F(__is_convertible_to(Function, Function))];
- int t22[F(__is_convertible_to(PrivateCopy, PrivateCopy))];
- int t23[T(__is_convertible_to(X0<int>, X0<float>))];
+ { int arr[T(__is_convertible_to(Int, Int))]; }
+ { int arr[F(__is_convertible_to(Int, IntAr))]; }
+ { int arr[F(__is_convertible_to(IntAr, IntAr))]; }
+ { int arr[T(__is_convertible_to(void, void))]; }
+ { int arr[T(__is_convertible_to(cvoid, void))]; }
+ { int arr[T(__is_convertible_to(void, cvoid))]; }
+ { int arr[T(__is_convertible_to(cvoid, cvoid))]; }
+ { int arr[T(__is_convertible_to(int, FromInt))]; }
+ { int arr[T(__is_convertible_to(long, FromInt))]; }
+ { int arr[T(__is_convertible_to(double, FromInt))]; }
+ { int arr[T(__is_convertible_to(const int, FromInt))]; }
+ { int arr[T(__is_convertible_to(const int&, FromInt))]; }
+ { int arr[T(__is_convertible_to(ToInt, int))]; }
+ { int arr[T(__is_convertible_to(ToInt, const int&))]; }
+ { int arr[T(__is_convertible_to(ToInt, long))]; }
+ { int arr[F(__is_convertible_to(ToInt, int&))]; }
+ { int arr[F(__is_convertible_to(ToInt, FromInt))]; }
+ { int arr[T(__is_convertible_to(IntAr&, IntAr&))]; }
+ { int arr[T(__is_convertible_to(IntAr&, const IntAr&))]; }
+ { int arr[F(__is_convertible_to(const IntAr&, IntAr&))]; }
+ { int arr[F(__is_convertible_to(Function, Function))]; }
+ { int arr[F(__is_convertible_to(PrivateCopy, PrivateCopy))]; }
+ { int arr[T(__is_convertible_to(X0<int>, X0<float>))]; }
+}
+
+void is_trivial()
+{
+ { int arr[T(__is_trivial(int))]; }
+ { int arr[T(__is_trivial(Enum))]; }
+ { int arr[T(__is_trivial(POD))]; }
+ { int arr[T(__is_trivial(Int))]; }
+ { int arr[T(__is_trivial(IntAr))]; }
+ { int arr[T(__is_trivial(IntArNB))]; }
+ { int arr[T(__is_trivial(Statics))]; }
+ { int arr[T(__is_trivial(Empty))]; }
+ { int arr[T(__is_trivial(EmptyUnion))]; }
+ { int arr[T(__is_trivial(Union))]; }
+ { int arr[T(__is_trivial(Derives))]; }
+ { int arr[T(__is_trivial(DerivesAr))]; }
+ { int arr[T(__is_trivial(DerivesArNB))]; }
+ { int arr[T(__is_trivial(DerivesEmpty))]; }
+ { int arr[T(__is_trivial(HasFunc))]; }
+ { int arr[T(__is_trivial(HasOp))]; }
+ { int arr[T(__is_trivial(HasConv))]; }
+ { int arr[T(__is_trivial(HasAssign))]; }
+ { int arr[T(__is_trivial(HasAnonymousUnion))]; }
+ { int arr[T(__is_trivial(HasPriv))]; }
+ { int arr[T(__is_trivial(HasProt))]; }
+ { int arr[T(__is_trivial(DerivesHasPriv))]; }
+ { int arr[T(__is_trivial(DerivesHasProt))]; }
+ { int arr[T(__is_trivial(Vector))]; }
+ { int arr[T(__is_trivial(VectorExt))]; }
+
+ { int arr[F(__is_trivial(HasCons))]; }
+ { int arr[F(__is_trivial(HasCopyAssign))]; }
+ { int arr[F(__is_trivial(HasMoveAssign))]; }
+ { int arr[F(__is_trivial(HasDest))]; }
+ { int arr[F(__is_trivial(HasRef))]; }
+ { int arr[F(__is_trivial(HasNonPOD))]; }
+ { int arr[F(__is_trivial(HasVirt))]; }
+ { int arr[F(__is_trivial(DerivesHasCons))]; }
+ { int arr[F(__is_trivial(DerivesHasCopyAssign))]; }
+ { int arr[F(__is_trivial(DerivesHasMoveAssign))]; }
+ { int arr[F(__is_trivial(DerivesHasDest))]; }
+ { int arr[F(__is_trivial(DerivesHasRef))]; }
+ { int arr[F(__is_trivial(DerivesHasVirt))]; }
+ { int arr[F(__is_trivial(void))]; }
+ { int arr[F(__is_trivial(cvoid))]; }
+}
+
+void array_rank() {
+ int t01[T(__array_rank(IntAr) == 1)];
+ int t02[T(__array_rank(ConstIntArAr) == 2)];
+}
+
+void array_extent() {
+ int t01[T(__array_extent(IntAr, 0) == 10)];
+ int t02[T(__array_extent(ConstIntArAr, 0) == 4)];
+ int t03[T(__array_extent(ConstIntArAr, 1) == 10)];
}
diff --git a/test/SemaCXX/uninit-variables-conditional.cpp b/test/SemaCXX/uninit-variables-conditional.cpp
new file mode 100644
index 0000000..3324215
--- /dev/null
+++ b/test/SemaCXX/uninit-variables-conditional.cpp
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -fsyntax-only -Wconditional-uninitialized -fsyntax-only %s -verify
+
+class Foo {
+public:
+ Foo();
+ ~Foo();
+ operator bool();
+};
+
+int bar();
+int baz();
+int init(double *);
+
+// This case flags a false positive under -Wconditional-uninitialized because
+// the destructor in Foo fouls about the minor bit of path-sensitivity in
+// -Wuninitialized.
+double test() {
+ double x; // expected-note {{variable 'x' is declared here}} expected-note{{add initialization to silence this warning}}
+ if (bar() || baz() || Foo() || init(&x))
+ return 1.0;
+
+ return x; // expected-warning {{variable 'x' may be uninitialized when used here}}
+}
diff --git a/test/SemaCXX/uninit-variables.cpp b/test/SemaCXX/uninit-variables.cpp
index 2bc7fb3..a0180e3 100644
--- a/test/SemaCXX/uninit-variables.cpp
+++ b/test/SemaCXX/uninit-variables.cpp
@@ -1,4 +1,7 @@
-// RUN: %clang_cc1 -fsyntax-only -Wuninitialized-experimental -fsyntax-only %s -verify
+// RUN: %clang_cc1 -fsyntax-only -Wuninitialized -fsyntax-only -fcxx-exceptions %s -verify
+
+// Stub out types for 'typeid' to work.
+namespace std { class type_info {}; }
int test1_aux(int &x);
int test1() {
@@ -13,6 +16,20 @@ int test2_aux() {
return x; // no-warning
}
+// Don't warn on unevaluated contexts.
+void unevaluated_tests() {
+ int x;
+ (void)sizeof(x);
+ (void)typeid(x);
+}
+
+// Warn for glvalue arguments to typeid whose type is polymorphic.
+struct A { virtual ~A() {} };
+void polymorphic_test() {
+ A *a; // expected-note{{declared here}} expected-note{{add initialization}}
+ (void)typeid(*a); // expected-warning{{variable 'a' is uninitialized when used here }}
+}
+
// Handle cases where the CFG may constant fold some branches, thus
// mitigating the need for some path-sensitivity in the analysis.
unsigned test3_aux();
@@ -38,7 +55,7 @@ unsigned test3_c() {
if (flag && (x = test3_aux()) == 0) {
x = 1;
}
- return x; // expected-warning{{variable 'x' is possibly uninitialized when used here}}
+ return x; // expected-warning{{variable 'x' is uninitialized when used here}}
}
enum test4_A {
@@ -46,6 +63,49 @@ enum test4_A {
};
test4_A test4() {
test4_A a; // expected-note{{variable 'a' is declared here}}
- return a; // expected-warning{{variable 'a' is possibly uninitialized when used here}}
+ return a; // expected-warning{{variable 'a' is uninitialized when used here}}
}
+// This test previously crashed Sema.
+class Rdar9188004A {
+public:
+ virtual ~Rdar9188004A();
+};
+
+template< typename T > class Rdar9188004B : public Rdar9188004A {
+virtual double *foo(Rdar9188004B *next) const {
+ double *values = next->foo(0);
+ try {
+ }
+ catch(double e) {
+ values[0] = e;
+ }
+ return 0;
+ }
+};
+class Rdar9188004C : public Rdar9188004B<Rdar9188004A> {
+ virtual void bar(void) const;
+};
+void Rdar9188004C::bar(void) const {}
+
+// Don't warn about uninitialized variables in unreachable code.
+void PR9625() {
+ if (false) {
+ int x;
+ (void)static_cast<float>(x); // no-warning
+ }
+}
+
+// Don't warn about variables declared in "catch"
+void RDar9251392_bar(const char *msg);
+
+void RDar9251392() {
+ try {
+ throw "hi";
+ }
+ catch (const char* msg) {
+ RDar9251392_bar(msg); // no-warning
+ }
+}
+
+
diff --git a/test/SemaCXX/uninitialized.cpp b/test/SemaCXX/uninitialized.cpp
index 26202fb..0a3b5d9 100644
--- a/test/SemaCXX/uninitialized.cpp
+++ b/test/SemaCXX/uninitialized.cpp
@@ -1,14 +1,45 @@
// RUN: %clang_cc1 -fsyntax-only -Wall -Wuninitialized -verify %s
-// Previously this triggered a warning on the sizeof(fieldB), indicating
-// a use of an uninitialized value.
-class Rdar8610363_A {
- int fieldA;
-public:
- Rdar8610363_A(int a);
-};
-class Rdar8610363_B {
- Rdar8610363_A fieldB;
-public:
- Rdar8610363_B(int b) : fieldB(sizeof(fieldB)) {} // no-warning
+int foo(int x);
+int bar(int* x);
+int boo(int& x);
+int far(const int& x);
+
+// Test self-references within initializers which are guaranteed to be
+// uninitialized.
+int a = a; // no-warning: used to signal intended lack of initialization.
+int b = b + 1; // expected-warning {{variable 'b' is uninitialized when used within its own initialization}}
+int c = (c + c); // expected-warning 2 {{variable 'c' is uninitialized when used within its own initialization}}
+void test() {
+ int d = ({ d + d ;}); // expected-warning {{variable 'd' is uninitialized when used within its own initialization}}
+}
+int e = static_cast<long>(e) + 1; // expected-warning {{variable 'e' is uninitialized when used within its own initialization}}
+int f = foo(f); // expected-warning {{variable 'f' is uninitialized when used within its own initialization}}
+
+// Thes don't warn as they don't require the value.
+int g = sizeof(g);
+void* ptr = &ptr;
+int h = bar(&h);
+int i = boo(i);
+int j = far(j);
+int k = __alignof__(k);
+
+// Also test similar constructs in a field's initializer.
+struct S {
+ int x;
+ void *ptr;
+
+ S(bool (*)[1]) : x(x) {} // expected-warning {{field is uninitialized when used here}}
+ S(bool (*)[2]) : x(x + 1) {} // expected-warning {{field is uninitialized when used here}}
+ S(bool (*)[3]) : x(x + x) {} // expected-warning {{field is uninitialized when used here}}
+ S(bool (*)[4]) : x(static_cast<long>(x) + 1) {} // expected-warning {{field is uninitialized when used here}}
+ S(bool (*)[5]) : x(foo(x)) {} // FIXME: This should warn!
+
+ // These don't actually require the value of x and so shouldn't warn.
+ S(char (*)[1]) : x(sizeof(x)) {} // rdar://8610363
+ S(char (*)[2]) : ptr(&ptr) {}
+ S(char (*)[3]) : x(__alignof__(x)) {}
+ S(char (*)[4]) : x(bar(&x)) {}
+ S(char (*)[5]) : x(boo(x)) {}
+ S(char (*)[6]) : x(far(x)) {}
};
diff --git a/test/SemaCXX/unknown-anytype.cpp b/test/SemaCXX/unknown-anytype.cpp
new file mode 100644
index 0000000..b0a2981
--- /dev/null
+++ b/test/SemaCXX/unknown-anytype.cpp
@@ -0,0 +1,36 @@
+// RUN: %clang_cc1 -funknown-anytype -fsyntax-only -verify %s
+
+namespace test0 {
+ extern __unknown_anytype test0;
+ extern __unknown_anytype test1();
+ extern __unknown_anytype test2(int);
+}
+
+namespace test1 {
+ extern __unknown_anytype foo;
+ int test() {
+ // TODO: it would be great if the 'cannot initialize' errors
+ // turned into something more interesting. It's just a matter of
+ // making sure that these locations check for placeholder types
+ // properly.
+
+ int x = foo; // expected-error {{cannot initialize}}
+ int y = 0 + foo; // expected-error {{'foo' has unknown type}}
+ return foo; // expected-error {{cannot initialize}}
+ }
+}
+
+namespace test2 {
+ extern __unknown_anytype foo();
+ void test() {
+ foo(); // expected-error {{'foo' has unknown return type}}
+ }
+}
+
+namespace test3 {
+ extern __unknown_anytype foo;
+ void test() {
+ foo(); // expected-error {{call to unsupported expression with unknown type}}
+ ((void(void)) foo)(); // expected-error {{variable 'foo' with unknown type cannot be given a function type}}
+ }
+}
diff --git a/test/SemaCXX/unreachable-catch-clauses.cpp b/test/SemaCXX/unreachable-catch-clauses.cpp
index e8158d4..c75067f 100644
--- a/test/SemaCXX/unreachable-catch-clauses.cpp
+++ b/test/SemaCXX/unreachable-catch-clauses.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fexceptions -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -fsyntax-only -verify %s
class BaseEx {};
class Ex1: public BaseEx {};
diff --git a/test/SemaCXX/unreachable-code.cpp b/test/SemaCXX/unreachable-code.cpp
index 03d44ab..743290e 100644
--- a/test/SemaCXX/unreachable-code.cpp
+++ b/test/SemaCXX/unreachable-code.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fexceptions -fsyntax-only -Wunreachable-code -fblocks -verify %s
+// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -fsyntax-only -Wunreachable-code -fblocks -verify %s
int j;
void bar() { }
diff --git a/test/SemaCXX/unused-functions.cpp b/test/SemaCXX/unused-functions.cpp
index cefa9e1..f164bf2 100644
--- a/test/SemaCXX/unused-functions.cpp
+++ b/test/SemaCXX/unused-functions.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -Wunused -verify %s
+// RUN: %clang_cc1 -std=c++0x -fsyntax-only -Wunused -verify %s
static int foo(int x) { return x; }
@@ -6,3 +6,5 @@ template<typename T>
T get_from_foo(T y) { return foo(y); }
int g(int z) { return get_from_foo(z); }
+
+namespace { void f() = delete; }
diff --git a/test/SemaCXX/vtable-instantiation.cc b/test/SemaCXX/vtable-instantiation.cc
index 5a13d95..49949a7 100644
--- a/test/SemaCXX/vtable-instantiation.cc
+++ b/test/SemaCXX/vtable-instantiation.cc
@@ -18,3 +18,29 @@ void f() {
c2.c2(); // expected-note {{in instantiation of member function}}
}
+namespace PR9325 {
+ template<typename T>
+ class Target
+ {
+ public:
+ virtual T Value() const
+ {
+ return 1; // expected-error{{cannot initialize return object of type 'int *' with an rvalue of type 'int'}}
+ }
+ };
+
+ template<typename T>
+ struct Provider
+ {
+ static Target<T> Instance;
+ };
+
+ template<typename T>
+ Target<T> Provider<T>::Instance; // expected-note{{in instantiation of}}
+
+ void f()
+ {
+ Target<int*>* traits = &Provider<int*>::Instance;
+ }
+
+}
diff --git a/test/SemaCXX/warn-assignment-condition.cpp b/test/SemaCXX/warn-assignment-condition.cpp
index 27eedb9..c0ef35b 100644
--- a/test/SemaCXX/warn-assignment-condition.cpp
+++ b/test/SemaCXX/warn-assignment-condition.cpp
@@ -125,3 +125,16 @@ void test2() {
if ((test2 == fn)) {}
}
+namespace rdar9027658 {
+template <typename T>
+void f() {
+ if ((T::g == 3)) { } // expected-warning {{equality comparison with extraneous parentheses}} \
+ // expected-note {{use '=' to turn this equality comparison into an assignment}} \
+ // expected-note {{remove extraneous parentheses around the comparison to silence this warning}}
+}
+
+struct S { int g; };
+void test() {
+ f<S>(); // expected-note {{in instantiation}}
+}
+}
diff --git a/test/SemaCXX/warn-bool-conversion.cpp b/test/SemaCXX/warn-bool-conversion.cpp
new file mode 100644
index 0000000..f6fa9f2
--- /dev/null
+++ b/test/SemaCXX/warn-bool-conversion.cpp
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+int* j = false; // expected-warning{{ initialization of pointer of type 'int *' to NULL from a constant boolean expression}}
+
+void foo(int* i, int *j=(false)) // expected-warning{{ initialization of pointer of type 'int *' to NULL from a constant boolean expression}}
+{
+ foo(false); // expected-warning{{ initialization of pointer of type 'int *' to NULL from a constant boolean expression}}
+ foo((int*)false); // no-warning: explicit cast
+ foo(0); // no-warning: not a bool, even though its convertible to bool
+
+ foo(false == true); // expected-warning{{ initialization of pointer of type 'int *' to NULL from a constant boolean expression}}
+ foo((42 + 24) < 32); // expected-warning{{ initialization of pointer of type 'int *' to NULL from a constant boolean expression}}
+
+ const bool kFlag = false;
+ foo(kFlag); // expected-warning{{ initialization of pointer of type 'int *' to NULL from a constant boolean expression}}
+}
+
+char f(struct Undefined*);
+double f(...);
+
+// Ensure that when using false in metaprogramming machinery its conversion
+// isn't flagged.
+template <int N> struct S {};
+S<sizeof(f(false))> s;
diff --git a/test/SemaCXX/warn-deprecated-header.cpp b/test/SemaCXX/warn-deprecated-header.cpp
new file mode 100644
index 0000000..f6ac2cb
--- /dev/null
+++ b/test/SemaCXX/warn-deprecated-header.cpp
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -fsyntax-only -fdeprecated-macro -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Werror %s
+
+#ifdef __DEPRECATED
+#warning This file is deprecated. // expected-warning {{This file is deprecated.}}
+#endif
diff --git a/test/SemaCXX/warn-exit-time-destructors.cpp b/test/SemaCXX/warn-exit-time-destructors.cpp
new file mode 100644
index 0000000..f49134b
--- /dev/null
+++ b/test/SemaCXX/warn-exit-time-destructors.cpp
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -fsyntax-only -Wexit-time-destructors %s -verify
+
+namespace test1 {
+ struct A { ~A(); };
+ A a; // expected-warning {{declaration requires an exit-time destructor}}
+ A b[10]; // expected-warning {{declaration requires an exit-time destructor}}
+ A c[10][10]; // expected-warning {{declaration requires an exit-time destructor}}
+
+ A &d = a;
+ A &e = b[5];
+ A &f = c[5][7];
+}
+
+namespace test2 {
+void f() {
+ struct A { ~A() { } };
+
+ static A a; // expected-warning {{declaration requires an exit-time destructor}}
+ static A b[10]; // expected-warning {{declaration requires an exit-time destructor}}
+ static A c[10][10]; // expected-warning {{declaration requires an exit-time destructor}}
+
+ static A &d = a;
+ static A &e = b[5];
+ static A &f = c[5][7];
+}
+
+}
diff --git a/test/SemaCXX/warn-global-constructors.cpp b/test/SemaCXX/warn-global-constructors.cpp
index ad60954..6330958 100644
--- a/test/SemaCXX/warn-global-constructors.cpp
+++ b/test/SemaCXX/warn-global-constructors.cpp
@@ -53,8 +53,8 @@ namespace test3 {
namespace test4 {
char a[] = "hello";
- char b[5] = "hello";
- char c[][5] = { "hello" };
+ char b[6] = "hello";
+ char c[][6] = { "hello" };
}
namespace test5 {
diff --git a/test/SemaCXX/warn-literal-conversion.cpp b/test/SemaCXX/warn-literal-conversion.cpp
index dab5c01..b9c9528 100644
--- a/test/SemaCXX/warn-literal-conversion.cpp
+++ b/test/SemaCXX/warn-literal-conversion.cpp
@@ -8,13 +8,18 @@ void test0() {
int y0 = 1.2222F; // expected-warning {{implicit conversion turns literal floating-point number into integer}}
int y1 = (1.2222F); // expected-warning {{implicit conversion turns literal floating-point number into integer}}
int y2 = (((1.2222F))); // expected-warning {{implicit conversion turns literal floating-point number into integer}}
- int y3 = 12E1F; // expected-warning {{implicit conversion turns literal floating-point number into integer}}
- int y4 = 1.2E1F; // expected-warning {{implicit conversion turns literal floating-point number into integer}}
+ int y3 = 12E1F; // expected-warning {{implicit conversion turns literal floating-point number into integer}} \
+ // expected-note {{this can be rewritten as an integer literal with the exact same value}}
+ int y4 = 1.2E1F; // expected-warning {{implicit conversion turns literal floating-point number into integer}} \
+ // expected-note {{this can be rewritten as an integer literal with the exact same value}}
// Double
int y5 = 1.2222; // expected-warning {{implicit conversion turns literal floating-point number into integer}}
- int y6 = 12E1; // expected-warning {{implicit conversion turns literal floating-point number into integer}}
- int y7 = 1.2E1; // expected-warning {{implicit conversion turns literal floating-point number into integer}}
- int y8 = (1.2E1); // expected-warning {{implicit conversion turns literal floating-point number into integer}}
+ int y6 = 12E1; // expected-warning {{implicit conversion turns literal floating-point number into integer}} \
+ // expected-note {{this can be rewritten as an integer literal with the exact same value}}
+ int y7 = 1.2E1; // expected-warning {{implicit conversion turns literal floating-point number into integer}} \
+ // expected-note {{this can be rewritten as an integer literal with the exact same value}}
+ int y8 = (1.2E1); // expected-warning {{implicit conversion turns literal floating-point number into integer}} \
+ // expected-note {{this can be rewritten as an integer literal with the exact same value}}
// Test assignment to an existing variable.
y8 = 2.22F; // expected-warning {{implicit conversion turns literal floating-point number into integer}}
diff --git a/test/SemaCXX/warn-missing-prototypes.cpp b/test/SemaCXX/warn-missing-prototypes.cpp
index b6ebe82..f7e8db3 100644
--- a/test/SemaCXX/warn-missing-prototypes.cpp
+++ b/test/SemaCXX/warn-missing-prototypes.cpp
@@ -24,3 +24,9 @@ template<typename> void h() { }
// Don't warn when instantiating function templates.
template void h<int>();
+
+// PR9519: don't warn about friend functions.
+class I {
+ friend void I_friend() {}
+};
+
diff --git a/test/SemaCXX/warn-non-pod-memset.cpp b/test/SemaCXX/warn-non-pod-memset.cpp
new file mode 100644
index 0000000..fbdcead
--- /dev/null
+++ b/test/SemaCXX/warn-non-pod-memset.cpp
@@ -0,0 +1,63 @@
+// RUN: %clang_cc1 -fsyntax-only -Wnon-pod-memset -verify %s
+
+extern void *memset(void *, int, unsigned);
+
+// Several POD types that should not warn.
+struct S1 {} s1;
+struct S2 { int x; } s2;
+struct S3 { float x, y; S1 s[4]; void (*f)(S1**); } s3;
+
+// We use the C++11 concept of POD for this warning, so ensure a non-aggregate
+// still warns.
+class C1 {
+ int x, y, z;
+public:
+ void foo() {}
+} c1;
+
+// Non-POD types that should warn.
+struct X1 { X1(); } x1;
+struct X2 { ~X2(); } x2;
+struct X3 { virtual void f(); } x3;
+struct X4 : X2 {} x4;
+struct X5 : virtual S1 {} x5;
+
+void test_warn() {
+ memset(&x1, 0, sizeof x1); // \
+ // expected-warning {{destination for this memset call is a pointer to a non-POD type}} \
+ // expected-note {{explicitly cast the pointer to silence this warning}}
+ memset(&x2, 0, sizeof x2); // \
+ // expected-warning {{destination for this memset call is a pointer to a non-POD type}} \
+ // expected-note {{explicitly cast the pointer to silence this warning}}
+ memset(&x3, 0, sizeof x3); // \
+ // expected-warning {{destination for this memset call is a pointer to a non-POD type}} \
+ // expected-note {{explicitly cast the pointer to silence this warning}}
+ memset(&x4, 0, sizeof x4); // \
+ // expected-warning {{destination for this memset call is a pointer to a non-POD type}} \
+ // expected-note {{explicitly cast the pointer to silence this warning}}
+ memset(&x5, 0, sizeof x5); // \
+ // expected-warning {{destination for this memset call is a pointer to a non-POD type}} \
+ // expected-note {{explicitly cast the pointer to silence this warning}}
+}
+
+void test_nowarn(void *void_ptr) {
+ int i, *iptr;
+ float y;
+ char c;
+
+ memset(&i, 0, sizeof i);
+ memset(&iptr, 0, sizeof iptr);
+ memset(&y, 0, sizeof y);
+ memset(&c, 0, sizeof c);
+ memset(void_ptr, 0, 42);
+ memset(&s1, 0, sizeof s1);
+ memset(&s2, 0, sizeof s2);
+ memset(&s3, 0, sizeof s3);
+ memset(&c1, 0, sizeof c1);
+
+ // Unevaluated code shouldn't warn.
+ (void)sizeof memset(&x1, 0, sizeof x1);
+
+ // Dead code shouldn't warn.
+ if (false) memset(&x1, 0, sizeof x1);
+}
diff --git a/test/SemaCXX/warn-overloaded-virtual.cpp b/test/SemaCXX/warn-overloaded-virtual.cpp
index 86b1d23..8e2b671 100644
--- a/test/SemaCXX/warn-overloaded-virtual.cpp
+++ b/test/SemaCXX/warn-overloaded-virtual.cpp
@@ -52,3 +52,15 @@ struct Derived : public Base {
void foo(int, int);
};
}
+
+namespace PR9396 {
+class A {
+public:
+ virtual void f(int) {}
+};
+
+class B : public A {
+public:
+ static void f() {}
+};
+}
diff --git a/test/SemaCXX/warn-shadow.cpp b/test/SemaCXX/warn-shadow.cpp
index 3bf9af4..68e9467 100644
--- a/test/SemaCXX/warn-shadow.cpp
+++ b/test/SemaCXX/warn-shadow.cpp
@@ -70,3 +70,14 @@ struct S {
}
};
}
+
+extern int bob; // expected-note {{previous declaration is here}}
+
+// rdar://8883302
+void rdar8883302() {
+ extern int bob; // don't warn for shadowing.
+}
+
+void test8() {
+ int bob; // expected-warning {{declaration shadows a variable in the global namespace}}
+}
diff --git a/test/SemaCXX/warn-unreachable.cpp b/test/SemaCXX/warn-unreachable.cpp
index 3c8a429..ea6755f 100644
--- a/test/SemaCXX/warn-unreachable.cpp
+++ b/test/SemaCXX/warn-unreachable.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -fexceptions -fsyntax-only -verify -fblocks -Wunreachable-code -Wno-unused-value
+// RUN: %clang_cc1 %s -fcxx-exceptions -fexceptions -fsyntax-only -verify -fblocks -Wunreachable-code -Wno-unused-value
int &halt() __attribute__((noreturn));
int &live();
diff --git a/test/SemaCXX/warn-unused-filescoped.cpp b/test/SemaCXX/warn-unused-filescoped.cpp
index c32acb0..dbff4b0 100644
--- a/test/SemaCXX/warn-unused-filescoped.cpp
+++ b/test/SemaCXX/warn-unused-filescoped.cpp
@@ -78,3 +78,12 @@ namespace test4 {
void test(A a); // expected-warning {{unused function}}
extern "C" void test4(A a);
}
+
+namespace rdar8733476 {
+ static void foo() { } // expected-warning {{not needed and will not be emitted}}
+
+ template <int>
+ void bar() {
+ foo();
+ }
+}
diff --git a/test/SemaCXX/warn-using-namespace-in-header.cpp b/test/SemaCXX/warn-using-namespace-in-header.cpp
new file mode 100644
index 0000000..72c2552
--- /dev/null
+++ b/test/SemaCXX/warn-using-namespace-in-header.cpp
@@ -0,0 +1,54 @@
+// RUN: %clang_cc1 -fsyntax-only -Wheader-hygiene -verify %s
+
+#include "warn-using-namespace-in-header.h"
+
+namespace dont_warn {}
+using namespace dont_warn;
+
+// Warning is actually in the header but only the cpp file gets scanned.
+// expected-warning {{using namespace directive in global context in header}}
+
+
+
+
+
+
+
+
+
+// Warn inside linkage specs too.
+// expected-warning {{using namespace directive in global context in header}}
+
+
+
+
+
+
+// expected-warning {{using namespace directive in global context in header}}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+// expected-warning {{using namespace directive in global context in header}}
+
+// |using namespace| through a macro shouldn't warn if the instantiation is in a
+// cc file.
+USING_MACRO
diff --git a/test/SemaCXX/warn-using-namespace-in-header.h b/test/SemaCXX/warn-using-namespace-in-header.h
new file mode 100644
index 0000000..b544c54
--- /dev/null
+++ b/test/SemaCXX/warn-using-namespace-in-header.h
@@ -0,0 +1,50 @@
+
+
+
+
+
+// Lots of vertical space to make the error line match up with the line of the
+// expected line in the source file.
+namespace warn_in_header_in_global_context {}
+using namespace warn_in_header_in_global_context;
+
+// While we want to error on the previous using directive, we don't when we are
+// inside a namespace
+namespace dont_warn_here {
+using namespace warn_in_header_in_global_context;
+}
+
+// We should warn in toplevel extern contexts.
+namespace warn_inside_linkage {}
+extern "C++" {
+using namespace warn_inside_linkage;
+}
+
+// This is really silly, but we should warn on it:
+extern "C++" {
+extern "C" {
+extern "C++" {
+using namespace warn_inside_linkage;
+}
+}
+}
+
+// But we shouldn't warn in extern contexts inside namespaces.
+namespace dont_warn_here {
+extern "C++" {
+using namespace warn_in_header_in_global_context;
+}
+}
+
+// We also shouldn't warn in case of functions.
+inline void foo() {
+ using namespace warn_in_header_in_global_context;
+}
+
+
+namespace macronamespace {}
+#define USING_MACRO using namespace macronamespace;
+
+// |using namespace| through a macro should warn if the instantiation is in a
+// header.
+USING_MACRO
diff --git a/test/SemaCXX/warn_false_to_pointer.cpp b/test/SemaCXX/warn_false_to_pointer.cpp
deleted file mode 100644
index fb6f955..0000000
--- a/test/SemaCXX/warn_false_to_pointer.cpp
+++ /dev/null
@@ -1,10 +0,0 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
-
-int* j = false; // expected-warning{{ initialization of pointer of type 'int *' from literal 'false'}}
-
-void foo(int* i, int *j=(false)) // expected-warning{{ initialization of pointer of type 'int *' from literal 'false'}}
-{
- foo(false); // expected-warning{{ initialization of pointer of type 'int *' from literal 'false'}}
- foo((int*)false);
-}
-
diff --git a/test/SemaCXX/writable-strings-deprecated.cpp b/test/SemaCXX/writable-strings-deprecated.cpp
index c89c882..8295401 100644
--- a/test/SemaCXX/writable-strings-deprecated.cpp
+++ b/test/SemaCXX/writable-strings-deprecated.cpp
@@ -1,4 +1,6 @@
// RUN: %clang_cc1 -fsyntax-only -Wno-deprecated-writable-strings -verify %s
+// RUN: %clang_cc1 -fsyntax-only -fwritable-strings -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wno-write-strings -verify %s
// rdar://8827606
char *fun(void)
OpenPOWER on IntegriCloud