diff options
Diffstat (limited to 'test/CXX')
-rw-r--r-- | test/CXX/basic/basic.lookup/basic.lookup.argdep/p4.cpp | 13 | ||||
-rw-r--r-- | test/CXX/class/p6-0x.cpp | 15 | ||||
-rw-r--r-- | test/CXX/dcl.dcl/dcl.spec/dcl.stc/p1.cpp | 4 | ||||
-rw-r--r-- | test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p5.cpp | 2 | ||||
-rw-r--r-- | test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p6.cpp | 3 | ||||
-rw-r--r-- | test/CXX/except/except.spec/canonical.cpp | 53 | ||||
-rw-r--r-- | test/CXX/except/except.spec/p14-ir.cpp | 13 | ||||
-rw-r--r-- | test/CXX/special/class.copy/p33-0x.cpp | 32 | ||||
-rw-r--r-- | test/CXX/stmt.stmt/stmt.dcl/p3-0x.cpp | 8 | ||||
-rw-r--r-- | test/CXX/stmt.stmt/stmt.iter/stmt.ranged/p1.cpp | 2 | ||||
-rw-r--r-- | test/CXX/temp/p3.cpp | 20 | ||||
-rw-r--r-- | test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p3.cpp | 25 | ||||
-rw-r--r-- | test/CXX/temp/temp.res/temp.local/p3.cpp | 8 | ||||
-rw-r--r-- | test/CXX/temp/temp.spec/temp.explicit/p7.cpp | 4 |
14 files changed, 176 insertions, 26 deletions
diff --git a/test/CXX/basic/basic.lookup/basic.lookup.argdep/p4.cpp b/test/CXX/basic/basic.lookup/basic.lookup.argdep/p4.cpp index ccadf41..15d86b7 100644 --- a/test/CXX/basic/basic.lookup/basic.lookup.argdep/p4.cpp +++ b/test/CXX/basic/basic.lookup/basic.lookup.argdep/p4.cpp @@ -19,8 +19,9 @@ namespace D { } namespace C { - class C {}; - void func(C); + class C {}; // expected-note {{candidate constructor (the implicit copy constructor) not viable: no known conversion from 'B::B' to 'const C::C &' for 1st argument}} + void func(C); // expected-note {{'C::func' declared here}} \ + // expected-note {{passing argument to parameter here}} C operator+(C,C); D::D operator+(D::D,D::D); } @@ -32,7 +33,13 @@ namespace D { namespace Test { void test() { func(A::A()); - func(B::B()); // expected-error {{use of undeclared identifier 'func'}} + // FIXME: namespace-aware typo correction causes an extra, misleading + // message in this case; some form of backtracking, diagnostic message + // delaying, or argument checking before emitting diagnostics is needed to + // avoid accepting and printing out a typo correction that proves to be + // incorrect once argument-dependent lookup resolution has occurred. + func(B::B()); // expected-error {{use of undeclared identifier 'func'; did you mean 'C::func'?}} \ + // expected-error {{no viable conversion from 'B::B' to 'C::C'}} func(C::C()); A::A() + A::A(); B::B() + B::B(); diff --git a/test/CXX/class/p6-0x.cpp b/test/CXX/class/p6-0x.cpp new file mode 100644 index 0000000..fc83e06 --- /dev/null +++ b/test/CXX/class/p6-0x.cpp @@ -0,0 +1,15 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++0x + +class Trivial { int n; void f(); }; +class NonTrivial1 { NonTrivial1(const NonTrivial1 &); }; +class NonTrivial2 { NonTrivial2(NonTrivial2 &&); }; +class NonTrivial3 { NonTrivial3 operator=(const NonTrivial3 &); }; +class NonTrivial4 { NonTrivial4 operator=(NonTrivial4 &&); }; +class NonTrivial5 { ~NonTrivial5(); }; + +static_assert(__is_trivial(Trivial), "Trivial is not trivial"); +static_assert(!__is_trivial(NonTrivial1), "NonTrivial1 is trivial"); +static_assert(!__is_trivial(NonTrivial2), "NonTrivial2 is trivial"); +static_assert(!__is_trivial(NonTrivial3), "NonTrivial3 is trivial"); +static_assert(!__is_trivial(NonTrivial4), "NonTrivial4 is trivial"); +static_assert(!__is_trivial(NonTrivial5), "NonTrivial5 is trivial"); diff --git a/test/CXX/dcl.dcl/dcl.spec/dcl.stc/p1.cpp b/test/CXX/dcl.dcl/dcl.spec/dcl.stc/p1.cpp index 40917b8..cbb439e 100644 --- a/test/CXX/dcl.dcl/dcl.spec/dcl.stc/p1.cpp +++ b/test/CXX/dcl.dcl/dcl.spec/dcl.stc/p1.cpp @@ -7,13 +7,13 @@ template<typename T> void f(T) {} template<typename T> static void g(T) {} -template<> static void f<int>(int); // expected-error{{explicit specialization cannot have a storage class}} +template<> static void f<int>(int); // expected-error{{explicit specialization has extraneous, inconsistent storage class 'static'}} template static void f<float>(float); // expected-error{{explicit instantiation cannot have a storage class}} template<> void f<double>(double); template void f<long>(long); -template<> static void g<int>(int); // expected-error{{explicit specialization cannot have a storage class}} +template<> static void g<int>(int); // expected-warning{{explicit specialization cannot have a storage class}} template static void g<float>(float); // expected-error{{explicit instantiation cannot have a storage class}} template<> void g<double>(double); diff --git a/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p5.cpp b/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p5.cpp index fabfb53..54da854 100644 --- a/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p5.cpp +++ b/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p5.cpp @@ -46,7 +46,7 @@ void j() { U<auto> v; // expected-error{{'auto' not allowed in template argument}} int n; - (void)dynamic_cast<auto&>(S()); // expected-error{{'auto' not allowed here}} + (void)dynamic_cast<auto&>(n); // expected-error{{'auto' not allowed here}} (void)static_cast<auto*>(&n); // expected-error{{'auto' not allowed here}} (void)reinterpret_cast<auto*>(&n); // expected-error{{'auto' not allowed here}} (void)const_cast<auto>(n); // expected-error{{'auto' not allowed here}} diff --git a/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p6.cpp b/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p6.cpp index 06aeaa6..8b4b703 100644 --- a/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p6.cpp +++ b/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p6.cpp @@ -54,8 +54,7 @@ void f() { auto *fail1 = 0; // expected-error {{variable 'fail1' with type 'auto *' has incompatible initializer of type 'int'}} int **p; - // FIXME: due to PR9233, we get the wrong diagnostic here. - const auto **fail2(p); // desired-error {{variable 'fail2' with type 'auto const **' has incompatible initializer of type 'int **'}} expected-error {{cannot initialize}} + const auto **fail2(p); // expected-error {{variable 'fail2' with type 'auto const **' has incompatible initializer of type 'int **'}} } struct S { diff --git a/test/CXX/except/except.spec/canonical.cpp b/test/CXX/except/except.spec/canonical.cpp new file mode 100644 index 0000000..9bc26de --- /dev/null +++ b/test/CXX/except/except.spec/canonical.cpp @@ -0,0 +1,53 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++0x %s + +// PR10087: Make sure that we don't conflate exception specifications +// from different functions in the canonical type system. +namespace std +{ + +template <class _Tp> _Tp&& declval() noexcept; + +template <class _Tp, class... _Args> +struct __is_nothrow_constructible +{ + static const bool value = noexcept(_Tp(declval<_Args>()...)); +}; + +template<class, class _Traits, class _Allocator> +class basic_string +{ +public: + typedef typename _Traits::char_type value_type; + typedef _Allocator allocator_type; + + basic_string() + noexcept(__is_nothrow_constructible<allocator_type>::value); +}; + +template <class, class, class _Compare> +struct __map_value_compare +{ +public: + __map_value_compare() + noexcept(__is_nothrow_constructible<_Compare>::value); +}; + +struct less +{ +}; + +struct map +{ + typedef __map_value_compare<int, short, less> __vc; + __vc vc_; +}; + + +template<class T, class _Traits, class _Allocator> +basic_string<T, _Traits, _Allocator>::basic_string() noexcept(__is_nothrow_constructible<allocator_type>::value) {} + +template <class T, class Value, class _Compare> +__map_value_compare<T, Value, _Compare>::__map_value_compare() + noexcept(__is_nothrow_constructible<_Compare>::value) {} + +} // std diff --git a/test/CXX/except/except.spec/p14-ir.cpp b/test/CXX/except/except.spec/p14-ir.cpp index c681727..81fbf7d 100644 --- a/test/CXX/except/except.spec/p14-ir.cpp +++ b/test/CXX/except/except.spec/p14-ir.cpp @@ -26,12 +26,12 @@ struct X4 { struct X5 : X0, X4 { }; void test(X2 x2, X3 x3, X5 x5) { - // CHECK: define linkonce_odr void @_ZN2X2C1ERKS_(%struct.X0* %this, %struct.X0*) unnamed_addr + // CHECK: define linkonce_odr void @_ZN2X2C1ERKS_(%struct.X2* %this, %struct.X2*) unnamed_addr // CHECK: call void @_ZN2X2C2ERKS_({{.*}}) nounwind // CHECK-NEXT: ret void // CHECK-NEXT: } X2 x2a(x2); - // CHECK: define linkonce_odr void @_ZN2X3C1ERKS_(%struct.X0* %this, %struct.X0*) unnamed_addr + // CHECK: define linkonce_odr void @_ZN2X3C1ERKS_(%struct.X3* %this, %struct.X3*) unnamed_addr // CHECK: call void @_ZN2X3C2ERKS_({{.*}}) nounwind // CHECK-NEXT: ret void // CHECK-NEXT: } @@ -55,24 +55,25 @@ struct X8 : X6 { }; struct X9 : X6, X7 { }; void test() { - // CHECK: define linkonce_odr void @_ZN2X8C1Ev(%struct.X0* %this) unnamed_addr + // CHECK: define linkonce_odr void @_ZN2X8C1Ev(%struct.X8* %this) unnamed_addr // CHECK: call void @_ZN2X8C2Ev({{.*}}) nounwind // CHECK-NEXT: ret void X8(); - // CHECK: define linkonce_odr void @_ZN2X9C1Ev(%struct.X0* %this) unnamed_addr + // CHECK: define linkonce_odr void @_ZN2X9C1Ev(%struct.X9* %this) unnamed_addr // FIXME: check that this is the end of the line here: // CHECK: call void @_ZN2X9C2Ev({{.*}}) // CHECK-NEXT: ret void X9(); - // CHECK: define linkonce_odr void @_ZN2X9C2Ev(%struct.X0* %this) unnamed_addr + // CHECK: define linkonce_odr void @_ZN2X9C2Ev(%struct.X9* %this) unnamed_addr // CHECK: call void @_ZN2X6C2Ev({{.*}}) nounwind // FIXME: and here: + // CHECK-NEXT: bitcast // CHECK-NEXT: call void @_ZN2X7C2Ev({{.*}}) // CHECK: ret void - // CHECK: define linkonce_odr void @_ZN2X8C2Ev(%struct.X0* %this) unnamed_addr + // CHECK: define linkonce_odr void @_ZN2X8C2Ev(%struct.X8* %this) unnamed_addr // CHECK: call void @_ZN2X6C2Ev({{.*}}) nounwind // CHECK-NEXT: ret void } diff --git a/test/CXX/special/class.copy/p33-0x.cpp b/test/CXX/special/class.copy/p33-0x.cpp index 1e6a025..b196865 100644 --- a/test/CXX/special/class.copy/p33-0x.cpp +++ b/test/CXX/special/class.copy/p33-0x.cpp @@ -23,3 +23,35 @@ void throw_move_only(X x) { throw x2; } +namespace PR10142 { + struct X { + X(); + X(X&&); + X(const X&) = delete; // expected-note 2{{function has been explicitly marked deleted here}} + }; + + void f(int i) { + X x; + try { + X x2; + if (i) + throw x2; // okay + throw x; // expected-error{{call to deleted constructor of 'PR10142::X'}} + } catch (...) { + } + } + + template<typename T> + void f2(int i) { + T x; + try { + T x2; + if (i) + throw x2; // okay + throw x; // expected-error{{call to deleted constructor of 'PR10142::X'}} + } catch (...) { + } + } + + template void f2<X>(int); // expected-note{{in instantiation of function template specialization 'PR10142::f2<PR10142::X>' requested here}} +} diff --git a/test/CXX/stmt.stmt/stmt.dcl/p3-0x.cpp b/test/CXX/stmt.stmt/stmt.dcl/p3-0x.cpp index b415044..40b4c23 100644 --- a/test/CXX/stmt.stmt/stmt.dcl/p3-0x.cpp +++ b/test/CXX/stmt.stmt/stmt.dcl/p3-0x.cpp @@ -30,13 +30,13 @@ struct Y { void f(); void test_Y() { - goto end; - Y y; + goto end; // expected-error{{goto into protected scope}} + Y y; // expected-note{{jump bypasses variable with a non-trivial destructor}} end: f(); - goto inner; + goto inner; // expected-error{{goto into protected scope}} { - Y y2; + Y y2; // expected-note{{jump bypasses variable with a non-trivial destructor}} inner: f(); } diff --git a/test/CXX/stmt.stmt/stmt.iter/stmt.ranged/p1.cpp b/test/CXX/stmt.stmt/stmt.iter/stmt.ranged/p1.cpp index 7bfa6fe..0c92f62 100644 --- a/test/CXX/stmt.stmt/stmt.iter/stmt.ranged/p1.cpp +++ b/test/CXX/stmt.stmt/stmt.iter/stmt.ranged/p1.cpp @@ -129,7 +129,7 @@ void g() { void *begin(); // expected-note {{selected 'begin' function with iterator type 'void *'}} void *end(); }; - for (auto u : NoIncr()) { // expected-error {{arithmetic on pointer to void type}} + for (auto u : NoIncr()) { // expected-error {{arithmetic on a pointer to void type}} } struct NoNotEq { diff --git a/test/CXX/temp/p3.cpp b/test/CXX/temp/p3.cpp new file mode 100644 index 0000000..16ebb38 --- /dev/null +++ b/test/CXX/temp/p3.cpp @@ -0,0 +1,20 @@ +// RUN: %clang_cc1 -verify %s + +template<typename T> struct S { + static int a, b; +}; + +template<typename T> int S<T>::a, S<T>::b; // expected-error {{can only declare a single entity}} + +// FIXME: the last two diagnostics here are terrible. +template<typename T> struct A { static A a; } A<T>::a; // expected-error {{expected ';' after struct}} \ + expected-error {{use of undeclared identifier 'T'}} \ + expected-error {{cannot name the global scope}} \ + expected-error {{no member named 'a' in the global namespace}} + +template<typename T> struct B { } f(); // expected-error {{expected ';' after struct}} \ + expected-error {{requires a type specifier}} + +template<typename T> struct C { } // expected-error {{expected ';' after struct}} + +A<int> c; diff --git a/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p3.cpp b/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p3.cpp index 3c22cf3..295f080 100644 --- a/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p3.cpp +++ b/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p3.cpp @@ -71,7 +71,21 @@ void test_f3(int ***ip, volatile int ***vip) { A<int> a0 = f3(ip); A<volatile int> a1 = f3(vip); } - + +// Also accept conversions for pointer types which require removing +// [[noreturn]]. +namespace noreturn_stripping { + template <class R> + void f(R (*function)()); + + void g() __attribute__ ((__noreturn__)); + void h(); + void test() { + f(g); + f(h); + } +} + // - If P is a class, and P has the form template-id, then A can be a // derived class of the deduced A. Likewise, if P is a pointer to a class // of the form template-id, A can be a pointer to a derived class pointed @@ -123,3 +137,12 @@ namespace N { N::F<T1>(d); // OK } } + +namespace PR9233 { + template<typename T> void f(const T **q); // expected-note{{candidate template ignored: substitution failure [with T = int]}} + + void g(int **p) { + f(p); // expected-error{{no matching function for call to 'f'}} + } + +} diff --git a/test/CXX/temp/temp.res/temp.local/p3.cpp b/test/CXX/temp/temp.res/temp.local/p3.cpp index 88f8963..54da885 100644 --- a/test/CXX/temp/temp.res/temp.local/p3.cpp +++ b/test/CXX/temp/temp.res/temp.local/p3.cpp @@ -22,11 +22,11 @@ template <class T> struct Derived: Base<int>, Base<char> { namespace PR6717 { template <typename T> class WebVector { - } + } // expected-error {{expected ';' after class}} - WebVector(const WebVector<T>& other) { } + WebVector(const WebVector<T>& other) { } // expected-error{{undeclared identifier 'T'}} \ + expected-error{{requires a type specifier}} template <typename C> - WebVector<T>& operator=(const C& other) { } // expected-error{{unknown type name 'WebVector'}} \ - // expected-error{{unqualified-id}} + WebVector<T>& operator=(const C& other) { } // expected-error{{undeclared identifier 'T'}} } diff --git a/test/CXX/temp/temp.spec/temp.explicit/p7.cpp b/test/CXX/temp/temp.spec/temp.explicit/p7.cpp index b62e0cb..7398dca 100644 --- a/test/CXX/temp/temp.spec/temp.explicit/p7.cpp +++ b/test/CXX/temp/temp.spec/temp.explicit/p7.cpp @@ -7,14 +7,14 @@ struct X0 { }; T* f0(T* ptr) { - return ptr + 1; // expected-error{{pointer to function}} + return ptr + 1; // expected-error{{pointer to the function}} } static T* static_member; }; template<typename T> -T* X0<T>::static_member = ((T*)0) + 1; // expected-error{{pointer to function}} +T* X0<T>::static_member = ((T*)0) + 1; // expected-error{{pointer to the function}} template class X0<int>; // okay |