diff options
Diffstat (limited to 'test/CXX')
687 files changed, 0 insertions, 50246 deletions
diff --git a/test/CXX/basic/basic.def.odr/p1-var.cpp b/test/CXX/basic/basic.def.odr/p1-var.cpp deleted file mode 100644 index 892f546ee545..000000000000 --- a/test/CXX/basic/basic.def.odr/p1-var.cpp +++ /dev/null @@ -1,21 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s - -// C++ [basic.def.odr]p1: -// No translation unit shall contain more than one definition of any -// variable, [...]. - -// Bad: in C++, these are both definitions. None of that C99 tentative stuff. -int i; // expected-note {{previous}} -int i; // expected-error {{redefinition}} - -// OK: decl + def -extern int j; -int j; - -// OK: def + decl -int k; -extern int k; - -// Bad. The important thing here is that we don't emit the diagnostic twice. -int l = 1; // expected-note {{previous}} -int l = 2; // expected-error {{redefinition}} diff --git a/test/CXX/basic/basic.def.odr/p2-typeid.cpp b/test/CXX/basic/basic.def.odr/p2-typeid.cpp deleted file mode 100644 index 55debe3ca731..000000000000 --- a/test/CXX/basic/basic.def.odr/p2-typeid.cpp +++ /dev/null @@ -1,36 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s - -// C++ [basic.def.odr]p2: -// An expression is potentially evaluated unless it [...] is the -// operand of the typeid operator and the expression does not -// designate an lvalue of polymorphic class type. - -// FIXME: This should really include <typeinfo>, but we don't have that yet. -namespace std { - class type_info; -} - -struct Poly { - virtual ~Poly(); -}; - -struct NonPoly { }; - -template<typename T, typename Result = T> -struct X { - Result f(T t) { return t + t; } // expected-error{{invalid operands}} - - void g(T t) { - (void)typeid(f(t)); // expected-note{{here}} - } -}; - -void test(X<Poly> xp, X<Poly, Poly&> xpr, X<NonPoly> xnp, X<NonPoly, NonPoly&> xnpr) { - // These are okay (although GCC and EDG get them wrong). - xp.g(Poly()); - xnp.g(NonPoly()); - xnpr.g(NonPoly()); - - // Triggers an error (as it should); - xpr.g(Poly()); // expected-note{{instantiation of member function}} -} diff --git a/test/CXX/basic/basic.def/p2.cpp b/test/CXX/basic/basic.def/p2.cpp deleted file mode 100644 index 598a79a8a3d7..000000000000 --- a/test/CXX/basic/basic.def/p2.cpp +++ /dev/null @@ -1,8 +0,0 @@ -// RUN: %clang_cc1 -std=c++1z -verify %s -Wdeprecated - -namespace { - struct A { - static constexpr int n = 0; - }; - const int A::n; // expected-warning {{deprecated}} -} diff --git a/test/CXX/basic/basic.def/p4.cpp b/test/CXX/basic/basic.def/p4.cpp deleted file mode 100644 index c3919156bbbb..000000000000 --- a/test/CXX/basic/basic.def/p4.cpp +++ /dev/null @@ -1,6 +0,0 @@ -// RUN: %clang_cc1 -std=c++1z -verify %s - -inline int f(); // expected-warning {{inline function 'f' is not defined}} -extern inline int n; // expected-error {{inline variable 'n' is not defined}} - -int use = f() + n; // expected-note 2{{used here}} diff --git a/test/CXX/basic/basic.link/p6.cpp b/test/CXX/basic/basic.link/p6.cpp deleted file mode 100644 index ac6dc2f1f1a3..000000000000 --- a/test/CXX/basic/basic.link/p6.cpp +++ /dev/null @@ -1,44 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++1y %s - -// expected-no-diagnostics - -// C++11 [basic.link]p6: -// The name of a function declared in block scope and the name -// of a variable declared by a block scope extern declaration -// have linkage. If there is a visible declaration of an entity -// with linkage having the same name and type, ignoring entities -// declared outside the innermost enclosing namespace scope, the -// block scope declaration declares that same entity and -// receives the linkage of the previous declaration. - -extern int same_entity; -constexpr int *get1() { - int same_entity = 0; // not the same entity - { - extern int same_entity; - return &same_entity; - } -} -static_assert(get1() == &same_entity, "failed to find previous decl"); - -static int same_entity_2[3]; -constexpr int *get2() { - // This is a redeclaration of the same entity, even though it doesn't - // inherit the type of the prior declaration. - extern int same_entity_2[]; - return same_entity_2; -} -static_assert(get2() == same_entity_2, "failed to find previous decl"); - -static int different_entities; -constexpr int *get3() { - int different_entities = 0; - { - // FIXME: This is not a redeclaration of the prior entity, because - // it is not visible here. Under DR426, this is ill-formed, and without - // it, the static_assert below should fail. - extern int different_entities; - return &different_entities; - } -} -static_assert(get3() == &different_entities, "failed to find previous decl"); diff --git a/test/CXX/basic/basic.link/p7.cpp b/test/CXX/basic/basic.link/p7.cpp deleted file mode 100644 index 9a85eacdda4f..000000000000 --- a/test/CXX/basic/basic.link/p7.cpp +++ /dev/null @@ -1,73 +0,0 @@ -// RUN: %clang_cc1 -verify -std=c++1y %s - -// Example from the standard. -namespace X { - void p() { - q(); // expected-error {{undeclared}} - extern void q(); - } - void middle() { - q(); // expected-error {{undeclared}} - } - void q() { /*...*/ } - void bottom() { - q(); - } -} -int q(); - -namespace Test1 { - void f() { - extern int a; // expected-note {{previous}} - int g(void); // expected-note {{previous}} - } - double a; // expected-error {{different type: 'double' vs 'int'}} - double g(); // expected-error {{differ only in their return type}} -} - -namespace Test2 { - void f() { - extern int a; // expected-note {{previous}} - int g(void); // expected-note {{previous}} - } - void h() { - extern double a; // expected-error {{different type: 'double' vs 'int'}} - double g(void); // expected-error {{differ only in their return type}} - } -} - -namespace Test3 { - constexpr void (*f())() { - void h(); - return &h; - } - constexpr void (*g())() { - void h(); - return &h; - } - static_assert(f() == g(), ""); -} - -namespace Test4 { - template<typename T> - constexpr void (*f())() { - void h(); - return &h; - } - static_assert(f<int>() == f<char>(), ""); - void h(); - static_assert(f<int>() == &h, ""); -} - -namespace Test5 { - constexpr auto f() -> void (*)() { - void g(); - struct X { - friend void g(); - static constexpr auto h() -> void (*)() { return g; } - }; - return X::h(); - } - void g(); - static_assert(f() == g, ""); -} diff --git a/test/CXX/basic/basic.link/p8.cpp b/test/CXX/basic/basic.link/p8.cpp deleted file mode 100644 index 54b977d77f68..000000000000 --- a/test/CXX/basic/basic.link/p8.cpp +++ /dev/null @@ -1,78 +0,0 @@ -// RUN: %clang_cc1 -std=c++2a -verify %s -pedantic - -template<typename T> struct Template {}; - -struct Linkage1 { struct Inner {}; }; -typedef struct { struct Inner {}; } Linkage2; - -typedef struct {} const NoLinkage1; -auto x = [] {}; -typedef decltype(x) NoLinkage2; -auto f() { return [] {}; } -typedef decltype(f()) NoLinkage3; - -inline auto g() { return [] {}; } -typedef decltype(g()) VisibleNoLinkage1; -inline auto y = [] {}; -typedef decltype(y) VisibleNoLinkage2; -inline auto h() { struct {} x; return x; } -typedef decltype(h()) VisibleNoLinkage3; - -extern Linkage1 linkage1v; -extern Linkage1::Inner linkage1iv; -extern Linkage2 linkage2v; -extern Linkage2::Inner linkage2iv; -extern Template<Linkage1> linkaget1v; -extern Linkage1 linkage1f(); -void linkage2f(Linkage2); - -void use_linkage() { - &linkage1v, &linkage1iv, &linkage2v, &linkage2iv, &linkaget1v; // expected-warning 5{{unused}} - linkage1f(); - linkage2f({}); -} - -extern NoLinkage1 no_linkage1(); // expected-error {{function 'no_linkage1' is used but not defined in this translation unit}} -extern NoLinkage2 no_linkage2(); // expected-error {{function 'no_linkage2' is used but not defined in this translation unit}} -extern NoLinkage3 no_linkage3(); // expected-error {{function 'no_linkage3' is used but not defined in this translation unit}} - -void use_no_linkage() { - no_linkage1(); // expected-note {{used here}} - no_linkage2(); // expected-note {{used here}} - no_linkage3(); // expected-note {{used here}} -} - -extern VisibleNoLinkage1 visible_no_linkage1(); // expected-warning {{ISO C++ requires a definition}} -extern VisibleNoLinkage2 visible_no_linkage2(); // expected-warning {{ISO C++ requires a definition}} -extern VisibleNoLinkage3 visible_no_linkage3(); // expected-warning {{ISO C++ requires a definition}} - -void use_visible_no_linkage() { - visible_no_linkage1(); // expected-note {{used here}} - visible_no_linkage2(); // expected-note {{used here}} - visible_no_linkage3(); // expected-note {{used here}} -} - -namespace { - struct InternalLinkage {}; -} -InternalLinkage internal_linkage(); // expected-error {{used but not defined}} -void use_internal_linkage() { - internal_linkage(); // expected-note {{used here}} -} - -extern inline int not_defined; // expected-error {{not defined}} -extern inline int defined_after_use; -void use_inline_vars() { - not_defined = 1; // expected-note {{used here}} - defined_after_use = 2; -} -inline int defined_after_use; - -namespace { - template<typename T> struct A { - static const int n; - }; - template<typename T> const int A<T>::n = 3; - static_assert(A<int>::n == 3); - int k = A<float>::n; -} diff --git a/test/CXX/basic/basic.link/p9.cpp b/test/CXX/basic/basic.link/p9.cpp deleted file mode 100644 index 680c93db2e29..000000000000 --- a/test/CXX/basic/basic.link/p9.cpp +++ /dev/null @@ -1,10 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s - -// FIXME: This test is woefully incomplete. -namespace N { } // expected-note{{here}} - -// First bullet: two names with external linkage that refer to -// different kinds of entities. -void f() { - int N(); // expected-error{{redefinition}} expected-warning{{interpreted as a function declaration}} expected-note {{replace parentheses with an initializer}} -} diff --git a/test/CXX/basic/basic.lookup/basic.lookup.argdep/p2-template-id.cpp b/test/CXX/basic/basic.lookup/basic.lookup.argdep/p2-template-id.cpp deleted file mode 100644 index eda869b9934d..000000000000 --- a/test/CXX/basic/basic.lookup/basic.lookup.argdep/p2-template-id.cpp +++ /dev/null @@ -1,28 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -// expected-no-diagnostics - -namespace N1 { - struct X { }; - int& f(void*); -} - -namespace N2 { - template<typename T> struct Y { }; -} - -namespace N3 { - void test() { - int &ir = f((N2::Y<N1::X>*)0); - } -} - -int g(void *); -long g(N1::X); - -namespace N1 { - void h(int (*)(void *)); -} - -void test() { - h((&g)); -} diff --git a/test/CXX/basic/basic.lookup/basic.lookup.argdep/p2.cpp b/test/CXX/basic/basic.lookup/basic.lookup.argdep/p2.cpp deleted file mode 100644 index e352bbe83c6b..000000000000 --- a/test/CXX/basic/basic.lookup/basic.lookup.argdep/p2.cpp +++ /dev/null @@ -1,134 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s - -namespace N { - struct X { }; - - X operator+(X, X); - - void f(X); // expected-note 2 {{'N::f' declared here}} - void g(X); // expected-note{{candidate function}} - - void test_multiadd(X x) { - (void)(x + x); - } -} - -namespace M { - struct Y : N::X { }; -} - -void f(); - -void test_operator_adl(N::X x, M::Y y) { - (void)(x + x); - (void)(y + y); -} - -void test_func_adl(N::X x, M::Y y) { - f(x); - f(y); - (f)(x); // expected-error{{too many arguments to function call, expected 0, have 1; did you mean 'N::f'?}} - ::f(x); // expected-error{{too many arguments to function call, expected 0, have 1; did you mean 'N::f'?}} -} - -namespace N { - void test_multiadd2(X x) { - (void)(x + x); - } -} - - -void test_func_adl_only(N::X x) { - g(x); -} - -namespace M { - int g(N::X); // expected-note{{candidate function}} - - void test(N::X x) { - g(x); // expected-error{{call to 'g' is ambiguous}} - int i = (g)(x); - - int g(N::X); - g(x); // okay; calls locally-declared function, no ADL - } -} - - -void test_operator_name_adl(N::X x) { - (void)operator+(x, x); -} - -struct Z { }; -int& f(Z); - -namespace O { - char &f(); - void test_global_scope_adl(Z z) { - { - int& ir = f(z); - } - } -} - -extern "C" { - struct L { int x; }; -} - -void h(L); // expected-note{{candidate function}} - -namespace P { - void h(L); // expected-note{{candidate function}} - void test_transparent_context_adl(L l) { - { - h(l); // expected-error {{call to 'h' is ambiguous}} - } - } -} - -namespace test5 { - namespace NS { - struct A; - void foo(void (*)(A&)); - } - void bar(NS::A& a); - - void test() { - foo(&bar); - } -} - -// PR6762: __builtin_va_list should be invisible to ADL on all platforms. -void test6_function(__builtin_va_list &argv); -namespace test6 { - void test6_function(__builtin_va_list &argv); - - void test() { - __builtin_va_list args; - test6_function(args); - } -} - -// PR13682: we might need to instantiate class temploids. -namespace test7 { - namespace inner { - class A {}; - void test7_function(A &); - } - template <class T> class B : public inner::A {}; - - void test(B<int> &ref) { - test7_function(ref); - } -} - -// Like test7, but ensure we don't complain if the type is properly -// incomplete. -namespace test8 { - template <class T> class B; - void test8_function(B<int> &); - - void test(B<int> &ref) { - test8_function(ref); - } -} diff --git a/test/CXX/basic/basic.lookup/basic.lookup.argdep/p3.cpp b/test/CXX/basic/basic.lookup/basic.lookup.argdep/p3.cpp deleted file mode 100644 index c4c2c8d60596..000000000000 --- a/test/CXX/basic/basic.lookup/basic.lookup.argdep/p3.cpp +++ /dev/null @@ -1,20 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s - -// FIXME: embellish - -namespace test0 { - namespace A { - class Foo { - }; - - void foo(const Foo &foo); - } - - class Test { - enum E { foo = 0 }; - - void test() { - foo(A::Foo()); // expected-error {{not a function}} - } - }; -} diff --git a/test/CXX/basic/basic.lookup/basic.lookup.argdep/p4.cpp b/test/CXX/basic/basic.lookup/basic.lookup.argdep/p4.cpp deleted file mode 100644 index 2292fc540c48..000000000000 --- a/test/CXX/basic/basic.lookup/basic.lookup.argdep/p4.cpp +++ /dev/null @@ -1,69 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s - -namespace A { - class A { - friend void func(A); - friend A operator+(A,A); - }; -} - -namespace B { - class B { - static void func(B); - }; - B operator+(B,B); -} - -namespace D { - class D {}; -} - -namespace 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}} -#if __cplusplus >= 201103L // C++11 or later - // expected-note@-2 {{candidate constructor (the implicit move constructor) not viable: no known conversion from 'B::B' to 'C::C &&' for 1st argument}} -#endif - 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); -} - -namespace D { - using namespace C; -} - -namespace Test { - void test() { - func(A::A()); - // 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(); - C::C() + C::C(); - D::D() + D::D(); // expected-error {{invalid operands to binary expression ('D::D' and 'D::D')}} - } -} - -// PR6716 -namespace test1 { - template <class T> class A { - template <class U> friend void foo(A &, U); // expected-note {{not viable: 1st argument ('const A<int>') would lose const qualifier}} - - public: - A(); - }; - - void test() { - const A<int> a; - foo(a, 10); // expected-error {{no matching function for call to 'foo'}} - } -} diff --git a/test/CXX/basic/basic.lookup/basic.lookup.classref/p1-cxx11.cpp b/test/CXX/basic/basic.lookup/basic.lookup.classref/p1-cxx11.cpp deleted file mode 100644 index f812ea1bd8be..000000000000 --- a/test/CXX/basic/basic.lookup/basic.lookup.classref/p1-cxx11.cpp +++ /dev/null @@ -1,69 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -fsyntax-only -fdiagnostics-show-option -verify %s - -template<typename T> -struct set{}; -struct Value { - template<typename T> - void set(T value) {} - - void resolves_to_same() { - Value v; - v.set<double>(3.2); - } -}; -void resolves_to_different() { - { - Value v; - // The fact that the next line is a warning rather than an error is an - // extension. - v.set<double>(3.2); - } - { - int set; // Non-template. - Value v; - v.set<double>(3.2); - } -} - -namespace rdar9915664 { - struct A { - template<typename T> void a(); - }; - - struct B : A { }; - - struct C : A { }; - - struct D : B, C { - A &getA() { return static_cast<B&>(*this); } - - void test_a() { - getA().a<int>(); - } - }; -} - -namespace PR11856 { - template<typename T> T end(T); - - template <typename T> - void Foo() { - T it1; - if (it1->end < it1->end) { - } - } - - template<typename T> T *end(T*); - - class X { }; - template <typename T> - void Foo2() { - T it1; - if (it1->end < it1->end) { - } - - X *x; - if (x->end < 7) { // expected-error{{no member named 'end' in 'PR11856::X'}} - } - } -} diff --git a/test/CXX/basic/basic.lookup/basic.lookup.classref/p1.cpp b/test/CXX/basic/basic.lookup/basic.lookup.classref/p1.cpp deleted file mode 100644 index bb6bb73ec702..000000000000 --- a/test/CXX/basic/basic.lookup/basic.lookup.classref/p1.cpp +++ /dev/null @@ -1,100 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -fdiagnostics-show-option -verify %s -// RUN: %clang_cc1 -fsyntax-only -fdiagnostics-show-option -verify -std=c++98 %s -// RUN: %clang_cc1 -fsyntax-only -fdiagnostics-show-option -verify -std=c++11 %s - -// C++98 [basic.lookup.classref]p1: -// In a class member access expression (5.2.5), if the . or -> token is -// immediately followed by an identifier followed by a <, the identifier must -// be looked up to determine whether the < is the beginning of a template -// argument list (14.2) or a less-than operator. The identifier is first -// looked up in the class of the object expression. If the identifier is not -// found, it is then looked up in the context of the entire postfix-expression -// and shall name a class or function template. If the lookup in the class of -// the object expression finds a template, the name is also looked up in the -// context of the entire postfix-expression and -// -- if the name is not found, the name found in the class of the object -// expression is used, otherwise -// -- if the name is found in the context of the entire postfix-expression -// and does not name a class template, the name found in the class of the -// object expression is used, otherwise -// -- if the name found is a class template, it must refer to the same -// entity as the one found in the class of the object expression, -// otherwise the program is ill-formed. - -// From PR 7247 -template<typename T> -struct set{}; -#if __cplusplus <= 199711L -// expected-note@-2 {{lookup from the current scope refers here}} -#endif -struct Value { - template<typename T> - void set(T value) {} -#if __cplusplus <= 199711L - // expected-note@-2 {{lookup in the object type 'Value' refers here}} -#endif - - void resolves_to_same() { - Value v; - v.set<double>(3.2); - } -}; -void resolves_to_different() { - { - Value v; - // The fact that the next line is a warning rather than an error is an - // extension. - v.set<double>(3.2); -#if __cplusplus <= 199711L - // expected-warning@-2 {{lookup of 'set' in member access expression is ambiguous; using member of 'Value'}} -#endif - } - { - int set; // Non-template. - Value v; - v.set<double>(3.2); - } -} - -namespace rdar9915664 { - struct A { - template<typename T> void a(); - }; - - struct B : A { }; - - struct C : A { }; - - struct D : B, C { - A &getA() { return static_cast<B&>(*this); } - - void test_a() { - getA().a<int>(); - } - }; -} - -namespace PR11856 { - template<typename T> T end(T); - - template <typename T> - void Foo() { - T it1; - if (it1->end < it1->end) { - } - } - - template<typename T> T *end(T*); - - class X { }; - template <typename T> - void Foo2() { - T it1; - if (it1->end < it1->end) { - } - - X *x; - if (x->end < 7) { // expected-error{{no member named 'end' in 'PR11856::X'}} - } - } -} diff --git a/test/CXX/basic/basic.lookup/basic.lookup.classref/p3.cpp b/test/CXX/basic/basic.lookup/basic.lookup.classref/p3.cpp deleted file mode 100644 index ef4243e28e89..000000000000 --- a/test/CXX/basic/basic.lookup/basic.lookup.classref/p3.cpp +++ /dev/null @@ -1,31 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -// expected-no-diagnostics - -// C++0x [basic.lookup.classref]p3: -// If the unqualified-id is ~type-name, the type-name is looked up in the -// context of the entire postfix-expression. If the type T of the object -// expression is of a class type C, the type-name is also looked up in the -// scope of class C. At least one of the lookups shall find a name that -// refers to (possibly cv-qualified) T. - -// From core issue 305 -struct A { -}; - -struct C { - struct A {}; - void f (); -}; - -void C::f () { - ::A *a; - a->~A (); -} - -// From core issue 414 -struct X {}; -void f() { - X x; - struct X {}; - x.~X(); -} diff --git a/test/CXX/basic/basic.lookup/basic.lookup.classref/p4-cxx11.cpp b/test/CXX/basic/basic.lookup/basic.lookup.classref/p4-cxx11.cpp deleted file mode 100644 index a4721d61a871..000000000000 --- a/test/CXX/basic/basic.lookup/basic.lookup.classref/p4-cxx11.cpp +++ /dev/null @@ -1,22 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 %s -verify -// expected-no-diagnostics - -struct A { void f(); }; -struct C { void f(); }; -struct B : A { typedef A X; }; -struct D : C { typedef C X; void g(); }; - -void D::g() -{ - B * b = new B; - b->X::f(); // lookup for X finds B::X -} - -typedef int X; -void h(void) -{ - B * b = new B; - b->X::f(); // lookup for X finds B::X -} - - diff --git a/test/CXX/basic/basic.lookup/basic.lookup.elab/p2.cpp b/test/CXX/basic/basic.lookup/basic.lookup.elab/p2.cpp deleted file mode 100644 index ca17ba50ac29..000000000000 --- a/test/CXX/basic/basic.lookup/basic.lookup.elab/p2.cpp +++ /dev/null @@ -1,60 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s - -namespace test0 { - struct A { - static int foo; - }; - - namespace i0 { - typedef int A; // expected-note {{declared here}} - - int test() { - struct A a; // expected-error {{typedef 'A' cannot be referenced with a struct specifier}} - return a.foo; - } - } - - namespace i1 { - template <class> class A; // expected-note {{declared here}} - - int test() { - struct A a; // expected-error {{template 'A' cannot be referenced with a struct specifier}} - return a.foo; - } - } - - namespace i2 { - int A; - - int test() { - struct A a; - return a.foo; - } - } - - namespace i3 { - void A(); - - int test() { - struct A a; - return a.foo; - } - } - - namespace i4 { - template <class T> void A(); - - int test() { - struct A a; - return a.foo; - } - } - - // This should magically be okay; see comment in SemaDecl.cpp. - // rdar://problem/7898108 - typedef struct A A; - int test() { - struct A a; - return a.foo; - } -} diff --git a/test/CXX/basic/basic.lookup/basic.lookup.elab/templateid.cpp b/test/CXX/basic/basic.lookup/basic.lookup.elab/templateid.cpp deleted file mode 100644 index 8126d28562ae..000000000000 --- a/test/CXX/basic/basic.lookup/basic.lookup.elab/templateid.cpp +++ /dev/null @@ -1,18 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s - -// elaborated-type-specifier: -// class-key '::'? nested-name-specifier? 'template'? simple-template-id -// Tests that this form is accepted by the compiler but does not follow -// the elaborated lookup rules of [basic.lookup.elab]. - -template <typename> class Ident {}; // expected-note {{previous use is here}} - -namespace A { - template <typename> void Ident(); - - class Ident<int> AIdent; // expected-error {{refers to a function template}} - class ::Ident<int> AnotherIdent; -} - -class Ident<int> GlobalIdent; -union Ident<int> GlobalIdent2; // expected-error {{ tag type that does not match }} diff --git a/test/CXX/basic/basic.lookup/basic.lookup.qual/class.qual/p2.cpp b/test/CXX/basic/basic.lookup/basic.lookup.qual/class.qual/p2.cpp deleted file mode 100644 index 73e0369e608e..000000000000 --- a/test/CXX/basic/basic.lookup/basic.lookup.qual/class.qual/p2.cpp +++ /dev/null @@ -1,218 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s -struct X0 { - X0(); - X0(int); - X0 f1(); - X0 f2(); - typedef int A; - typedef X0 B; -}; - -template<typename T> -struct X1 : X0 { - X1(); - X1<T>(int); - (X1<T>)(float); - X1 f2(); - X1 f2(int); - X1 f2(float); - X1 f2(double); - X1 f2(short); - X1 f2(long); -}; - -// Error recovery: out-of-line constructors whose names have template arguments. -template<typename T> X1<T>::X1<T>(int) { } // expected-error{{out-of-line constructor for 'X1' cannot have template arguments}} -template<typename T> (X1<T>::X1<T>)(float) { } // expected-error{{out-of-line constructor for 'X1' cannot have template arguments}} - -// Error recovery: out-of-line constructor names intended to be types -X0::X0 X0::f1() { return X0(); } // expected-error{{qualified reference to 'X0' is a constructor name rather than a type in this context}} - -struct X0::X0 X0::f2() { return X0(); } - -template<typename T> X1<T>::X1<T> X1<T>::f2() { } // expected-error{{missing 'typename'}} -template<typename T> X1<T>::X1<T> (X1<T>::f2)(int) { } // expected-error{{missing 'typename'}} -template<typename T> struct X1<T>::X1<T> (X1<T>::f2)(float) { } -template<typename T> struct X1<T>::X1 (X1<T>::f2)(double) { } -template<typename T> typename X1<T>::template X1<T> X1<T>::f2(short) { } // expected-warning {{qualified reference to 'X1' is a constructor name rather than a template name in this context}} -template<typename T> typename X1<T>::template X1<T> (X1<T>::f2)(long) { } // expected-warning {{qualified reference to 'X1' is a constructor name rather than a template name in this context}} - -void x1test(X1<int> x1i) { - x1i.f2(); - x1i.f2(0); - x1i.f2(0.f); - x1i.f2(0.); -} - -void other_contexts() { - X0::X0 x0; // expected-error{{qualified reference to 'X0' is a constructor name rather than a type in this context}} - X1<int>::X1 x1a; // expected-error{{qualified reference to 'X1' is a constructor name rather than a type in this context}} - X1<int>::X1<float> x1b; // expected-error{{qualified reference to 'X1' is a constructor name rather than a template name in this context}} - - X0::B ok1; - X0::X0::A ok2; - X0::X0::X0 x0b; // expected-error{{qualified reference to 'X0' is a constructor name rather than a type in this context}} - X1<int>::X0 ok3; - X1<int>::X0::X0 x0c; // expected-error{{qualified reference to 'X0' is a constructor name rather than a type in this context}} - X1<int>::X1<float>::X0 ok4; - - { - typename X0::X0 tn1; // expected-warning{{qualified reference to 'X0' is a constructor name rather than a type in this context}} expected-warning 0-1{{typename}} - typename X1<int>::X1<float> tn2; // expected-warning{{qualified reference to 'X1' is a constructor name rather than a template name in this context}} expected-warning 0-1{{typename}} - typename X0::B ok1; // expected-warning 0-1{{typename}} - typename X1<int>::X0 ok2; // expected-warning 0-1{{typename}} - } - - { - struct X0::X0 tag1; - struct X1<int>::X1 tag2; - struct X1<int>::X1<int> tag3; - } - - int a; - { - X0::X0(a); // expected-error{{qualified reference to 'X0' is a constructor name rather than a type in this context}} - // expected-warning@-1 {{redundant parentheses around declaration of variable named 'a'}} expected-note@-1 2{{}} - } -} - -template<typename T> void in_instantiation_x0() { - typename T::X0 x0; // expected-warning{{qualified reference to 'X0' is a constructor name rather than a type in this context}} - typename T::A a; - typename T::B b; -} -template void in_instantiation_x0<X0>(); // expected-note {{instantiation of}} - -template<typename T> void in_instantiation_x1() { - typename T::X1 x1; // expected-warning{{qualified reference to 'X1' is a constructor name rather than a type in this context}} - typename T::template X1<int> x1i; // expected-warning{{qualified reference to 'X1' is a constructor name rather than a template name in this context}} - typename T::X0 x0; -} -template void in_instantiation_x1<X1<int> >(); // expected-note {{instantiation of}} - -namespace sfinae { - template<typename T> void f(typename T::X0 *) = delete; // expected-warning 0-1{{extension}} - template<typename T> void f(...); - void g() { f<X0>(0); } -} - -namespace versus_injected_class_name { - template <typename T> struct A : T::B { - struct T::B *p; - typename T::B::type a; - A() : T::B() {} - - typename T::B b; // expected-warning {{qualified reference to 'B' is a constructor name rather than a type in this context}} - }; - struct B { - typedef int type; - }; - template struct A<B>; // expected-note {{in instantiation of}} -} - -// We have a special case for lookup within using-declarations that are -// member-declarations: foo::bar::baz::baz always names baz's constructor -// in such a context, even if looking up 'baz' within foo::bar::baz would -// not find the injected-class-name. Likewise foo::bar::baz<T>::baz also -// names the constructor. -namespace InhCtor { - struct A { - A(int); - protected: - int T(); - }; - typedef A T; - struct B : A { - // This is a using-declaration for 'int A::T()' in C++98, but is an - // inheriting constructor declaration in C++11. - using InhCtor::T::T; - }; -#if __cplusplus < 201103L - B b(123); // expected-error {{no matching constructor}} - // expected-note@-7 2{{candidate constructor}} - int n = b.T(); // ok, accessible -#else - B b(123); // ok, inheriting constructor - int n = b.T(); // expected-error {{'T' is a protected member of 'InhCtor::A'}} - // expected-note@-15 {{declared protected here}} - - // FIXME: EDG and GCC reject this too, but it's not clear why it would be - // ill-formed. - template<typename T> - struct S : T { - struct U : S { // expected-note 6{{candidate}} - using S::S; - }; - using T::T; - }; - S<A>::U ua(0); // expected-error {{no match}} - S<B>::U ub(0); // expected-error {{no match}} - - template<typename T> - struct X : T { - using T::Z::U::U; - }; - template<typename T> - struct X2 : T { - using T::Z::template V<int>::V; - }; - struct Y { - struct Z { - typedef Y U; - template<typename T> using V = Y; - }; - Y(int); - }; - X<Y> xy(0); - - namespace Repeat { - struct A { - struct T { - T(int); - }; - }; - struct Z : A { - using A::A::A; - }; - template<typename T> - struct ZT : T::T { - using T::T::T; - }; - } - - namespace NS { - struct NS {}; - } - struct DerivedFromNS : NS::NS { - // No special case unless the NNS names a class. - using InhCtor::NS::NS; // expected-error {{using declaration in class refers into 'InhCtor::NS::', which is not a class}} - - }; - - // FIXME: Consider reusing the same diagnostic between dependent and non-dependent contexts - typedef int I; - struct UsingInt { - using I::I; // expected-error {{'InhCtor::I' (aka 'int') is not a class, namespace, or enumeration}} - }; - template<typename T> struct UsingIntTemplate { - using T::T; // expected-error {{type 'int' cannot be used prior to '::' because it has no members}} - }; - UsingIntTemplate<int> uit; // expected-note {{here}} - - // This case is odd: we don't name the constructor of a dependent base as - // Base::Base, but we still happen to have enough information to identify - // when parsing the template that we're inheriting constructors. - // - // FIXME: Once CWG 2070 is resolved, check whether this case should be - // accepted or not. - namespace DependentCtorName { - template <typename T> struct B { B(int); }; - template <typename T> struct A : B<T> { - using X = B<T>; - using X::B; - }; - A<int> ab = 0; - } -#endif -} diff --git a/test/CXX/basic/basic.lookup/basic.lookup.qual/namespace.qual/p2.cpp b/test/CXX/basic/basic.lookup/basic.lookup.qual/namespace.qual/p2.cpp deleted file mode 100644 index ed6c6c0bccf1..000000000000 --- a/test/CXX/basic/basic.lookup/basic.lookup.qual/namespace.qual/p2.cpp +++ /dev/null @@ -1,86 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s - -namespace Ints { - int zero = 0; // expected-note {{candidate found by name lookup is 'Ints::zero'}} - void f(int); // expected-note 3 {{candidate function}} - void g(int); -} - -namespace Floats { - float zero = 0.0f; // expected-note {{candidate found by name lookup is 'Floats::zero'}} - void f(float); // expected-note 3 {{candidate function}} - void g(float); -} - -namespace Numbers { - using namespace Ints; - using namespace Floats; -} - -void test() { - int i = Ints::zero; - Ints::f(i); - - float f = Floats::zero; - Floats::f(f); - - double n = Numbers::zero; // expected-error {{reference to 'zero' is ambiguous}} - Numbers::f(n); // expected-error{{call to 'f' is ambiguous}} - Numbers::f(i); - Numbers::f(f); -} - -namespace Numbers { - struct Number { // expected-note 2 {{candidate constructor (the implicit copy constructor) not viable}} -#if __cplusplus >= 201103L // C++11 or later - // expected-note@-2 2 {{candidate constructor (the implicit move constructor) not viable}} -#endif - - explicit Number(double d) : d(d) {} - double d; - }; - Number zero(0.0f); - void g(Number); // expected-note 2{{passing argument to parameter here}} -} - -void test2() { - Numbers::Number n = Numbers::zero; - Numbers::f(n); // expected-error {{no matching function for call to 'f'}} - Numbers::g(n); -} - -namespace Numbers2 { - using Numbers::f; - using Numbers::g; -} - -void test3() { - Numbers::Number n = Numbers::zero; - Numbers2::f(n); // expected-error {{no matching function for call to 'f'}} - Numbers2::g(n); - - int i = Ints::zero; - Numbers2::f(i); - Numbers2::g(i); // expected-error {{no viable conversion from 'int' to 'Numbers::Number'}} - - float f = Floats::zero; - Numbers2::f(f); - Numbers2::g(f); // expected-error {{no viable conversion from 'float' to 'Numbers::Number'}} -} - -namespace inline_ns { - int x; // expected-note 2{{found}} - inline namespace A { -#if __cplusplus <= 199711L // C++03 or earlier - // expected-warning@-2 {{inline namespaces are a C++11 feature}} -#endif - - int x; // expected-note 2{{found}} - int y; // expected-note 2{{found}} - } - int y; // expected-note 2{{found}} - int k1 = x + y; // expected-error 2{{ambiguous}} - int k2 = inline_ns::x + inline_ns::y; // expected-error 2{{ambiguous}} -} diff --git a/test/CXX/basic/basic.lookup/basic.lookup.qual/namespace.qual/p3.cpp b/test/CXX/basic/basic.lookup/basic.lookup.qual/namespace.qual/p3.cpp deleted file mode 100644 index 1060f6159911..000000000000 --- a/test/CXX/basic/basic.lookup/basic.lookup.qual/namespace.qual/p3.cpp +++ /dev/null @@ -1,42 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -// expected-no-diagnostics - -// This is basically paraphrased from the standard. - -namespace Root { - int i = 0; - void f(); -} - -namespace A { - using namespace Root; -} - -namespace B { - using namespace Root; -} - -namespace AB { - using namespace A; - using namespace B; -} - -void test() { - if (AB::i) - AB::f(); -} - -namespace C { - using Root::i; - using Root::f; -} - -namespace AC { - using namespace A; - using namespace C; -} - -void test2() { - if (AC::i) - AC::f(); -} diff --git a/test/CXX/basic/basic.lookup/basic.lookup.qual/namespace.qual/p4.cpp b/test/CXX/basic/basic.lookup/basic.lookup.qual/namespace.qual/p4.cpp deleted file mode 100644 index 7c292d58f500..000000000000 --- a/test/CXX/basic/basic.lookup/basic.lookup.qual/namespace.qual/p4.cpp +++ /dev/null @@ -1,26 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -// expected-no-diagnostics - -namespace A { - int a; -} - -namespace C { - int c; -} - -namespace B { - using namespace C; - int b; -} - -namespace C { - using namespace B; - using namespace A; -} - -void test() { - C::a++; - C::b++; - C::c++; -} diff --git a/test/CXX/basic/basic.lookup/basic.lookup.qual/namespace.qual/p5.cpp b/test/CXX/basic/basic.lookup/basic.lookup.qual/namespace.qual/p5.cpp deleted file mode 100644 index 5045baccb4d0..000000000000 --- a/test/CXX/basic/basic.lookup/basic.lookup.qual/namespace.qual/p5.cpp +++ /dev/null @@ -1,35 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s - -namespace A { - struct x {}; // expected-note {{candidate found by name lookup is 'A::x'}} - int x; // expected-note {{candidate found by name lookup is 'A::x'}} - - struct y {}; // expected-note {{type declaration hidden}} - - struct z; - void z(float); -} - -namespace B { - struct x {}; // expected-note {{candidate found by name lookup is 'B::x'}} - float x; // expected-note {{candidate found by name lookup is 'B::x'}} - - float y; // expected-note {{declaration hides type}} - - void z(int); -} - -namespace AB { - using namespace A; - using namespace B; -} - -void test() { - struct AB::x foo; // expected-error {{reference to 'x' is ambiguous}} - int i = AB::x; // expected-error {{reference to 'x' is ambiguous}} - - struct AB::y bar; - float f = AB::y; // expected-error {{a type named 'y' is hidden by a declaration in a different namespace}} - AB::z(i); - AB::z(f); -} diff --git a/test/CXX/basic/basic.lookup/basic.lookup.qual/p6-0x.cpp b/test/CXX/basic/basic.lookup/basic.lookup.qual/p6-0x.cpp deleted file mode 100644 index c3be712ddbca..000000000000 --- a/test/CXX/basic/basic.lookup/basic.lookup.qual/p6-0x.cpp +++ /dev/null @@ -1,25 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s -// expected-no-diagnostics - -struct C { - typedef int I; -}; - -typedef int I1, I2; -extern int* p; -extern int* q; - -void f() { - p->C::I::~I(); - q->I1::~I2(); -} - -struct A { - ~A(); -}; - -typedef A AB; -int main() { - AB *p; - p->AB::~AB(); -} diff --git a/test/CXX/basic/basic.lookup/basic.lookup.qual/p6.cpp b/test/CXX/basic/basic.lookup/basic.lookup.qual/p6.cpp deleted file mode 100644 index 83c8dd8fc22d..000000000000 --- a/test/CXX/basic/basic.lookup/basic.lookup.qual/p6.cpp +++ /dev/null @@ -1,25 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -// expected-no-diagnostics - -struct C { - typedef int I; -}; - -typedef int I1, I2; -extern int* p; -extern int* q; - -void f() { - p->C::I::~I(); - q->I1::~I2(); -} - -struct A { - ~A(); -}; - -typedef A AB; -int main() { - AB *p; - p->AB::~AB(); -} diff --git a/test/CXX/basic/basic.lookup/basic.lookup.udir/p1.cpp b/test/CXX/basic/basic.lookup/basic.lookup.udir/p1.cpp deleted file mode 100644 index 91f5a54eb9ce..000000000000 --- a/test/CXX/basic/basic.lookup/basic.lookup.udir/p1.cpp +++ /dev/null @@ -1,36 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -// expected-no-diagnostics - -// When looking up a namespace-name in a using-directive or -// namespace-alias-definition, only namespace names are considered. - -struct ns1 {}; -void ns2(); -int ns3 = 0; - -namespace ns0 { - namespace ns1 { - struct test0 {}; - } - namespace ns2 { - struct test1 {}; - } - namespace ns3 { - struct test2 {}; - } -} - -using namespace ns0; - -namespace test3 = ns1; -namespace test4 = ns2; -namespace test5 = ns3; - -using namespace ns1; -using namespace ns2; -using namespace ns3; - -test0 a; -test1 b; -test2 c; - diff --git a/test/CXX/basic/basic.lookup/basic.lookup.unqual/p11.cpp b/test/CXX/basic/basic.lookup/basic.lookup.unqual/p11.cpp deleted file mode 100644 index a1cf529741b9..000000000000 --- a/test/CXX/basic/basic.lookup/basic.lookup.unqual/p11.cpp +++ /dev/null @@ -1,12 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s - -static const int a = 10; - -void f0(int a, - int b = a) { // expected-error {{default argument references parameter 'a'}} -} - -template<int a, - int b = a> -class A { -}; diff --git a/test/CXX/basic/basic.lookup/basic.lookup.unqual/p12.cpp b/test/CXX/basic/basic.lookup/basic.lookup.unqual/p12.cpp deleted file mode 100644 index 6bf74c1da131..000000000000 --- a/test/CXX/basic/basic.lookup/basic.lookup.unqual/p12.cpp +++ /dev/null @@ -1,14 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -// expected-no-diagnostics - -struct S {}; -S E0; - -namespace { - enum { - E0 = 1, - E1 = E0 + 1 - }; -} - - diff --git a/test/CXX/basic/basic.lookup/basic.lookup.unqual/p13.cpp b/test/CXX/basic/basic.lookup/basic.lookup.unqual/p13.cpp deleted file mode 100644 index ba34571d7b6c..000000000000 --- a/test/CXX/basic/basic.lookup/basic.lookup.unqual/p13.cpp +++ /dev/null @@ -1,9 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -// expected-no-diagnostics - -struct S { - static const int f0 = 0; - static int f1; -}; - -int S::f1 = f0; diff --git a/test/CXX/basic/basic.lookup/basic.lookup.unqual/p14.cpp b/test/CXX/basic/basic.lookup/basic.lookup.unqual/p14.cpp deleted file mode 100644 index 6fba97298981..000000000000 --- a/test/CXX/basic/basic.lookup/basic.lookup.unqual/p14.cpp +++ /dev/null @@ -1,72 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -// expected-no-diagnostics - -// C++0x [basic.lookup.unqual]p14: -// If a variable member of a namespace is defined outside of the -// scope of its namespace then any name used in the definition of -// the variable member (after the declarator-id) is looked up as if -// the definition of the variable member occurred in its namespace. - -namespace N { - struct S {}; - S i; - extern S j; - extern S j2; -} - -int i = 2; -N::S N::j = i; -N::S N::j2(i); - -// <rdar://problem/13317030> -namespace M { - class X { }; - inline X operator-(int, X); - - template<typename T> - class Y { }; - - typedef Y<float> YFloat; - - namespace yfloat { - YFloat operator-(YFloat, YFloat); - } - using namespace yfloat; -} - -using namespace M; - -namespace M { - -class Other { - void foo(YFloat a, YFloat b); -}; - -} - -void Other::foo(YFloat a, YFloat b) { - YFloat c = a - b; -} - -// <rdar://problem/13540899> -namespace Other { - void other_foo(); -} - -namespace M2 { - using namespace Other; - - extern "C" { - namespace MInner { - extern "C" { - class Bar { - void bar(); - }; - } - } - } -} - -void M2::MInner::Bar::bar() { - other_foo(); -} diff --git a/test/CXX/basic/basic.lookup/basic.lookup.unqual/p15.cpp b/test/CXX/basic/basic.lookup/basic.lookup.unqual/p15.cpp deleted file mode 100644 index c59c4a550d7a..000000000000 --- a/test/CXX/basic/basic.lookup/basic.lookup.unqual/p15.cpp +++ /dev/null @@ -1,21 +0,0 @@ -// RUN: %clang_cc1 -fexceptions -fcxx-exceptions -fsyntax-only -verify %s - -class C { -public: - C(int a, int b); -}; - -C::C(int a, // expected-note {{previous definition}} - int b) // expected-note {{previous definition}} -try { - int c; -} catch (int a) { // expected-error {{redefinition of 'a'}} - int b; // expected-error {{redefinition of 'b'}} - ++c; // expected-error {{use of undeclared identifier 'c'}} -} - -void f(int i) { - struct S { - void g() try {} catch (int i) {}; // OK - }; -} diff --git a/test/CXX/basic/basic.lookup/basic.lookup.unqual/p3.cpp b/test/CXX/basic/basic.lookup/basic.lookup.unqual/p3.cpp deleted file mode 100644 index abcc6eee94a7..000000000000 --- a/test/CXX/basic/basic.lookup/basic.lookup.unqual/p3.cpp +++ /dev/null @@ -1,25 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -// expected-no-diagnostics - -typedef int f; - -namespace N0 { - struct A { - friend void f(); - void g() { - int i = f(1); - } - }; -} - -namespace N1 { - struct A { - friend void f(A &); - operator int(); - void g(A a) { - // ADL should not apply to the lookup of 'f', it refers to the typedef - // above. - int i = f(a); - } - }; -} diff --git a/test/CXX/basic/basic.lookup/basic.lookup.unqual/p7.cpp b/test/CXX/basic/basic.lookup/basic.lookup.unqual/p7.cpp deleted file mode 100644 index 9632fda296aa..000000000000 --- a/test/CXX/basic/basic.lookup/basic.lookup.unqual/p7.cpp +++ /dev/null @@ -1,37 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s - -// PR5741 -namespace test0 { - struct A { - struct B { }; - struct C; - }; - - struct A::C : B { }; -} - -// Test that successive base specifiers don't screw with each other. -namespace test1 { - struct Opaque1 {}; - struct Opaque2 {}; - - struct A { - struct B { B(Opaque1); }; - }; - struct B { - B(Opaque2); - }; - - struct C : A, B { - // Apparently the base-or-member lookup is actually ambiguous - // without this qualification. - C() : A(), test1::B(Opaque2()) {} - }; -} - -// Test that we don't find the injected class name when parsing base -// specifiers. -namespace test2 { - template <class T> struct bar {}; - template <class T> struct foo : bar<foo> {}; // expected-error {{use of class template 'foo' requires template arguments}} expected-note {{template is declared here}} -} diff --git a/test/CXX/basic/basic.scope/basic.scope.declarative/p4.cpp b/test/CXX/basic/basic.scope/basic.scope.declarative/p4.cpp deleted file mode 100644 index 8c14546edc74..000000000000 --- a/test/CXX/basic/basic.scope/basic.scope.declarative/p4.cpp +++ /dev/null @@ -1,19 +0,0 @@ -// RUN: %clang_cc1 -std=c++2a -verify %s - -namespace TagVs { - struct Bindable { int a; }; - struct binding_a {}; // expected-note {{previous}} - auto [binding_a] = Bindable{}; // expected-error {{redefinition}} - auto [binding_b] = Bindable{}; // expected-note {{previous}} - struct binding_b {}; // expected-error {{redefinition}} - - struct vartemplate_a {}; // expected-note {{previous}} - template<typename T> int vartemplate_a; // expected-error {{redefinition}} - template<typename T> int vartemplate_b; // expected-note {{previous}} - struct vartemplate_b {}; // expected-error {{redefinition}} - - struct aliastemplate_a {}; // expected-note {{previous}} - template<typename T> using aliastemplate_a = int; // expected-error {{redefinition}} - template<typename T> using aliastemplate_b = int; // expected-note {{previous}} - struct aliastemplate_b {}; // expected-error {{redefinition}} -} diff --git a/test/CXX/basic/basic.scope/basic.scope.hiding/p2.cpp b/test/CXX/basic/basic.scope/basic.scope.hiding/p2.cpp deleted file mode 100644 index bf8df1abee4e..000000000000 --- a/test/CXX/basic/basic.scope/basic.scope.hiding/p2.cpp +++ /dev/null @@ -1,77 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s - -// rdar4641403 -namespace N { - struct X { // expected-note{{candidate found by name lookup}} - float b; - }; -} - -using namespace N; - -typedef struct { - int a; -} X; // expected-note{{candidate found by name lookup}} - - -struct Y { }; -void Y(int) { } - -void f() { - X *x; // expected-error{{reference to 'X' is ambiguous}} - Y(1); // okay -} - -namespace PR17731 { - void f() { - struct S { S() {} }; - int S(void); - int a = S(); - struct S b; - { - int S(void); - int a = S(); - struct S c = b; - } - { - struct S { S() {} }; // expected-note {{candidate constructor (the implicit copy constructor) not viable}} -#if __cplusplus >= 201103L // C++11 or later - // expected-note@-2 {{candidate constructor (the implicit move constructor) not viable}} -#endif - int a = S(); // expected-error {{no viable conversion from 'S'}} - struct S c = b; // expected-error {{no viable conversion from 'struct S'}} - } - } - void g() { - int S(void); - struct S { S() {} }; - int a = S(); - struct S b; - { - int S(void); - int a = S(); - struct S c = b; - } - { - struct S { S() {} }; // expected-note {{candidate constructor (the implicit copy constructor) not viable}} -#if __cplusplus >= 201103L // C++11 or later - // expected-note@-2 {{candidate constructor (the implicit move constructor) not viable}} -#endif - int a = S(); // expected-error {{no viable conversion from 'S'}} - struct S c = b; // expected-error {{no viable conversion from 'struct S'}} - } - } - - struct A { - struct B; - void f(); - int B; - }; - struct A::B {}; - void A::f() { - B = 123; - struct B b; - } -} diff --git a/test/CXX/basic/basic.scope/basic.scope.local/p2.cpp b/test/CXX/basic/basic.scope/basic.scope.local/p2.cpp deleted file mode 100644 index 1b4199155fae..000000000000 --- a/test/CXX/basic/basic.scope/basic.scope.local/p2.cpp +++ /dev/null @@ -1,66 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -fsyntax-only -fcxx-exceptions -fexceptions -verify %s - -void func1(int i) { // expected-note{{previous definition is here}} - int i; // expected-error{{redefinition of 'i'}} -} - -void func2(int i) try { // expected-note{{previous definition is here}} - int i; // expected-error{{redefinition of 'i'}} -} catch (...) { -} - -void func3(int i) try { // expected-note {{previous definition is here}} -} catch (int i) { // expected-error {{redefinition of 'i'}} -} - -void func4(int i) try { // expected-note{{previous definition is here}} -} catch (...) { - int i; // expected-error{{redefinition of 'i'}} -} - -void func5() try { - int i; -} catch (...) { - int j = i; // expected-error{{use of undeclared identifier 'i'}} -} - -void func6() try { -} catch (int i) { // expected-note{{previous definition is here}} - int i; // expected-error{{redefinition of 'i'}} -} - -void func7() { - try { - } catch (int i) { // expected-note{{previous definition is here}} - int i; // expected-error{{redefinition of 'i'}} - } -} - -void func8() { - int i; - try { - int i; - } catch (...) { - } -} - -void func9() { - if (bool b = true) - try { - int b; // FIXME: this probably should be invalid, maybe - } catch (...) { - } -} - -void func10() { - if (bool b = true) - if (true) { - int b; // FIXME: decide whether this is valid - } -} - -void func11(int a) { - try { - } catch (int a) { // OK - } -} diff --git a/test/CXX/basic/basic.scope/basic.scope.local/p4-0x.cpp b/test/CXX/basic/basic.scope/basic.scope.local/p4-0x.cpp deleted file mode 100644 index cd51c78a5e9c..000000000000 --- a/test/CXX/basic/basic.scope/basic.scope.local/p4-0x.cpp +++ /dev/null @@ -1,68 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s - -void f() { - int b; - int arr[] = {1, 2, 3}; - - if (bool b = true) // expected-note 2{{previous definition}} - bool b; // expected-error {{redefinition}} - else - int b; // expected-error {{redefinition}} - while (bool b = true) // expected-note {{previous definition}} - int b; // expected-error {{redefinition}} - for (int c; // expected-note 2{{previous definition}} - bool c = true;) // expected-error {{redefinition}} - double c; // expected-error {{redefinition}} - switch (int n = 37 + 5) // expected-note {{previous definition}} - int n; // expected-error {{redefinition}} - for (int a : arr) // expected-note {{previous definition}} - int a = 0; // expected-error {{redefinition}} - - if (bool b = true) { // expected-note 2{{previous definition}} - int b; // expected-error {{redefinition}} - } else { - int b; // expected-error {{redefinition}} - } - while (bool b = true) { // expected-note {{previous definition}} - int b; // expected-error {{redefinition}} - } - for (int c; // expected-note 2{{previous definition}} - bool c = true;) { // expected-error {{redefinition}} - double c; // expected-error {{redefinition}} - } - switch (int n = 37 + 5) { // expected-note {{previous definition}} - int n; // expected-error {{redefinition}} - } - for (int &a : arr) { // expected-note {{previous definition}} - int a = 0; // expected-error {{redefinition}} - } - - if (bool b = true) {{ // expected-note {{previous definition}} - bool b; - }} else { - int b; // expected-error {{redefinition}} - } - if (bool b = true) { // expected-note {{previous definition}} - bool b; // expected-error {{redefinition}} - } else {{ - int b; - }} - if (bool b = true) {{ - bool b; - }} else {{ - int b; - }} - while (bool b = true) {{ - int b; - }} - for (int c; // expected-note {{previous definition}} - bool c = true; ) {{ // expected-error {{redefinition}} - double c; - }} - switch (int n = 37 + 5) {{ - int n; - }} - for (int &a : arr) {{ - int a = 0; - }} -} diff --git a/test/CXX/basic/basic.scope/basic.scope.pdecl/p3.cpp b/test/CXX/basic/basic.scope/basic.scope.pdecl/p3.cpp deleted file mode 100644 index 407a5f744e37..000000000000 --- a/test/CXX/basic/basic.scope/basic.scope.pdecl/p3.cpp +++ /dev/null @@ -1,26 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s - -// Classes. -namespace Class { - namespace NS { - class C {}; // expected-note {{candidate}} - } - using namespace NS; - class C : C {}; // expected-error {{reference to 'C' is ambiguous}} \ - expected-note {{candidate}} -} - -// Enumerations. -enum E { - EPtrSize = sizeof((E*)0) // ok, E is already declared -}; - -// Alias declarations. clang implements the proposed resolution to N1044. -namespace Alias { - namespace NS { - class C; - } - using namespace NS; - using C = C; // ok, C = B::C - using C = NS::C; // ok, same type -} diff --git a/test/CXX/basic/basic.scope/basic.scope.pdecl/p9.cpp b/test/CXX/basic/basic.scope/basic.scope.pdecl/p9.cpp deleted file mode 100644 index c62753538040..000000000000 --- a/test/CXX/basic/basic.scope/basic.scope.pdecl/p9.cpp +++ /dev/null @@ -1,19 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -// expected-no-diagnostics - -// Template type parameters. -typedef unsigned char T; -template<typename T = T> struct X0 { }; -template<> struct X0<unsigned char> { static const bool value = true; }; -int array0[X0<>::value? 1 : -1]; - -// Non-type template parameters. -const int N = 17; -template<int N = N> struct X1 { }; -template<> struct X1<17> { static const bool value = true; }; -int array1[X1<>::value? 1 : -1]; - -// Template template parameters. -template<template<class> class X0 = X0> struct X2 { }; -template<> struct X2<X0> { static const bool value = true; }; -int array2[X2<>::value? 1 : -1]; diff --git a/test/CXX/basic/basic.start/basic.start.init/p2.cpp b/test/CXX/basic/basic.start/basic.start.init/p2.cpp deleted file mode 100644 index 36158210ac93..000000000000 --- a/test/CXX/basic/basic.start/basic.start.init/p2.cpp +++ /dev/null @@ -1,21 +0,0 @@ -// RUN: %clang_cc1 -verify %s -pedantic-errors -std=c++11 -// RUN: %clang_cc1 -verify %s -pedantic-errors -std=c++14 -// expected-no-diagnostics - -struct foo_t { - union { - int i; - volatile int j; - } u; -}; - -__attribute__((__require_constant_initialization__)) -static const foo_t x = {{0}}; - -union foo_u { - int i; - volatile int j; -}; - -__attribute__((__require_constant_initialization__)) -static const foo_u y = {0}; diff --git a/test/CXX/basic/basic.start/basic.start.init/p3.cpp b/test/CXX/basic/basic.start/basic.start.init/p3.cpp deleted file mode 100644 index 506232ebacc4..000000000000 --- a/test/CXX/basic/basic.start/basic.start.init/p3.cpp +++ /dev/null @@ -1,24 +0,0 @@ -// RUN: %clang_cc1 -verify %s -pedantic-errors -// RUN: %clang_cc1 -verify %s -pedantic-errors -DINLINE -// RUN: %clang_cc1 -verify %s -pedantic-errors -DSTATIC -// RUN: %clang_cc1 -verify %s -pedantic-errors -std=c++11 -DCONSTEXPR -// RUN: %clang_cc1 -verify %s -std=c++11 -DDELETED - -#if INLINE -inline // expected-error {{'main' is not allowed to be declared inline}} -#elif STATIC -static // expected-error {{'main' is not allowed to be declared static}} -#elif CONSTEXPR -constexpr // expected-error {{'main' is not allowed to be declared constexpr}} -#endif -int main(int argc, char **argv) -#if DELETED - = delete; // expected-error {{'main' is not allowed to be deleted}} -#else -{ - int (*pmain)(int, char**) = &main; // expected-error {{ISO C++ does not allow 'main' to be used by a program}} - - if (argc) - main(0, 0); // expected-error {{ISO C++ does not allow 'main' to be used by a program}} -} -#endif diff --git a/test/CXX/basic/basic.start/basic.start.main/p2.cpp b/test/CXX/basic/basic.start/basic.start.main/p2.cpp deleted file mode 100644 index 42e87e5431f2..000000000000 --- a/test/CXX/basic/basic.start/basic.start.main/p2.cpp +++ /dev/null @@ -1,119 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -DTEST1 -// RUN: %clang_cc1 -fsyntax-only -verify %s -DTEST2 -// RUN: %clang_cc1 -fsyntax-only -verify %s -DTEST3 -// RUN: %clang_cc1 -fsyntax-only -verify %s -DTEST4 -// RUN: %clang_cc1 -fsyntax-only -verify %s -DTEST5 -// RUN: %clang_cc1 -fsyntax-only -verify %s -DTEST6 -// RUN: %clang_cc1 -fsyntax-only -verify %s -DTEST7 -// RUN: %clang_cc1 -fsyntax-only -verify %s -DTEST8 - -// RUN: cp %s %t -// RUN: %clang_cc1 -x c++ %s -std=c++11 -fsyntax-only -verify -DTEST9 -// RUN: not %clang_cc1 -x c++ %t -std=c++11 -fixit -DTEST9 -// RUN: %clang_cc1 -x c++ %t -std=c++11 -fsyntax-only -DTEST9 - -// RUN: %clang_cc1 -fsyntax-only -verify %s -DTEST10 -// RUN: %clang_cc1 -fsyntax-only -verify %s -DTEST11 -// RUN: %clang_cc1 -fsyntax-only -verify %s -DTEST12 -// RUN: %clang_cc1 -fsyntax-only -verify %s -DTEST13 -// RUN: %clang_cc1 -fsyntax-only -verify %s -DTEST14 - -#if TEST1 - -// expected-no-diagnostics -typedef int Int; -typedef char Char; -typedef Char* Carp; - -Int main(Int argc, Carp argv[]) { -} - -#elif TEST2 - -// expected-no-diagnostics -typedef int Int; -typedef char Char; -typedef Char* Carp; - -Int main(Int argc, Carp argv[], Char *env[]) { -} - -#elif TEST3 - -// expected-no-diagnostics -int main() { -} - -#elif TEST4 - -static int main() { // expected-error {{'main' is not allowed to be declared static}} -} - -#elif TEST5 - -inline int main() { // expected-error {{'main' is not allowed to be declared inline}} -} - -#elif TEST6 - -void // expected-error {{'main' must return 'int'}} -main( // expected-error {{first parameter of 'main' (argument count) must be of type 'int'}} - float a -) { -} - -const int main(); // expected-error {{'main' must return 'int'}} - -#elif TEST7 - -// expected-no-diagnostics -int main(int argc, const char* const* argv) { -} - -#elif TEST8 - -template<typename T> -int main() { } // expected-error{{'main' cannot be a template}} - -#elif TEST9 - -constexpr int main() { } // expected-error{{'main' is not allowed to be declared constexpr}} - -#elif TEST10 - -// PR15100 -// expected-no-diagnostics -typedef char charT; -int main(int, const charT**) {} - -#elif TEST11 - -// expected-no-diagnostics -typedef char charT; -int main(int, charT* const *) {} - -#elif TEST12 - -// expected-no-diagnostics -typedef char charT; -int main(int, const charT* const *) {} - -#elif TEST13 - -int main(void) {} - -template <typename T> -int main(void); // expected-error{{'main' cannot be a template}} - -#elif TEST14 - -template <typename T> -int main(void); // expected-error{{'main' cannot be a template}} - -int main(void) {} - -#else - -#error Unknown test mode - -#endif diff --git a/test/CXX/basic/basic.start/basic.start.main/p3.cpp b/test/CXX/basic/basic.start/basic.start.main/p3.cpp deleted file mode 100644 index f7085ca31d6c..000000000000 --- a/test/CXX/basic/basic.start/basic.start.main/p3.cpp +++ /dev/null @@ -1,66 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -DTEST1 -// RUN: %clang_cc1 -fsyntax-only -verify %s -DTEST2 -// RUN: %clang_cc1 -fsyntax-only -verify %s -DTEST3 -// RUN: %clang_cc1 -fsyntax-only -verify %s -DTEST4 -// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++14 -DTEST5 -// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++14 -DTEST6 -// RUN: %clang_cc1 -fsyntax-only -verify %s -DTEST7 -// RUN: %clang_cc1 -fsyntax-only -verify %s -DTEST8 -// RUN: %clang_cc1 -fsyntax-only -verify %s -DTEST9 -// RUN: %clang_cc1 -fsyntax-only -verify %s -DTEST10 -ffreestanding - -#if TEST1 -int main; // expected-error{{main cannot be declared as global variable}} - -#elif TEST2 -// expected-no-diagnostics -int f () { - int main; - return main; -} - -#elif TEST3 -// expected-no-diagnostics -void x(int main) {}; -int y(int main); - -#elif TEST4 -// expected-no-diagnostics -class A { - static int main; -}; - -#elif TEST5 -// expected-no-diagnostics -template<class T> constexpr T main; - -#elif TEST6 -extern template<class T> constexpr T main; //expected-error{{expected unqualified-id}} - -#elif TEST7 -// expected-no-diagnostics -namespace foo { - int main; -} - -#elif TEST8 -void z(void) -{ - extern int main; // expected-error{{main cannot be declared as global variable}} -} - -#elif TEST9 -// expected-no-diagnostics -int q(void) -{ - static int main; - return main; -} - -#elif TEST10 -// expected-no-diagnostics -int main; - -#else -#error Unknown Test -#endif diff --git a/test/CXX/basic/basic.stc/basic.stc.dynamic/basic.stc.dynamic.allocation/p1.cpp b/test/CXX/basic/basic.stc/basic.stc.dynamic/basic.stc.dynamic.allocation/p1.cpp deleted file mode 100644 index 3b77a62ce7d6..000000000000 --- a/test/CXX/basic/basic.stc/basic.stc.dynamic/basic.stc.dynamic.allocation/p1.cpp +++ /dev/null @@ -1,45 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -#include <stddef.h> - -struct A { - void *operator new(size_t); -}; - -namespace NS { - void *operator new(size_t);; // expected-error {{'operator new' cannot be declared inside a namespace}} -} - -static void *operator new(size_t); // expected-error {{static declaration of 'operator new' follows non-static declaration}} expected-note {{previous}} -static void *operator new(size_t, int, int); // expected-error {{'operator new' cannot be declared static in global scope}} - -struct B { - void operator new(size_t); // expected-error {{'operator new' must return type 'void *'}} -}; - -struct C { - void *operator new(); // expected-error {{'operator new' must have at least one parameter}} -}; - -struct D { - void *operator new(bool); // expected-error {{'operator new' takes type size_t}} -}; - -struct E { - void *operator new(size_t = 0); // expected-error {{parameter of 'operator new' cannot have a default argument}} -}; - -struct F { - template<typename T> void *operator new(size_t, int); -}; - -struct G { - template<typename T> T operator new(size_t, int); // expected-error {{'operator new' cannot have a dependent return type; use 'void *' instead}} -}; - -struct H { - template<typename T> void *operator new(T, int); // expected-error {{'operator new' cannot take a dependent type as first parameter; use size_t}} -}; - -struct I { - template<typename T> void *operator new(size_t); // expected-error {{'operator new' template must have at least two parameters}} -}; diff --git a/test/CXX/basic/basic.stc/basic.stc.dynamic/basic.stc.dynamic.deallocation/p1.cpp b/test/CXX/basic/basic.stc/basic.stc.dynamic/basic.stc.dynamic.deallocation/p1.cpp deleted file mode 100644 index 09dde8efde00..000000000000 --- a/test/CXX/basic/basic.stc/basic.stc.dynamic/basic.stc.dynamic.deallocation/p1.cpp +++ /dev/null @@ -1,12 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s - -struct A { - void operator delete(void*); -}; - -namespace NS { - void operator delete(void *); // expected-error {{'operator delete' cannot be declared inside a namespace}} -} - -static void operator delete(void *); // expected-error {{follows non-static declaration}} expected-note {{implicit}} -static void operator delete(void *, int, int); // expected-error {{'operator delete' cannot be declared static in global scope}} diff --git a/test/CXX/basic/basic.stc/basic.stc.dynamic/basic.stc.dynamic.deallocation/p2.cpp b/test/CXX/basic/basic.stc/basic.stc.dynamic/basic.stc.dynamic.deallocation/p2.cpp deleted file mode 100644 index 9e3210c6650f..000000000000 --- a/test/CXX/basic/basic.stc/basic.stc.dynamic/basic.stc.dynamic.deallocation/p2.cpp +++ /dev/null @@ -1,19 +0,0 @@ -// RUN: %clang_cc1 -std=c++1z -fsized-deallocation -fexceptions -verify %s - -using size_t = decltype(sizeof(0)); - -namespace std { enum class align_val_t : size_t {}; } - -// p2 says "A template instance is never a usual deallocation function, -// regardless of its signature." We (and every other implementation) assume -// this means "A function template specialization [...]" -template<typename...Ts> struct A { - void *operator new(size_t); - void operator delete(void*, Ts...) = delete; // expected-note 4{{deleted}} -}; - -auto *a1 = new A<>; // expected-error {{deleted}} -auto *a2 = new A<size_t>; // expected-error {{deleted}} -auto *a3 = new A<std::align_val_t>; // expected-error {{deleted}} -auto *a4 = new A<size_t, std::align_val_t>; // expected-error {{deleted}} -auto *a5 = new A<std::align_val_t, size_t>; // ok, not usual diff --git a/test/CXX/basic/basic.stc/basic.stc.dynamic/p2-nodef.cpp b/test/CXX/basic/basic.stc/basic.stc.dynamic/p2-nodef.cpp deleted file mode 100644 index 9a740df5cebe..000000000000 --- a/test/CXX/basic/basic.stc/basic.stc.dynamic/p2-nodef.cpp +++ /dev/null @@ -1,8 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -// expected-no-diagnostics - -int *use_new(int N) { - return new int [N]; -} - -int std = 17; diff --git a/test/CXX/basic/basic.stc/basic.stc.dynamic/p2-noexceptions.cpp b/test/CXX/basic/basic.stc/basic.stc.dynamic/p2-noexceptions.cpp deleted file mode 100644 index 41aeeee73eda..000000000000 --- a/test/CXX/basic/basic.stc/basic.stc.dynamic/p2-noexceptions.cpp +++ /dev/null @@ -1,16 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s -// RUN: %clang_cc1 -fsyntax-only -verify %s -// expected-no-diagnostics -namespace std { - class bad_alloc { }; - - typedef __SIZE_TYPE__ size_t; -} - -class foo { virtual ~foo(); }; - -void* operator new(std::size_t); -void* operator new[](std::size_t); -void operator delete(void*); -void operator delete[](void*); diff --git a/test/CXX/basic/basic.stc/basic.stc.dynamic/p2.cpp b/test/CXX/basic/basic.stc/basic.stc.dynamic/p2.cpp deleted file mode 100644 index 257aca1c3f7b..000000000000 --- a/test/CXX/basic/basic.stc/basic.stc.dynamic/p2.cpp +++ /dev/null @@ -1,41 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -fexceptions -fcxx-exceptions -verify -std=c++98 %s -// RUN: %clang_cc1 -fsyntax-only -fexceptions -fcxx-exceptions -verify -std=c++11 %s -// RUN: %clang_cc1 -fsyntax-only -fexceptions -fcxx-exceptions -verify %s -int *use_new(int N) { - if (N == 1) - return new int; - - return new int [N]; -} - -void use_delete(int* ip, int N) { - if (N == 1) - delete ip; - else - delete [] ip; -} - -namespace std { - class bad_alloc { }; - - typedef __SIZE_TYPE__ size_t; -} - -void* operator new(std::size_t) throw(std::bad_alloc); -#if __cplusplus < 201103L -// expected-note@-2 {{previous declaration}} -#endif -void* operator new[](std::size_t) throw(std::bad_alloc); -void operator delete(void*) throw(); // expected-note{{previous declaration}} -void operator delete[](void*) throw(); - -void* operator new(std::size_t); -#if __cplusplus < 201103L -// expected-warning@-2 {{'operator new' is missing exception specification 'throw(std::bad_alloc)'}} -#endif -void operator delete(void*); -#if __cplusplus < 201103L -// expected-warning@-2 {{'operator delete' is missing exception specification 'throw()'}} -#else -// expected-warning@-4 {{previously declared with an explicit exception specification redeclared with an implicit}} -#endif diff --git a/test/CXX/basic/basic.types/p10.cpp b/test/CXX/basic/basic.types/p10.cpp deleted file mode 100644 index 31ef6b62cead..000000000000 --- a/test/CXX/basic/basic.types/p10.cpp +++ /dev/null @@ -1,185 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++1y %s -DCXX1Y - -struct NonLiteral { NonLiteral(); }; - -// A type is a literal type if it is: - -// [C++1y] - void -constexpr void f() {} -#ifndef CXX1Y -// expected-error@-2 {{'void' is not a literal type}} -#endif - -// - a scalar type -constexpr int f1(double) { return 0; } - -// - a reference type -struct S { S(); }; -constexpr int f2(S &) { return 0; } - -struct BeingDefined; -extern BeingDefined beingdefined; -struct BeingDefined { - static constexpr BeingDefined& t = beingdefined; -}; - -// - a class type that has all of the following properties: - -// (implied) - it is complete - -struct Incomplete; // expected-note 2{{forward declaration of 'Incomplete'}} -template<class T> struct ClassTemp {}; - -constexpr Incomplete incomplete = {}; // expected-error {{constexpr variable cannot have non-literal type 'const Incomplete'}} expected-note {{incomplete type 'const Incomplete' is not a literal type}} -constexpr Incomplete incomplete2[] = {}; // expected-error {{constexpr variable cannot have non-literal type 'Incomplete const[]'}} expected-note {{incomplete type 'Incomplete const[]' is not a literal type}} -constexpr ClassTemp<int> classtemplate = {}; -constexpr ClassTemp<int> classtemplate2[] = {}; - -// - it has a trivial destructor -struct UserProvDtor { - ~UserProvDtor(); // expected-note {{has a user-provided destructor}} -}; -constexpr int f(UserProvDtor) { return 0; } // expected-error {{'UserProvDtor' is not a literal type}} -struct NonTrivDtor { - constexpr NonTrivDtor(); - virtual ~NonTrivDtor() = default; // expected-note {{has a non-trivial destructor}} expected-note {{because it is virtual}} -}; -constexpr int f(NonTrivDtor) { return 0; } // expected-error {{'NonTrivDtor' is not a literal type}} -struct NonTrivDtorBase { - ~NonTrivDtorBase(); -}; -template<typename T> -struct DerivedFromNonTrivDtor : T { // expected-note {{'DerivedFromNonTrivDtor<NonTrivDtorBase>' is not literal because it has base class 'NonTrivDtorBase' of non-literal type}} - constexpr DerivedFromNonTrivDtor(); -}; -constexpr int f(DerivedFromNonTrivDtor<NonTrivDtorBase>) { return 0; } // expected-error {{constexpr function's 1st parameter type 'DerivedFromNonTrivDtor<NonTrivDtorBase>' is not a literal type}} -struct TrivDtor { - constexpr TrivDtor(); -}; -constexpr int f(TrivDtor) { return 0; } -struct TrivDefaultedDtor { - constexpr TrivDefaultedDtor(); - ~TrivDefaultedDtor() = default; -}; -constexpr int f(TrivDefaultedDtor) { return 0; } - -// - it is an aggregate type or has at least one constexpr constructor or -// constexpr constructor template that is not a copy or move constructor -struct Agg { - int a; - char *b; -}; -constexpr int f3(Agg a) { return a.a; } -struct CtorTemplate { - template<typename T> constexpr CtorTemplate(T); -}; -struct CopyCtorOnly { // expected-note {{'CopyCtorOnly' is not literal because it is not an aggregate and has no constexpr constructors other than copy or move constructors}} - constexpr CopyCtorOnly(CopyCtorOnly&); -}; -constexpr int f(CopyCtorOnly) { return 0; } // expected-error {{'CopyCtorOnly' is not a literal type}} -struct MoveCtorOnly { // expected-note {{no constexpr constructors other than copy or move constructors}} - constexpr MoveCtorOnly(MoveCtorOnly&&); -}; -constexpr int f(MoveCtorOnly) { return 0; } // expected-error {{'MoveCtorOnly' is not a literal type}} -template<typename T> -struct CtorArg { - constexpr CtorArg(T); -}; -constexpr int f(CtorArg<int>) { return 0; } // ok -constexpr int f(CtorArg<NonLiteral>) { return 0; } // ok, ctor is still constexpr -// We have a special-case diagnostic for classes with virtual base classes. -struct VBase {}; -struct HasVBase : virtual VBase {}; // expected-note 2{{virtual base class declared here}} -struct Derived : HasVBase { - constexpr Derived() {} // expected-error {{constexpr constructor not allowed in struct with virtual base class}} -}; -template<typename T> struct DerivedFromVBase : T { // expected-note {{struct with virtual base class is not a literal type}} - constexpr DerivedFromVBase(); -}; -constexpr int f(DerivedFromVBase<HasVBase>) {} // expected-error {{constexpr function's 1st parameter type 'DerivedFromVBase<HasVBase>' is not a literal type}} -template<typename T> constexpr DerivedFromVBase<T>::DerivedFromVBase() : T() {} -constexpr int nVBase = (DerivedFromVBase<HasVBase>(), 0); // expected-error {{constant expression}} expected-note {{cannot construct object of type 'DerivedFromVBase<HasVBase>' with virtual base class in a constant expression}} - -// - it has all non-static data members and base classes of literal types -struct NonLitMember { - S s; // expected-note {{has data member 's' of non-literal type 'S'}} -}; -constexpr int f(NonLitMember) {} // expected-error {{1st parameter type 'NonLitMember' is not a literal type}} -struct NonLitBase : - S { // expected-note {{base class 'S' of non-literal type}} - constexpr NonLitBase(); -}; -constexpr int f(NonLitBase) { return 0; } // expected-error {{'NonLitBase' is not a literal type}} -struct LitMemBase : Agg { - Agg agg; -}; -template<typename T> -struct MemberType { - T t; // expected-note {{'MemberType<NonLiteral>' is not literal because it has data member 't' of non-literal type 'NonLiteral'}} - constexpr MemberType(); -}; -constexpr int f(MemberType<int>) { return 0; } -constexpr int f(MemberType<NonLiteral>) { return 0; } // expected-error {{not a literal type}} - -// - an array of literal type [C++1y] other than an array of runtime bound -struct ArrGood { - Agg agg[24]; - double d[12]; - TrivDtor td[3]; - TrivDefaultedDtor tdd[3]; -}; -constexpr int f(ArrGood) { return 0; } - -struct ArrBad { - S s[3]; // expected-note {{data member 's' of non-literal type 'S [3]'}} -}; -constexpr int f(ArrBad) { return 0; } // expected-error {{1st parameter type 'ArrBad' is not a literal type}} - -constexpr int arb(int n) { - int a[n]; // expected-error {{variable of non-literal type 'int [n]' cannot be defined in a constexpr function}} -} -constexpr long Overflow[ // expected-error {{constexpr variable cannot have non-literal type 'long const[(1 << 30) << 2]'}} - (1 << 30) << 2]{}; // expected-warning {{requires 34 bits to represent}} - -namespace inherited_ctor { - struct A { constexpr A(int); }; - struct B : A { - B(); - using A::A; - }; - constexpr int f(B) { return 0; } // ok - - struct C { constexpr C(int); }; - struct D : C { // expected-note {{because}} - D(int); - using C::C; - }; - constexpr int f(D) { return 0; } // expected-error {{not a literal type}} - - // This one is a bit odd: F inherits E's default constructor, which is - // constexpr. Because F has a constructor of its own, it doesn't declare a - // default constructor hiding E's one. - struct E {}; - struct F : E { - F(int); - using E::E; - }; - constexpr int f(F) { return 0; } - - // FIXME: Is this really the right behavior? We presumably should be checking - // whether the inherited constructor would be a copy or move constructor for - // the derived class, not for the base class. - struct G { constexpr G(const G&); }; - struct H : G { // expected-note {{because}} - using G::G; - }; - constexpr int f(H) { return 0; } // expected-error {{not a literal type}} - - struct J; - struct I { constexpr I(const J&); }; - struct J : I { - using I::I; - }; - constexpr int f(J) { return 0; } -} diff --git a/test/CXX/class.access/class.access.base/p1.cpp b/test/CXX/class.access/class.access.base/p1.cpp deleted file mode 100644 index 88e2688406c7..000000000000 --- a/test/CXX/class.access/class.access.base/p1.cpp +++ /dev/null @@ -1,170 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s - -// C++0x [class.access.base]p1(a): -// If a class is declared to be a base class for another class using -// the public access specifier, the public members of the base class -// are accessible as public members of the derived class and protected -// members of the base class are accessible as protected members of -// the derived class. -namespace test0 { - class Base { - public: int pub; static int spub; - protected: int prot; static int sprot; // expected-note 4 {{declared protected here}} - private: int priv; static int spriv; // expected-note 8 {{declared private here}} - }; - - class Test : public Base { - void test() { - pub++; - spub++; - prot++; - sprot++; - priv++; // expected-error {{private member}} - spriv++; // expected-error {{private member}} - - Base::pub++; - Base::spub++; - Base::prot++; - Base::sprot++; - Base::priv++; // expected-error {{private member}} - Base::spriv++; // expected-error {{private member}} - } - }; - - void test(Test *t) { - t->pub++; - t->spub++; - t->prot++; // expected-error {{protected member}} - t->sprot++; // expected-error {{protected member}} - t->priv++; // expected-error {{private member}} - t->spriv++; // expected-error {{private member}} - - t->Base::pub++; - t->Base::spub++; - t->Base::prot++; // expected-error {{protected member}} - t->Base::sprot++; // expected-error {{protected member}} - t->Base::priv++; // expected-error {{private member}} - t->Base::spriv++; // expected-error {{private member}} - } -} - -// C++0x [class.access.base]p1(b): -// If a class is declared to be a base class for another class using -// the protected access specifier, the public and protected members -// of the base class are accessible as protected members of the -// derived class. -namespace test1 { - class Base { // expected-note 6{{member is declared here}} - public: - int pub; // expected-note{{member is declared here}} - static int spub; // expected-note{{member is declared here}} - protected: int prot; static int sprot; // expected-note 4 {{declared protected here}} - private: int priv; static int spriv; // expected-note 8 {{declared private here}} - }; - - class Test : protected Base { // expected-note 6 {{declared protected here}} expected-note 8 {{constrained by protected inheritance here}} - void test() { - pub++; - spub++; - prot++; - sprot++; - priv++; // expected-error {{private member}} - spriv++; // expected-error {{private member}} - - Base::pub++; - Base::spub++; - Base::prot++; - Base::sprot++; - Base::priv++; // expected-error {{private member}} - Base::spriv++; // expected-error {{private member}} - } - }; - - void test(Test *t) { - t->pub++; // expected-error {{protected member}} expected-error {{protected base class}} - t->spub++; // expected-error {{protected member}} - t->prot++; // expected-error {{protected member}} expected-error {{protected base class}} - t->sprot++; // expected-error {{protected member}} - t->priv++; // expected-error {{private member}} expected-error {{protected base class}} - t->spriv++; // expected-error {{private member}} - - // Two possible errors here: one for Base, one for the member - t->Base::pub++; // expected-error {{protected member}} expected-error {{protected base class}} - t->Base::spub++; // expected-error {{protected member}} - t->Base::prot++; // expected-error 2 {{protected member}} expected-error {{protected base class}} - t->Base::sprot++; // expected-error 2 {{protected member}} - t->Base::priv++; // expected-error {{protected member}} expected-error {{private member}} expected-error {{protected base class}} - t->Base::spriv++; // expected-error {{protected member}} expected-error {{private member}} - } -} - -// C++0x [class.access.base]p1(b): -// If a class is declared to be a base class for another class using -// the private access specifier, the public and protected members of -// the base class are accessible as private members of the derived -// class. -namespace test2 { - class Base { // expected-note 6{{member is declared here}} - public: - int pub; // expected-note{{member is declared here}} - static int spub; // expected-note{{member is declared here}} - protected: - int prot; // expected-note {{declared protected here}} \ - // expected-note{{member is declared here}} - static int sprot; // expected-note {{declared protected here}} \ - // expected-note{{member is declared here}} - private: - int priv; // expected-note 4 {{declared private here}} - static int spriv; // expected-note 4 {{declared private here}} - }; - - class Test : private Base { // expected-note 6 {{declared private here}} \ - // expected-note 10 {{constrained by private inheritance here}} - void test() { - pub++; - spub++; - prot++; - sprot++; - priv++; // expected-error {{private member}} - spriv++; // expected-error {{private member}} - - Base::pub++; - Base::spub++; - Base::prot++; - Base::sprot++; - Base::priv++; // expected-error {{private member}} - Base::spriv++; // expected-error {{private member}} - } - }; - - void test(Test *t) { - t->pub++; // expected-error {{private member}} expected-error {{private base class}} - t->spub++; // expected-error {{private member}} - t->prot++; // expected-error {{private member}} expected-error {{private base class}} - t->sprot++; // expected-error {{private member}} - t->priv++; // expected-error {{private member}} expected-error {{private base class}} - t->spriv++; // expected-error {{private member}} - - t->Base::pub++; // expected-error {{private member}} expected-error {{private base class}} - t->Base::spub++; // expected-error {{private member}} - t->Base::prot++; // expected-error {{protected member}} expected-error {{private member}} expected-error {{private base class}} - t->Base::sprot++; // expected-error {{protected member}} expected-error {{private member}} - t->Base::priv++; // expected-error 2 {{private member}} expected-error {{private base class}} - t->Base::spriv++; // expected-error 2 {{private member}} - } -} - -namespace PR12788 { - class A { - protected: - struct { - int x; - }; - }; - class B : A { - void f() { - ++x; - A::x++; - } - }; -} diff --git a/test/CXX/class.access/class.access.base/p5.cpp b/test/CXX/class.access/class.access.base/p5.cpp deleted file mode 100644 index 5b08a8619921..000000000000 --- a/test/CXX/class.access/class.access.base/p5.cpp +++ /dev/null @@ -1,98 +0,0 @@ -// RUN: %clang_cc1 -verify %s - -namespace test0 { - struct A { - static int x; - }; - struct B : A {}; - struct C : B {}; - - int test() { - return A::x - + B::x - + C::x; - } -} - -namespace test1 { - struct A { - private: static int x; // expected-note 5 {{declared private here}} - static int test() { return x; } - }; - struct B : public A { - static int test() { return x; } // expected-error {{private member}} - }; - struct C : private A { - static int test() { return x; } // expected-error {{private member}} - }; - - struct D { - public: static int x; // expected-note{{member is declared here}} - static int test() { return x; } - }; - struct E : private D { // expected-note{{constrained by private inheritance}} - static int test() { return x; } - }; - - int test() { - return A::x // expected-error {{private member}} - + B::x // expected-error {{private member}} - + C::x // expected-error {{private member}} - + D::x - + E::x; // expected-error {{private member}} - } -} - -namespace test2 { - class A { - protected: static int x; // expected-note{{member is declared here}} - }; - - class B : private A {}; // expected-note {{private inheritance}} - class C : private A { - int test(B *b) { - return b->x; // expected-error {{private member}} - } - }; -} - -namespace test3 { - class A { - protected: static int x; - }; - - class B : public A {}; - class C : private A { - int test(B *b) { - // x is accessible at C when named in A. - // A is an accessible base of B at C. - // Therefore this succeeds. - return b->x; - } - }; -} - -// Don't crash. <rdar://12926092> -// Note that 'field' is indeed a private member of X but that access -// is indeed ultimately constrained by the protected inheritance from Y. -// If someone wants to put the effort into improving this diagnostic, -// they can feel free; even explaining it in person would be a pain. -namespace test4 { - class Z; - class X { - public: - void f(Z *p); - - private: - int field; // expected-note {{member is declared here}} - }; - - class Y : public X { }; - class Z : protected Y { }; // expected-note 2 {{constrained by protected inheritance here}} - - void X::f(Z *p) { - p->field = 0; // expected-error {{cannot cast 'test4::Z' to its protected base class 'test4::X'}} expected-error {{'field' is a private member of 'test4::X'}} - } -} - -// TODO: flesh out these cases diff --git a/test/CXX/class.access/class.access.dcl/p1.cpp b/test/CXX/class.access/class.access.dcl/p1.cpp deleted file mode 100644 index 118ab9e52d0a..000000000000 --- a/test/CXX/class.access/class.access.dcl/p1.cpp +++ /dev/null @@ -1,350 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s - -// This is just the test for [namespace.udecl]p4 with 'using' -// uniformly stripped out. - -// C++03 [namespace.udecl]p4: -// A using-declaration used as a member-declaration shall refer to a -// member of a base class of the class being defined, shall refer to -// a member of an anonymous union that is a member of a base class -// of the class being defined, or shall refer to an enumerator for -// an enumeration type that is a member of a base class of the class -// being defined. - -// There is no directly analogous paragraph in C++0x, and the feature -// works sufficiently differently there that it needs a separate test. - -namespace test0 { - namespace NonClass { - typedef int type; - struct hiding {}; - int hiding; - static union { double union_member; }; - enum tagname { enumerator }; - } - - class Test0 { - NonClass::type; // expected-error {{not a class}} -#if __cplusplus <= 199711L - // expected-warning@-2 {{access declarations are deprecated; use using declarations instead}} -#else - // expected-error@-4 {{ISO C++11 does not allow access declarations; use using declarations instead}} -#endif - - NonClass::hiding; // expected-error {{not a class}} -#if __cplusplus <= 199711L - // expected-warning@-2 {{access declarations are deprecated; use using declarations instead}} -#else - // expected-error@-4 {{ISO C++11 does not allow access declarations; use using declarations instead}} -#endif - - NonClass::union_member; // expected-error {{not a class}} -#if __cplusplus <= 199711L - // expected-warning@-2 {{access declarations are deprecated; use using declarations instead}} -#else - // expected-error@-4 {{ISO C++11 does not allow access declarations; use using declarations instead}} -#endif - - NonClass::enumerator; // expected-error {{not a class}} -#if __cplusplus <= 199711L - // expected-warning@-2 {{access declarations are deprecated; use using declarations instead}} -#else - // expected-error@-4 {{ISO C++11 does not allow access declarations; use using declarations instead}} -#endif - }; -} - -struct Opaque0 {}; - -namespace test1 { - struct A { - typedef int type; - struct hiding {}; // expected-note {{previous use is here}} - Opaque0 hiding; - union { double union_member; }; - enum tagname { enumerator }; - }; - - struct B : A { - A::type; -#if __cplusplus <= 199711L - // expected-warning@-2 {{access declarations are deprecated; use using declarations instead}} -#else - // expected-error@-4 {{ISO C++11 does not allow access declarations; use using declarations instead}} -#endif - A::hiding; -#if __cplusplus <= 199711L - // expected-warning@-2 {{access declarations are deprecated; use using declarations instead}} -#else - // expected-error@-4 {{ISO C++11 does not allow access declarations; use using declarations instead}} -#endif - - A::union_member; -#if __cplusplus <= 199711L - // expected-warning@-2 {{access declarations are deprecated; use using declarations instead}} -#else - // expected-error@-4 {{ISO C++11 does not allow access declarations; use using declarations instead}} -#endif - - A::enumerator; -#if __cplusplus <= 199711L - // expected-warning@-2 {{access declarations are deprecated; use using declarations instead}} -#else - // expected-error@-4 {{ISO C++11 does not allow access declarations; use using declarations instead}} -#endif - - A::tagname; -#if __cplusplus <= 199711L - // expected-warning@-2 {{access declarations are deprecated; use using declarations instead}} -#else - // expected-error@-4 {{ISO C++11 does not allow access declarations; use using declarations instead}} -#endif - - void test0() { - type t = 0; - } - - void test1() { - typedef struct A::hiding local; - struct hiding _ = local(); - } - - void test2() { - union hiding _; // expected-error {{tag type that does not match previous}} - } - - void test3() { - char array[sizeof(union_member) == sizeof(double) ? 1 : -1]; - } - - void test4() { - enum tagname _ = enumerator; - } - - void test5() { - Opaque0 _ = hiding; - } - }; -} - -namespace test2 { - struct A { - typedef int type; - struct hiding {}; // expected-note {{previous use is here}} - int hiding; - union { double union_member; }; - enum tagname { enumerator }; - }; - - template <class T> struct B : A { - A::type; -#if __cplusplus <= 199711L - // expected-warning@-2 {{access declarations are deprecated; use using declarations instead}} -#else - // expected-error@-4 {{ISO C++11 does not allow access declarations; use using declarations instead}} -#endif - - A::hiding; -#if __cplusplus <= 199711L - // expected-warning@-2 {{access declarations are deprecated; use using declarations instead}} -#else - // expected-error@-4 {{ISO C++11 does not allow access declarations; use using declarations instead}} -#endif - - A::union_member; -#if __cplusplus <= 199711L - // expected-warning@-2 {{access declarations are deprecated; use using declarations instead}} -#else - // expected-error@-4 {{ISO C++11 does not allow access declarations; use using declarations instead}} -#endif - - A::enumerator; -#if __cplusplus <= 199711L - // expected-warning@-2 {{access declarations are deprecated; use using declarations instead}} -#else - // expected-error@-4 {{ISO C++11 does not allow access declarations; use using declarations instead}} -#endif - - A::tagname; -#if __cplusplus <= 199711L - // expected-warning@-2 {{access declarations are deprecated; use using declarations instead}} -#else - // expected-error@-4 {{ISO C++11 does not allow access declarations; use using declarations instead}} -#endif - - void test0() { - type t = 0; - } - - void test1() { - typedef struct A::hiding local; - struct hiding _ = local(); - } - - void test2() { - union hiding _; // expected-error {{tag type that does not match previous}} - } - - void test3() { - char array[sizeof(union_member) == sizeof(double) ? 1 : -1]; - } - - void test4() { - enum tagname _ = enumerator; - } - - void test5() { - Opaque0 _ = hiding; - } - }; -} - -namespace test3 { - struct hiding {}; - - template <class T> struct A { - typedef int type; // expected-note {{target of using declaration}} - struct hiding {}; - Opaque0 hiding; - union { double union_member; }; - enum tagname { enumerator }; // expected-note {{target of using declaration}} - }; - - template <class T> struct B : A<T> { - A<T>::type; // expected-error {{dependent using declaration resolved to type without 'typename'}} -#if __cplusplus <= 199711L - // expected-warning@-2 {{access declarations are deprecated; use using declarations instead}} -#else - // expected-error@-4 {{ISO C++11 does not allow access declarations; use using declarations instead}} -#endif - - A<T>::hiding; -#if __cplusplus <= 199711L - // expected-warning@-2 {{access declarations are deprecated; use using declarations instead}} -#else - // expected-error@-4 {{ISO C++11 does not allow access declarations; use using declarations instead}} -#endif - - A<T>::union_member; -#if __cplusplus <= 199711L - // expected-warning@-2 {{access declarations are deprecated; use using declarations instead}} -#else - // expected-error@-4 {{ISO C++11 does not allow access declarations; use using declarations instead}} -#endif - - A<T>::enumerator; -#if __cplusplus <= 199711L - // expected-warning@-2 {{access declarations are deprecated; use using declarations instead}} -#else - // expected-error@-4 {{ISO C++11 does not allow access declarations; use using declarations instead}} -#endif - - A<T>::tagname; // expected-error {{dependent using declaration resolved to type without 'typename'}} -#if __cplusplus <= 199711L - // expected-warning@-2 {{access declarations are deprecated; use using declarations instead}} -#else - // expected-error@-4 {{ISO C++11 does not allow access declarations; use using declarations instead}} -#endif - - // FIXME: re-enable these when the various bugs involving tags are fixed -#if 0 - void test1() { - typedef struct A<T>::hiding local; - struct hiding _ = local(); - } - - void test2() { - typedef struct A<T>::hiding local; - union hiding _ = local(); - } -#endif - - void test3() { - char array[sizeof(union_member) == sizeof(double) ? 1 : -1]; - } - -#if 0 - void test4() { - enum tagname _ = enumerator; - } -#endif - - void test5() { - Opaque0 _ = hiding; - } - }; - - template struct B<int>; // expected-note {{in instantiation}} -} - -namespace test4 { - struct Base { - int foo(); - }; - - struct Unrelated { - int foo(); - }; - - struct Subclass : Base { - }; - - namespace InnerNS { - int foo(); - } - - // We should be able to diagnose these without instantiation. - template <class T> struct C : Base { - InnerNS::foo; // expected-error {{not a class}} -#if __cplusplus <= 199711L - // expected-warning@-2 {{access declarations are deprecated; use using declarations instead}} -#else - // expected-error@-4 {{ISO C++11 does not allow access declarations; use using declarations instead}} -#endif - - Base::bar; // expected-error {{no member named 'bar'}} -#if __cplusplus <= 199711L - // expected-warning@-2 {{access declarations are deprecated; use using declarations instead}} -#else - // expected-error@-4 {{ISO C++11 does not allow access declarations; use using declarations instead}} -#endif - - Unrelated::foo; // expected-error {{not a base class}} -#if __cplusplus <= 199711L - // expected-warning@-2 {{access declarations are deprecated; use using declarations instead}} -#else - // expected-error@-4 {{ISO C++11 does not allow access declarations; use using declarations instead}} -#endif - - C::foo; // legal in C++03 -#if __cplusplus <= 199711L - // expected-warning@-2 {{access declarations are deprecated; use using declarations instead}} -#else - // expected-error@-4 {{ISO C++11 does not allow access declarations; use using declarations instead}} - // expected-error@-5 {{using declaration refers to its own class}} -#endif - - Subclass::foo; // legal in C++03 -#if __cplusplus <= 199711L - // expected-warning@-2 {{access declarations are deprecated; use using declarations instead}} -#else - // expected-error@-4 {{ISO C++11 does not allow access declarations; use using declarations instead}} - // expected-error@-5 {{using declaration refers into 'Subclass::', which is not a base class of 'C'}} -#endif - - int bar(); -#if __cplusplus <= 199711L - //expected-note@-2 {{target of using declaration}} -#endif - C::bar; -#if __cplusplus <= 199711L - // expected-warning@-2 {{access declarations are deprecated; use using declarations instead}} -#else - // expected-error@-4 {{ISO C++11 does not allow access declarations; use using declarations instead}} -#endif - // expected-error@-6 {{using declaration refers to its own class}} - }; -} - diff --git a/test/CXX/class.access/class.access.nest/p1.cpp b/test/CXX/class.access/class.access.nest/p1.cpp deleted file mode 100644 index eceffcf991bb..000000000000 --- a/test/CXX/class.access/class.access.nest/p1.cpp +++ /dev/null @@ -1,33 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s - -// Derived from GNU's std::string -namespace test0 { - class A { - struct B { - unsigned long length; - }; - struct C : B { - static const unsigned long max_length; - }; - }; - - const unsigned long A::C::max_length = sizeof(B); -} - -// Example from the standard. -namespace test1 { - class E { - int x; - class B {}; - - class I { - B b; - int y; // expected-note {{declared private here}} - void f(E* p, int i) { - p->x = i; - } - }; - - int g(I* p) { return p->y; } // expected-error {{'y' is a private member of 'test1::E::I'}} - }; -} diff --git a/test/CXX/class.access/class.friend/p1.cpp b/test/CXX/class.access/class.friend/p1.cpp deleted file mode 100644 index b335b0a8c884..000000000000 --- a/test/CXX/class.access/class.friend/p1.cpp +++ /dev/null @@ -1,389 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++14 %s -// RUN: %clang_cc1 -fsyntax-only -verify %s - -// C++'0x [class.friend] p1: -// A friend of a class is a function or class that is given permission to use -// the private and protected member names from the class. A class specifies -// its friends, if any, by way of friend declarations. Such declarations give -// special access rights to the friends, but they do not make the nominated -// friends members of the befriending class. - -struct S { static void f(); }; // expected-note 2 {{'S' declared here}} -S* g() { return 0; } // expected-note 2 {{'g' declared here}} - -struct X { - friend struct S; - friend S* g(); -}; - -void test1() { - S s; - g()->f(); - S::f(); - X::g(); // expected-error{{no member named 'g' in 'X'; did you mean simply 'g'?}} - X::S x_s; // expected-error{{no type named 'S' in 'X'; did you mean simply 'S'?}} - X x; - x.g(); // expected-error{{no member named 'g' in 'X'}} -} - -// Test that we recurse through namespaces to find already declared names, but -// new names are declared within the enclosing namespace. -namespace N { - struct X { - friend struct S; - friend S* g(); - - friend struct S2; - friend struct S2* g2(); - }; - - struct S2 { static void f2(); }; // expected-note 2 {{'S2' declared here}} - S2* g2() { return 0; } // expected-note 2 {{'g2' declared here}} - - void test() { - g()->f(); - S s; - S::f(); - X::g(); // expected-error{{no member named 'g' in 'N::X'; did you mean simply 'g'?}} - X::S x_s; // expected-error{{no type named 'S' in 'N::X'; did you mean simply 'S'?}} - X x; - x.g(); // expected-error{{no member named 'g' in 'N::X'}} - - g2(); - S2 s2; - ::g2(); // expected-error{{no member named 'g2' in the global namespace; did you mean simply 'g2'?}} - ::S2 g_s2; // expected-error{{no type named 'S2' in the global namespace; did you mean simply 'S2'?}} - X::g2(); // expected-error{{no member named 'g2' in 'N::X'; did you mean simply 'g2'?}} - X::S2 x_s2; // expected-error{{no type named 'S2' in 'N::X'; did you mean simply 'S2'?}} - x.g2(); // expected-error{{no member named 'g2' in 'N::X'}} - } -} - -namespace test0 { - class ClassFriend { - void test(); - }; - - class MemberFriend { - public: - void test(); - }; - - void declared_test(); - - class Class { - static void member(); // expected-note 2 {{declared private here}} - - friend class ClassFriend; - friend class UndeclaredClassFriend; - - friend void undeclared_test(); - friend void declared_test(); - friend void MemberFriend::test(); - }; - - void declared_test() { - Class::member(); - } - - void undeclared_test() { - Class::member(); - } - - void unfriended_test() { - Class::member(); // expected-error {{'member' is a private member of 'test0::Class'}} - } - - void ClassFriend::test() { - Class::member(); - } - - void MemberFriend::test() { - Class::member(); - } - - class UndeclaredClassFriend { - void test() { - Class::member(); - } - }; - - class ClassNonFriend { - void test() { - Class::member(); // expected-error {{'member' is a private member of 'test0::Class'}} - } - }; -} - -// Make sure that friends have access to inherited protected members. -namespace test2 { - struct X; - - class ilist_half_node { - friend struct ilist_walker_bad; - X *Prev; - protected: - X *getPrev() { return Prev; } // expected-note{{member is declared here}} - }; - - class ilist_node : private ilist_half_node { // expected-note {{declared private here}} expected-note {{constrained by private inheritance here}} - friend struct ilist_walker; - X *Next; - X *getNext() { return Next; } // expected-note {{declared private here}} - }; - - struct X : ilist_node {}; - - struct ilist_walker { - static X *getPrev(X *N) { return N->getPrev(); } - static X *getNext(X *N) { return N->getNext(); } - }; - - struct ilist_walker_bad { - static X *getPrev(X *N) { return N->getPrev(); } // \ - // expected-error {{'getPrev' is a private member of 'test2::ilist_half_node'}} \ - // expected-error {{cannot cast 'test2::X' to its private base class 'test2::ilist_half_node'}} - - static X *getNext(X *N) { return N->getNext(); } // \ - // expected-error {{'getNext' is a private member of 'test2::ilist_node'}} - }; -} - -namespace test3 { - class A { protected: int x; }; // expected-note {{declared protected here}} - - class B : public A { - friend int foo(B*); - }; - - int foo(B *p) { - return p->x; - } - - int foo(const B *p) { - return p->x; // expected-error {{'x' is a protected member of 'test3::A'}} - } -} - -namespace test3a { - class A { protected: int x; }; - - class B : public A { - friend int foo(B*); - }; - - int foo(B * const p) { - return p->x; - } -} - -namespace test4 { - template <class T> class Holder { - T object; - friend bool operator==(Holder &a, Holder &b) { - return a.object == b.object; // expected-error {{invalid operands to binary expression}} - } - }; - - struct Inequal {}; - bool test() { - Holder<Inequal> a, b; - return a == b; // expected-note {{requested here}} - } -} - - -// PR6174 -namespace test5 { - namespace ns { - class A; - } - - class ns::A { - private: int x; - friend class B; - }; - - namespace ns { - class B { - int test(A *p) { return p->x; } - }; - } -} - -// PR6207 -namespace test6 { - struct A {}; - - struct B { - friend -#if __cplusplus >= 201103L - constexpr -#endif - A::A(); - friend A::~A(); - friend -#if __cplusplus >= 201402L - constexpr -#endif - A &A::operator=(const A&); - }; -} - -namespace test7 { - template <class T> struct X { - X(); - ~X(); - void foo(); - void bar(); - }; - - class A { - friend void X<int>::foo(); - friend X<int>::X(); - friend -#if __cplusplus >= 201103L - constexpr -#endif - X<int>::X(const X&); - - private: - A(); // expected-note 2 {{declared private here}} - }; - - template<> void X<int>::foo() { - A a; - } - - template<> void X<int>::bar() { - A a; // expected-error {{calling a private constructor}} - } - - template<> X<int>::X() { - A a; - } - - template<> X<int>::~X() { - A a; // expected-error {{calling a private constructor}} - } -} - -// Return types, parameters and default arguments to friend functions. -namespace test8 { - class A { - typedef int I; // expected-note 4 {{declared private here}} - static const I x = 0; // expected-note {{implicitly declared private here}} - friend I f(I i); - template<typename T> friend I g(I i); - }; - - const A::I A::x; - A::I f(A::I i = A::x) {} - template<typename T> A::I g(A::I i) { - T t; - } - template A::I g<A::I>(A::I i); - - A::I f2(A::I i = A::x) {} // expected-error 3 {{is a private member of}} - template<typename T> A::I g2(A::I i) { // expected-error 2 {{is a private member of}} - T t; - } - template A::I g2<A::I>(A::I i); -} - -// PR6885 -namespace test9 { - class B { - friend class test9; - }; -} - -// PR7230 -namespace test10 { - extern "C" void test10_f(void); - extern "C" void test10_g(void); - - namespace NS { - class C { - void foo(void); // expected-note {{declared private here}} - friend void test10::test10_f(void); - }; - static C* bar; - } - - void test10_f(void) { - NS::bar->foo(); - } - - void test10_g(void) { - NS::bar->foo(); // expected-error {{private member}} - } -} - -// PR8705 -namespace test11 { - class A { - public: - void test0(int); - void test1(int); - void test2(int); - void test3(int); - }; - - class B { - typedef int private_type; // expected-note 2 {{implicitly declared private here}} - friend void A::test0(int); - friend void A::test1(int); - }; - - void A::test0(B::private_type x) {} - void A::test1(int x = B::private_type()) {} - void A::test2(B::private_type x) {} // expected-error {{'private_type' is a private member of 'test11::B'}} - void A::test3(int x = B::private_type()) {} // expected-error {{'private_type' is a private member of 'test11::B'}} -} - - -// PR9221 -namespace test12 { - struct A { - void foo(); - }; - class B : private A { - friend void A::foo(); - void *mem; - }; - void A::foo() { - void *var = static_cast<B*>(this)->mem; - } -} - -namespace PR9103 { - struct base { - protected: - static void foo(void) {} - }; - - struct cls: base { - friend void bar(void) { - base::foo(); - } - }; -} - -// PR13642. When computing the effective context, we were walking up -// the DC chain for the canonical decl, which is unfortunate if that's -// (e.g.) a friend declaration. -namespace test14 { - class A { - class B { // expected-note {{implicitly declared private here}} - static int i; - friend void c(); - }; - }; - - void c() { - A::B::i = 5; // expected-error {{'B' is a private member of 'test14::A'}} - } -} diff --git a/test/CXX/class.access/class.friend/p11.cpp b/test/CXX/class.access/class.friend/p11.cpp deleted file mode 100644 index 0deead19a0fb..000000000000 --- a/test/CXX/class.access/class.friend/p11.cpp +++ /dev/null @@ -1,99 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s - -// rdar://problem/8540720 -namespace test0 { - void foo() { - void bar(); - class A { - friend void bar(); - }; - } -} - -namespace test1 { - void foo() { - class A { - friend void bar(); // expected-error {{no matching function found in local scope}} - }; - } -} - -namespace test2 { - void bar(); // expected-note 3{{'::test2::bar' declared here}} - - void foo() { // expected-note 2{{'::test2::foo' declared here}} - struct S1 { - friend void foo(); // expected-error {{no matching function 'foo' found in local scope; did you mean '::test2::foo'?}} - }; - - void foo(); // expected-note {{local declaration nearly matches}} - struct S2 { - friend void foo(); - }; - - { - struct S2 { - friend void foo(); // expected-error {{no matching function found in local scope}} - }; - } - - { - int foo; - struct S3 { - friend void foo(); // expected-error {{no matching function 'foo' found in local scope; did you mean '::test2::foo'?}} - }; - } - - struct S4 { - friend void bar(); // expected-error {{no matching function 'bar' found in local scope; did you mean '::test2::bar'?}} - }; - - { void bar(); } - struct S5 { - friend void bar(); // expected-error {{no matching function 'bar' found in local scope; did you mean '::test2::bar'?}} - }; - - { - void bar(); - struct S6 { - friend void bar(); - }; - } - - struct S7 { - void bar() { Inner::f(); } - struct Inner { - friend void bar(); - static void f() {} - }; - }; - - void bar(); // expected-note {{'bar' declared here}} - struct S8 { - struct Inner { - friend void bar(); - }; - }; - - struct S9 { - struct Inner { - friend void baz(); // expected-error {{no matching function 'baz' found in local scope; did you mean 'bar'?}} - }; - }; - - struct S10 { - void quux() {} - void foo() { - struct Inner1 { - friend void bar(); // expected-error {{no matching function 'bar' found in local scope; did you mean '::test2::bar'?}} - friend void quux(); // expected-error {{no matching function found in local scope}} - }; - - void bar(); - struct Inner2 { - friend void bar(); - }; - } - }; - } -} diff --git a/test/CXX/class.access/class.friend/p2-cxx03.cpp b/test/CXX/class.access/class.friend/p2-cxx03.cpp deleted file mode 100644 index 88b2ea3a9b73..000000000000 --- a/test/CXX/class.access/class.friend/p2-cxx03.cpp +++ /dev/null @@ -1,20 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s -template<typename T> -class X0 { - friend T; -#if __cplusplus <= 199711L // C++03 or earlier modes - // expected-warning@-2{{non-class friend type 'T' is a C++11 extension}} -#else - // expected-no-diagnostics -#endif -}; - -class X1 { }; -enum E1 { }; -X0<X1> x0a; -X0<X1 *> x0b; -X0<int> x0c; -X0<E1> x0d; - diff --git a/test/CXX/class.access/class.friend/p3-cxx0x.cpp b/test/CXX/class.access/class.friend/p3-cxx0x.cpp deleted file mode 100644 index 9aabdbe540a6..000000000000 --- a/test/CXX/class.access/class.friend/p3-cxx0x.cpp +++ /dev/null @@ -1,80 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s -template<typename T> -class X0 { - friend T; -}; - -class Y1 { }; -enum E1 { }; -X0<Y1> x0a; -X0<Y1 *> x0b; -X0<int> x0c; -X0<E1> x0d; - -template<typename T> -class X1 { - friend typename T::type; // expected-error{{no type named 'type' in 'Y1'}} -}; - -struct Y2 { - struct type { }; -}; - -struct Y3 { - typedef int type; -}; - -X1<Y2> x1a; -X1<Y3> x1b; -X1<Y1> x1c; // expected-note{{in instantiation of template class 'X1<Y1>' requested here}} - -template<typename T> class B; - -template<typename T> -class A { - T x; -public: - class foo {}; - static int y; - template <typename S> friend class B<S>::ty; // expected-warning {{dependent nested name specifier 'B<S>::' for friend class declaration is not supported}} -}; - -template<typename T> class B { typedef int ty; }; - -template<> class B<int> { - class ty { - static int f(A<int> &a) { return a.y; } // ok, befriended - }; -}; -int f(A<char> &a) { return a.y; } // FIXME: should be an error - -struct { - // Ill-formed - int friend; // expected-error {{'friend' must appear first in a non-function declaration}} - unsigned friend int; // expected-error {{'friend' must appear first in a non-function declaration}} - const volatile friend int; // expected-error {{'friend' must appear first in a non-function declaration}} \ - // expected-error {{'const' is invalid in friend declarations}} \ - // expected-error {{'volatile' is invalid in friend declarations}} - int - friend; // expected-error {{'friend' must appear first in a non-function declaration}} - friend const int; // expected-error {{'const' is invalid in friend declarations}} - friend volatile int; // expected-error {{'volatile' is invalid in friend declarations}} - template <typename T> friend const class X; // expected-error {{'const' is invalid in friend declarations}} - // C++ doesn't have restrict and _Atomic, but they're both the same sort - // of qualifier. - typedef int *PtrToInt; - friend __restrict PtrToInt; // expected-error {{'restrict' is invalid in friend declarations}} \ - // expected-error {{restrict requires a pointer or reference}} - friend _Atomic int; // expected-error {{'_Atomic' is invalid in friend declarations}} - - // OK - int friend foo(void); - const int friend foo2(void); - friend int; - friend - - float; - template<typename T> friend class A<T>::foo; // expected-warning {{not supported}} -} a; - -void testA() { (void)sizeof(A<int>); } diff --git a/test/CXX/class.access/class.friend/p6.cpp b/test/CXX/class.access/class.friend/p6.cpp deleted file mode 100644 index 2fe20fe77fc8..000000000000 --- a/test/CXX/class.access/class.friend/p6.cpp +++ /dev/null @@ -1,24 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s - -void f1(); - -struct X { - void f2(); -}; - -struct Y { - friend void ::f1() { } // expected-error{{friend function definition cannot be qualified with '::'}} - friend void X::f2() { } // expected-error{{friend function definition cannot be qualified with 'X::'}} -}; - -template <typename T> struct Z { - friend void T::f() {} // expected-error{{friend function definition cannot be qualified with 'T::'}} -}; - -void local() { - void f(); - - struct Local { - friend void f() { } // expected-error{{friend function cannot be defined in a local class}} - }; -} diff --git a/test/CXX/class.access/class.friend/p9-cxx0x.cpp b/test/CXX/class.access/class.friend/p9-cxx0x.cpp deleted file mode 100644 index f748a2bb3ba6..000000000000 --- a/test/CXX/class.access/class.friend/p9-cxx0x.cpp +++ /dev/null @@ -1,117 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s - -// C++98 [class.friend]p7: -// C++11 [class.friend]p9: -// A name nominated by a friend declaration shall be accessible in -// the scope of the class containing the friend declaration. - -// PR12328 -// Simple, non-templated case. -namespace test0 { - class X { - void f(); // expected-note {{implicitly declared private here}} - }; - - class Y { - friend void X::f(); // expected-error {{friend function 'f' is a private member of 'test0::X'}} - }; -} - -// Templated but non-dependent. -namespace test1 { - class X { - void f(); // expected-note {{implicitly declared private here}} - }; - - template <class T> class Y { - friend void X::f(); // expected-error {{friend function 'f' is a private member of 'test1::X'}} - }; -} - -// Dependent but instantiated at the right type. -namespace test2 { - template <class T> class Y; - - class X { - void f(); - friend class Y<int>; - }; - - template <class T> class Y { - friend void X::f(); - }; - - template class Y<int>; -} - -// Dependent and instantiated at the wrong type. -namespace test3 { - template <class T> class Y; - - class X { - void f(); // expected-note {{implicitly declared private here}} - friend class Y<int>; - }; - - template <class T> class Y { - friend void X::f(); // expected-error {{friend function 'f' is a private member of 'test3::X'}} - }; - - template class Y<float>; // expected-note {{in instantiation}} -} - -// Dependent because dependently-scoped. -namespace test4 { - template <class T> class X { - void f(); - }; - - template <class T> class Y { - friend void X<T>::f(); - }; -} - -// Dependently-scoped, no friends. -namespace test5 { - template <class T> class X { - void f(); // expected-note {{implicitly declared private here}} - }; - - template <class T> class Y { - friend void X<T>::f(); // expected-error {{friend function 'f' is a private member of 'test5::X<int>'}} - }; - - template class Y<int>; // expected-note {{in instantiation}} -} - -// Dependently-scoped, wrong friend. -namespace test6 { - template <class T> class Y; - - template <class T> class X { - void f(); // expected-note {{implicitly declared private here}} - friend class Y<float>; - }; - - template <class T> class Y { - friend void X<T>::f(); // expected-error {{friend function 'f' is a private member of 'test6::X<int>'}} - }; - - template class Y<int>; // expected-note {{in instantiation}} -} - -// Dependently-scoped, right friend. -namespace test7 { - template <class T> class Y; - - template <class T> class X { - void f(); - friend class Y<int>; - }; - - template <class T> class Y { - friend void X<T>::f(); - }; - - template class Y<int>; -} diff --git a/test/CXX/class.access/class.protected/p1-cxx11.cpp b/test/CXX/class.access/class.protected/p1-cxx11.cpp deleted file mode 100644 index c1cf047aadb4..000000000000 --- a/test/CXX/class.access/class.protected/p1-cxx11.cpp +++ /dev/null @@ -1,21 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -// expected-no-diagnostics - -// PR12497 -namespace test0 { - class A { - protected: - A() {} - A(const A &) {} - ~A() {} - A &operator=(const A &a) { return *this; } - }; - - class B : public A {}; - - void test() { - B b1; - B b2 = b1; - b1 = b2; - } -} diff --git a/test/CXX/class.access/class.protected/p1.cpp b/test/CXX/class.access/class.protected/p1.cpp deleted file mode 100644 index 825447ef1605..000000000000 --- a/test/CXX/class.access/class.protected/p1.cpp +++ /dev/null @@ -1,520 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s - -namespace test0 { - class A { - protected: int x; // expected-note 3 {{declared}} \ - // expected-note {{member is declared here}} - static int sx; // expected-note 3 {{declared}} \ - // expected-note {{member is declared here}} - }; - class B : public A { - }; - class C : protected A { // expected-note {{declared}} - }; - class D : private B { // expected-note 3 {{constrained}} - }; - - void test(A &a) { - (void) a.x; // expected-error {{'x' is a protected member}} - (void) a.sx; // expected-error {{'sx' is a protected member}} - } - void test(B &b) { - (void) b.x; // expected-error {{'x' is a protected member}} - (void) b.sx; // expected-error {{'sx' is a protected member}} - } - void test(C &c) { - (void) c.x; // expected-error {{'x' is a protected member}} expected-error {{protected base class}} - (void) c.sx; // expected-error {{'sx' is a protected member}} - } - void test(D &d) { - (void) d.x; // expected-error {{'x' is a private member}} expected-error {{private base class}} - (void) d.sx; // expected-error {{'sx' is a private member}} - } -} - -namespace test1 { - class A { - protected: int x; - static int sx; - static void test(A&); - }; - class B : public A { - static void test(B&); - }; - class C : protected A { - static void test(C&); - }; - class D : private B { - static void test(D&); - }; - - void A::test(A &a) { - (void) a.x; - (void) a.sx; - } - void B::test(B &b) { - (void) b.x; - (void) b.sx; - } - void C::test(C &c) { - (void) c.x; - (void) c.sx; - } - void D::test(D &d) { - (void) d.x; - (void) d.sx; - } -} - -namespace test2 { - class A { - protected: int x; // expected-note 3 {{can only access this member on an object of type}} - static int sx; - static void test(A&); - }; - class B : public A { - static void test(A&); - }; - class C : protected A { - static void test(A&); - }; - class D : private B { - static void test(A&); - }; - - void A::test(A &a) { - (void) a.x; - (void) a.sx; - } - void B::test(A &a) { - (void) a.x; // expected-error {{'x' is a protected member}} - (void) a.sx; - } - void C::test(A &a) { - (void) a.x; // expected-error {{'x' is a protected member}} - (void) a.sx; - } - void D::test(A &a) { - (void) a.x; // expected-error {{'x' is a protected member}} - (void) a.sx; - } -} - -namespace test3 { - class B; - class A { - protected: int x; //expected-note {{declared protected}} // expected-note {{can only access this member on an object of type}} - static int sx; - static void test(B&); - }; - class B : public A { - static void test(B&); - }; - class C : protected A { - static void test(B&); - }; - class D : private B { - static void test(B&); - }; - - void A::test(B &b) { - (void) b.x; - (void) b.sx; - } - void B::test(B &b) { - (void) b.x; - (void) b.sx; - } - void C::test(B &b) { - (void) b.x; // expected-error {{'x' is a protected member}} - (void) b.sx; - } - void D::test(B &b) { - (void) b.x; // expected-error {{'x' is a protected member}} - (void) b.sx; - } -} - -namespace test4 { - class C; - class A { - protected: int x; // expected-note 2{{declared protected here}} expected-note{{member is declared here}} - static int sx; // expected-note 3{{member is declared here}} - static void test(C&); - }; - class B : public A { - static void test(C&); - }; - class C : protected A { // expected-note 4 {{constrained}} expected-note 3 {{declared}} - static void test(C&); - }; - class D : private B { - static void test(C&); - }; - - void A::test(C &c) { - (void) c.x; // expected-error {{'x' is a protected member}} \ - // expected-error {{protected base class}} - (void) c.sx; // expected-error {{'sx' is a protected member}} - } - void B::test(C &c) { - (void) c.x; // expected-error {{'x' is a protected member}} \ - // expected-error {{protected base class}} - (void) c.sx; // expected-error {{'sx' is a protected member}} - } - void C::test(C &c) { - (void) c.x; - (void) c.sx; - } - void D::test(C &c) { - (void) c.x; // expected-error {{'x' is a protected member}} \ - // expected-error {{protected base class}} - (void) c.sx; // expected-error {{'sx' is a protected member}} - } -} - -namespace test5 { - class D; - class A { - protected: int x; // expected-note 3{{member is declared here}} - static int sx; // expected-note 3{{member is declared here}} - static void test(D&); - }; - class B : public A { - static void test(D&); - }; - class C : protected A { - static void test(D&); - }; - class D : private B { // expected-note 9 {{constrained}} - static void test(D&); - }; - - void A::test(D &d) { - (void) d.x; // expected-error {{'x' is a private member}} \ - // expected-error {{cannot cast}} - (void) d.sx; // expected-error {{'sx' is a private member}} - } - void B::test(D &d) { - (void) d.x; // expected-error {{'x' is a private member}} \ - // expected-error {{cannot cast}} - (void) d.sx; // expected-error {{'sx' is a private member}} - } - void C::test(D &d) { - (void) d.x; // expected-error {{'x' is a private member}} \ - // expected-error {{cannot cast}} - (void) d.sx; // expected-error {{'sx' is a private member}} - } - void D::test(D &d) { - (void) d.x; - (void) d.sx; - } -} - -namespace test6 { - class Static {}; - class A { - protected: - void foo(int); // expected-note 3 {{can only access this member on an object of type}} - void foo(long); - static void foo(Static); - - static void test(A&); - }; - class B : public A { - static void test(A&); - }; - class C : protected A { - static void test(A&); - }; - class D : private B { - static void test(A&); - }; - - void A::test(A &a) { - a.foo(10); - a.foo(Static()); - } - void B::test(A &a) { - a.foo(10); // expected-error {{'foo' is a protected member}} - a.foo(Static()); - } - void C::test(A &a) { - a.foo(10); // expected-error {{'foo' is a protected member}} - a.foo(Static()); - } - void D::test(A &a) { - a.foo(10); // expected-error {{'foo' is a protected member}} - a.foo(Static()); - } -} - -namespace test7 { - class Static {}; - class A { - protected: - void foo(int); // expected-note 3 {{must name member using the type of the current context}} - void foo(long); - static void foo(Static); - - static void test(); - }; - class B : public A { - static void test(); - }; - class C : protected A { - static void test(); - }; - class D : private B { - static void test(); - }; - - void A::test() { - void (A::*x)(int) = &A::foo; - void (*sx)(Static) = &A::foo; - } - void B::test() { - void (A::*x)(int) = &A::foo; // expected-error {{'foo' is a protected member}} - void (*sx)(Static) = &A::foo; - } - void C::test() { - void (A::*x)(int) = &A::foo; // expected-error {{'foo' is a protected member}} - void (*sx)(Static) = &A::foo; - } - void D::test() { - void (A::*x)(int) = &A::foo; // expected-error {{'foo' is a protected member}} - void (*sx)(Static) = &A::foo; - } -} - -namespace test8 { - class Static {}; - class A { - protected: - void foo(int); // expected-note 3 {{must name member using the type of the current context}} - void foo(long); - static void foo(Static); - - static void test(); - }; - class B : public A { - static void test(); - }; - class C : protected A { - static void test(); - }; - class D : private B { - static void test(); - }; - void call(void (A::*)(int)); - void calls(void (*)(Static)); - - void A::test() { - call(&A::foo); - calls(&A::foo); - } - void B::test() { - call(&A::foo); // expected-error {{'foo' is a protected member}} - calls(&A::foo); - } - void C::test() { - call(&A::foo); // expected-error {{'foo' is a protected member}} - calls(&A::foo); - } - void D::test() { - call(&A::foo); // expected-error {{'foo' is a protected member}} - calls(&A::foo); - } -} - -namespace test9 { - class A { // expected-note {{member is declared here}} - protected: int foo(); // expected-note 4 {{declared}} expected-note 3 {{can only access this member on an object of type}} expected-note 2 {{member is declared here}} - }; - - class B : public A { // expected-note {{member is declared here}} - friend class D; - }; - - class C : protected B { // expected-note {{declared}} \ - // expected-note 9 {{constrained}} - }; - - class D : public A { - static void test(A &a) { - a.foo(); // expected-error {{'foo' is a protected member}} - a.A::foo(); // expected-error {{'foo' is a protected member}} - a.B::foo(); // expected-error {{'foo' is a protected member}} - a.C::foo(); // expected-error {{'foo' is a protected member}} - a.D::foo(); // expected-error {{'foo' is a protected member}} - } - - static void test(B &b) { - b.foo(); - b.A::foo(); - b.B::foo(); // accessible as named in A - b.C::foo(); // expected-error {{'foo' is a protected member}} - } - - static void test(C &c) { - c.foo(); // expected-error {{'foo' is a protected member}} \ - // expected-error {{cannot cast}} - c.A::foo(); // expected-error {{'A' is a protected member}} \ - // expected-error {{cannot cast}} - c.B::foo(); // expected-error {{'B' is a protected member}} \ - // expected-error {{cannot cast}} - c.C::foo(); // expected-error {{'foo' is a protected member}} \ - // expected-error {{cannot cast}} - } - - static void test(D &d) { - d.foo(); - d.A::foo(); - d.B::foo(); - d.C::foo(); // expected-error {{'foo' is a protected member}} - } - }; -} - -namespace test10 { - template<typename T> class A { - protected: - int foo(); - int foo() const; - - ~A() { foo(); } - }; - - template class A<int>; -} - -// rdar://problem/8360285: class.protected friendship -namespace test11 { - class A { - protected: - int foo(); - }; - - class B : public A { - friend class C; - }; - - class C { - void test() { - B b; - b.A::foo(); - } - }; -} - -// This friendship is considered because a public member of A would be -// a private member of C. -namespace test12 { - class A { protected: int foo(); }; - class B : public virtual A {}; - class C : private B { friend void test(); }; - class D : private C, public virtual A {}; - - void test() { - D d; - d.A::foo(); - } -} - -// This friendship is not considered because a public member of A is -// inaccessible in C. -namespace test13 { - class A { protected: int foo(); }; // expected-note {{declared protected here}} - class B : private virtual A {}; - class C : private B { friend void test(); }; - class D : public virtual A {}; - - void test() { - D d; - d.A::foo(); // expected-error {{protected member}} - } -} - -// PR8058 -namespace test14 { - class A { - protected: - template <class T> void temp(T t); // expected-note {{must name member using the type of the current context}} - - void nontemp(int); // expected-note {{must name member using the type of the current context}} - - template <class T> void ovl_temp(T t); // expected-note {{must name member using the type of the current context}} - void ovl_temp(float); - - void ovl_nontemp(int); // expected-note {{must name member using the type of the current context}} - void ovl_nontemp(float); - - template <class T> void ovl_withtemp(T); - void ovl_withtemp(int); // expected-note {{must name member using the type of the current context}} - }; - - class B : public A { - void use() { - void (A::*ptr)(int); - ptr = &A::temp; // expected-error {{protected member}} - ptr = &A::nontemp; // expected-error {{protected member}} - ptr = &A::ovl_temp; // expected-error {{protected member}} - ptr = &A::ovl_nontemp; // expected-error {{protected member}} - ptr = &A::ovl_withtemp; // expected-error {{protected member}} - } - }; -} - -namespace test15 { - class A { - protected: - A(); // expected-note 2 {{protected constructor can only be used to construct a base class subobject}} - A(const A &); // expected-note {{protected constructor can only be used to construct a base class subobject}} - ~A(); // expected-note 3 {{protected destructor can only be used to destroy a base class subobject}} - }; - - class B : public A { - // The uses here are fine. - B() {} - B(int i) : A() {} - ~B() {} - - // All these uses are bad. - - void test0() { - A a; // expected-error {{protected constructor}} expected-error {{protected destructor}} - } - - A *test1() { - return new A(); // expected-error {{protected constructor}} - } - - void test2(A *a) { - delete a; // expected-error {{protected destructor}} - } - - A test3(A *a) { - return *a; // expected-error {{protected constructor}} - } - - void test4(A *a) { - a->~A(); // expected-error {{protected member}} - } - }; -} - -namespace test16 { - class A { - protected: - ~A(); - }; - - class B : public virtual A { - public: - ~B() {} - }; - - class C : public B { - ~C() {} - }; -} diff --git a/test/CXX/class.access/p4.cpp b/test/CXX/class.access/p4.cpp deleted file mode 100644 index 6d452d8199e0..000000000000 --- a/test/CXX/class.access/p4.cpp +++ /dev/null @@ -1,586 +0,0 @@ -// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -fsyntax-only -verify -std=c++98 %s -// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -fsyntax-only -verify -std=c++11 %s -// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -fsyntax-only -verify %s - -// C++0x [class.access]p4: - -// Access control is applied uniformly to all names, whether the -// names are referred to from declarations or expressions. In the -// case of overloaded function names, access control is applied to -// the function selected by overload resolution. - -class Public {} PublicInst; -class Protected {} ProtectedInst; -class Private {} PrivateInst; - -namespace test0 { - class A { - public: - void foo(Public&); - protected: - void foo(Protected&); // expected-note 2 {{declared protected here}} - private: - void foo(Private&); // expected-note 2 {{declared private here}} - }; - - void test(A *op) { - op->foo(PublicInst); - op->foo(ProtectedInst); // expected-error {{'foo' is a protected member}} - op->foo(PrivateInst); // expected-error {{'foo' is a private member}} - - void (A::*a)(Public&) = &A::foo; - void (A::*b)(Protected&) = &A::foo; // expected-error {{'foo' is a protected member}} - void (A::*c)(Private&) = &A::foo; // expected-error {{'foo' is a private member}} - } -} - -// Member operators. -namespace test1 { - class A { - public: - void operator+(Public&); - void operator[](Public&); - void operator()(Public&); - typedef void (*PublicSurrogate)(Public&); - operator PublicSurrogate() const; - protected: - void operator+(Protected&); // expected-note {{declared protected here}} - void operator[](Protected&); // expected-note {{declared protected here}} - void operator()(Protected&); // expected-note {{declared protected here}} - typedef void (*ProtectedSurrogate)(Protected&); - operator ProtectedSurrogate() const; // expected-note {{declared protected here}} - private: - void operator+(Private&); // expected-note {{declared private here}} - void operator[](Private&); // expected-note {{declared private here}} - void operator()(Private&); // expected-note {{declared private here}} - void operator-(); // expected-note {{declared private here}} - typedef void (*PrivateSurrogate)(Private&); - operator PrivateSurrogate() const; // expected-note {{declared private here}} - }; - void operator+(const A &, Public&); - void operator+(const A &, Protected&); - void operator+(const A &, Private&); - void operator-(const A &); - - void test(A &a, Public &pub, Protected &prot, Private &priv) { - a + pub; - a + prot; // expected-error {{'operator+' is a protected member}} - a + priv; // expected-error {{'operator+' is a private member}} - a[pub]; - a[prot]; // expected-error {{'operator[]' is a protected member}} - a[priv]; // expected-error {{'operator[]' is a private member}} - a(pub); - a(prot); // expected-error {{'operator()' is a protected member}} - a(priv); // expected-error {{'operator()' is a private member}} - -a; // expected-error {{'operator-' is a private member}} - - const A &ca = a; - ca + pub; - ca + prot; - ca + priv; - -ca; - // These are all surrogate calls - ca(pub); - ca(prot); // expected-error {{'operator void (*)(Protected &)' is a protected member}} - ca(priv); // expected-error {{'operator void (*)(Private &)' is a private member}} - } -} - -// Implicit constructor calls. -namespace test2 { - class A { - private: - A(); // expected-note 1+{{declared private here}} - - static A foo; - }; - - A a; // expected-error {{calling a private constructor}} - A A::foo; // okay - -#if __cplusplus < 201103L - class B : A { }; // expected-error {{base class 'test2::A' has private default constructor}} - B b; // expected-note{{implicit default constructor}} - - class C : virtual A { - public: - C(); - }; - - class D : C { }; // expected-error {{inherited virtual base class 'test2::A' has private default constructor}} - D d; // expected-note{{implicit default constructor}} -#else - class B : A { }; // expected-note {{base class 'test2::A' has an inaccessible default constructor}} - B b; // expected-error {{call to implicitly-deleted default constructor}} - - // FIXME: Do a better job of explaining how we get here from class D. - class C : virtual A { // expected-note {{default constructor of 'D' is implicitly deleted because base class 'test2::A' has an inaccessible default constructor}} - public: - C(); - }; - - class D : C { }; - D d; // expected-error {{call to implicitly-deleted default constructor}} -#endif -} - -// Implicit destructor calls. -namespace test3 { - class A { - private: - ~A(); // expected-note 2 {{declared private here}} - static A foo; - }; - - A a; // expected-error {{variable of type 'test3::A' has private destructor}} - A A::foo; - - void foo(A param) { // okay - A local; // expected-error {{variable of type 'test3::A' has private destructor}} - } - -#if __cplusplus < 201103L - template <unsigned N> class Base { ~Base(); }; // expected-note 14 {{declared private here}} - class Base2 : virtual Base<2> { ~Base2(); }; // expected-note 3 {{declared private here}} \ - // expected-error {{base class 'Base<2>' has private destructor}} - class Base3 : virtual Base<3> { public: ~Base3(); }; // expected-error {{base class 'Base<3>' has private destructor}} - - // These don't cause diagnostics because we don't need the destructor. - class Derived0 : Base<0> { ~Derived0(); }; - class Derived1 : Base<1> { }; - - class Derived2 : // expected-error {{inherited virtual base class 'Base<2>' has private destructor}} \ - // expected-error {{inherited virtual base class 'Base<3>' has private destructor}} - Base<0>, // expected-error {{base class 'Base<0>' has private destructor}} - virtual Base<1>, // expected-error {{base class 'Base<1>' has private destructor}} - Base2, // expected-error {{base class 'test3::Base2' has private destructor}} - virtual Base3 - { - ~Derived2() {} - }; - - class Derived3 : // expected-error 2 {{inherited virtual base class 'Base<2>' has private destructor}} \ - // expected-error 2 {{inherited virtual base class 'Base<3>' has private destructor}} \ - // expected-note 2{{implicit default constructor}} - Base<0>, // expected-error 2 {{base class 'Base<0>' has private destructor}} - virtual Base<1>, // expected-error 2 {{base class 'Base<1>' has private destructor}} - Base2, // expected-error 2 {{base class 'test3::Base2' has private destructor}} - virtual Base3 - {}; - Derived3 d3; // expected-note 3{{implicit default constructor}}\ - // expected-note{{implicit destructor}}} -#else - template <unsigned N> class Base { ~Base(); }; // expected-note 4{{declared private here}} - class Base2 : virtual Base<2> { ~Base2(); }; // expected-note 1{{declared private here}} - class Base3 : virtual Base<3> { public: ~Base3(); }; - - // These don't cause diagnostics because we don't need the destructor. - class Derived0 : Base<0> { ~Derived0(); }; - class Derived1 : Base<1> { }; - - class Derived2 : // expected-error {{inherited virtual base class 'Base<2>' has private destructor}} \ - // expected-error {{inherited virtual base class 'Base<3>' has private destructor}} - Base<0>, // expected-error {{base class 'Base<0>' has private destructor}} - virtual Base<1>, // expected-error {{base class 'Base<1>' has private destructor}} - Base2, // expected-error {{base class 'test3::Base2' has private destructor}} - virtual Base3 - { - ~Derived2() {} - }; - - class Derived3 : - Base<0>, // expected-note {{deleted because base class 'Base<0>' has an inaccessible destructor}} - virtual Base<1>, - Base2, - virtual Base3 - {}; - Derived3 d3; // expected-error {{implicitly-deleted default constructor}} -#endif -} - -// Conversion functions. -namespace test4 { - class Base { - private: - operator Private(); // expected-note 4 {{declared private here}} - public: - operator Public(); // expected-note 2{{member is declared here}} - }; - - class Derived1 : private Base { // expected-note 2 {{declared private here}} \ - // expected-note {{constrained by private inheritance}} - Private test1() { return *this; } // expected-error {{'operator Private' is a private member}} - Public test2() { return *this; } - }; - Private test1(Derived1 &d) { return d; } // expected-error {{'operator Private' is a private member}} \ - // expected-error {{cannot cast 'test4::Derived1' to its private base class}} - Public test2(Derived1 &d) { return d; } // expected-error {{cannot cast 'test4::Derived1' to its private base class}} \ - // expected-error {{'operator Public' is a private member}} - - - class Derived2 : public Base { - Private test1() { return *this; } // expected-error {{'operator Private' is a private member}} - Public test2() { return *this; } - }; - Private test1(Derived2 &d) { return d; } // expected-error {{'operator Private' is a private member}} - Public test2(Derived2 &d) { return d; } - - class Derived3 : private Base { // expected-note {{constrained by private inheritance here}} \ - // expected-note {{declared private here}} - public: - operator Private(); - }; - Private test1(Derived3 &d) { return d; } - Public test2(Derived3 &d) { return d; } // expected-error {{'operator Public' is a private member of 'test4::Base'}} \ - // expected-error {{cannot cast 'test4::Derived3' to its private base class}} - - class Derived4 : public Base { - public: - operator Private(); - }; - Private test1(Derived4 &d) { return d; } - Public test2(Derived4 &d) { return d; } -} - -// Implicit copy assignment operator uses. -namespace test5 { - class A { - void operator=(const A &); -#if __cplusplus < 201103L - // expected-note@-2 2{{implicitly declared private here}} -#endif - }; - -#if __cplusplus < 201103L - class Test1 { A a; }; // expected-error {{private member}} - void test1() { - Test1 a; - a = Test1(); // expected-note{{implicit copy}} - } - - class Test2 : A {}; // expected-error {{private member}} - void test2() { - Test2 a; - a = Test2(); // expected-note{{implicit copy}} - } -#else - class Test1 { A a; }; // expected-note {{because field 'a' has an inaccessible copy assignment operator}} - void test1() { - Test1 a; - a = Test1(); // expected-error {{copy assignment operator is implicitly deleted}} - } - - class Test2 : A {}; // expected-note {{because base class 'test5::A' has an inaccessible copy assignment operator}} - void test2() { - Test2 a; - a = Test2(); // expected-error {{copy assignment operator is implicitly deleted}} - } -#endif -} - -// Implicit copy constructor uses. -namespace test6 { - class A { - public: A(); - private: A(const A &); -#if __cplusplus < 201103L - // expected-note@-2 2{{declared private here}} -#endif - }; - -#if __cplusplus < 201103L - class Test1 { A a; }; // expected-error {{field of type 'test6::A' has private copy constructor}} - void test1(const Test1 &t) { - Test1 a = t; // expected-note{{implicit copy}} - } - - class Test2 : A {}; // expected-error {{base class 'test6::A' has private copy constructor}} - void test2(const Test2 &t) { - Test2 a = t; // expected-note{{implicit copy}} - } -#else - class Test1 { A a; }; // expected-note {{field 'a' has an inaccessible copy constructor}} - void test1(const Test1 &t) { - Test1 a = t; // expected-error{{implicitly-deleted}} - } - - class Test2 : A {}; // expected-note {{base class 'test6::A' has an inaccessible copy constructor}} - void test2(const Test2 &t) { - Test2 a = t; // expected-error{{implicitly-deleted}} - } -#endif -} - -// Redeclaration lookups are not accesses. -namespace test7 { - class A { - int private_member; - }; - class B : A { - int foo(int private_member) { - return 0; - } - }; -} - -// Ignored operator new and delete overloads are not -namespace test8 { - typedef __typeof__(sizeof(int)) size_t; - - class A { - void *operator new(size_t s); - void operator delete(void *p); - public: - void *operator new(size_t s, int n); - void operator delete(void *p, int n); - }; - - void test() { - new (2) A(); - } -} - -// Don't silently upgrade forbidden-access paths to private. -namespace test9 { - class A { - public: static int x; // expected-note {{member is declared here}} - }; - class B : private A { // expected-note {{constrained by private inheritance here}} - }; - class C : public B { - static int getX() { return x; } // expected-error {{'x' is a private member of 'test9::A'}} - }; -} - -namespace test10 { - class A { - enum { - value = 10 // expected-note {{declared private here}} - }; - friend class C; - }; - - class B { - enum { - value = A::value // expected-error {{'value' is a private member of 'test10::A'}} - }; - }; - - class C { - enum { - value = A::value - }; - }; -} - -namespace test11 { - class A { - protected: virtual ~A(); - }; - - class B : public A { - ~B(); - }; - - B::~B() {}; -} - -namespace test12 { - class A { - int x; - - void foo() { - class Local { - int foo(A *a) { - return a->x; - } - }; - } - }; -} - -namespace test13 { - struct A { - int x; - unsigned foo() const; - }; - - struct B : protected A { - using A::foo; - using A::x; - }; - - void test() { - A *d; - d->foo(); - (void) d->x; - } -} - -// Destructors for temporaries. -namespace test14 { - class A { - private: ~A(); // expected-note {{declared private here}} - }; - A foo(); - - void test() { - foo(); // expected-error {{temporary of type 'test14::A' has private destructor}} - } - - class X { - ~X(); // expected-note {{declared private here}} - }; - - struct Y1 { - operator X(); - }; - - void g() { - const X &xr = Y1(); // expected-error{{temporary of type 'test14::X' has private destructor}} - } -} - -// PR 7024 -namespace test15 { - template <class T> class A { - private: - int private_foo; // expected-note {{declared private here}} - static int private_sfoo; // expected-note {{declared private here}} - protected: - int protected_foo; // expected-note 3 {{declared protected here}} // expected-note {{can only access this member on an object of type 'test15::B<int>'}} - static int protected_sfoo; // expected-note 3 {{declared protected here}} - - int test1(A<int> &a) { - return a.private_foo; // expected-error {{private member}} - } - - int test2(A<int> &a) { - return a.private_sfoo; // expected-error {{private member}} - } - - int test3(A<int> &a) { - return a.protected_foo; // expected-error {{protected member}} - } - - int test4(A<int> &a) { - return a.protected_sfoo; // expected-error {{protected member}} - } - }; - - template class A<int>; - template class A<long>; // expected-note 4 {{in instantiation}} - - template <class T> class B : public A<T> { - // TODO: These first two accesses can be detected as ill-formed at - // definition time because they're member accesses and A<int> can't - // be a subclass of B<T> for any T. - - int test1(A<int> &a) { - return a.protected_foo; // expected-error 2 {{protected member}} - } - - int test2(A<int> &a) { - return a.protected_sfoo; // expected-error {{protected member}} - } - - int test3(B<int> &b) { - return b.protected_foo; // expected-error {{protected member}} - } - - int test4(B<int> &b) { - return b.protected_sfoo; // expected-error {{protected member}} - } - }; - - template class B<int>; // expected-note {{in instantiation}} - template class B<long>; // expected-note 4 {{in instantiation}} -} - -// PR7281 -namespace test16 { - class A { ~A(); }; // expected-note 2{{declared private here}} - void b() { throw A(); } // expected-error{{temporary of type 'test16::A' has private destructor}} \ - // expected-error{{exception object of type 'test16::A' has private destructor}} -} - -// rdar://problem/8146294 -namespace test17 { - class A { - template <typename T> class Inner { }; // expected-note {{declared private here}} - }; - - A::Inner<int> s; // expected-error {{'Inner' is a private member of 'test17::A'}} -} - -namespace test18 { - template <class T> class A {}; - class B : A<int> { - A<int> member; - }; - - // FIXME: this access to A should be forbidden (because C++ is dumb), - // but LookupResult can't express the necessary information to do - // the check, so we aggressively suppress access control. - class C : B { - A<int> member; - }; -} - -// PR8325 -namespace test19 { - class A { ~A(); }; - // The destructor is not implicitly referenced here. Contrast to test16, - // testing PR7281, earlier in this file. - void b(A* x) { throw x; } -} - -// PR7930 -namespace test20 { - class Foo { - Foo(); // expected-note {{implicitly declared private here}} - }; - Foo::Foo() {} - - void test() { - Foo a; // expected-error {{calling a private constructor}} - } -} - -namespace test21 { - template <class T> class A { - void foo(); - void bar(); - class Inner; // expected-note {{implicitly declared private here}} - public: - void baz(); - }; - template <class T> class A<T>::Inner {}; - class B { - template <class T> class A<T>::Inner; // expected-error{{non-friend class member 'Inner' cannot have a qualified name}} - }; - - void test() { - A<int>::Inner i; // expected-error {{'Inner' is a private member}} - } -} - -namespace rdar8876150 { - struct A { operator bool(); }; - struct B : private A { using A::operator bool; }; - - bool f() { - B b; - return !b; - } -} - -namespace test23 { - template <typename T> class A { - A(); - static A instance; - }; - - template <typename T> A<T> A<T>::instance; - template class A<int>; -} diff --git a/test/CXX/class.access/p6.cpp b/test/CXX/class.access/p6.cpp deleted file mode 100644 index f9b95f0851ef..000000000000 --- a/test/CXX/class.access/p6.cpp +++ /dev/null @@ -1,192 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s - -// C++0x [class.access]p6: -// All access controls in [class.access] affect the ability to -// access a class member name from a particular scope. For purposes -// of access control, the base-specifiers of a class and the -// definitions of class members that appear outside of the class -// definition are considered to be within the scope of that -// class. In particular, access controls apply as usual to member -// names accessed as part of a function return type, even though it -// is not possible to determine the access privileges of that use -// without first parsing the rest of the function -// declarator. Similarly, access control for implicit calls to the -// constructors, the conversion functions, or the destructor called -// to create and destroy a static data member is performed as if -// these calls appeared in the scope of the member's class. - -struct Public {}; struct Protected {}; struct Private {}; - -namespace test0 { - class A { - typedef int type; // expected-note {{declared private here}} - type foo(); - }; - - A::type foo() { } // expected-error {{'type' is a private member}} - A::type A::foo() { } -} - -// conversion decls -namespace test1 { - class A { - public: - A(); - operator Public (); - A(Public); - protected: - operator Protected (); // expected-note {{declared protected here}} - A(Protected); // expected-note {{declared protected here}} - private: - operator Private (); // expected-note {{declared private here}} - A(Private); // expected-note {{declared private here}} - }; - - void test() { - A a; - Public pub = a; - Protected prot = a; // expected-error {{'operator Protected' is a protected member}} - Private priv = a; // expected-error {{'operator Private' is a private member}} - A apub = pub; - A aprot = prot; // expected-error {{protected constructor}} - A apriv = priv; // expected-error {{private constructor}} - } -} - -// PR6967 -namespace test2 { - class A { - public: - template <class T> static void set(T &t, typename T::type v) { - t.value = v; - } - template <class T> static typename T::type get(const T &t) { - return t.value; - } - }; - - class B { - friend class A; - - private: - typedef int type; - type value; - }; - - int test() { - B b; - A::set(b, 0); - return A::get(b); - } -} - -namespace test3 { - class Green {}; class Blue {}; - - // We have to wrap this in a class because a partial specialization - // isn't actually in the context of the template. - struct Outer { - template <class T, class Nat> class A { - }; - }; - - template <class T> class Outer::A<T, typename T::nature> { - public: - static void foo(); // expected-note {{'Outer::A<B, Green>::foo' declared here}} - }; - - class B { - private: typedef Green nature; - friend class Outer; - }; - - void test() { - Outer::A<B, Green>::foo(); - Outer::A<B, Blue>::foo(); // expected-error {{no member named 'foo' in 'test3::Outer::A<test3::B, test3::Blue>'; did you mean 'Outer::A<B, Green>::foo'?}} - } -} - -namespace test4 { - template <class T> class A { - private: typedef int type; - template <class U> friend void foo(U &, typename U::type); - }; - - template <class U> void foo(U &, typename U::type) {} - - void test() { - A<int> a; - foo(a, 0); - } -} - -// PR7644 -namespace test5 { - class A { - enum Enum { E0, E1, E2 }; // expected-note 4 {{declared private here}} - template <Enum> void foo(); - template <Enum> class bar; - }; - - template <A::Enum en> void A::foo() {} - template <A::Enum en> class A::bar {}; - - template <A::Enum en> void foo() {} // expected-error {{'Enum' is a private member of 'test5::A'}} - template <A::Enum en> class bar {}; // expected-error {{'Enum' is a private member of 'test5::A'}} - - class B { - template <A::Enum en> void foo() {} // expected-error {{'Enum' is a private member of 'test5::A'}} - template <A::Enum en> class bar {}; // expected-error {{'Enum' is a private member of 'test5::A'}} - }; -} - -namespace test6 { - class A { - public: class public_inner {}; - protected: class protected_inner {}; - private: class private_inner {}; // expected-note {{declared private here}} - }; - - class B : A { - public_inner a; - protected_inner b; - private_inner c; // expected-error {{'private_inner' is a private member of 'test6::A'}} - }; -} - -// PR9229 -namespace test7 { - void foo(int arg[1]); - class A { - void check(); - }; - class B { - friend class A; - A ins; - }; - void A::check() { - void foo(int arg[__builtin_offsetof(B, ins)]); - } -} - -// rdar://problem/10155256 -namespace test8 { - class A { - typedef void* (A::*UnspecifiedBoolType)() const; - operator UnspecifiedBoolType() const; // expected-note {{implicitly declared private here}} - }; - - void test(A &a) { - if (a) return; // expected-error-re {{'operator void *(test8::A::*)(){{( __attribute__\(\(thiscall\)\))?}} const' is a private member of 'test8::A'}} - } -} - -namespace test9 { - class A { - operator char*() const; // expected-note {{implicitly declared private here}} - }; - - void test(A &a) { - delete a; // expected-error {{'operator char *' is a private member of 'test9::A'}} - } -} diff --git a/test/CXX/class.derived/class.abstract/p16.cpp b/test/CXX/class.derived/class.abstract/p16.cpp deleted file mode 100644 index fe31b7321bd0..000000000000 --- a/test/CXX/class.derived/class.abstract/p16.cpp +++ /dev/null @@ -1,52 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s - -struct A { - virtual void a(); // expected-note{{overridden virtual function is here}} - virtual void b() = delete; // expected-note{{overridden virtual function is here}} -}; - -struct B: A { - virtual void a() = delete; // expected-error{{deleted function 'a' cannot override a non-deleted function}} - virtual void b(); // expected-error{{non-deleted function 'b' cannot override a deleted function}} -}; - -struct C: A { - virtual void a(); - virtual void b() = delete; -}; - -struct E; -struct F; -struct G; -struct H; -struct D { - virtual E &operator=(const E &); // expected-note {{here}} - virtual F &operator=(const F &); - virtual G &operator=(G&&); // expected-note {{here}} - virtual H &operator=(H&&); // expected-note {{here}} - friend struct F; - -private: - D &operator=(const D&) = default; - D &operator=(D&&) = default; - virtual ~D(); // expected-note 2{{here}} -}; -struct E : D {}; -// expected-error@-1 {{deleted function '~E' cannot override a non-deleted function}} -// expected-note@-2 {{destructor of 'E' is implicitly deleted because base class 'D' has an inaccessible destructor}} -// expected-error@-3 {{deleted function 'operator=' cannot override a non-deleted function}} -// expected-note@-4 {{while declaring the implicit copy assignment operator for 'E'}} -// expected-note@-5 {{copy assignment operator of 'E' is implicitly deleted because base class 'D' has an inaccessible copy assignment operator}} -struct F : D {}; -struct G : D {}; -// expected-error@-1 {{deleted function '~G' cannot override a non-deleted function}} -// expected-note@-2 {{destructor of 'G' is implicitly deleted because base class 'D' has an inaccessible destructor}} -// expected-error@-3 {{deleted function 'operator=' cannot override a non-deleted function}} -// expected-note@-4 {{while declaring the implicit move assignment operator for 'G'}} -// expected-note@-5 {{move assignment operator of 'G' is implicitly deleted because base class 'D' has an inaccessible move assignment operator}} -struct H : D { // expected-note {{deleted because base class 'D' has an inaccessible move assignment}} - H &operator=(H&&) = default; // expected-warning {{implicitly deleted}} - // expected-error@-1 {{deleted function 'operator=' cannot override a non-deleted function}} - // expected-note@-3 {{move assignment operator of 'H' is implicitly deleted because base class 'D' has an inaccessible move assignment operator}} - ~H(); -}; diff --git a/test/CXX/class.derived/class.abstract/p2.cpp b/test/CXX/class.derived/class.abstract/p2.cpp deleted file mode 100644 index 713a5269f143..000000000000 --- a/test/CXX/class.derived/class.abstract/p2.cpp +++ /dev/null @@ -1,23 +0,0 @@ -// RUN: %clang_cc1 -std=c++1z -verify %s - -// no objects of an abstract class can be created except as subobjects of a -// class derived from it - -struct A { - A() {} - A(int) : A() {} // ok - - virtual void f() = 0; // expected-note 1+{{unimplemented}} -}; - -void f(A &&a); - -void g() { - f({}); // expected-error {{abstract class}} - f({0}); // expected-error {{abstract class}} - f(0); // expected-error {{abstract class}} -} - -struct B : A { - B() : A() {} // ok -}; diff --git a/test/CXX/class.derived/class.abstract/p3.cpp b/test/CXX/class.derived/class.abstract/p3.cpp deleted file mode 100644 index ad5b87478835..000000000000 --- a/test/CXX/class.derived/class.abstract/p3.cpp +++ /dev/null @@ -1,97 +0,0 @@ -// RUN: %clang_cc1 -std=c++1z -verify %s - -struct A { - A() {} - A(int) : A() {} // ok - - virtual void f() = 0; // expected-note 1+{{unimplemented}} -}; - -template<typename> struct SecretlyAbstract { - SecretlyAbstract(); - SecretlyAbstract(int); - virtual void f() = 0; // expected-note 1+{{unimplemented}} -}; -using B = SecretlyAbstract<int>; -using C = SecretlyAbstract<float>; -using D = SecretlyAbstract<char>[1]; - -B b; // expected-error {{abstract class}} -D d; // expected-error {{abstract class}} - -template<int> struct N; - -// Note: C is not instantiated anywhere in this file, so we never discover that -// it is in fact abstract. The C++ standard suggests that we need to -// instantiate in all cases where abstractness could affect the validity of a -// program, but that breaks a *lot* of code, so we don't do that. -// -// FIXME: Once DR1640 is resolved, remove the check on forming an abstract -// array type entirely. The only restriction we need is that you can't create -// an object of abstract (most-derived) type. - - -// An abstract class shall not be used - -// - as a parameter type -void f(A&); -void f(A); // expected-error {{abstract class}} -void f(A[1]); // expected-error {{abstract class}} -void f(B); // expected-error {{abstract class}} -void f(B[1]); // expected-error {{abstract class}} -void f(C); -void f(C[1]); -void f(D); // expected-error {{abstract class}} -void f(D[1]); // expected-error {{abstract class}} - -// - as a function return type -A &f(N<0>); -A *f(N<1>); -A f(N<2>); // expected-error {{abstract class}} -A (&f(N<3>))[2]; // expected-error {{abstract class}} -B f(N<4>); // expected-error {{abstract class}} -B (&f(N<5>))[2]; // expected-error {{abstract class}} -C f(N<6>); -C (&f(N<7>))[2]; - -// - as the type of an explicit conversion -void g(A&&); -void h() { - A(); // expected-error {{abstract class}} - A(0); // expected-error {{abstract class}} - A{}; // expected-error {{abstract class}} - A{0}; // expected-error {{abstract class}} - (A)(0); // expected-error {{abstract class}} - (A){}; // expected-error {{abstract class}} - (A){0}; // expected-error {{abstract class}} - - D(); // expected-error {{array type}} - D{}; // expected-error {{abstract class}} - D{0}; // expected-error {{abstract class}} - (D){}; // expected-error {{abstract class}} - (D){0}; // expected-error {{abstract class}} -} - -template<typename T> void t(T); // expected-note 2{{abstract class}} -void i(A &a, B &b, C &c, D &d) { - // FIXME: These should be handled consistently. We currently reject the first - // two early because we (probably incorrectly, depending on dr1640) take - // abstractness into account in forming implicit conversion sequences. - t(a); // expected-error {{no matching function}} - t(b); // expected-error {{no matching function}} - t(c); // expected-error {{allocating an object of abstract class type}} - t(d); // ok, decays to pointer -} - -struct E : A { - E() : A() {} // ok - E(int n) : A( A(n) ) {} // expected-error {{abstract class}} -}; - -namespace std { - template<typename T> struct initializer_list { - const T *begin, *end; - initializer_list(); - }; -} -std::initializer_list<A> ila = {1, 2, 3, 4}; // expected-error {{abstract class}} diff --git a/test/CXX/class.derived/class.abstract/p4.cpp b/test/CXX/class.derived/class.abstract/p4.cpp deleted file mode 100644 index b04de213874f..000000000000 --- a/test/CXX/class.derived/class.abstract/p4.cpp +++ /dev/null @@ -1,80 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s - -namespace PR6631 { - struct A { - virtual void f() = 0; - }; - - struct B : virtual A { }; - - struct C : virtual A { - virtual void f(); - }; - - struct D : public B, public C { - virtual void f(); - }; - - void f() { - (void)new D; // okay - } -} - -// Check cases where we have a virtual function that is pure in one -// subobject but not pure in another subobject. -namespace PartlyPure { - struct A { - virtual void f() = 0; // expected-note{{unimplemented pure virtual method}} - }; - - struct B : A { - virtual void f(); - }; - - struct C : virtual A { }; - - struct D : B, C { }; - - void f() { - (void) new D; // expected-error{{abstract class}} - } -} - -namespace NonPureAlongOnePath { - struct A { - virtual void f() = 0; - }; - - struct B : virtual A { - virtual void f(); - }; - - struct C : virtual A { }; - - struct D : B, C { }; - - void f() { - (void) new D; // okay - } -} - -namespace NonPureAlongOnePath2 { - struct Aprime { - virtual void f() = 0; - }; - - struct A : Aprime { - }; - - struct B : virtual A { - virtual void f(); - }; - - struct C : virtual A { }; - - struct D : B, C { }; - - void f() { - (void) new D; // okay - } -} diff --git a/test/CXX/class.derived/class.abstract/p5.cpp b/test/CXX/class.derived/class.abstract/p5.cpp deleted file mode 100644 index cdff93122344..000000000000 --- a/test/CXX/class.derived/class.abstract/p5.cpp +++ /dev/null @@ -1,23 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s - -struct A { - virtual void f() = 0; // expected-note{{unimplemented pure virtual method}} -}; - -struct B : A { - virtual void f(); -}; - -struct C : B { - virtual void f() = 0; // expected-note 2{{unimplemented pure virtual method}} -}; - -struct D : C { -}; - -void test() { - (void)new A; // expected-error{{abstract class}} - (void)new B; - (void)new C; // expected-error{{abstract class}} - (void)new D; // expected-error{{abstract class}} -} diff --git a/test/CXX/class.derived/class.member.lookup/p10.cpp b/test/CXX/class.derived/class.member.lookup/p10.cpp deleted file mode 100644 index afd87521885a..000000000000 --- a/test/CXX/class.derived/class.member.lookup/p10.cpp +++ /dev/null @@ -1,114 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -Wshadow-all - -// Basic cases, ambiguous paths, and fields with different access -class A { -public: - int x; // expected-note 2{{declared here}} -protected: - int y; // expected-note 2{{declared here}} -private: - int z; -}; - -struct B : A { -}; - -struct C : A { -}; - -struct W { - int w; // expected-note {{declared here}} -}; - -struct U : W { -}; - -struct V : W { -}; - -class D { -public: - char w; // expected-note {{declared here}} -private: - char x; -}; - -// Check direct inheritance and multiple paths to the same base. -class E : B, C, D, U, V -{ - unsigned x; // expected-warning {{non-static data member 'x' of 'E' shadows member inherited from type 'A'}} - char y; // expected-warning {{non-static data member 'y' of 'E' shadows member inherited from type 'A'}} - double z; - char w; // expected-warning {{non-static data member 'w' of 'E' shadows member inherited from type 'D'}} expected-warning {{non-static data member 'w' of 'E' shadows member inherited from type 'W'}} -}; - -// Virtual inheritance -struct F : virtual A { -}; - -struct G : virtual A { -}; - -class H : F, G { - int x; // expected-warning {{non-static data member 'x' of 'H' shadows member inherited from type 'A'}} - int y; // expected-warning {{non-static data member 'y' of 'H' shadows member inherited from type 'A'}} - int z; -}; - -// Indirect inheritance -struct I { - union { - int x; // expected-note {{declared here}} - int y; - }; -}; - -struct J : I { - int x; // expected-warning {{non-static data member 'x' of 'J' shadows member inherited from type 'I'}} -}; - -// non-access paths -class N : W { -}; - -struct K { - int y; -}; - -struct L : private K { -}; - -struct M : L { - int y; - int w; -}; - -// Multiple ambiguous paths with different accesses -struct A1 { - int x; // expected-note {{declared here}} -}; - -class B1 : A1 { -}; - -struct B2 : A1 { -}; - -struct C1 : B1, B2 { -}; - -class D1 : C1 { -}; - -struct D2 : C1 { -}; - -class D3 : C1 { -}; - -struct E1 : D1, D2, D3{ - int x; // expected-warning {{non-static data member 'x' of 'E1' shadows member inherited from type 'A1'}} -}; - - - diff --git a/test/CXX/class.derived/class.member.lookup/p6.cpp b/test/CXX/class.derived/class.member.lookup/p6.cpp deleted file mode 100644 index 0a400a2405e9..000000000000 --- a/test/CXX/class.derived/class.member.lookup/p6.cpp +++ /dev/null @@ -1,40 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -Wshadow-field - -class V { -public: - int f(); - int x; // expected-note {{declared here}} -}; - -class W { -public: - int g(); // expected-note{{member found by ambiguous name lookup}} - int y; // expected-note{{member found by ambiguous name lookup}} expected-note {{declared here}} -}; - -class B : public virtual V, public W -{ -public: - int f(); - int x; // expected-warning {{non-static data member 'x' of 'B' shadows member inherited from type 'V'}} - int g(); // expected-note{{member found by ambiguous name lookup}} - int y; // expected-note{{member found by ambiguous name lookup}} expected-warning {{non-static data member 'y' of 'B' shadows member inherited from type 'W'}} -}; - -class C : public virtual V, public W { }; - -class D : public B, public C { void glorp(); }; - -void D::glorp() { - x++; - f(); - y++; // expected-error{{member 'y' found in multiple base classes of different types}} - g(); // expected-error{{member 'g' found in multiple base classes of different types}} -} - -// PR6462 -struct BaseIO { BaseIO* rdbuf() { return 0; } }; -struct Pcommon : virtual BaseIO { int rdbuf() { return 0; } }; -struct P : virtual BaseIO, Pcommon {}; - -void f() { P p; p.rdbuf(); } diff --git a/test/CXX/class.derived/class.member.lookup/p7.cpp b/test/CXX/class.derived/class.member.lookup/p7.cpp deleted file mode 100644 index 775057792c5c..000000000000 --- a/test/CXX/class.derived/class.member.lookup/p7.cpp +++ /dev/null @@ -1,9 +0,0 @@ -// RUN: %clang_cc1 -verify %s -Wshadow-field - -struct A { int n; }; // expected-note {{declared here}} -struct B { float n; }; // expected-note {{declared here}} -struct C : A, B {}; -struct D : virtual C {}; -struct E : virtual C { char n; }; // expected-warning {{non-static data member 'n' of 'E' shadows member inherited from type 'A'}} expected-warning {{non-static data member 'n' of 'E' shadows member inherited from type 'B'}} -struct F : D, E {} f; -char &k = f.n; diff --git a/test/CXX/class.derived/class.member.lookup/p8.cpp b/test/CXX/class.derived/class.member.lookup/p8.cpp deleted file mode 100644 index 4d4acc3460e4..000000000000 --- a/test/CXX/class.derived/class.member.lookup/p8.cpp +++ /dev/null @@ -1,63 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s - -// FIXME: Access control checks - -namespace PR5820 { - // also <rdar://problem/7535045> - struct Base { - void Foo(); - int Member; - }; - - struct D1 : public Base {}; - struct D2 : public Base {}; - - struct Derived : public D1, public D2 { - void Inner(); - }; - - void Test() { - Derived d; - d.D1::Foo(); - d.D1::Member = 17; - } - - void Derived::Inner() { - D1::Foo(); - D1::Member = 42; - this->D1::Foo(); - this->D1::Member = 42; - } -} - -template<typename T> -struct BaseT { - void Foo(); // expected-note{{found by ambiguous name lookup}} - int Member; -}; - -template<typename T> struct Derived1T : BaseT<T> { }; -template<typename T> struct Derived2T : BaseT<T> { }; - -template<typename T> -struct DerivedT : public Derived1T<T>, public Derived2T<T> { - void Inner(); -}; - -template<typename T> -void DerivedT<T>::Inner() { - Derived1T<T>::Foo(); - Derived2T<T>::Member = 42; - this->Derived1T<T>::Foo(); - this->Derived2T<T>::Member = 42; - this->Foo(); // expected-error{{non-static member 'Foo' found in multiple base-class subobjects of type 'BaseT<int>'}} -} - -template<typename T> -void Test(DerivedT<T> d) { - d.template Derived1T<T>::Foo(); - d.template Derived2T<T>::Member = 17; - d.Inner(); // expected-note{{in instantiation}} -} - -template void Test(DerivedT<int>); diff --git a/test/CXX/class.derived/class.member.lookup/p9.cpp b/test/CXX/class.derived/class.member.lookup/p9.cpp deleted file mode 100644 index ba7bd21f8699..000000000000 --- a/test/CXX/class.derived/class.member.lookup/p9.cpp +++ /dev/null @@ -1,28 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s - -namespace rdar8436162 { - class ClsA { - public: - static void f(); - void g(); - }; - - class ClsB : virtual private ClsA { - public: - using ClsA::f; - using ClsA::g; // expected-note{{member found by ambiguous name lookup}} - }; - - class ClsF : virtual private ClsA { - public: - using ClsA::f; - using ClsA::g; // expected-note{{member found by ambiguous name lookup}} - }; - - class ClsE : public ClsB, public ClsF { - void test() { - f(); - g(); // expected-error{{member 'g' found in multiple base classes of different types}} - } - }; -} diff --git a/test/CXX/class.derived/class.virtual/p12.cpp b/test/CXX/class.derived/class.virtual/p12.cpp deleted file mode 100644 index 208a0d155fe7..000000000000 --- a/test/CXX/class.derived/class.virtual/p12.cpp +++ /dev/null @@ -1,19 +0,0 @@ -// RUN: %clang_cc1 -ast-print %s | FileCheck %s - -// CHECK: test12_A::foo() -struct test12_A { - virtual void foo(); - - void bar() { - test12_A::foo(); - } -}; - -// CHECK: xp->test24_B::wibble() -struct test24_B { - virtual void wibble(); -}; - -void foo(test24_B *xp) { - xp->test24_B::wibble(); -} diff --git a/test/CXX/class.derived/class.virtual/p2.cpp b/test/CXX/class.derived/class.virtual/p2.cpp deleted file mode 100644 index 9e8d243fc3b0..000000000000 --- a/test/CXX/class.derived/class.virtual/p2.cpp +++ /dev/null @@ -1,37 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -Wno-inaccessible-base %s -struct A { - virtual void f() = 0; // expected-note 2{{overridden virtual function}} -}; - -struct Aprime : virtual A { - virtual void f(); -}; - -struct B : Aprime { - virtual void f(); // expected-note 3{{final overrider of 'A::f'}} -}; - -struct C : virtual A { - virtual void f(); // expected-note{{final overrider of 'A::f'}} -}; - -struct D : B, C { }; // expected-error{{virtual function 'A::f' has more than one final overrider in 'D'}} - -struct B2 : B { }; - -struct E : B, B2 { }; //expected-error{{virtual function 'A::f' has more than one final overrider in 'E'}} - -struct F : B, B2 { - virtual void f(); // okay -}; - -struct G : F { }; // okay - -struct H : G, A { }; // okay - -namespace MultipleSubobjects { - struct A { virtual void f(); }; - struct B : A { virtual void f(); }; - struct C : A { virtual void f(); }; - struct D : B, C { }; // okay -} diff --git a/test/CXX/class.derived/class.virtual/p3-0x.cpp b/test/CXX/class.derived/class.virtual/p3-0x.cpp deleted file mode 100644 index 41a5954bf863..000000000000 --- a/test/CXX/class.derived/class.virtual/p3-0x.cpp +++ /dev/null @@ -1,152 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s - -namespace Test1 { - -struct B { - virtual void f(int); -}; - -struct D : B { - virtual void f(long) override; // expected-error {{'f' marked 'override' but does not override any member functions}} - void f(int) override; -}; -} - -namespace Test2 { - -struct A { - virtual void f(int, char, int); -}; - -template<typename T> -struct B : A { - // FIXME: Diagnose this. - virtual void f(T) override; -}; - -template<typename T> -struct C : A { - virtual void f(int) override; // expected-error {{does not override}} -}; - -} - -namespace Test3 { - -struct A { - virtual void f(int, char, int); -}; - -template<typename... Args> -struct B : A { - virtual void f(Args...) override; // expected-error {{'f' marked 'override' but does not override any member functions}} -}; - -template struct B<int, char, int>; -template struct B<int>; // expected-note {{in instantiation of template class 'Test3::B<int>' requested here}} - -} - -namespace Test4 { -struct B { - virtual void f() const final; // expected-note {{overridden virtual function is here}} -}; - -struct D : B { - void f() const; // expected-error {{declaration of 'f' overrides a 'final' function}} -}; - -} - -namespace PR13499 { - struct X { - virtual void f(); - virtual void h(); - }; - template<typename T> struct A : X { - void f() override; - void h() final; - }; - template<typename T> struct B : X { - void g() override; // expected-error {{only virtual member functions can be marked 'override'}} - void i() final; // expected-error {{only virtual member functions can be marked 'final'}} - }; - B<int> b; // no-note - template<typename T> struct C : T { - void g() override; - void i() final; - }; - template<typename T> struct D : X { - virtual void g() override; // expected-error {{does not override}} - virtual void i() final; - }; - template<typename...T> struct E : X { - void f(T...) override; - void g(T...) override; // expected-error {{only virtual member functions can be marked 'override'}} - void h(T...) final; - void i(T...) final; // expected-error {{only virtual member functions can be marked 'final'}} - }; - // FIXME: Diagnose these in the template definition, not in the instantiation. - E<> e; // expected-note {{in instantiation of}} - - template<typename T> struct Y : T { - void f() override; - void h() final; - }; - template<typename T> struct Z : T { - void g() override; // expected-error {{only virtual member functions can be marked 'override'}} - void i() final; // expected-error {{only virtual member functions can be marked 'final'}} - }; - Y<X> y; - Z<X> z; // expected-note {{in instantiation of}} -} - -namespace MemberOfUnknownSpecialization { - template<typename T> struct A { - struct B {}; - struct C : B { - void f() override; - }; - }; - - template<> struct A<int>::B { - virtual void f(); - }; - // ok - A<int>::C c1; - - template<> struct A<char>::B { - void f(); - }; - // expected-error@-13 {{only virtual member functions can be marked 'override'}} - // expected-note@+1 {{in instantiation of}} - A<char>::C c2; - - template<> struct A<double>::B { - virtual void f() final; - }; - // expected-error@-20 {{declaration of 'f' overrides a 'final' function}} - // expected-note@-3 {{here}} - // expected-note@+1 {{in instantiation of}} - A<double>::C c3; -} - -namespace DiagnosticsQOI { - struct X { - virtual ~X(); - virtual void foo(int x); // expected-note {{hidden overloaded virtual function}} - virtual void bar(int x); // expected-note 2 {{hidden overloaded virtual function}} - virtual void bar(float x); // expected-note 2 {{hidden overloaded virtual function}} - }; - - struct Y : X { - void foo(int x, int y) override; // expected-error {{non-virtual member function marked 'override' hides virtual member function}} - void bar(double) override; // expected-error {{non-virtual member function marked 'override' hides virtual member functions}} - void bar(long double) final; // expected-error {{non-virtual member function marked 'final' hides virtual member functions}} - }; - - template<typename T> - struct Z : T { - static void foo() override; // expected-error {{only virtual member functions can be marked 'override'}} - }; -} diff --git a/test/CXX/class.derived/p1.cpp b/test/CXX/class.derived/p1.cpp deleted file mode 100644 index dc5cb2b8c2a3..000000000000 --- a/test/CXX/class.derived/p1.cpp +++ /dev/null @@ -1,40 +0,0 @@ -// RUN: %clang_cc1 %s -fsyntax-only -verify -std=c++11 - -// base-clause: -// : base-specifier-list -// base-specifier-list: -// base-specifier ...[opt] -// base-specifier-list , base-specifier ...[opt] -// base-specifier: -// attribute-specifier-seq[opt] base-type-specifier -// attribute-specifier-seq[opt] virtual access-specifier[opt] base-type-specifier -// attribute-specifier-seq[opt] access-specifier virtual[opt] base-type-specifier -// class-or-decltype: -// nested-name-specifier[opt] class-name -// decltype-specifier -// base-type-specifier: -// class-or-decltype -// access-specifier: -// private -// protected -// public - -namespace PR11216 { - struct Base { }; - struct Derived : decltype(Base()) { }; - - int func(); - struct Derived2 : decltype(func()) { }; // expected-error {{base specifier must name a class}} - - template<typename T> - struct Derived3 : decltype(T().foo()) { }; - struct Foo { Base foo(); }; - Derived3<Foo> d; - - struct Derived4 : :: decltype(Base()) { }; // expected-error {{unexpected namespace scope prior to decltype}} - - struct Derived5 : PR11216:: decltype(Base()) { }; // expected-error {{unexpected namespace scope prior to decltype}} - - template<typename T> - struct Derived6 : typename T::foo { }; // expected-error {{'typename' is redundant; base classes are implicitly types}} -} diff --git a/test/CXX/class.derived/p2.cpp b/test/CXX/class.derived/p2.cpp deleted file mode 100644 index 87e0f7486154..000000000000 --- a/test/CXX/class.derived/p2.cpp +++ /dev/null @@ -1,9 +0,0 @@ -// RUN: %clang_cc1 %s -fsyntax-only -verify -// expected-no-diagnostics - -// "During the lookup for a base class name, non-type names are ignored" -namespace PR5840 { - struct Base {}; - int Base = 10; - struct Derived : Base {}; -} diff --git a/test/CXX/class/class.base/class.base.init/p5-0x.cpp b/test/CXX/class/class.base/class.base.init/p5-0x.cpp deleted file mode 100644 index e9aa6da7dc7b..000000000000 --- a/test/CXX/class/class.base/class.base.init/p5-0x.cpp +++ /dev/null @@ -1,26 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s - -// [class.base.init]p5 -// A ctor-initializer may initialize a variant member of the constructor’s -// class. If a ctor-initializer specifies more than one mem-initializer for the -// same member or for the same base class, the ctor-initializer is ill-formed. - -union E { - int a; - int b; - E() : a(1), // expected-note{{previous initialization is here}} - b(2) { // expected-error{{initializing multiple members of union}} - } -}; - -union F { - struct { - int a; - int b; - }; - int c; - F() : a(1), // expected-note{{previous initialization is here}} - b(2), - c(3) { // expected-error{{initializing multiple members of union}} - } -}; diff --git a/test/CXX/class/class.bit/p2.cpp b/test/CXX/class/class.bit/p2.cpp deleted file mode 100644 index 8b2436a869ba..000000000000 --- a/test/CXX/class/class.bit/p2.cpp +++ /dev/null @@ -1,22 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s - -struct A { -private: - int : 0; -}; - -A a = { }; -A a2 = { 1 }; // expected-error{{excess elements in struct initializer}} - -struct B { - const int : 0; // expected-error{{anonymous bit-field cannot have qualifiers}} -}; - -B b; - -void testB() { - B b2(b); - B b3(static_cast<B&&>(b2)); - b = b; - b = static_cast<B&&>(b); -} diff --git a/test/CXX/class/class.friend/p1-ambiguous.cpp b/test/CXX/class/class.friend/p1-ambiguous.cpp deleted file mode 100644 index 3bb32718361d..000000000000 --- a/test/CXX/class/class.friend/p1-ambiguous.cpp +++ /dev/null @@ -1,38 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -// expected-no-diagnostics - -// Make sure that friend declarations don't introduce ambiguous -// declarations. - -// Test case courtesy of Shantonu Sen. -// Bug 4784. - -class foo; - -extern "C" { - int c_func(foo *a); -}; -int cpp_func(foo *a); - -class foo { -public: - friend int c_func(foo *a); - friend int cpp_func(foo *a); - int caller(); -private: - int x; -}; - -int c_func(foo *a) { - return a->x; -} - -int cpp_func(foo *a) { - return a->x; -} - -int foo::caller() { - c_func(this); - cpp_func(this); - return 0; -} diff --git a/test/CXX/class/class.friend/p1-cxx11.cpp b/test/CXX/class/class.friend/p1-cxx11.cpp deleted file mode 100644 index 6e3d85001fa8..000000000000 --- a/test/CXX/class/class.friend/p1-cxx11.cpp +++ /dev/null @@ -1,13 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s -// expected-no-diagnostics - -class A { - class AInner { - }; - - void a_member(); - friend void A::a_member(); // ok in c++11, ill-formed in c++98 - friend void a_member(); // ok in both, refers to non-member - friend class A::AInner; // ok in c++11, extension in c++98 - friend class AInner; // ok in both, refers to non-member -}; diff --git a/test/CXX/class/class.friend/p1.cpp b/test/CXX/class/class.friend/p1.cpp deleted file mode 100644 index 08498c07330e..000000000000 --- a/test/CXX/class/class.friend/p1.cpp +++ /dev/null @@ -1,92 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s - -struct Outer { - struct Inner { - int intfield; - }; -}; - -struct Base { - void base_member(); - - typedef int Int; - Int typedeffed_member(); -}; - -struct Derived : public Base { -}; - -int myglobal; - -void global_function(); -extern "C" { - void global_c_function(); -} - -class A { - class AInner { - }; - - friend class PreDeclared; - friend class Outer::Inner; - friend int Outer::Inner::intfield; // expected-error {{friends can only be classes or functions}} - friend int Outer::Inner::missing_field; //expected-error {{friends can only be classes or functions}} - friend int myoperation(float); // okay - friend int myglobal; // expected-error {{friends can only be classes or functions}} - - friend void global_function(); - friend void global_c_function(); - - friend class UndeclaredSoFar; - UndeclaredSoFar x; // expected-error {{unknown type name 'UndeclaredSoFar'}} - - void a_member(); - friend void A::a_member(); -#if __cplusplus <= 199711L - // expected-error@-2 {{friends cannot be members of the declaring class}} -#endif - friend void a_member(); // okay (because we ignore class scopes when looking up friends) - friend class A::AInner; // this is okay as an extension - friend class AInner; // okay, refers to ::AInner - - friend void Derived::missing_member(); // expected-error {{friend declaration of 'missing_member' does not match any declaration in 'Derived'}} - - friend void Derived::base_member(); // expected-error {{friend declaration of 'base_member' does not match any declaration in 'Derived'}} - - friend int Base::typedeffed_member(); // okay: should look through typedef - - // These test that the friend is properly not being treated as a - // member function. - friend A operator|(const A& l, const A& r); // okay - friend A operator|(const A& r); // expected-error {{overloaded 'operator|' must be a binary operator (has 1 parameter)}} - - friend operator bool() const; // expected-error {{must use a qualified name when declaring a conversion operator as a friend}} \ - // expected-error{{non-member function cannot have 'const' qualifier}} - - typedef void ftypedef(); - friend ftypedef typedeffed_function; // okay (because it's not declared as a member) - - class facet; - friend class facet; // should not assert - class facet {}; - - friend int Unknown::thing(); // expected-error {{use of undeclared identifier}} - friend int friendfunc(), Unknown::thing(); // expected-error {{use of undeclared identifier}} - friend int friendfunc(), Unknown::thing() : 4; // expected-error {{use of undeclared identifier}} -}; - -A::UndeclaredSoFar y; // expected-error {{no type named 'UndeclaredSoFar' in 'A'}} - -class PreDeclared; - -int myoperation(float f) { - return (int) f; -} - -template <typename T> -class B { - template <typename U> - friend B<U>() {} // expected-error {{must use a qualified name when declaring a constructor as a friend}} -}; diff --git a/test/CXX/class/class.friend/p2.cpp b/test/CXX/class/class.friend/p2.cpp deleted file mode 100644 index e4a46b30e788..000000000000 --- a/test/CXX/class/class.friend/p2.cpp +++ /dev/null @@ -1,18 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s - -struct B0; - -class A { - friend class B {}; // expected-error {{cannot define a type in a friend declaration}} - friend int; -#if __cplusplus <= 199711L - // expected-warning@-2 {{non-class friend type 'int' is a C++11 extension}} -#endif - friend B0; -#if __cplusplus <= 199711L - // expected-warning@-2 {{unelaborated friend declaration is a C++11 extension; specify 'struct' to befriend 'B0'}} -#endif - friend class C; // okay -}; diff --git a/test/CXX/class/class.friend/p6.cpp b/test/CXX/class/class.friend/p6.cpp deleted file mode 100644 index e4c59f781e3d..000000000000 --- a/test/CXX/class/class.friend/p6.cpp +++ /dev/null @@ -1,22 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -Wc++11-compat -verify -std=c++98 %s -// RUN: %clang_cc1 -fsyntax-only -Wc++11-compat -verify -std=c++11 %s - -class A { - friend static class B; // expected-error {{'static' is invalid in friend declarations}} - friend extern class C; // expected-error {{'extern' is invalid in friend declarations}} -#if __cplusplus < 201103L - friend register class E; // expected-error {{'register' is invalid in friend declarations}} -#else - friend register class E; // expected-error {{'register' is invalid in friend declarations}} -#endif - friend mutable class F; // expected-error {{'mutable' is invalid in friend declarations}} - friend typedef class G; // expected-error {{'typedef' is invalid in friend declarations}} - friend __thread class G; // expected-error {{'__thread' is invalid in friend declarations}} - friend _Thread_local class G; // expected-error {{'_Thread_local' is invalid in friend declarations}} - friend static _Thread_local class G; // expected-error {{'static _Thread_local' is invalid in friend declarations}} -#if __cplusplus < 201103L - friend auto class D; // expected-warning {{incompatible with C++11}} expected-error {{'auto' is invalid in friend declarations}} -#else - friend thread_local class G; // expected-error {{'thread_local' is invalid in friend declarations}} -#endif -}; diff --git a/test/CXX/class/class.local/p1-0x.cpp b/test/CXX/class/class.local/p1-0x.cpp deleted file mode 100644 index 49125f5f9b06..000000000000 --- a/test/CXX/class/class.local/p1-0x.cpp +++ /dev/null @@ -1,18 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s - -void f() { - int x = 3; // expected-note{{'x' declared here}} - const int c = 2; - struct C { - int& x2 = x; // expected-error{{reference to local variable 'x' declared in enclosing function 'f'}} - int cc = c; - }; - (void)[]() mutable { - int x = 3; // expected-note{{'x' declared here}} - struct C { - int& x2 = x; // expected-error{{reference to local variable 'x' declared in enclosing lambda expression}} - }; - }; - C(); -} - diff --git a/test/CXX/class/class.local/p1.cpp b/test/CXX/class/class.local/p1.cpp deleted file mode 100644 index 62ade5cb8846..000000000000 --- a/test/CXX/class/class.local/p1.cpp +++ /dev/null @@ -1,18 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s - -int x; -void f() -{ - static int s; - int x; // expected-note{{'x' declared here}} - extern int g(); - - struct local { - int g() { return x; } // expected-error{{reference to local variable 'x' declared in enclosing function 'f'}} - int h() { return s; } - int k() { return :: x; } - int l() { return g(); } - }; -} - -local* p = 0; // expected-error{{unknown type name 'local'}} diff --git a/test/CXX/class/class.local/p2.cpp b/test/CXX/class/class.local/p2.cpp deleted file mode 100644 index db4c90f564fe..000000000000 --- a/test/CXX/class/class.local/p2.cpp +++ /dev/null @@ -1,11 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s - -struct A { }; - -void f() { - struct B : private A {}; // expected-note{{declared private here}} - - B b; - - A *a = &b; // expected-error{{cannot cast 'B' to its private base class 'A'}} -} diff --git a/test/CXX/class/class.local/p3.cpp b/test/CXX/class/class.local/p3.cpp deleted file mode 100644 index 375379038496..000000000000 --- a/test/CXX/class/class.local/p3.cpp +++ /dev/null @@ -1,30 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s - -void f1() { - struct X { - struct Y; - }; - - struct X::Y { - void f() {} - }; -} - -void f2() { - struct X { - struct Y; - - struct Y { - void f() {} - }; - }; -} - -// A class nested within a local class is a local class. -void f3(int a) { // expected-note{{'a' declared here}} - struct X { - struct Y { - int f() { return a; } // expected-error{{reference to local variable 'a' declared in enclosing function 'f3'}} - }; - }; -} diff --git a/test/CXX/class/class.local/p4.cpp b/test/CXX/class/class.local/p4.cpp deleted file mode 100644 index d7807440cc9c..000000000000 --- a/test/CXX/class/class.local/p4.cpp +++ /dev/null @@ -1,10 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s - -void f() { - struct X { - static int a; // expected-error {{static data member 'a' not allowed in local class 'X'}} - int b; - - static void f() { } - }; -} diff --git a/test/CXX/class/class.mem/p1.cpp b/test/CXX/class/class.mem/p1.cpp deleted file mode 100644 index a41f1dbb75ec..000000000000 --- a/test/CXX/class/class.mem/p1.cpp +++ /dev/null @@ -1,91 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s - -struct S -{ - static int v1; // expected-note{{previous declaration is here}} - int v1; //expected-error{{duplicate member 'v1'}} - int v; //expected-note 2{{previous definition is here}} \ - // expected-note{{previous declaration is here}} - static int v; //expected-error{{redefinition of 'v' as different kind of symbol}} - int v; //expected-error{{duplicate member 'v'}} - static int v; //expected-error{{redefinition of 'v' as different kind of symbol}} - enum EnumT { E = 10 }; - friend struct M; - struct X; //expected-note{{forward declaration of 'S::X'}} - friend struct X; -}; - -S::EnumT Evar = S::E; // ok -S::EnumT Evar2 = EnumT(); //expected-error{{use of undeclared identifier 'EnumT'}} -S::M m; //expected-error{{no type named 'M' in 'S'}} -S::X x; //expected-error{{variable has incomplete type 'S::X'}} - - -struct S2 -{ - static int v2; // expected-note{{previous declaration is here}} - static int v2; //expected-error{{duplicate member 'v2'}} -}; - -struct S3 -{ - static int v3; - struct S4 - { - static int v3; - }; -}; - -struct S4 -{ - static int v4; -}; - -int S4::v4; //expected-note{{previous definition is here}} -int S4::v4; //expected-error{{redefinition of 'v4'}} - -struct S5 -{ - static int v5; //expected-note{{previous definition is here}} - void v5() { } //expected-error{{redefinition of 'v5' as different kind of symbol}} - - void v6() { } //expected-note{{previous definition is here}} - static int v6; //expected-error{{redefinition of 'v6' as different kind of symbol}} - - void v7() { } - void v7(int) { } //expected-note{{previous definition is here}} - static int v7; //expected-error{{redefinition of 'v7' as different kind of symbol}} - - void v8(); - int v8(int); //expected-note{{previous declaration is here}} - int v8; //expected-error{{duplicate member 'v8'}} - - -}; - -namespace PR8245 { - class X { - public: - template<class C> - class Inner { - public: - void foo(bool bar = true); - int bam; - }; - - Inner<int> _foo; - }; - - void f() { - X::Inner<int> c2i; - X::Inner<float> c2f; - c2i.foo(); - c2f.foo(); - } - - class Y { - class Inner { - void foo(int = sizeof(Y)); - }; - }; -} diff --git a/test/CXX/class/class.mem/p13.cpp b/test/CXX/class/class.mem/p13.cpp deleted file mode 100644 index 1b1c0c7f8fc3..000000000000 --- a/test/CXX/class/class.mem/p13.cpp +++ /dev/null @@ -1,116 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++14 %s - -// If T is the name of a class, then each of the following shall have -// a name different from T: - -// - every static data member of class T; -struct X0 { - static int X0; // expected-error{{member 'X0' has the same name as its class}} -}; - -// - every member function of class T -struct Xa { - int Xa() {} // expected-error{{constructor cannot have a return type}} -}; - -// - every member of class T that is itself a type; -struct X1 { - enum X1 { }; // expected-error{{member 'X1' has the same name as its class}} -}; - -struct X1a { - struct X1a; // expected-error{{member 'X1a' has the same name as its class}} -}; - -struct X2 { - typedef int X2; // expected-error{{member 'X2' has the same name as its class}} -}; - -struct X2a { - using X2a = int; // expected-error{{member 'X2a' has the same name as its class}} -}; - -// - every member template of class T - -struct X2b { - template<typename T> struct X2b; // expected-error{{member 'X2b' has the same name as its class}} -}; -struct X2c { - template<typename T> void X2c(); // expected-error{{constructor cannot have a return type}} -}; -struct X2d { - template<typename T> static int X2d; // expected-error{{member 'X2d' has the same name as its class}} -}; -struct X2e { - template<typename T> using X2e = int; // expected-error{{member 'X2e' has the same name as its class}} -}; - -// - every enumerator of every member of class T that is an unscoped enumerated type; and -struct X3 { - enum E { - X3 // expected-error{{member 'X3' has the same name as its class}} - }; -}; -struct X3a { - enum class E { - X3a // ok - }; -}; - -// - every member of every anonymous union that is a member of class T. -struct X4 { // expected-note{{previous}} - union { - int X; - union { - float Y; - unsigned X4; // expected-error{{redeclares 'X4'}} - }; - }; -}; - -// This includes such things inherited from base classes. -struct B { - static int D0; - int Da() {}; - enum D1 {}; - struct D1a; - typedef int D2; - using D2a = int; - template<typename T> struct D2b; - template<typename T> void D2c(); - template<typename T> static int D2d; - template<typename T> using D2e = int; - union { int D4; }; - int Dtemplate; - int Dtemplate_with_ctors; -}; -struct B2 { int Dtemplate(); }; - -struct D0 : B { using B::D0; }; // expected-error {{member 'D0' has the same name as its class}} -struct Da : B { using B::Da; }; // expected-error {{member 'Da' has the same name as its class}} -struct D1 : B { using B::D1; }; // expected-error {{member 'D1' has the same name as its class}} -struct D1a : B { using B::D1a; }; // expected-error {{member 'D1a' has the same name as its class}} -struct D2 : B { using B::D2; }; // expected-error {{member 'D2' has the same name as its class}} -struct D2a : B { using B::D2a; }; // expected-error {{member 'D2a' has the same name as its class}} -struct D2b : B { using B::D2b; }; // expected-error {{member 'D2b' has the same name as its class}} -struct D2c : B { using B::D2c; }; // expected-error {{member 'D2c' has the same name as its class}} -struct D2d : B { using B::D2d; }; // expected-error {{member 'D2d' has the same name as its class}} -struct D2e : B { using B::D2e; }; // expected-error {{member 'D2e' has the same name as its class}} -struct D4 : B { using B::D4; }; // expected-error {{member 'D4' has the same name as its class}} - -template<typename B> struct Dtemplate : B { - using B::Dtemplate; // expected-error {{member 'Dtemplate' has the same name as its class}} -}; -Dtemplate<B> ok; -Dtemplate<B2> error; // expected-note {{in instantiation of}} - -template<typename B> struct Dtemplate_with_ctors : B { - Dtemplate_with_ctors(); - using B::Dtemplate_with_ctors; // expected-error {{member 'Dtemplate_with_ctors' has the same name as its class}} -}; - -template<typename B> struct CtorDtorName : B { - using B::CtorDtorName; // expected-error {{member 'CtorDtorName' has the same name as its class}} - CtorDtorName(); - ~CtorDtorName(); // expected-error {{expected the class name after '~' to name a destructor}} -}; diff --git a/test/CXX/class/class.mem/p14.cpp b/test/CXX/class/class.mem/p14.cpp deleted file mode 100644 index a2f60618565d..000000000000 --- a/test/CXX/class/class.mem/p14.cpp +++ /dev/null @@ -1,19 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s - -// In addition, if class T has a user-declared constructor (12.1), -// every non-static data member of class T shall have a name different -// from T. - -struct X0 { - int X0; // okay -}; - -struct X1 { - int X1; // expected-error{{member 'X1' has the same name as its class}} - X1(); -}; - -struct X2 { - X2(); - float X2; // expected-error{{member 'X2' has the same name as its class}} -}; diff --git a/test/CXX/class/class.mem/p1b.cpp b/test/CXX/class/class.mem/p1b.cpp deleted file mode 100644 index 3e8c98530599..000000000000 --- a/test/CXX/class/class.mem/p1b.cpp +++ /dev/null @@ -1,46 +0,0 @@ -// The first run checks that the correct errors are generated, -// implicitly checking the order of default argument parsing: -// RUN: %clang_cc1 -fsyntax-only -verify %s -// The second run checks the order of inline method definitions: -// RUN: not %clang_cc1 -fsyntax-only %s 2> %t -// RUN: FileCheck %s < %t - -class A { -public: - void a1() { - B b = B(); - } - - class B; - void a2(B b = B()); // expected-error{{use of default argument to function 'B' that is declared later in class 'B'}} - - void a3(int a = 42); - - // CHECK: error: use of undeclared identifier 'first' - void a4(int a = first); // expected-error{{use of undeclared identifier 'first'}} - - class B { - public: - B(int b = 42) { // expected-note{{default argument declared here}} - A a; - a.a3(); - a.a6(); - } - - void b1(A a = A()); // expected-error{{use of default argument to function 'A' that is declared later in class 'A'}} - - // CHECK: error: use of undeclared identifier 'second' - void b2(int a = second); // expected-error{{use of undeclared identifier 'second'}} - }; - - void a5() { - B b = B(); - } - - void a6(B b = B()); - - A(int a = 42); // expected-note{{default argument declared here}} - - // CHECK: error: use of undeclared identifier 'third' - void a7(int a = third); // expected-error{{use of undeclared identifier 'third'}} -}; diff --git a/test/CXX/class/class.mem/p2.cpp b/test/CXX/class/class.mem/p2.cpp deleted file mode 100644 index 1f0dfd05a20d..000000000000 --- a/test/CXX/class/class.mem/p2.cpp +++ /dev/null @@ -1,85 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s - -// C++11 [class.mem]p2: -// A class is considered a completely-defined object type (or -// complete type) at the closing } of the class-specifier. Within -// the class member-specification, the class is regarded as complete -// within function bodies, default arguments, -// exception-specifications, and brace-or-equal-initializers for -// non-static data members (including such things in nested classes). -// Otherwise it is regarded as incomplete within its own class -// member-specification. - -namespace test0 { - struct A { // expected-note {{definition of 'test0::A' is not complete until the closing '}'}} - A x; // expected-error {{field has incomplete type 'test0::A'}} - }; -} - -namespace test1 { - template <class T> struct A { - A<int> x; // expected-error {{implicit instantiation of template 'test1::A<int>' within its own definition}} - }; -} - -namespace test2 { - template <class T> struct A; - template <> struct A<int> {}; - template <class T> struct A { - A<int> x; - }; -} - -namespace test3 { - struct A { - struct B { - void f() throw(A); - void g() throw(B); - }; - - void f() throw(A); - void g() throw(B); - }; - - template<typename T> - struct A2 { - struct B { - void f1() throw(A2); - void f2() throw(A2<T>); - void g() throw(B); - }; - - void f1() throw(A2); - void f2() throw(A2<T>); - void g() throw(B); - }; - - template struct A2<int>; -} - -namespace PR12629 { - struct S { - static int (f)() throw(); - static int ((((((g))))() throw(U))); - int (*h)() noexcept(false); - static int (&i)() noexcept(true); - static int (*j)() throw(U); // expected-error {{unknown type name 'U'}} - static int (k)() throw(U); - - struct U {}; - }; - static_assert(noexcept(S::f()), ""); - static_assert(!noexcept(S::g()), ""); - static_assert(!noexcept(S().h()), ""); - static_assert(noexcept(S::i()), ""); -} - -namespace PR12688 { - struct S { - // FIXME: Maybe suppress the "constructor cannot have a return type" error - // if the return type is invalid. - nonsense S() throw (more_nonsense); // \ - // expected-error {{'nonsense'}} \ - // expected-error {{constructor cannot have a return type}} - }; -} diff --git a/test/CXX/class/class.mem/p5-0x.cpp b/test/CXX/class/class.mem/p5-0x.cpp deleted file mode 100644 index 6061c4c20a67..000000000000 --- a/test/CXX/class/class.mem/p5-0x.cpp +++ /dev/null @@ -1,9 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s - -int f(); - -struct S -{ - int a = f(); // ok - int b = g(); // expected-error {{use of undeclared identifier 'g'}} -}; diff --git a/test/CXX/class/class.mem/p8-0x.cpp b/test/CXX/class/class.mem/p8-0x.cpp deleted file mode 100644 index d2c3dc36075b..000000000000 --- a/test/CXX/class/class.mem/p8-0x.cpp +++ /dev/null @@ -1,53 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s - -struct Base1 { - virtual void g(); -}; - -struct A : Base1 { - virtual void g() override override; // expected-error {{class member already marked 'override'}} - virtual void h() final final; // expected-error {{class member already marked 'final'}} -}; - -struct Base2 { - virtual void e1(), e2(); - virtual void f(); -}; - -struct B : Base2 { - virtual void e1() override, e2(int); // No error. - virtual void f() override; - void g() override; // expected-error {{only virtual member functions can be marked 'override'}} - int h override; // expected-error {{only virtual member functions can be marked 'override'}} -}; - -struct C { - virtual void f() final; - void g() final; // expected-error {{only virtual member functions can be marked 'final'}} - int h final; // expected-error {{only virtual member functions can be marked 'final'}} -}; - -namespace inline_extension { - struct Base1 { - virtual void g() {} - }; - - struct A : Base1 { - virtual void g() override override {} // expected-error {{class member already marked 'override'}} - virtual void h() final final {} // expected-error {{class member already marked 'final'}} - }; - - struct Base2 { - virtual void f(); - }; - - struct B : Base2 { - virtual void f() override {} - void g() override {} // expected-error {{only virtual member functions can be marked 'override'}} - }; - - struct C { - virtual void f() final {} - void g() final {} // expected-error {{only virtual member functions can be marked 'final'}} - }; -} diff --git a/test/CXX/class/class.mfct/class.mfct.non-static/p3.cpp b/test/CXX/class/class.mfct/class.mfct.non-static/p3.cpp deleted file mode 100644 index 9116e7146f81..000000000000 --- a/test/CXX/class/class.mfct/class.mfct.non-static/p3.cpp +++ /dev/null @@ -1,98 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s - -// [class.mfct.non-static]p3: -// When an id-expression (5.1) that is not part of a class member -// access syntax (5.2.5) and not used to form a pointer to member -// (5.3.1) is used in the body of a non-static member function of -// class X, if name lookup (3.4.1) resolves the name in the -// id-expression to a non-static non-type member of some class C, -// the id-expression is transformed into a class member access -// expression (5.2.5) using (*this) (9.3.2) as the -// postfix-expression to the left of the . operator. [ Note: if C is -// not X or a base class of X, the class member access expression is -// ill-formed. --end note] Similarly during name lookup, when an -// unqualified-id (5.1) used in the definition of a member function -// for class X resolves to a static member, an enumerator or a -// nested type of class X or of a base class of X, the -// unqualified-id is transformed into a qualified-id (5.1) in which -// the nested-name-specifier names the class of the member function. - -namespace test0 { - class A { - int data_member; - int instance_method(); - static int static_method(); - - bool test() { - return data_member + instance_method() < static_method(); - } - }; -} - -namespace test1 { - struct Opaque1 {}; struct Opaque2 {}; struct Opaque3 {}; - - struct A { - void foo(Opaque1); // expected-note {{candidate}} - void foo(Opaque2); // expected-note {{candidate}} - }; - - struct B : A { - void test(); - }; - - struct C1 : A { }; - struct C2 : B { }; - - void B::test() { - A::foo(Opaque1()); - A::foo(Opaque2()); - A::foo(Opaque3()); // expected-error {{no matching member function}} - - C1::foo(Opaque1()); // expected-error {{call to non-static member function without an object argument}} - C2::foo(Opaque1()); // expected-error {{call to non-static member function without an object argument}} - } -} - -namespace test2 { - struct Unrelated { - void foo(); - }; - - template <class T> struct B; - template <class T> struct C; - - template <class T> struct A { - void foo(); - - void test0() { - Unrelated::foo(); // expected-error {{call to non-static member function without an object argument}} - } - - void test1() { - B<T>::foo(); - } - - static void test2() { - B<T>::foo(); // expected-error {{call to non-static member function without an object argument}} - } - - void test3() { - C<T>::foo(); // expected-error {{no member named 'foo'}} - } - }; - - template <class T> struct B : A<T> { - }; - - template <class T> struct C { - }; - - int test() { - A<int> a; - a.test0(); // no instantiation note here, decl is ill-formed - a.test1(); - a.test2(); // expected-note {{in instantiation}} - a.test3(); // expected-note {{in instantiation}} - } -} diff --git a/test/CXX/class/class.nest/p1-cxx0x.cpp b/test/CXX/class/class.nest/p1-cxx0x.cpp deleted file mode 100644 index b7a1a48c64f6..000000000000 --- a/test/CXX/class/class.nest/p1-cxx0x.cpp +++ /dev/null @@ -1,14 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s - -class Outer { - int x; - static int sx; - int f(); - - // The first case is invalid in the C++03 mode but valid in C++0x (see 5.1.1.10). - class Inner { - static char a[sizeof(x)]; // okay - static char b[sizeof(sx)]; // okay - static char c[sizeof(f)]; // expected-error {{call to non-static member function without an object argument}} - }; -}; diff --git a/test/CXX/class/class.nest/p1.cpp b/test/CXX/class/class.nest/p1.cpp deleted file mode 100644 index 59bf50f42400..000000000000 --- a/test/CXX/class/class.nest/p1.cpp +++ /dev/null @@ -1,19 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s - -class Outer { - int x; - static int sx; - int f(); - - // C++11 does relax this rule (see 5.1.1.10) in the first case, but we need to enforce it in C++03 mode. - class Inner { - static char a[sizeof(x)]; -#if __cplusplus <= 199711L - // expected-error@-2 {{invalid use of non-static data member 'x'}} -#endif - static char b[sizeof(sx)]; // okay - static char c[sizeof(f)]; // expected-error {{call to non-static member function without an object argument}} - }; -}; diff --git a/test/CXX/class/class.nest/p3.cpp b/test/CXX/class/class.nest/p3.cpp deleted file mode 100644 index 677411fe3c8a..000000000000 --- a/test/CXX/class/class.nest/p3.cpp +++ /dev/null @@ -1,26 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -// expected-no-diagnostics - -// C++0x [class.nest] p3: -// If class X is defined in a namespace scope, a nested class Y may be -// declared in class X and later defined in the definition of class X or be -// later defined in a namespace scope enclosing the definition of class X. - -namespace example { - class E { - class I1; - class I2; - class I1 { }; - }; - class E::I2 { }; -} - -// Don't insert out-of-line inner class definitions into the namespace scope. -namespace PR6107 { - struct S1 { }; - struct S2 { - struct S1; - }; - struct S2::S1 { }; - S1 s1; -} diff --git a/test/CXX/class/class.nested.type/p1.cpp b/test/CXX/class/class.nested.type/p1.cpp deleted file mode 100644 index 929565441230..000000000000 --- a/test/CXX/class/class.nested.type/p1.cpp +++ /dev/null @@ -1,13 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s - -class X { -public: - typedef int I; // expected-note{{'X::I' declared here}} - class Y { }; // expected-note{{'X::Y' declared here}} - I a; -}; - -I b; // expected-error{{unknown type name 'I'; did you mean 'X::I'?}} -Y c; // expected-error{{unknown type name 'Y'; did you mean 'X::Y'?}} -X::Y d; -X::I e; diff --git a/test/CXX/class/class.static/class.static.data/p2.cpp b/test/CXX/class/class.static/class.static.data/p2.cpp deleted file mode 100644 index 8c38276641d4..000000000000 --- a/test/CXX/class/class.static/class.static.data/p2.cpp +++ /dev/null @@ -1,7 +0,0 @@ -// RUN: %clang_cc1 -std=c++1z -verify %s - -struct X { - static struct A a; - static inline struct B b; // expected-error {{incomplete type}} expected-note {{forward decl}} - static inline struct C c = {}; // expected-error {{incomplete type}} expected-note {{forward decl}} -}; diff --git a/test/CXX/class/class.static/class.static.data/p3.cpp b/test/CXX/class/class.static/class.static.data/p3.cpp deleted file mode 100644 index 5640bc30ad4c..000000000000 --- a/test/CXX/class/class.static/class.static.data/p3.cpp +++ /dev/null @@ -1,53 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++1z %s - -struct NonLit { // expected-note 3{{no constexpr constructors}} - NonLit(); -}; - -struct S { - static constexpr int a = 0; - static constexpr int b; // expected-error {{initializ}} expected-note 0-1{{previous}} - - static constexpr int c = 0; - static const int d; - static const int d2 = 0; - - static constexpr double e = 0.0; // ok - static const double f = 0.0; // expected-error {{requires 'constexpr' specifier}} expected-note {{add 'constexpr'}} - static char *const g = 0; // expected-error {{requires 'constexpr' specifier}} - static const NonLit h = NonLit(); // expected-error {{must be initialized out of line}} - - static inline int i; // expected-note {{previous}} expected-warning 0-1{{extension}} - static inline int j; // expected-note {{previous}} expected-warning 0-1{{extension}} - static constexpr int k = 0; -}; - -constexpr int S::a; -constexpr int S::b = 0; // expected-error 0-1{{redefinition}} - -const int S::c; -constexpr int S::d = 0; -constexpr int S::d2; - -int S::i; // expected-error {{redefinition}} -int S::j; // expected-error {{redefinition}} -const int S::k; // ok (deprecated) - -template<typename T> -struct U { - static constexpr int a = 0; - static constexpr int b; // expected-error {{initializ}} - static constexpr NonLit h = NonLit(); // expected-error {{cannot have non-literal type 'const NonLit'}} - static constexpr T c = T(); // expected-error {{cannot have non-literal type}} - static const T d; -}; - -template<typename T> constexpr T U<T>::d = T(); // expected-error {{non-literal type 'const NonLit'}} - -U<int> u1; -U<NonLit> u2; // expected-note {{here}} - -static_assert(U<int>::a == 0, ""); - -constexpr int outofline = (U<NonLit>::d, 0); // expected-note {{here}} diff --git a/test/CXX/class/class.static/class.static.data/p4.cpp b/test/CXX/class/class.static/class.static.data/p4.cpp deleted file mode 100644 index 85d18c6b5fac..000000000000 --- a/test/CXX/class/class.static/class.static.data/p4.cpp +++ /dev/null @@ -1,24 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -struct InClassInitializerOnly { - static const int i = 0; -}; -int const InClassInitializerOnly::i; - -struct OutOfClassInitializerOnly { - static const int i; -}; -int const OutOfClassInitializerOnly::i = 0; - -struct InClassInitializerAndOutOfClassCopyInitializer { - static const int i = 0; // expected-note{{previous initialization is here}} -}; -int const InClassInitializerAndOutOfClassCopyInitializer::i = 0; // expected-error{{static data member 'i' already has an initializer}} - -struct InClassInitializerAndOutOfClassDirectInitializer { - static const int i = 0; // expected-note{{previous initialization is here}} -}; -int const InClassInitializerAndOutOfClassDirectInitializer::i(0); // expected-error{{static data member 'i' already has an initializer}} - - -int main() { } - diff --git a/test/CXX/class/class.union/class.union.anon/p1.cpp b/test/CXX/class/class.union/class.union.anon/p1.cpp deleted file mode 100644 index 31c9313cf53a..000000000000 --- a/test/CXX/class/class.union/class.union.anon/p1.cpp +++ /dev/null @@ -1,24 +0,0 @@ -// RUN: %clang_cc1 -verify %s - -struct X { - int a; // expected-note {{previous}} - void b(); // expected-note {{previous}} - struct c; // expected-note {{previous}} - typedef int d; // expected-note {{previous}} - - union { - int a; // expected-error {{member of anonymous union redeclares}} - int b; // expected-error {{member of anonymous union redeclares}} - int c; // expected-error {{member of anonymous union redeclares}} - int d; // expected-error {{member of anonymous union redeclares}} - int e; // expected-note {{previous}} - int f; // expected-note {{previous}} - int g; // expected-note {{previous}} - int h; // expected-note {{previous}} - }; - - int e; // expected-error {{duplicate member}} - void f(); // expected-error {{redefinition}} - struct g; // expected-error {{redefinition}} - typedef int h; // expected-error {{redefinition}} -}; diff --git a/test/CXX/class/class.union/class.union.anon/p4.cpp b/test/CXX/class/class.union/class.union.anon/p4.cpp deleted file mode 100644 index cc54ba406619..000000000000 --- a/test/CXX/class/class.union/class.union.anon/p4.cpp +++ /dev/null @@ -1,10 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -verify %s - -union U { - int x = 0; // expected-note {{previous initialization is here}} - union {}; - union { - int z; - int y = 1; // expected-error {{initializing multiple members of union}} - }; -}; diff --git a/test/CXX/class/class.union/p1.cpp b/test/CXX/class/class.union/p1.cpp deleted file mode 100644 index bf7f2ad24f98..000000000000 --- a/test/CXX/class/class.union/p1.cpp +++ /dev/null @@ -1,133 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s - -void abort() __attribute__((noreturn)); - -class Okay { - int a_; -}; - -class Virtual { - virtual void foo() { abort(); } // expected-note 4 {{because type 'Virtual' has a virtual member function}} -}; - -class VirtualBase : virtual Okay { // expected-note 4 {{because type 'VirtualBase' has a virtual base class}} -}; - -class Ctor { - Ctor() { abort(); } // expected-note 2{{because type 'Ctor' has a user-provided default constructor}} expected-note 2{{here}} -}; -class Ctor2 { - Ctor2(); // expected-note {{because type 'Ctor2' has a user-provided default constructor}} expected-note 2{{here}} -}; -class CtorTmpl { // expected-note {{because type 'CtorTmpl' has no default constructor}} - template<typename T> CtorTmpl(); // expected-note {{implicit default constructor suppressed by user-declared constructor}} -}; - -class CopyCtor { // expected-note 2{{because no constructor can be used to copy an object of type 'const CopyCtor'}} - CopyCtor(CopyCtor &cc) { abort(); } -}; - -class CopyAssign { // expected-note 2 {{because no assignment operator can be used to copy an object of type 'const CopyAssign'}} - CopyAssign& operator=(CopyAssign& CA) { abort(); } -}; - -class Dtor { - ~Dtor() { abort(); } // expected-note 2 {{because type 'Dtor' has a user-provided destructor}} expected-note 2{{here}} -}; - -union U1 { - Virtual v; // expected-error {{union member 'v' has a non-trivial copy constructor}} - VirtualBase vbase; // expected-error {{union member 'vbase' has a non-trivial copy constructor}} - Ctor ctor; // expected-error {{union member 'ctor' has a non-trivial default constructor}} - Ctor2 ctor2; // expected-error {{union member 'ctor2' has a non-trivial default constructor}} - CtorTmpl ctortmpl; // expected-error {{union member 'ctortmpl' has a non-trivial default constructor}} - CopyCtor copyctor; // expected-error {{union member 'copyctor' has a non-trivial copy constructor}} - CopyAssign copyassign; // expected-error {{union member 'copyassign' has a non-trivial copy assignment operator}} - Dtor dtor; // expected-error {{union member 'dtor' has a non-trivial destructor}} - Okay okay; -}; - -union U2 { - struct { - Virtual v; // expected-note {{because the function selected to copy field of type 'Virtual' is not trivial}} - } m1; // expected-error {{union member 'm1' has a non-trivial copy constructor}} - struct { - VirtualBase vbase; // expected-note {{because the function selected to copy field of type 'VirtualBase' is not trivial}} - } m2; // expected-error {{union member 'm2' has a non-trivial copy constructor}} - struct { - Ctor ctor; // expected-note {{because field of type 'Ctor' has a user-provided default constructor}} - } m3; // expected-error {{union member 'm3' has a non-trivial default constructor}} - struct { - Ctor2 ctor2; // expected-note {{because field of type 'Ctor2' has a user-provided default constructor}} - } m3a; // expected-error {{union member 'm3a' has a non-trivial default constructor}} - struct { // expected-note {{no constructor can be used to copy an object of type 'const}} - CopyCtor copyctor; - } m4; // expected-error {{union member 'm4' has a non-trivial copy constructor}} - struct { // expected-note {{no assignment operator can be used to copy an object of type 'const}} - CopyAssign copyassign; - } m5; // expected-error {{union member 'm5' has a non-trivial copy assignment operator}} - struct { - Dtor dtor; // expected-note {{because field of type 'Dtor' has a user-provided destructor}} - } m6; // expected-error {{union member 'm6' has a non-trivial destructor}} - struct { - Okay okay; - } m7; -}; - -union U3 { - struct s1 : Virtual { // expected-note {{because the function selected to copy base class of type 'Virtual' is not trivial}} - } m1; // expected-error {{union member 'm1' has a non-trivial copy constructor}} - struct s2 : VirtualBase { // expected-note {{because the function selected to copy base class of type 'VirtualBase' is not trivial}} - } m2; // expected-error {{union member 'm2' has a non-trivial copy constructor}} - struct s3 : Ctor { // expected-note {{because base class of type 'Ctor' has a user-provided default constructor}} - } m3; // expected-error {{union member 'm3' has a non-trivial default constructor}} - struct s3a : Ctor2 { // expected-note {{because base class of type 'Ctor2' has a user-provided default constructor}} - } m3a; // expected-error {{union member 'm3a' has a non-trivial default constructor}} - struct s4 : CopyCtor { // expected-note {{because no constructor can be used to copy an object of type 'const U3::s4'}} - } m4; // expected-error {{union member 'm4' has a non-trivial copy constructor}} - struct s5 : CopyAssign { // expected-note {{because no assignment operator can be used to copy an object of type 'const U3::s5'}} - } m5; // expected-error {{union member 'm5' has a non-trivial copy assignment operator}} - struct s6 : Dtor { // expected-note {{because base class of type 'Dtor' has a user-provided destructor}} - } m6; // expected-error {{union member 'm6' has a non-trivial destructor}} - struct s7 : Okay { - } m7; - struct s8 { - s8(...) = delete; // expected-note {{because it is a variadic function}} expected-warning {{C++11}} - } m8; // expected-error {{union member 'm8' has a non-trivial default constructor}} -}; - -union U4 { - static int i1; // expected-warning {{static data member 'i1' in union is a C++11 extension}} -}; -int U4::i1 = 10; - -union U5 { - int& i1; // expected-error {{union member 'i1' has reference type 'int &'}} -}; - -union U6 { - struct S { - int &i; - } s; // ok -}; - -template <class A, class B> struct Either { - bool tag; - union { // expected-note 6 {{in instantiation of member class}} - A a; - B b; // expected-error 6 {{non-trivial}} - }; - - Either(const A& a) : tag(true), a(a) {} - Either(const B& b) : tag(false), b(b) {} -}; - -void fred() { - Either<int,Virtual> virt(0); // expected-note {{in instantiation of template}} - Either<int,VirtualBase> vbase(0); // expected-note {{in instantiation of template}} - Either<int,Ctor> ctor(0); // expected-note {{in instantiation of template}} - Either<int,CopyCtor> copyctor(0); // expected-note {{in instantiation of template}} - Either<int,CopyAssign> copyassign(0); // expected-note {{in instantiation of template}} - Either<int,Dtor> dtor(0); // expected-note {{in instantiation of template}} - Either<int,Okay> okay(0); -} diff --git a/test/CXX/class/class.union/p2-0x.cpp b/test/CXX/class/class.union/p2-0x.cpp deleted file mode 100644 index 5fb8a671e31b..000000000000 --- a/test/CXX/class/class.union/p2-0x.cpp +++ /dev/null @@ -1,48 +0,0 @@ -// RUN: %clang_cc1 -verify -std=c++11 %s - -// Unlike in C++98, C++11 allows unions to have static data members. - -union U1 { - static constexpr int k1 = 0; - static const int k2 = k1; - static int k3 = k2; // expected-error {{non-const static data member must be initialized out of line}} - static constexpr double k4 = k2; - static const double k5 = k4; // expected-error {{requires 'constexpr' specifier}} expected-note {{add 'constexpr'}} - int n[k1 + 3]; -}; - -constexpr int U1::k1; -constexpr int U1::k2; -int U1::k3; - -const double U1::k4; -const double U1::k5; - -template<typename T> -union U2 { - static const int k1; - static double k2; - T t; -}; -template<typename T> constexpr int U2<T>::k1 = sizeof(U2<T>); -template<typename T> double U2<T>::k2 = 5.3; - -static_assert(U2<int>::k1 == sizeof(int), ""); -static_assert(U2<char>::k1 == sizeof(char), ""); - -union U3 { - static const int k; - U3() : k(0) {} // expected-error {{does not name a non-static data member}} -}; - -struct S { - union { - static const int n; // expected-error {{static members cannot be declared in an anonymous union}} - int a; - int b; - }; -}; -static union { - static const int k; // expected-error {{static members cannot be declared in an anonymous union}} - int n; -}; diff --git a/test/CXX/class/p1-0x.cpp b/test/CXX/class/p1-0x.cpp deleted file mode 100644 index 5c327880e4b7..000000000000 --- a/test/CXX/class/p1-0x.cpp +++ /dev/null @@ -1,7 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11 -// expected-no-diagnostics -namespace Test1 { - -class A final { }; - -} diff --git a/test/CXX/class/p2-0x.cpp b/test/CXX/class/p2-0x.cpp deleted file mode 100644 index 5b39e0ada7e2..000000000000 --- a/test/CXX/class/p2-0x.cpp +++ /dev/null @@ -1,36 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11 -namespace Test1 { - -class A final { }; // expected-note {{'A' declared here}} -class B : A { }; // expected-error {{base 'A' is marked 'final'}} - -} - -namespace Test2 { - -template<typename T> struct A final { }; // expected-note 2 {{'A' declared here}} -struct B : A<int> { }; // expected-error {{base 'A' is marked 'final'}} - -template<typename T> struct C : A<T> { }; // expected-error {{base 'A' is marked 'final'}} -struct D : C<int> { }; // expected-note {{in instantiation of template class 'Test2::C<int>' requested here}} - -} - -namespace Test3 { - -template<typename T> struct A { }; -template<> struct A<int> final { }; // expected-note {{'A' declared here}} - -struct B : A<bool> { }; -struct C : A<int> { }; // expected-error {{base 'A' is marked 'final'}} - -} - -namespace Test4 { - -struct A final { virtual void func() = 0; }; // expected-warning {{abstract class is marked 'final'}} expected-note {{unimplemented pure virtual method 'func' in 'A'}} -struct B { virtual void func() = 0; }; // expected-note {{unimplemented pure virtual method 'func' in 'C'}} - -struct C final : B { }; // expected-warning {{abstract class is marked 'final'}} - -} diff --git a/test/CXX/class/p6-0x.cpp b/test/CXX/class/p6-0x.cpp deleted file mode 100644 index cf628a6343ae..000000000000 --- a/test/CXX/class/p6-0x.cpp +++ /dev/null @@ -1,31 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11 -// expected-no-diagnostics - -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"); - -struct Trivial2 { - Trivial2() = default; - Trivial2(const Trivial2 &) = default; - Trivial2(Trivial2 &&) = default; - Trivial2 &operator=(const Trivial2 &) = default; - Trivial2 &operator=(Trivial2 &&) = default; - ~Trivial2() = default; -}; - -class NonTrivial6 { ~NonTrivial6(); }; - -NonTrivial6::~NonTrivial6() = default; - -static_assert(!__is_trivial(NonTrivial6), "NonTrivial6 is trivial"); diff --git a/test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p1.cpp b/test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p1.cpp deleted file mode 100644 index 3baf238241a6..000000000000 --- a/test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p1.cpp +++ /dev/null @@ -1,60 +0,0 @@ -// RUN: %clang_cc1 -std=c++14 -fconcepts-ts -fcxx-exceptions -x c++ -verify %s - -namespace A { - template<typename T> concept bool C1() { return true; } - - template<typename T> concept bool C2 = true; -} - -template<typename T> concept bool C3() { return (throw 0, true); } -static_assert(noexcept(C3<int>()), "function concept should be treated as if noexcept(true) specified"); - -template<typename T> concept bool D1(); // expected-error {{function concept declaration must be a definition}} - -struct B { - template<typename T> concept bool D2() { return true; } // expected-error {{concept declarations may only appear in namespace scope}} -}; - -struct C { - template<typename T> static concept bool D3 = true; // expected-error {{concept declarations may only appear in namespace scope}} -}; - -concept bool D4() { return true; } // expected-error {{'concept' can only appear on the definition of a function template or variable template}} - -concept bool D5 = true; // expected-error {{'concept' can only appear on the definition of a function template or variable template}} - -template<typename T> -concept bool D6; // expected-error {{variable concept declaration must be initialized}} - -template<typename T> -concept bool D7() throw(int) { return true; } // expected-error {{function concept cannot have exception specification}} - -// Tag -concept class CC1 {}; // expected-error {{'concept' can only appear on the definition of a function template or variable template}} -concept struct CS1 {}; // expected-error {{'concept' can only appear on the definition of a function template or variable template}} -concept union CU1 {}; // expected-error {{'concept' can only appear on the definition of a function template or variable template}} -concept enum CE1 {}; // expected-error {{'concept' can only appear on the definition of a function template or variable template}} -template <typename T> concept class TCC1 {}; // expected-error {{'concept' can only appear on the definition of a function template or variable template}} -template <typename T> concept struct TCS1 {}; // expected-error {{'concept' can only appear on the definition of a function template or variable template}} -template <typename T> concept union TCU1 {}; // expected-error {{'concept' can only appear on the definition of a function template or variable template}} -typedef concept int CI; // expected-error {{'concept' can only appear on the definition of a function template or variable template}} -void fpc(concept int i) {} // expected-error {{'concept' can only appear on the definition of a function template or variable template}} - -concept bool; // expected-error {{'concept' can only appear on the definition of a function template or variable template}} - -template <typename T> concept bool VCEI{ true }; -template concept bool VCEI<int>; // expected-error {{'concept' cannot be applied on an explicit instantiation}} -extern template concept bool VCEI<int>; // expected-error {{'concept' cannot be applied on an explicit instantiation}} - -template <typename T> concept bool VCPS{ true }; -template <typename T> concept bool VCPS<T *>{ true }; // expected-error {{'concept' cannot be applied on an partial specialization}} - -template <typename T> concept bool VCES{ true }; -template <> concept bool VCES<int>{ true }; // expected-error {{'concept' cannot be applied on an explicit specialization}} - -template <typename T> concept bool FCEI() { return true; } -template concept bool FCEI<int>(); // expected-error {{'concept' cannot be applied on an explicit instantiation}} -extern template concept bool FCEI<int>(); // expected-error {{'concept' cannot be applied on an explicit instantiation}} - -template <typename T> concept bool FCES() { return true; } -template <> concept bool FCES<bool>() { return true; } // expected-error {{'concept' cannot be applied on an explicit specialization}} diff --git a/test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p2.cpp b/test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p2.cpp deleted file mode 100644 index 477910986de1..000000000000 --- a/test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p2.cpp +++ /dev/null @@ -1,13 +0,0 @@ -// RUN: %clang_cc1 -std=c++14 -fconcepts-ts -x c++ -verify %s - -template<typename T> concept thread_local bool VCTL = true; // expected-error {{variable concept cannot be declared 'thread_local'}} - -template<typename T> concept constexpr bool VCC = true; // expected-error {{variable concept cannot be declared 'constexpr'}} - -template<typename T> concept inline bool FCI() { return true; } // expected-error {{function concept cannot be declared 'inline'}} - -struct X { - template<typename T> concept friend bool FCF() { return true; } // expected-error {{function concept cannot be declared 'friend'}} -}; - -template<typename T> concept constexpr bool FCC() { return true; } // expected-error {{function concept cannot be declared 'constexpr'}} diff --git a/test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p5.cpp b/test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p5.cpp deleted file mode 100644 index 69672ca83063..000000000000 --- a/test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p5.cpp +++ /dev/null @@ -1,25 +0,0 @@ -// RUN: %clang_cc1 -std=c++14 -fconcepts-ts -x c++ -verify %s - -template<typename T> -concept bool fcpv(void) { return true; } - -template<typename T> -concept bool fcpi(int i = 0) { return true; } // expected-error {{function concept cannot have any parameters}} - -template<typename... Ts> -concept bool fcpp(Ts... ts) { return true; } // expected-error {{function concept cannot have any parameters}} - -template<typename T> -concept bool fcpva(...) { return true; } // expected-error {{function concept cannot have any parameters}} - -template<typename T> -concept const bool fcrtc() { return true; } // expected-error {{declared return type of function concept must be 'bool'}} - -template<typename T> -concept int fcrti() { return 5; } // expected-error {{declared return type of function concept must be 'bool'}} - -template<typename T> -concept float fcrtf() { return 5.5; } // expected-error {{declared return type of function concept must be 'bool'}} - -template<typename T> -concept decltype(auto) fcrtd(void) { return true; } // expected-error {{declared return type of function concept must be 'bool'}} diff --git a/test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p6.cpp b/test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p6.cpp deleted file mode 100644 index f8a1bb72e39a..000000000000 --- a/test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p6.cpp +++ /dev/null @@ -1,25 +0,0 @@ -// RUN: %clang_cc1 -std=c++14 -fconcepts-ts -x c++ -verify %s - -template<typename T> -concept bool vc { true }; - -template<typename T> -struct B { typedef bool Boolean; }; - -template<int N> -B<void>::Boolean concept vctb(!0); - -template<typename T> -concept const bool vctc { true }; // expected-error {{declared type of variable concept must be 'bool'}} - -template<typename T> -concept int vcti { 5 }; // expected-error {{declared type of variable concept must be 'bool'}} - -template<typename T> -concept float vctf { 5.5 }; // expected-error {{declared type of variable concept must be 'bool'}} - -template<typename T> -concept auto vcta { true }; // expected-error {{declared type of variable concept must be 'bool'}} - -template<typename T> -concept decltype(auto) vctd { true }; // expected-error {{declared type of variable concept must be 'bool'}} diff --git a/test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p7.cpp b/test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p7.cpp deleted file mode 100644 index 1bad6bb93294..000000000000 --- a/test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p7.cpp +++ /dev/null @@ -1,18 +0,0 @@ -// RUN: %clang_cc1 -std=c++14 -fconcepts-ts -x c++ -verify %s - -template <typename T> concept bool FCEI() { return true; } // expected-note {{previous declaration is here}} expected-note {{previous declaration is here}} -template bool FCEI<int>(); // expected-error {{function concept cannot be explicitly instantiated}} -extern template bool FCEI<double>(); // expected-error {{function concept cannot be explicitly instantiated}} - -template <typename T> concept bool FCES() { return true; } // expected-note {{previous declaration is here}} -template <> bool FCES<int>() { return true; } // expected-error {{function concept cannot be explicitly specialized}} - -template <typename T> concept bool VC { true }; // expected-note {{previous declaration is here}} expected-note {{previous declaration is here}} -template bool VC<int>; // expected-error {{variable concept cannot be explicitly instantiated}} -extern template bool VC<double>; // expected-error {{variable concept cannot be explicitly instantiated}} - -template <typename T> concept bool VCES { true }; // expected-note {{previous declaration is here}} -template <> bool VCES<int> { true }; // expected-error {{variable concept cannot be explicitly specialized}} - -template <typename T> concept bool VCPS { true }; // expected-note {{previous declaration is here}} -template <typename T> bool VCPS<T *> { true }; // expected-error {{variable concept cannot be partially specialized}} diff --git a/test/CXX/concepts-ts/dcl.dcl/lit.cfg.py b/test/CXX/concepts-ts/dcl.dcl/lit.cfg.py deleted file mode 100644 index c705e3cb93b4..000000000000 --- a/test/CXX/concepts-ts/dcl.dcl/lit.cfg.py +++ /dev/null @@ -1,26 +0,0 @@ -# -*- Python -*- - -import os -import lit.formats - -from lit.llvm import llvm_config - -# Configuration file for the 'lit' test runner. - -# name: The name of this test suite. -config.name = 'Clang-Concepts-TS-Unsupported' - -# testFormat: The test format to use to interpret tests. -# -# For now we require '&&' between commands, until they get globally killed and -# the test runner updated. -config.test_format = lit.formats.ShTest(not llvm_config.use_lit_shell) - -# suffixes: A list of file extensions to treat as test files. -config.suffixes = ['.c', '.cpp', '.cppm', '.m', '.mm', '.cu', - '.ll', '.cl', '.s', '.S', '.modulemap', '.test', '.rs'] - -config.unsupported = True - -# test_source_root: The root path where tests are located. -config.test_source_root = os.path.dirname(__file__) diff --git a/test/CXX/concepts-ts/temp/temp.constr/temp.constr.decl/class-template-decl.cpp b/test/CXX/concepts-ts/temp/temp.constr/temp.constr.decl/class-template-decl.cpp deleted file mode 100644 index d1ad0404ef42..000000000000 --- a/test/CXX/concepts-ts/temp/temp.constr/temp.constr.decl/class-template-decl.cpp +++ /dev/null @@ -1,65 +0,0 @@ -// RUN: %clang_cc1 -std=c++14 -fconcepts-ts -x c++ -verify %s - -namespace nodiag { - -template <typename T> requires bool(T()) -struct A; -template <typename U> requires bool(U()) -struct A; - -} // end namespace nodiag - -namespace diag { - -template <typename T> requires true // expected-note{{previous template declaration is here}} -struct A; -template <typename T> struct A; // expected-error{{associated constraints differ in template redeclaration}} - -template <typename T> struct B; // expected-note{{previous template declaration is here}} -template <typename T> requires true // expected-error{{associated constraints differ in template redeclaration}} -struct B; - -template <typename T> requires true // expected-note{{previous template declaration is here}} -struct C; -template <typename T> requires !0 // expected-error{{associated constraints differ in template redeclaration}} -struct C; - -} // end namespace diag - -namespace nodiag { - -struct AA { - template <typename T> requires someFunc(T()) - struct A; -}; - -template <typename T> requires someFunc(T()) -struct AA::A { }; - -struct AAF { - template <typename T> requires someFunc(T()) - friend struct AA::A; -}; - -} // end namespace nodiag - -namespace diag { - -template <unsigned N> -struct TA { - template <template <unsigned> class TT> requires TT<N>::happy // expected-note 2{{previous template declaration is here}} - struct A; - - struct AF; -}; - -template <unsigned N> -template <template <unsigned> class TT> struct TA<N>::A { }; // expected-error{{associated constraints differ in template redeclaration}} - -template <unsigned N> -struct TA<N>::AF { - template <template <unsigned> class TT> requires TT<N + 0>::happy // expected-error{{associated constraints differ in template redeclaration}} - friend struct TA::A; -}; - -} // end namespace diag diff --git a/test/CXX/conv/conv.fctptr/p1.cpp b/test/CXX/conv/conv.fctptr/p1.cpp deleted file mode 100644 index be9c050af51e..000000000000 --- a/test/CXX/conv/conv.fctptr/p1.cpp +++ /dev/null @@ -1,43 +0,0 @@ -// RUN: %clang_cc1 -std=c++1z -verify %s -triple x86_64-unknown-unknown - -struct S; - -typedef void Nothrow() noexcept; -typedef void Throw(); - -Nothrow *a; -Throw *b; -Nothrow S::*c; -Throw S::*d; - -void test() { - a = b; // expected-error {{assigning to 'Nothrow *' (aka 'void (*)() noexcept') from incompatible type 'Throw *' (aka 'void (*)()'): different exception specifications}} - b = a; - c = d; // expected-error {{assigning to 'Nothrow S::*' from incompatible type 'Throw S::*': different exception specifications}} - d = c; - - // Function pointer conversions do not combine properly with qualification conversions. - // FIXME: This seems like a defect. - Nothrow *const *pa = b; // expected-error {{cannot initialize}} - Throw *const *pb = a; // expected-error {{cannot initialize}} - Nothrow *const S::*pc = d; // expected-error {{cannot initialize}} - Throw *const S::*pd = c; // expected-error {{cannot initialize}} -} - -// ... The result is a pointer to the function. -void f() noexcept; -constexpr void (*p)() = &f; -static_assert(f == p); - -struct S { void f() noexcept; }; -constexpr void (S::*q)() = &S::f; -static_assert(q == &S::f); - - -namespace std_example { - void (*p)(); - void (**pp)() noexcept = &p; // expected-error {{cannot initialize a variable of type 'void (**)() noexcept' with an rvalue of type 'void (**)()'}} - - struct S { typedef void (*p)(); operator p(); }; // expected-note {{candidate}} - void (*q)() noexcept = S(); // expected-error {{no viable conversion from 'std_example::S' to 'void (*)() noexcept'}} -} diff --git a/test/CXX/conv/conv.mem/p4.cpp b/test/CXX/conv/conv.mem/p4.cpp deleted file mode 100644 index 1618ae125d2f..000000000000 --- a/test/CXX/conv/conv.mem/p4.cpp +++ /dev/null @@ -1,65 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s - -struct Base { - int data; - int method(); -}; -int (Base::*data_ptr) = &Base::data; -int (Base::*method_ptr)() = &Base::method; - -namespace test0 { - struct Derived : Base {}; - void test() { - int (Derived::*d) = data_ptr; - int (Derived::*m)() = method_ptr; - } -} - -// Can't be inaccessible. -namespace test1 { - struct Derived : private Base {}; // expected-note 2 {{declared private here}} - void test() { - int (Derived::*d) = data_ptr; // expected-error {{cannot cast private base class 'Base' to 'test1::Derived'}} - int (Derived::*m)() = method_ptr; // expected-error {{cannot cast private base class 'Base' to 'test1::Derived'}} - } -}; - -// Can't be ambiguous. -namespace test2 { - struct A : Base {}; - struct B : Base {}; - struct Derived : A, B {}; - void test() { - int (Derived::*d) = data_ptr; // expected-error {{ambiguous conversion from pointer to member of base class 'Base' to pointer to member of derived class 'test2::Derived':}} - int (Derived::*m)() = method_ptr; // expected-error {{ambiguous conversion from pointer to member of base class 'Base' to pointer to member of derived class 'test2::Derived':}} - } -} - -// Can't be virtual. -namespace test3 { - struct Derived : virtual Base {}; - void test() { - int (Derived::*d) = data_ptr; // expected-error {{conversion from pointer to member of class 'Base' to pointer to member of class 'test3::Derived' via virtual base 'Base' is not allowed}} - int (Derived::*m)() = method_ptr; // expected-error {{conversion from pointer to member of class 'Base' to pointer to member of class 'test3::Derived' via virtual base 'Base' is not allowed}} - } -} - -// Can't be virtual even if there's a non-virtual path. -namespace test4 { - struct A : Base {}; - struct Derived : Base, virtual A {}; // expected-warning {{direct base 'Base' is inaccessible due to ambiguity:\n struct test4::Derived -> struct Base\n struct test4::Derived -> struct test4::A -> struct Base}} - void test() { - int (Derived::*d) = data_ptr; // expected-error {{ambiguous conversion from pointer to member of base class 'Base' to pointer to member of derived class 'test4::Derived':}} - int (Derived::*m)() = method_ptr; // expected-error {{ambiguous conversion from pointer to member of base class 'Base' to pointer to member of derived class 'test4::Derived':}} - } -} - -// PR6254: don't get thrown off by a virtual base. -namespace test5 { - struct A {}; - struct Derived : Base, virtual A {}; - void test() { - int (Derived::*d) = data_ptr; - int (Derived::*m)() = method_ptr; - } -} diff --git a/test/CXX/conv/conv.prom/p2.cpp b/test/CXX/conv/conv.prom/p2.cpp deleted file mode 100644 index c5ac9112d887..000000000000 --- a/test/CXX/conv/conv.prom/p2.cpp +++ /dev/null @@ -1,17 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++0x -triple x86_64-pc-linux-gnu -ffreestanding %s -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++0x -triple x86_64-pc-linux-gnu -ffreestanding -fwchar-type=short -fno-signed-wchar %s -// expected-no-diagnostics - -#include <stdint.h> - -// In theory, the promoted types vary by platform; however, in reality they -// are quite consistent across all platforms where clang runs. - -extern int promoted_wchar; -extern decltype(+L'a') promoted_wchar; - -extern int promoted_char16; -extern decltype(+u'a') promoted_char16; - -extern unsigned promoted_char32; -extern decltype(+U'a') promoted_char32; diff --git a/test/CXX/conv/conv.prom/p4.cpp b/test/CXX/conv/conv.prom/p4.cpp deleted file mode 100644 index 8c86d2a1838d..000000000000 --- a/test/CXX/conv/conv.prom/p4.cpp +++ /dev/null @@ -1,28 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++0x %s -// expected-no-diagnostics - -enum X : short { A, B }; -extern decltype(+A) x; -extern int x; - -enum Y : long { C, D }; -extern decltype(+C) y; -extern long y; - -// An enum with a fixed underlying type has an integral promotion to that type, -// and to its promoted type. -enum B : bool { false_, true_ }; -template<bool> struct T {}; -T<false_> f; -T<true_> t; -// FIXME: DR1407 will make this ill-formed -T<+true_> q; // desired-error {{conversion from 'int' to 'bool'}} - -enum B2 : bool { - a = false, - b = true, - c = false_, - d = true_, - // FIXME: DR1407 will make this ill-formed - e = +false_ // desired-error {{conversion from 'int' to 'bool'}} -}; diff --git a/test/CXX/conv/conv.prom/p5.cpp b/test/CXX/conv/conv.prom/p5.cpp deleted file mode 100644 index 0c72ebce4aa9..000000000000 --- a/test/CXX/conv/conv.prom/p5.cpp +++ /dev/null @@ -1,19 +0,0 @@ -// RUN: %clang_cc1 -verify %s -// expected-no-diagnostics - -// A prvalue for an integral bit-field can be converted to a prvalue of type -// int if int can represent all the values of the bit-field -struct X { long long e : 1; }; -static_assert(sizeof(+X().e) == sizeof(int), ""); -static_assert(sizeof(X().e + 1) == sizeof(int), ""); -static_assert(sizeof(true ? X().e : 0) == sizeof(int), ""); - -enum E : long long { a = __LONG_LONG_MAX__ }; -static_assert(sizeof(E{}) == sizeof(long long), ""); - -// If the bit-field has an enumerated type, it is treated as any other value of -// that [enumerated] type for promotion purposes. -struct Y { E e : 1; }; -static_assert(sizeof(+Y().e) == sizeof(long long), ""); -static_assert(sizeof(Y().e + 1) == sizeof(long long), ""); -static_assert(sizeof(true ? Y().e : 0) == sizeof(long long), ""); diff --git a/test/CXX/conv/conv.ptr/p2.cpp b/test/CXX/conv/conv.ptr/p2.cpp deleted file mode 100644 index b7617696e6fb..000000000000 --- a/test/CXX/conv/conv.ptr/p2.cpp +++ /dev/null @@ -1,7 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -// expected-no-diagnostics - -namespace pr7801 { - extern void* x[]; - void* dummy[] = { &x }; -} diff --git a/test/CXX/conv/conv.qual/pr6089.cpp b/test/CXX/conv/conv.qual/pr6089.cpp deleted file mode 100644 index bfadc6cac48e..000000000000 --- a/test/CXX/conv/conv.qual/pr6089.cpp +++ /dev/null @@ -1,19 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -// expected-no-diagnostics - -bool is_char_ptr( const char* ); - -template< class T > - long is_char_ptr( T /* r */ ); - -// Note: the const here does not lead to a qualification conversion -template< class T > - void make_range( T* const r, bool ); - -template< class T > - void make_range( T& r, long ); - -void first_finder( const char*& Search ) -{ - make_range( Search, is_char_ptr(Search) ); -} diff --git a/test/CXX/cpp/cpp.predefined/p1.cpp b/test/CXX/cpp/cpp.predefined/p1.cpp deleted file mode 100644 index c0dcbd54f387..000000000000 --- a/test/CXX/cpp/cpp.predefined/p1.cpp +++ /dev/null @@ -1,9 +0,0 @@ -// RUN: %clang_cc1 -std=c++1z %s -verify -triple x86_64-linux-gnu -DALIGN=16 -// RUN: %clang_cc1 -std=c++1z %s -verify -fnew-alignment=2 -DALIGN=2 -// RUN: %clang_cc1 -std=c++1z %s -verify -fnew-alignment=256 -DALIGN=256 - -// expected-no-diagnostics - -#if ALIGN != __STDCPP_DEFAULT_NEW_ALIGNMENT__ -#error wrong value for __STDCPP_DEFAULT_NEW_ALIGNMENT__ -#endif diff --git a/test/CXX/dcl.dcl/basic.namespace/namespace.def/namespace.memdef/p3.cpp b/test/CXX/dcl.dcl/basic.namespace/namespace.def/namespace.memdef/p3.cpp deleted file mode 100644 index 11372dd48a10..000000000000 --- a/test/CXX/dcl.dcl/basic.namespace/namespace.def/namespace.memdef/p3.cpp +++ /dev/null @@ -1,194 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only %s -verify - -// C++'0x [namespace.memdef] p3: -// Every name first declared in a namespace is a member of that namespace. If -// a friend declaration in a non-local class first declares a class or -// function the friend class or function is a member of the innermost -// enclosing namespace. - -namespace N { - struct S0 { - friend struct F0; - friend void f0(int); - struct F0 member_func(); - }; - struct F0 { }; - F0 f0() { return S0().member_func(); } -} -N::F0 f0_var = N::f0(); - -// Ensure we can handle attaching friend declarations to an enclosing namespace -// with multiple contexts. -namespace N { struct S1 { struct IS1; }; } -namespace N { - struct S1::IS1 { - friend struct F1; - friend void f1(int); - struct F1 member_func(); - }; - struct F1 { }; - F1 f1() { return S1::IS1().member_func(); } -} -N::F1 f1_var = N::f1(); - -// The name of the friend is not found by unqualified lookup (3.4.1) or by -// qualified lookup (3.4.3) until a matching declaration is provided in that -// namespace scope (either before or after the class definition granting -// friendship). If a friend function is called, its name may be found by the -// name lookup that considers functions from namespaces and classes -// associated with the types of the function arguments (3.4.2). If the name -// in a friend declaration is neither qualified nor a template-id and the -// declaration is a function or an elaborated-type-specifier, the lookup to -// determine whether the entity has been previously declared shall not -// consider any scopes outside the innermost enclosing namespace. - -template<typename T> struct X0 { }; -struct X1 { }; - -struct Y { - template<typename T> union X0; - template<typename T> friend union X0; - - union X1; - friend union X1; -}; - -namespace N { - namespace M { - template<typename T> class X; - } -} - -namespace N3 { - class Y { - template<typename T> friend class N::M::X; - }; -} - -// FIXME: Woefully inadequate for testing - -// Friends declared as template-ids aren't subject to the restriction -// on innermost namespaces. -// rdar://problem/8552377 -namespace test5 { - template <class T> void f(T); - namespace ns { - class A { - friend void f<int>(int); - static void foo(); // expected-note 2 {{declared private here}} - }; - - // Note that this happens without instantiation. - template <class T> void f(T) { - A::foo(); // expected-error {{'foo' is a private member of 'test5::ns::A'}} - } - } - - template <class T> void f(T) { - ns::A::foo(); // expected-error {{'foo' is a private member of 'test5::ns::A'}} - } - - template void f<int>(int); - template void f<long>(long); //expected-note {{instantiation}} -} - -// rdar://13393749 -namespace test6 { - class A; - namespace ns { - class B { - static void foo(); // expected-note {{implicitly declared private here}} - friend union A; - }; - - union A { - void test() { - B::foo(); - } - }; - } - - class A { - void test() { - ns::B::foo(); // expected-error {{'foo' is a private member of 'test6::ns::B'}} - } - }; -} - -// We seem to be following a correct interpretation with these, but -// the standard could probably be a bit clearer. -namespace test7a { - namespace ns { - class A; - } - - using namespace ns; - class B { - static void foo(); - friend class A; - }; - - class ns::A { - void test() { - B::foo(); - } - }; -} -namespace test7b { - namespace ns { - class A; - } - - using ns::A; - class B { - static void foo(); - friend class A; - }; - - class ns::A { - void test() { - B::foo(); - } - }; -} -namespace test7c { - namespace ns1 { - class A; - } - - namespace ns2 { - // ns1::A appears as if declared in test7c according to [namespace.udir]p2. - // I think that means we aren't supposed to find it. - using namespace ns1; - class B { - static void foo(); // expected-note {{implicitly declared private here}} - friend class A; - }; - } - - class ns1::A { - void test() { - ns2::B::foo(); // expected-error {{'foo' is a private member of 'test7c::ns2::B'}} - } - }; -} -namespace test7d { - namespace ns1 { - class A; - } - - namespace ns2 { - // Honor the lexical context of a using-declaration, though. - using ns1::A; - class B { - static void foo(); - friend class A; - }; - } - - class ns1::A { - void test() { - ns2::B::foo(); - } - }; -} diff --git a/test/CXX/dcl.dcl/basic.namespace/namespace.def/namespace.unnamed/p1.cpp b/test/CXX/dcl.dcl/basic.namespace/namespace.def/namespace.unnamed/p1.cpp deleted file mode 100644 index b4ec585e48e3..000000000000 --- a/test/CXX/dcl.dcl/basic.namespace/namespace.def/namespace.unnamed/p1.cpp +++ /dev/null @@ -1,42 +0,0 @@ -// RUN: %clang_cc1 -emit-llvm-only -verify %s - -// This lame little test was ripped straight from the standard. -namespace { - int i; // expected-note {{candidate}} -} -void test0() { i++; } - -namespace A { - namespace { - int i; // expected-note {{candidate}} - int j; - } - void test1() { i++; } -} - -using namespace A; - -void test2() { - i++; // expected-error {{reference to 'i' is ambiguous}} - A::i++; - j++; -} - - -// Test that all anonymous namespaces in a translation unit are -// considered the same context. -namespace { - class Test3 {}; // expected-note {{previous definition}} -} -namespace { - class Test3 {}; // expected-error {{redefinition of 'Test3'}} -} - -namespace test4 { - namespace { - class Test4 {}; // expected-note {{previous definition}} - } - namespace { - class Test4 {}; // expected-error {{redefinition of 'Test4'}} - } -} diff --git a/test/CXX/dcl.dcl/basic.namespace/namespace.def/p1.cpp b/test/CXX/dcl.dcl/basic.namespace/namespace.def/p1.cpp deleted file mode 100644 index 6ffa873cd46b..000000000000 --- a/test/CXX/dcl.dcl/basic.namespace/namespace.def/p1.cpp +++ /dev/null @@ -1,9 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 -pedantic %s - -// Intentionally compiled as C++03 to test the extension warning. - -namespace a {} // original -namespace a {} // ext -inline namespace b {} // inline original expected-warning {{inline namespaces are}} -inline namespace b {} // inline ext expected-warning {{inline namespaces are}} -inline namespace {} // inline unnamed expected-warning {{inline namespaces are}} diff --git a/test/CXX/dcl.dcl/basic.namespace/namespace.def/p2.cpp b/test/CXX/dcl.dcl/basic.namespace/namespace.def/p2.cpp deleted file mode 100644 index 943e05322d25..000000000000 --- a/test/CXX/dcl.dcl/basic.namespace/namespace.def/p2.cpp +++ /dev/null @@ -1,25 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -// expected-no-diagnostics - -// PR8430 -namespace N { - class A { }; -} - -namespace M { } - -using namespace M; - -namespace N { - namespace M { - } -} - -namespace M { - namespace N { - } -} - -namespace N { - A *getA(); -} diff --git a/test/CXX/dcl.dcl/basic.namespace/namespace.def/p7.cpp b/test/CXX/dcl.dcl/basic.namespace/namespace.def/p7.cpp deleted file mode 100644 index 39bed7db7ab3..000000000000 --- a/test/CXX/dcl.dcl/basic.namespace/namespace.def/p7.cpp +++ /dev/null @@ -1,18 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s - -// FIXME: We should probably suppress the warning on reopening an inline -// namespace without the inline keyword if it's not the first opening of the -// namespace in the file, because there's no risk of the inlineness differing -// across TUs in that case. - -namespace NIL {} // expected-note {{previous definition}} -inline namespace NIL {} // expected-error {{cannot be reopened as inline}} -inline namespace IL {} // expected-note {{previous definition}} -namespace IL {} // expected-warning{{inline namespace reopened as a non-inline namespace}} - -namespace {} // expected-note {{previous definition}} -inline namespace {} // expected-error {{cannot be reopened as inline}} -namespace X { - inline namespace {} // expected-note {{previous definition}} - namespace {} // expected-warning {{inline namespace reopened as a non-inline namespace}} -} diff --git a/test/CXX/dcl.dcl/basic.namespace/namespace.def/p8.cpp b/test/CXX/dcl.dcl/basic.namespace/namespace.def/p8.cpp deleted file mode 100644 index 96a0df4a03f0..000000000000 --- a/test/CXX/dcl.dcl/basic.namespace/namespace.def/p8.cpp +++ /dev/null @@ -1,118 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s - -// Fun things you can do with inline namespaces: - -inline namespace X { - void f1(); // expected-note {{'f1' declared here}} - - inline namespace Y { - void f2(); - - template <typename T> class C {}; - } - - // Specialize and partially specialize somewhere else. - template <> class C<int> {}; - template <typename T> class C<T*> {}; -} - -// Qualified and unqualified lookup as if member of enclosing NS. -void foo1() { - f1(); - ::f1(); - X::f1(); - Y::f1(); // expected-error {{no member named 'f1' in namespace 'X::Y'; did you mean simply 'f1'?}} - - f2(); - ::f2(); - X::f2(); - Y::f2(); -} - -template <> class C<float> {}; -template <typename T> class C<T&> {}; - -template class C<double>; - - -// As well as all the fun with ADL. - -namespace ADL { - struct Outer {}; - - inline namespace IL { - struct Inner {}; - - void fo(Outer); - } - - void fi(Inner); - - inline namespace IL2 { - void fi2(Inner); - } -} - -void foo2() { - ADL::Outer o; - ADL::Inner i; - fo(o); - fi(i); - fi2(i); -} - -// Let's not forget overload sets. -struct Distinct {}; -inline namespace Over { - void over(Distinct); -} -void over(int); - -void foo3() { - Distinct d; - ::over(d); -} - -// Don't forget to do correct lookup for redeclarations. -namespace redecl { inline namespace n1 { - - template <class Tp> class allocator; - - template <> - class allocator<void> - { - public: - typedef const void* const_pointer; - }; - - template <class Tp> - class allocator - { - public: - typedef Tp& reference; - - void allocate(allocator<void>::const_pointer = 0); - }; - -} } - -// Normal redeclarations (not for explicit instantiations or -// specializations) are distinct in an inline namespace vs. not in an -// inline namespace. -namespace redecl2 { - inline namespace n1 { - void f(int) { } - struct X1 { }; - template<typename T> void f(T) { } - template<typename T> struct X2 { }; - int i = 71; - enum E { e }; - } - - void f(int) { } - struct X1 { }; - template<typename T> void f(T) { } - template<typename T> struct X2 { }; - int i = 71; - enum E { e }; -} diff --git a/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p1.cpp b/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p1.cpp deleted file mode 100644 index 021c25016c93..000000000000 --- a/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p1.cpp +++ /dev/null @@ -1,115 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s - -// We have to avoid ADL for this test. - -template <unsigned N> class test {}; - -class foo {}; // expected-note {{candidate constructor (the implicit copy constructor) not viable}} -#if __cplusplus >= 201103L // C++11 or later -// expected-note@-2 {{candidate constructor (the implicit move constructor) not viable}} -#endif -test<0> foo(foo); // expected-note {{candidate}} - -namespace Test0 { - class foo { int x; }; - test<1> foo(class foo); - - namespace A { - test<2> foo(class ::foo); // expected-note {{candidate}} \ - // expected-note{{passing argument to parameter here}} - - void test0() { - using ::foo; - - class foo a; - test<0> _ = (foo)(a); - } - - void test1() { - using Test0::foo; - - class foo a; - test<1> _ = (foo)(a); - }; - - void test2() { - class ::foo a; - - // Argument-dependent lookup is ambiguous between B:: and ::. - test<0> _0 = foo(a); // expected-error {{call to 'foo' is ambiguous}} - - // But basic unqualified lookup is not. - test<2> _1 = (foo)(a); - - class Test0::foo b; - test<2> _2 = (foo)(b); // expected-error {{no viable conversion from 'class Test0::foo' to 'class ::foo'}} - } - } -} - -namespace Test1 { - namespace A { - class a {}; - } - - namespace B { - typedef class {} b; - } - - namespace C { - int c(); // expected-note {{target of using declaration}} - } - - namespace D { - using typename A::a; - using typename B::b; - using typename C::c; // expected-error {{'typename' keyword used on a non-type}} - - a _1 = A::a(); - b _2 = B::b(); - } -} - -namespace test2 { - class A { - protected: - operator int(); - operator bool(); - }; - - class B : private A { - protected: - using A::operator int; // expected-note {{declared protected here}} - public: - using A::operator bool; - }; - - int test() { - bool b = B(); - return B(); // expected-error {{'operator int' is a protected member of 'test2::B'}} - } -} - -namespace test3 { - class A { - public: - ~A(); - }; - - class B { - friend class C; - private: - operator A*(); - }; - - class C : public B { - public: - using B::operator A*; - }; - - void test() { - delete C(); - } -} diff --git a/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p10.cpp b/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p10.cpp deleted file mode 100644 index a38ff15525d2..000000000000 --- a/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p10.cpp +++ /dev/null @@ -1,44 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -// expected-no-diagnostics - -namespace test0 { - namespace ns0 { - class tag; - int tag(); - } - - namespace ns1 { - using ns0::tag; - } - - namespace ns2 { - using ns0::tag; - } - - using ns1::tag; - using ns2::tag; -} - -// PR 5752 -namespace test1 { - namespace ns { - void foo(); - } - - using ns::foo; - void foo(int); - - namespace ns { - using test1::foo; - } -} - -// PR 14768 -namespace PR14768 { - template<typename eT> class Mat; - template<typename eT> class Col : public Mat<eT> { - using Mat<eT>::operator(); - using Col<eT>::operator(); - void operator() (); - }; -} diff --git a/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p11.cpp b/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p11.cpp deleted file mode 100644 index 4ffb93a1ef74..000000000000 --- a/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p11.cpp +++ /dev/null @@ -1,109 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s - -// C++03 [namespace.udecl]p11: (per DR101) -// If a function declaration in namespace scope or block scope has -// the same name and the same parameter types as a function -// introduced by a using-declaration, and the declarations do not declare the -// same function, the program is ill-formed. [Note: two using-declarations may -// introduce functions with the same name and the same parameter types. If, -// for a call to an unqualified function name, function overload resolution -// selects the functions introduced by such using-declarations, the function -// call is ill-formed.] -// -// FIXME: DR565 introduces parallel wording here for function templates. - -namespace test0 { - namespace ns { void foo(); } // expected-note {{target of using declaration}} - int foo(void); // expected-note {{conflicting declaration}} - using ns::foo; // expected-error {{target of using declaration conflicts with declaration already in scope}} -} - -namespace test1 { - namespace ns { void foo(); } // expected-note {{target of using declaration}} - using ns::foo; //expected-note {{using declaration}} - int foo(void); // expected-error {{declaration conflicts with target of using declaration already in scope}} -} - -namespace test2 { - namespace ns { void foo(); } // expected-note 2 {{target of using declaration}} - void test0() { - int foo(void); // expected-note {{conflicting declaration}} - using ns::foo; // expected-error {{target of using declaration conflicts with declaration already in scope}} - } - - void test1() { - using ns::foo; //expected-note {{using declaration}} - int foo(void); // expected-error {{declaration conflicts with target of using declaration already in scope}} - } -} - -namespace test3 { - namespace ns { void foo(); } // expected-note 2 {{target of using declaration}} - class Test0 { - void test() { - int foo(void); // expected-note {{conflicting declaration}} - using ns::foo; // expected-error {{target of using declaration conflicts with declaration already in scope}} - } - }; - - class Test1 { - void test() { - using ns::foo; //expected-note {{using declaration}} - int foo(void); // expected-error {{declaration conflicts with target of using declaration already in scope}} - } - }; -} - -namespace test4 { - namespace ns { void foo(); } // expected-note 2 {{target of using declaration}} - template <typename> class Test0 { - void test() { - int foo(void); // expected-note {{conflicting declaration}} - using ns::foo; // expected-error {{target of using declaration conflicts with declaration already in scope}} - } - }; - - template <typename> class Test1 { - void test() { - using ns::foo; //expected-note {{using declaration}} - int foo(void); // expected-error {{declaration conflicts with target of using declaration already in scope}} - } - }; -} - -// FIXME: we should be able to diagnose both of these, but we can't. -namespace test5 { - namespace ns { void foo(int); } - template <typename T> class Test0 { - void test() { - int foo(T); - using ns::foo; - } - }; - - template <typename T> class Test1 { - void test() { - using ns::foo; - int foo(T); - } - }; - - template class Test0<int>; - template class Test1<int>; -} - -namespace test6 { - namespace ns { void foo(); } // expected-note {{target of using declaration}} - using ns::foo; // expected-note {{using declaration}} - namespace ns { - using test6::foo; - void foo() {} - } - void foo(); // expected-error {{declaration conflicts with target of using declaration already in scope}} -} - -namespace test7 { - void foo(); - using test7::foo; - void foo() {} -} diff --git a/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p12.cpp b/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p12.cpp deleted file mode 100644 index ce43720cb2d3..000000000000 --- a/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p12.cpp +++ /dev/null @@ -1,195 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s -// RUN: %clang_cc1 -fsyntax-only -verify %s - -// C++03 [namespace.udecl]p12: -// When a using-declaration brings names from a base class into a -// derived class scope, member functions in the derived class -// override and/or hide member functions with the same name and -// parameter types in a base class (rather than conflicting). - -template <unsigned n> struct Opaque {}; -template <unsigned n> void expect(Opaque<n> _) {} - -// PR5727 -// This just shouldn't crash. -namespace test0 { - template<typename> struct RefPtr { }; - template<typename> struct PtrHash { - static void f() { } - }; - template<typename T> struct PtrHash<RefPtr<T> > : PtrHash<T*> { - using PtrHash<T*>::f; - static void f() { f(); } - }; -} - -// Simple hiding. -namespace test1 { - struct Base { - Opaque<0> foo(Opaque<0>); - Opaque<0> foo(Opaque<1>); - Opaque<0> foo(Opaque<2>); - }; - - // using before decls - struct Test0 : Base { - using Base::foo; - Opaque<1> foo(Opaque<1>); - Opaque<1> foo(Opaque<3>); - - void test0() { Opaque<0> _ = foo(Opaque<0>()); } - void test1() { Opaque<1> _ = foo(Opaque<1>()); } - void test2() { Opaque<0> _ = foo(Opaque<2>()); } - void test3() { Opaque<1> _ = foo(Opaque<3>()); } - }; - - // using after decls - struct Test1 : Base { - Opaque<1> foo(Opaque<1>); - Opaque<1> foo(Opaque<3>); - using Base::foo; - - void test0() { Opaque<0> _ = foo(Opaque<0>()); } - void test1() { Opaque<1> _ = foo(Opaque<1>()); } - void test2() { Opaque<0> _ = foo(Opaque<2>()); } - void test3() { Opaque<1> _ = foo(Opaque<3>()); } - }; - - // using between decls - struct Test2 : Base { - Opaque<1> foo(Opaque<0>); - using Base::foo; - Opaque<1> foo(Opaque<2>); - Opaque<1> foo(Opaque<3>); - - void test0() { Opaque<1> _ = foo(Opaque<0>()); } - void test1() { Opaque<0> _ = foo(Opaque<1>()); } - void test2() { Opaque<1> _ = foo(Opaque<2>()); } - void test3() { Opaque<1> _ = foo(Opaque<3>()); } - }; -} - -// Crazy dependent hiding. -namespace test2 { - struct Base { - void foo(int); - }; - - template <typename T> struct Derived1 : Base { - using Base::foo; - void foo(T); - - void testUnresolved(int i) { foo(i); } - }; - - void test0(int i) { - Derived1<int> d1; - d1.foo(i); - d1.testUnresolved(i); - } - - // Same thing, except with the order of members reversed. - template <typename T> struct Derived2 : Base { - void foo(T); - using Base::foo; - - void testUnresolved(int i) { foo(i); } - }; - - void test1(int i) { - Derived2<int> d2; - d2.foo(i); - d2.testUnresolved(i); - } -} - -// Hiding of member templates. -namespace test3 { - struct Base { - template <class T> Opaque<0> foo() { return Opaque<0>(); } - template <int n> Opaque<1> foo() { return Opaque<1>(); } - }; - - struct Derived1 : Base { - using Base::foo; - template <int n> Opaque<2> foo() { return Opaque<2>(); } // expected-note {{invalid explicitly-specified argument for template parameter 'n'}} - }; - - struct Derived2 : Base { - template <int n> Opaque<2> foo() { return Opaque<2>(); } // expected-note {{invalid explicitly-specified argument for template parameter 'n'}} - using Base::foo; - }; - - struct Derived3 : Base { - using Base::foo; - template <class T> Opaque<3> foo() { return Opaque<3>(); } // expected-note {{invalid explicitly-specified argument for template parameter 'T'}} - }; - - struct Derived4 : Base { - template <class T> Opaque<3> foo() { return Opaque<3>(); } // expected-note {{invalid explicitly-specified argument for template parameter 'T'}} - using Base::foo; - }; - - void test() { - expect<0>(Base().foo<int>()); - expect<1>(Base().foo<0>()); - expect<0>(Derived1().foo<int>()); // expected-error {{no matching member function for call to 'foo'}} - expect<2>(Derived1().foo<0>()); - expect<0>(Derived2().foo<int>()); // expected-error {{no matching member function for call to 'foo'}} - expect<2>(Derived2().foo<0>()); - expect<3>(Derived3().foo<int>()); - expect<1>(Derived3().foo<0>()); // expected-error {{no matching member function for call to 'foo'}} - expect<3>(Derived4().foo<int>()); - expect<1>(Derived4().foo<0>()); // expected-error {{no matching member function for call to 'foo'}} - } -} - -// PR7384: access control for member templates. -namespace test4 { - class Base { - protected: - template<typename T> void foo(T); - template<typename T> void bar(T); // expected-note {{declared protected here}} - }; - - struct Derived : Base { - using Base::foo; - }; - - void test() { - Derived d; - d.foo<int>(3); - d.bar<int>(3); // expected-error {{'bar' is a protected member}} - } -} - -namespace test5 { - struct Derived; - struct Base { - void operator=(const Derived&); - }; - struct Derived : Base { - // Hidden by implicit derived class operator. - using Base::operator=; - }; - void f(Derived d) { - d = d; - } -} - -#if __cplusplus >= 201103L -namespace test6 { - struct Derived; - struct Base { - void operator=(Derived&&); - }; - struct Derived : Base { - // Hidden by implicit derived class operator. - using Base::operator=; - }; - void f(Derived d) { - d = Derived(); - } -} -#endif diff --git a/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p13.cpp b/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p13.cpp deleted file mode 100644 index 699d80ae7c7f..000000000000 --- a/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p13.cpp +++ /dev/null @@ -1,77 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -// expected-no-diagnostics - -// C++03 [namespace.udecl]p3: -// For the purpose of overload resolution, the functions which are -// introduced by a using-declaration into a derived class will be -// treated as though they were members of the derived class. In -// particular, the implicit this parameter shall be treated as if it -// were a pointer to the derived class rather than to the base -// class. This has no effect on the type of the function, and in all -// other respects the function remains a member of the base class. - -namespace test0 { - struct Opaque0 {}; - struct Opaque1 {}; - - struct Base { - Opaque0 test0(int*); - Opaque0 test1(const int*); - Opaque0 test2(int*); - Opaque0 test3(int*) const; - }; - - struct Derived : Base { - using Base::test0; - Opaque1 test0(const int*); - - using Base::test1; - Opaque1 test1(int*); - - using Base::test2; - Opaque1 test2(int*) const; - - using Base::test3; - Opaque1 test3(int*); - }; - - void test0() { - Opaque0 a = Derived().test0((int*) 0); - Opaque1 b = Derived().test0((const int*) 0); - } - - void test1() { - Opaque1 a = Derived().test1((int*) 0); - Opaque0 b = Derived().test1((const int*) 0); - } - - void test2() { - Opaque0 a = ((Derived*) 0)->test2((int*) 0); - Opaque1 b = ((const Derived*) 0)->test2((int*) 0); - } - - void test3() { - Opaque1 a = ((Derived*) 0)->test3((int*) 0); - Opaque0 b = ((const Derived*) 0)->test3((int*) 0); - } -} - -// Typedef redeclaration. -namespace rdar8018262 { - typedef void (*fp)(); - - namespace N { - typedef void (*fp)(); - } - - using N::fp; - - fp fp_1; -} - -// Things to test: -// member operators -// conversion operators -// call operators -// call-surrogate conversion operators -// everything, but in dependent contexts diff --git a/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p15.cpp b/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p15.cpp deleted file mode 100644 index 0c58da01be59..000000000000 --- a/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p15.cpp +++ /dev/null @@ -1,105 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -verify %s - -struct B1 { - B1(int); // expected-note {{candidate}} -}; - -struct B2 { - B2(int); // expected-note {{candidate}} -}; - -struct D1 : B1, B2 { // expected-note 2{{candidate}} - using B1::B1; // expected-note {{inherited here}} - using B2::B2; // expected-note {{inherited here}} -}; -D1 d1(0); // expected-error {{ambiguous}} - -struct D2 : B1, B2 { - using B1::B1; - using B2::B2; - D2(int); -}; -D2 d2(0); // ok - - -// The emergent behavior of implicit special members is a bit odd when -// inheriting from multiple base classes. -namespace default_ctor { - struct C; - struct D; - - struct convert_to_D1 { - operator D&&(); - }; - struct convert_to_D2 { - operator D&&(); - }; - - struct A { // expected-note 2{{candidate}} - A(); // expected-note {{candidate}} - - A(C &&); // expected-note {{candidate}} - C &operator=(C&&); // expected-note {{candidate}} - - A(D &&); - D &operator=(D&&); // expected-note {{candidate}} - - A(convert_to_D2); // expected-note {{candidate}} - }; - - struct B { // expected-note 2{{candidate}} - B(); // expected-note {{candidate}} - - B(C &&); // expected-note {{candidate}} - C &operator=(C&&); // expected-note {{candidate}} - - B(D &&); - D &operator=(D&&); // expected-note {{candidate}} - - B(convert_to_D2); // expected-note {{candidate}} - }; - - struct C : A, B { - using A::A; - using A::operator=; - using B::B; - using B::operator=; - }; - struct D : A, B { - using A::A; // expected-note 3{{inherited here}} - using A::operator=; - using B::B; // expected-note 3{{inherited here}} - using B::operator=; - - D(int); - D(const D&); // expected-note {{candidate}} - D &operator=(const D&); // expected-note {{candidate}} - }; - - C c; - void f(C c) { - C c2(static_cast<C&&>(c)); - c = static_cast<C&&>(c); - } - - // D does not declare D(), D(D&&), nor operator=(D&&), so the base class - // versions are inherited. - D d; // expected-error {{ambiguous}} - void f(D d) { - D d2(static_cast<D&&>(d)); // ok, ignores inherited constructors - D d3(convert_to_D1{}); // ok, ignores inherited constructors - D d4(convert_to_D2{}); // expected-error {{ambiguous}} - d = static_cast<D&&>(d); // expected-error {{ambiguous}} - } - - struct Y; - struct X { - X(); - X(volatile Y &); // expected-note 3{{inherited constructor cannot be used to copy object}} - } x; - struct Y : X { using X::X; } volatile y; - struct Z : Y { using Y::Y; } volatile z; // expected-note 4{{no known conversion}} expected-note 2{{would lose volatile}} expected-note 3{{requires 0}} expected-note 3{{inherited here}} - Z z1(x); // expected-error {{no match}} - Z z2(y); // expected-error {{no match}} - Z z3(z); // expected-error {{no match}} -} diff --git a/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p18.cpp b/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p18.cpp deleted file mode 100644 index b9fca4bd5b61..000000000000 --- a/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p18.cpp +++ /dev/null @@ -1,77 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -verify %s - -struct Public {} public_; -struct Protected {} protected_; -struct Private {} private_; - -class A { -public: - A(Public); - void f(Public); - -protected: - A(Protected); // expected-note {{protected here}} - void f(Protected); - -private: - A(Private); // expected-note 4{{private here}} - void f(Private); // expected-note {{private here}} - - friend void Friend(); -}; - -class B : private A { - using A::A; // ok - using A::f; // expected-error {{private member}} - - void f() { - B a(public_); - B b(protected_); - B c(private_); // expected-error {{private}} - } - - B(Public p, int) : B(p) {} - B(Protected p, int) : B(p) {} - B(Private p, int) : B(p) {} // expected-error {{private}} -}; - -class C : public B { - C(Public p) : B(p) {} - // There is no access check on the conversion from derived to base here; - // protected constructors of A act like protected constructors of B. - C(Protected p) : B(p) {} - C(Private p) : B(p) {} // expected-error {{private}} -}; - -void Friend() { - // There is no access check on the conversion from derived to base here. - B a(public_); - B b(protected_); - B c(private_); -} - -void NonFriend() { - B a(public_); - B b(protected_); // expected-error {{protected}} - B c(private_); // expected-error {{private}} -} - -namespace ProtectedAccessFromMember { -namespace a { - struct ES { - private: - ES(const ES &) = delete; - protected: - ES(const char *); - }; -} -namespace b { - struct DES : a::ES { - DES *f(); - private: - using a::ES::ES; - }; -} -b::DES *b::DES::f() { return new b::DES("foo"); } - -} diff --git a/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p3.cpp b/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p3.cpp deleted file mode 100644 index 6c505a55c2af..000000000000 --- a/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p3.cpp +++ /dev/null @@ -1,82 +0,0 @@ -// RUN: %clang_cc1 -std=c++98 -fsyntax-only -verify %s -// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s -// RUN: %clang_cc1 -fsyntax-only -verify %s - -struct B { - void f(char); - void g(char); - enum E { e }; - union { int x; }; - - enum class EC { ec }; // expected-warning 0-1 {{C++11}} - - void f2(char); - void g2(char); - enum E2 { e2 }; - union { int x2; }; -}; - -class C { - int g(); -}; - -struct D : B {}; - -class D2 : public B { - using B::f; - using B::E; - using B::e; - using B::x; - using C::g; // expected-error{{using declaration refers into 'C::', which is not a base class of 'D2'}} - - // These are valid in C++98 but not in C++11. - using D::f2; - using D::E2; - using D::e2; - using D::x2; -#if __cplusplus >= 201103L - // expected-error@-5 {{using declaration refers into 'D::', which is not a base class of 'D2'}} - // expected-error@-5 {{using declaration refers into 'D::', which is not a base class of 'D2'}} - // expected-error@-5 {{using declaration refers into 'D::', which is not a base class of 'D2'}} - // expected-error@-5 {{using declaration refers into 'D::', which is not a base class of 'D2'}} -#endif - - using B::EC; - using B::EC::ec; // expected-error {{not a class}} expected-warning 0-1 {{C++11}} -}; - -namespace test1 { - struct Base { - int foo(); - }; - - struct Unrelated { - int foo(); - }; - - struct Subclass : Base { - }; - - namespace InnerNS { - int foo(); - } - - struct B : Base { - }; - - // We should be able to diagnose these without instantiation. - template <class T> struct C : Base { - using InnerNS::foo; // expected-error {{not a class}} - using Base::bar; // expected-error {{no member named 'bar'}} - using Unrelated::foo; // expected-error {{not a base class}} - - // In C++98, it's hard to see that these are invalid, because indirect - // references to base class members are permitted. - using C::foo; - using Subclass::foo; -#if __cplusplus >= 201103L - // expected-error@-3 {{refers to its own class}} - // expected-error@-3 {{not a base class}} -#endif - }; -} diff --git a/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p4.cpp b/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p4.cpp deleted file mode 100644 index 781a1a1824e9..000000000000 --- a/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p4.cpp +++ /dev/null @@ -1,239 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s - -// C++03 [namespace.udecl]p4: -// A using-declaration used as a member-declaration shall refer to a -// member of a base class of the class being defined, shall refer to -// a member of an anonymous union that is a member of a base class -// of the class being defined, or shall refer to an enumerator for -// an enumeration type that is a member of a base class of the class -// being defined. - -// There is no directly analogous paragraph in C++0x, and the feature -// works sufficiently differently there that it needs a separate test. - -namespace test0 { - namespace NonClass { - typedef int type; - struct hiding {}; - int hiding; - static union { double union_member; }; - enum tagname { enumerator }; - } - - class Test0 { - using NonClass::type; // expected-error {{not a class}} - using NonClass::hiding; // expected-error {{not a class}} - using NonClass::union_member; // expected-error {{not a class}} - using NonClass::enumerator; // expected-error {{not a class}} - }; -} - -struct Opaque0 {}; - -namespace test1 { - struct A { - typedef int type; - struct hiding {}; // expected-note {{previous use is here}} - Opaque0 hiding; - union { double union_member; }; - enum tagname { enumerator }; - }; - - struct B : A { - using A::type; - using A::hiding; - using A::union_member; - using A::enumerator; - using A::tagname; - - void test0() { - type t = 0; - } - - void test1() { - typedef struct A::hiding local; - struct hiding _ = local(); - } - - void test2() { - union hiding _; // expected-error {{tag type that does not match previous}} - } - - void test3() { - char array[sizeof(union_member) == sizeof(double) ? 1 : -1]; - } - - void test4() { - enum tagname _ = enumerator; - } - - void test5() { - Opaque0 _ = hiding; - } - }; -} - -namespace test2 { - struct A { - typedef int type; - struct hiding {}; // expected-note {{previous use is here}} - int hiding; - union { double union_member; }; - enum tagname { enumerator }; - }; - - template <class T> struct B : A { - using A::type; - using A::hiding; - using A::union_member; - using A::enumerator; - using A::tagname; - - void test0() { - type t = 0; - } - - void test1() { - typedef struct A::hiding local; - struct hiding _ = local(); - } - - void test2() { - union hiding _; // expected-error {{tag type that does not match previous}} - } - - void test3() { - char array[sizeof(union_member) == sizeof(double) ? 1 : -1]; - } - - void test4() { - enum tagname _ = enumerator; - } - - void test5() { - Opaque0 _ = hiding; - } - }; -} - -namespace test3 { - struct hiding {}; - - template <class T> struct A { - typedef int type; // expected-note {{target of using declaration}} - struct hiding {}; - Opaque0 hiding; // expected-note {{target of using declaration}} - union { double union_member; }; // expected-note {{target of using declaration}} - enum tagname { enumerator }; // expected-note 2 {{target of using declaration}} - }; - - template <class T> struct B : A<T> { - using A<T>::type; // expected-error {{dependent using declaration resolved to type without 'typename'}} - using A<T>::hiding; - using A<T>::union_member; - using A<T>::enumerator; - using A<T>::tagname; // expected-error {{dependent using declaration resolved to type without 'typename'}} - - // FIXME: re-enable these when the various bugs involving tags are fixed -#if 0 - void test1() { - typedef struct A<T>::hiding local; - struct hiding _ = local(); - } - - void test2() { - typedef struct A<T>::hiding local; - union hiding _ = local(); - } -#endif - - void test3() { - char array[sizeof(union_member) == sizeof(double) ? 1 : -1]; - } - -#if 0 - void test4() { - enum tagname _ = enumerator; - } -#endif - - void test5() { - Opaque0 _ = hiding; - } - }; - - template struct B<int>; // expected-note {{in instantiation}} - - template <class T> struct C : A<T> { - using typename A<T>::type; - using typename A<T>::hiding; // expected-note {{declared here}} \ - // expected-error {{'typename' keyword used on a non-type}} - using typename A<T>::union_member; // expected-error {{'typename' keyword used on a non-type}} - using typename A<T>::enumerator; // expected-error {{'typename' keyword used on a non-type}} - - void test6() { - type t = 0; - } - - void test7() { - Opaque0 _ = hiding; // expected-error {{does not refer to a value}} - } - }; - - template struct C<int>; // expected-note {{in instantiation}} -} - -namespace test4 { - struct Base { - int foo(); - }; - - struct Unrelated { - int foo(); - }; - - struct Subclass : Base { - }; - - namespace InnerNS { - int foo(); - } - - // We should be able to diagnose these without instantiation. - template <class T> struct C : Base { - using InnerNS::foo; // expected-error {{not a class}} - using Base::bar; // expected-error {{no member named 'bar'}} - using Unrelated::foo; // expected-error {{not a base class}} - using C::foo; // legal in C++03 - using Subclass::foo; // legal in C++03 -#if __cplusplus >= 201103L - // expected-error@-3 {{refers to its own class}} - // expected-error@-3 {{refers into 'Subclass::', which is not a base class}} -#endif - - int bar(); -#if __cplusplus < 201103L - // expected-note@-2 {{target of using declaration}} -#endif - using C::bar; // expected-error {{refers to its own class}} - }; -} - -namespace test5 { - struct B; - struct A { - A(const B&); - B &operator=(const B&); - }; - struct B : A { -#if __cplusplus >= 201103L - using A::A; -#endif - using A::operator=; - }; - void test(B b) { - B b2(b); - b2 = b; - } -} diff --git a/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p5-cxx0x.cpp b/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p5-cxx0x.cpp deleted file mode 100644 index 35ef3b57b0cc..000000000000 --- a/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p5-cxx0x.cpp +++ /dev/null @@ -1,12 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -// C++0x N2914. - -struct A { - template<class T> void f(T); - template<class T> struct X { }; -}; - -struct B : A { - using A::f<double>; // expected-error{{using declaration cannot refer to a template specialization}} - using A::X<int>; // expected-error{{using declaration cannot refer to a template specialization}} -}; diff --git a/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p6-cxx11.cpp b/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p6-cxx11.cpp deleted file mode 100644 index 97b2953b9031..000000000000 --- a/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p6-cxx11.cpp +++ /dev/null @@ -1,7 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s - -namespace A { - namespace B { } -} - -using A::B; // expected-error{{using declaration cannot refer to a namespace}} diff --git a/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p7.cpp b/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p7.cpp deleted file mode 100644 index 6c9379fac27f..000000000000 --- a/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p7.cpp +++ /dev/null @@ -1,4 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -verify %s - -enum class EC { ec }; -using EC::ec; // expected-error {{using declaration cannot refer to a scoped enumerator}} diff --git a/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p8-cxx0x.cpp b/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p8-cxx0x.cpp deleted file mode 100644 index 0ea4eeb1e9b0..000000000000 --- a/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p8-cxx0x.cpp +++ /dev/null @@ -1,290 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -std=c++98 -verify %s -// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s -// RUN: %clang_cc1 -fsyntax-only -std=c++14 -verify %s -// RUN: not %clang_cc1 -fsyntax-only -std=c++98 -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck --check-prefix=CXX98 %s -// RUN: not %clang_cc1 -fsyntax-only -std=c++11 -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck --check-prefix=CXX11 %s -// C++0x N2914. - -struct X { - int i; - static int a; - enum E { e }; -}; - -using X::i; // expected-error{{using declaration cannot refer to class member}} -using X::s; // expected-error{{using declaration cannot refer to class member}} -using X::e; // expected-error{{using declaration cannot refer to class member}} -using X::E::e; // expected-error{{using declaration cannot refer to class member}} expected-warning 0-1{{C++11}} -#if __cplusplus < 201103L -// expected-note@-3 {{use a const variable}} -// expected-note@-3 {{use a const variable}} -// CXX98-NOT: fix-it:"{{.*}}":{[[@LINE-5]]: -// CXX98-NOT: fix-it:"{{.*}}":{[[@LINE-5]]: -#else -// expected-note@-8 {{use a constexpr variable}} -// expected-note@-8 {{use a constexpr variable}} -// CXX11: fix-it:"{{.*}}":{[[@LINE-10]]:1-[[@LINE-10]]:6}:"constexpr auto e = " -// CXX11: fix-it:"{{.*}}":{[[@LINE-10]]:1-[[@LINE-10]]:6}:"constexpr auto e = " -#endif - -void f() { - using X::i; // expected-error{{using declaration cannot refer to class member}} - using X::s; // expected-error{{using declaration cannot refer to class member}} - using X::e; // expected-error{{using declaration cannot refer to class member}} - using X::E::e; // expected-error{{using declaration cannot refer to class member}} expected-warning 0-1{{C++11}} -#if __cplusplus < 201103L - // expected-note@-3 {{use a const variable}} - // expected-note@-3 {{use a const variable}} - // CXX98-NOT: fix-it:"{{.*}}":{[[@LINE-5]]: - // CXX98-NOT: fix-it:"{{.*}}":{[[@LINE-5]]: -#else - // expected-note@-8 {{use a constexpr variable}} - // expected-note@-8 {{use a constexpr variable}} - // CXX11: fix-it:"{{.*}}":{[[@LINE-10]]:3-[[@LINE-10]]:8}:"constexpr auto e = " - // CXX11: fix-it:"{{.*}}":{[[@LINE-10]]:3-[[@LINE-10]]:8}:"constexpr auto e = " -#endif -} - -namespace PR21933 { - struct A { int member; }; - struct B { static int member; }; - enum C { member }; - - template <typename T> - struct X { - static void StaticFun() { - using T::member; // expected-error 2{{class member}} expected-note {{use a reference instead}} -#if __cplusplus < 201103L - // expected-error@-2 {{cannot be used prior to '::'}} -#endif - (void)member; - } - }; - template<typename T> - struct Y : T { - static void StaticFun() { - using T::member; // expected-error 2{{class member}} expected-note {{use a reference instead}} - (void)member; - } - }; - - void f() { - X<A>::StaticFun(); // expected-note {{instantiation of}} - X<B>::StaticFun(); // expected-note {{instantiation of}} - X<C>::StaticFun(); -#if __cplusplus < 201103L - // expected-note@-2 {{instantiation of}} -#endif - Y<A>::StaticFun(); // expected-note {{instantiation of}} - Y<B>::StaticFun(); // expected-note {{instantiation of}} - } - - template<typename T, typename U> void value_vs_value() { - using T::a; // expected-note {{previous}} -#if __cplusplus < 201103L - // expected-error@-2 {{cannot be used prior to '::'}} -#endif - extern int a(); // expected-error {{different kind of symbol}} - a(); - - extern int b(); // expected-note {{previous}} - using T::b; // expected-error {{different kind of symbol}} - b(); - - using T::c; // expected-note {{previous}} - using U::c; // expected-error-re {{redefinition of 'c'{{$}}}} - c(); - } - - template<typename T, typename U> void value_vs_type() { - using T::Xt; // expected-note {{previous}} - typedef struct {} Xt; // expected-error {{different kind of symbol}} - (void)Xt; - - using T::Xs; // expected-note {{hidden by}} - struct Xs {}; - (void)Xs; - Xs xs; // expected-error {{must use 'struct'}} - - using T::Xe; // expected-note {{hidden by}} - enum Xe {}; - (void)Xe; - Xe xe; // expected-error {{must use 'enum'}} - - typedef struct {} Yt; // expected-note {{candidate}} - using T::Yt; // eypected-error {{different kind of symbol}} expected-note {{candidate}} - Yt yt; // expected-error {{ambiguous}} - - struct Ys {}; - using T::Ys; // expected-note {{hidden by}} - (void)Ys; - Ys ys; // expected-error {{must use 'struct'}} - - enum Ye {}; - using T::Ye; // expected-note {{hidden by}} - Ye ye; // expected-error {{must use 'enum'}} - } - - template<typename T> void type() { - // Must be a class member because T:: can only name a class or enum, - // and an enum cannot have a type member. - using typename T::X; // expected-error {{cannot refer to class member}} - } - - namespace N1 { enum E { a, b, c }; } - namespace N2 { enum E { a, b, c }; } - void g() { value_vs_value<N1::E, N2::E>(); } -#if __cplusplus < 201103L - // expected-note@-2 {{in instantiation of}} -#endif - -#if __cplusplus >= 201402L - namespace partial_substitute { - template<typename T> auto f() { - return [](auto x) { - using A = typename T::template U<decltype(x)>; - using A::E::e; - struct S : A { - using A::f; - using typename A::type; - type f(int) { return e; } - }; - return S(); - }; - } - enum Enum { e }; - struct X { - template<typename T> struct U { - int f(int, int); - using type = int; - using E = Enum; - }; - }; - int test() { - auto s = f<X>()(0); - return s.f(0) + s.f(0, 0); - } - - template<typename T, typename U> auto g() { - return [](auto x) { - using X = decltype(x); - struct S : T::template Q<X>, U::template Q<X> { - using T::template Q<X>::f; - using U::template Q<X>::f; - void h() { f(); } - void h(int n) { f(n); } - }; - return S(); - }; - } - struct A { template<typename> struct Q { int f(); }; }; - struct B { template<typename> struct Q { int f(int); }; }; - int test2() { - auto s = g<A, B>()(0); - s.f(); - s.f(0); - s.h(); - s.h(0); - } - } -#endif - - template<typename T, typename U> struct RepeatedMember : T, U { - // FIXME: This is the wrong error: we should complain that a member type - // cannot be redeclared at class scope. - using typename T::type; // expected-note {{candidate}} - using typename U::type; // expected-note {{candidate}} - type x; // expected-error {{ambiguous}} - }; -} - -struct S { - static int n; - struct Q {}; - enum E {}; - typedef Q T; - void f(); - static void g(); -}; - -using S::n; // expected-error{{class member}} expected-note {{use a reference instead}} -#if __cplusplus < 201103L -// CXX98-NOT: fix-it:"{{.*}}":{[[@LINE-2]] -#else -// CXX11: fix-it:"{{.*}}":{[[@LINE-4]]:1-[[@LINE-4]]:6}:"auto &n = " -#endif - -using S::Q; // expected-error{{class member}} -#if __cplusplus < 201103L -// expected-note@-2 {{use a typedef declaration instead}} -// CXX98: fix-it:"{{.*}}":{[[@LINE-3]]:1-[[@LINE-3]]:6}:"typedef" -// CXX98: fix-it:"{{.*}}":{[[@LINE-4]]:11-[[@LINE-4]]:11}:" Q" -#else -// expected-note@-6 {{use an alias declaration instead}} -// CXX11: fix-it:"{{.*}}":{[[@LINE-7]]:7-[[@LINE-7]]:7}:"Q = " -#endif - -using S::E; // expected-error{{class member}} -#if __cplusplus < 201103L -// expected-note@-2 {{use a typedef declaration instead}} -// CXX98: fix-it:"{{.*}}":{[[@LINE-3]]:1-[[@LINE-3]]:6}:"typedef" -// CXX98: fix-it:"{{.*}}":{[[@LINE-4]]:11-[[@LINE-4]]:11}:" E" -#else -// expected-note@-6 {{use an alias declaration instead}} -// CXX11: fix-it:"{{.*}}":{[[@LINE-7]]:7-[[@LINE-7]]:7}:"E = " -#endif - -using S::T; // expected-error{{class member}} -#if __cplusplus < 201103L -// expected-note@-2 {{use a typedef declaration instead}} -// CXX98: fix-it:"{{.*}}":{[[@LINE-3]]:1-[[@LINE-3]]:6}:"typedef" -// CXX98: fix-it:"{{.*}}":{[[@LINE-4]]:11-[[@LINE-4]]:11}:" T" -#else -// expected-note@-6 {{use an alias declaration instead}} -// CXX11: fix-it:"{{.*}}":{[[@LINE-7]]:7-[[@LINE-7]]:7}:"T = " -#endif - -using S::f; // expected-error{{class member}} -using S::g; // expected-error{{class member}} - -void h() { - using S::n; // expected-error{{class member}} expected-note {{use a reference instead}} -#if __cplusplus < 201103L - // CXX98-NOT: fix-it:"{{.*}}":{[[@LINE-2]] -#else - // CXX11: fix-it:"{{.*}}":{[[@LINE-4]]:3-[[@LINE-4]]:8}:"auto &n = " -#endif - - using S::Q; // expected-error{{class member}} -#if __cplusplus < 201103L - // expected-note@-2 {{use a typedef declaration instead}} - // CXX98: fix-it:"{{.*}}":{[[@LINE-3]]:3-[[@LINE-3]]:8}:"typedef" - // CXX98: fix-it:"{{.*}}":{[[@LINE-4]]:13-[[@LINE-4]]:13}:" Q" -#else - // expected-note@-6 {{use an alias declaration instead}} - // CXX11: fix-it:"{{.*}}":{[[@LINE-7]]:9-[[@LINE-7]]:9}:"Q = " -#endif - - using S::E; // expected-error{{class member}} -#if __cplusplus < 201103L - // expected-note@-2 {{use a typedef declaration instead}} - // CXX98: fix-it:"{{.*}}":{[[@LINE-3]]:3-[[@LINE-3]]:8}:"typedef" - // CXX98: fix-it:"{{.*}}":{[[@LINE-4]]:13-[[@LINE-4]]:13}:" E" -#else - // expected-note@-6 {{use an alias declaration instead}} - // CXX11: fix-it:"{{.*}}":{[[@LINE-7]]:9-[[@LINE-7]]:9}:"E = " -#endif - - using S::T; // expected-error{{class member}} -#if __cplusplus < 201103L - // expected-note@-2 {{use a typedef declaration instead}} - // CXX98: fix-it:"{{.*}}":{[[@LINE-3]]:3-[[@LINE-3]]:8}:"typedef" - // CXX98: fix-it:"{{.*}}":{[[@LINE-4]]:13-[[@LINE-4]]:13}:" T" -#else - // expected-note@-6 {{use an alias declaration instead}} - // CXX11: fix-it:"{{.*}}":{[[@LINE-7]]:9-[[@LINE-7]]:9}:"T = " -#endif - - using S::f; // expected-error{{class member}} - using S::g; // expected-error{{class member}} -} diff --git a/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p8.cpp b/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p8.cpp deleted file mode 100644 index 466097171c8d..000000000000 --- a/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p8.cpp +++ /dev/null @@ -1,98 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s - -struct Opaque0 {}; -struct Opaque1 {}; - -// Redeclarations are okay in a namespace. -namespace test0 { - namespace ns { - void foo(Opaque0); // expected-note 2 {{candidate function}} - } - - using ns::foo; - using ns::foo; - - void test0() { - foo(Opaque1()); // expected-error {{no matching function for call}} - } - - namespace ns { - void foo(Opaque1); - } - - void test1() { - foo(Opaque1()); // expected-error {{no matching function for call}} - } - - using ns::foo; - - void test2() { - foo(Opaque1()); - } - - using ns::foo; -} - -// Make sure we handle transparent contexts the same way. -namespace test1 { - namespace ns { - void foo(Opaque0); // expected-note 2 {{candidate function}} - } - - extern "C++" { - using ns::foo; - } - - void test0() { - foo(Opaque1()); // expected-error {{no matching function for call}} - } - - namespace ns { - void foo(Opaque1); - } - - void test1() { - foo(Opaque1()); // expected-error {{no matching function for call}} - } - - extern "C++" { - using ns::foo; - } - - void test2() { - foo(Opaque1()); - } -} - -// Make sure we detect invalid redeclarations that can't be detected -// until template instantiation. -namespace test2 { - template <class T> struct Base { - typedef Base type; - void foo(); - }; - - template <class T> struct Derived : Base<T> { - // These are invalid redeclarations, detectable only after - // instantiation. - using Base<T>::foo; // expected-note {{previous using decl}} - using Base<T>::type::foo; //expected-error {{redeclaration of using decl}} - }; - - template struct Derived<int>; // expected-note {{in instantiation of template class}} -} - -// Redeclarations are okay in a function. -namespace test3 { - namespace N { - int f(int); - typedef int type; - } - - void g() { - using N::f; - using N::f; - using N::type; - using N::type; - } -} diff --git a/test/CXX/dcl.dcl/basic.namespace/namespace.udir/p1.cpp b/test/CXX/dcl.dcl/basic.namespace/namespace.udir/p1.cpp deleted file mode 100644 index 20a19ab04250..000000000000 --- a/test/CXX/dcl.dcl/basic.namespace/namespace.udir/p1.cpp +++ /dev/null @@ -1,141 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s - -// (this actually occurs before paragraph 1) -namespace test0 { - namespace A {} - class B { - using namespace A; // expected-error {{'using namespace' is not allowed in classes}} - }; -} - - -struct opaque0 {}; -struct opaque1 {}; - -// Test that names appear as if in deepest common ancestor. -namespace test1 { - namespace A { - namespace B { - opaque0 foo(); // expected-note {{candidate}} - } - } - - namespace C { - opaque1 foo(); // expected-note {{candidate}} - - opaque1 test() { - using namespace A::B; - return foo(); // C::foo - } - } - - opaque1 test() { - using namespace A::B; - using namespace C; - return foo(); // expected-error {{call to 'foo' is ambiguous}} - } -} - -// Same thing, but with the directives in namespaces. -namespace test2 { - namespace A { - namespace B { - opaque0 foo(); // expected-note {{candidate}} - } - } - - namespace C { - opaque1 foo(); // expected-note {{candidate}} - - namespace test { - using namespace A::B; - - opaque1 test() { - return foo(); // C::foo - } - } - } - - namespace test { - using namespace A::B; - using namespace C; - - opaque1 test() { - return foo(); // expected-error {{call to 'foo' is ambiguous}} - } - } -} - -// Transitivity. -namespace test3 { - namespace A { - namespace B { - opaque0 foo(); - } - } - namespace C { - using namespace A; - } - - opaque0 test0() { - using namespace C; - using namespace B; - return foo(); - } - - namespace D { - using namespace C; - } - namespace A { - opaque1 foo(); - } - - opaque1 test1() { - using namespace D; - return foo(); - } -} - -// Transitivity acts like synthetic using directives. -namespace test4 { - namespace A { - namespace B { - opaque0 foo(); // expected-note {{candidate}} - } - } - - namespace C { - using namespace A::B; - } - - opaque1 foo(); // expected-note {{candidate}} - - namespace A { - namespace D { - using namespace C; - } - - opaque0 test() { - using namespace D; - return foo(); - } - } - - opaque0 test() { - using namespace A::D; - return foo(); // expected-error {{call to 'foo' is ambiguous}} - } -} - -// Bug: using directives should be followed when parsing default -// arguments in scoped declarations. -class test5 { - int inc(int x); -}; -namespace Test5 { - int default_x = 0; -} -using namespace Test5; -int test5::inc(int x = default_x) { - return x+1; -} diff --git a/test/CXX/dcl.dcl/basic.namespace/namespace.udir/p6.cpp b/test/CXX/dcl.dcl/basic.namespace/namespace.udir/p6.cpp deleted file mode 100644 index 2bcbe269e122..000000000000 --- a/test/CXX/dcl.dcl/basic.namespace/namespace.udir/p6.cpp +++ /dev/null @@ -1,16 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -// expected-no-diagnostics - -// <rdar://problem/8296180> -typedef int pid_t; -namespace ns { - typedef int pid_t; -} -using namespace ns; -pid_t x; - -struct A { }; -namespace ns { - typedef ::A A; -} -A a; diff --git a/test/CXX/dcl.dcl/dcl.attr/dcl.align/p1.cpp b/test/CXX/dcl.dcl/dcl.attr/dcl.align/p1.cpp deleted file mode 100644 index ec7b22f753f1..000000000000 --- a/test/CXX/dcl.dcl/dcl.attr/dcl.align/p1.cpp +++ /dev/null @@ -1,6 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -verify %s - -typedef int A alignas(4); // expected-error {{'alignas' attribute only applies to variables, data members and tag types}} -template<int N> void f() { - typedef int B alignas(N); // expected-error {{'alignas' attribute only applies to variables, data members and tag types}} -} diff --git a/test/CXX/dcl.dcl/dcl.attr/dcl.align/p5.cpp b/test/CXX/dcl.dcl/dcl.attr/dcl.align/p5.cpp deleted file mode 100644 index e713d72dc58f..000000000000 --- a/test/CXX/dcl.dcl/dcl.attr/dcl.align/p5.cpp +++ /dev/null @@ -1,81 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -triple x86_64-linux-gnu -verify %s - -alignas(1) int n1; // expected-error {{requested alignment is less than minimum alignment of 4 for type 'int'}} -alignas(1) alignas(2) int n2; // expected-error {{less than minimum alignment}} -alignas(1) alignas(2) alignas(4) int n3; // ok -alignas(1) alignas(2) alignas(0) int n4; // expected-error {{less than minimum alignment}} -alignas(1) alignas(2) int n5 alignas(4); // ok -alignas(1) alignas(4) int n6 alignas(2); // ok -alignas(1) int n7 alignas(2), // expected-error {{less than minimum alignment}} - n8 alignas(4); // ok -alignas(8) int n9 alignas(2); // ok, overaligned -alignas(1) extern int n10; // expected-error {{less than minimum alignment}} - -enum alignas(1) E1 {}; // expected-error {{requested alignment is less than minimum alignment of 4 for type 'E1'}} -enum alignas(1) E2 : char {}; // ok -enum alignas(4) E3 { e3 = 0 }; // ok -enum alignas(4) E4 { e4 = 1ull << 33 }; // expected-error {{requested alignment is less than minimum alignment of 8 for type 'E4'}} -enum alignas(8) E5 {}; -static_assert(alignof(E5) == 8, ""); - -typedef __attribute__((aligned(16))) int IntAlign16; -enum E6 : IntAlign16 {}; -static_assert(alignof(E6) == 4, ""); - -struct S1 { - alignas(8) int n; -}; -struct alignas(2) S2 { // expected-error {{requested alignment is less than minimum alignment of 4 for type 'S2'}} - int n; -}; -struct alignas(2) S3 { // expected-error {{requested alignment is less than minimum alignment of 8 for type 'S3'}} - S1 s1; -}; -struct alignas(2) S4 : S1 { // expected-error {{requested alignment is less than minimum alignment of 8 for type 'S4'}} -}; -struct S5 : S1 { - alignas(2) S1 s1; // expected-error {{requested alignment is less than minimum alignment of 8 for type 'S1'}} -}; -struct S6 { - S1 s1; -}; -struct S7 : S1 { -}; -struct alignas(2) alignas(8) alignas(1) S8 : S1 { -}; - -S1 s1 alignas(4); // expected-error {{requested alignment is less than minimum alignment of 8 for type 'S1'}} -S6 s6 alignas(4); // expected-error {{requested alignment is less than minimum alignment of 8 for type 'S6'}} -S7 s7 alignas(4); // expected-error {{requested alignment is less than minimum alignment of 8 for type 'S7'}} - -template<int N, int M, typename T> -struct alignas(N) X { // expected-error 3{{requested alignment is less than minimum}} - alignas(M) T t; // expected-error 3{{requested alignment is less than minimum}} -}; - -template struct X<1, 1, char>; -template struct X<4, 1, char>; -template struct X<1, 2, char>; // expected-note {{instantiation}} -template struct X<1, 1, short>; // expected-note {{instantiation}} -template struct X<2, 1, short>; // expected-note {{instantiation}} -template struct X<2, 2, short>; -template struct X<16, 8, S1>; -template struct X<4, 4, S1>; // expected-note {{instantiation}} - -template<int N, typename T> -struct Y { - enum alignas(N) E : T {}; // expected-error {{requested alignment is less than minimum}} -}; -template struct Y<1, char>; -template struct Y<2, char>; -template struct Y<1, short>; // expected-note {{instantiation}} -template struct Y<2, short>; - -template<int N, typename T> -void f() { - alignas(N) T v; // expected-error {{requested alignment is less than minimum}} -}; -template void f<1, char>(); -template void f<2, char>(); -template void f<1, short>(); // expected-note {{instantiation}} -template void f<2, short>(); diff --git a/test/CXX/dcl.dcl/dcl.attr/dcl.align/p6.cpp b/test/CXX/dcl.dcl/dcl.attr/dcl.align/p6.cpp deleted file mode 100644 index e78857748077..000000000000 --- a/test/CXX/dcl.dcl/dcl.attr/dcl.align/p6.cpp +++ /dev/null @@ -1,86 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -verify %s - -alignas(4) extern int n1; // expected-note {{previous declaration}} -alignas(8) int n1; // expected-error {{redeclaration has different alignment requirement (8 vs 4)}} - -alignas(8) int n2; // expected-note {{previous declaration}} -alignas(4) extern int n2; // expected-error {{different alignment requirement (4 vs 8)}} - -alignas(8) extern int n3; // expected-note {{previous declaration}} -alignas(4) extern int n3; // expected-error {{different alignment requirement (4 vs 8)}} - -extern int n4; -alignas(8) extern int n4; - -alignas(8) extern int n5; -extern int n5; - -int n6; // expected-error {{'alignas' must be specified on definition if it is specified on any declaration}} -alignas(8) extern int n6; // expected-note {{declared with 'alignas' attribute here}} - -extern int n7; -alignas(8) int n7; - -alignas(8) extern int n8; // expected-note {{declared with 'alignas' attribute here}} -int n8; // expected-error {{'alignas' must be specified on definition if it is specified on any declaration}} - -int n9; // expected-error {{'alignas' must be specified on definition if it is specified on any declaration}} -alignas(4) extern int n9; // expected-note {{declared with 'alignas' attribute here}} - - -enum alignas(2) E : char; // expected-note {{declared with 'alignas' attribute here}} -enum E : char {}; // expected-error {{'alignas' must be specified on definition if it is specified on any declaration}} - -enum alignas(4) F : char; // expected-note {{previous declaration is here}} -enum alignas(2) F : char; // expected-error {{redeclaration has different alignment requirement (2 vs 4)}} - -enum G : char; -enum alignas(8) G : char {}; -enum G : char; - -enum H : char {}; // expected-error {{'alignas' must be specified on definition if it is specified on any declaration}} -enum alignas(1) H : char; // expected-note {{declared with 'alignas' attribute here}} - - -struct S; -struct alignas(16) S; // expected-note {{declared with 'alignas' attribute here}} -struct S; -struct S { int n; }; // expected-error {{'alignas' must be specified on definition if it is specified on any declaration}} - -struct alignas(2) T; -struct alignas(2) T { char c; }; // expected-note {{previous declaration is here}} -struct T; -struct alignas(4) T; // expected-error {{redeclaration has different alignment requirement (4 vs 2)}} - -struct U; -struct alignas(2) U {}; - -struct V {}; // expected-error {{'alignas' must be specified on definition if it is specified on any declaration}} -struct alignas(1) V; // expected-note {{declared with 'alignas' attribute here}} - -template<int M, int N> struct alignas(M) W; -template<int M, int N> struct alignas(N) W {}; -W<4,4> w44; // ok -// FIXME: We should reject this. -W<1,2> w12; -static_assert(alignof(W<4,4>) == 4, ""); - -template<int M, int N, int O, int P> struct X { - alignas(M) alignas(N) static char Buffer[32]; // expected-note {{previous declaration is here}} -}; -template<int M, int N, int O, int P> -alignas(O) alignas(P) char X<M, N, O, P>::Buffer[32]; // expected-error {{redeclaration has different alignment requirement (8 vs 2)}} -char *x1848 = X<1,8,4,8>::Buffer; // ok -char *x1248 = X<1,2,4,8>::Buffer; // expected-note {{in instantiation of}} - -template<int M, int N, int O, int P> struct Y { - enum alignas(M) alignas(N) E : char; -}; -template<int M, int N, int O, int P> -enum alignas(O) alignas(P) Y<M,N,O,P>::E : char { e }; -int y1848 = Y<1,8,4,8>::e; -// FIXME: We should reject this. -int y1248 = Y<1,2,4,8>::e; - -// Don't crash here. -alignas(4) struct Incomplete incomplete; // expected-error {{incomplete type}} expected-note {{forward declaration}} diff --git a/test/CXX/dcl.dcl/dcl.attr/dcl.align/p7.cpp b/test/CXX/dcl.dcl/dcl.attr/dcl.align/p7.cpp deleted file mode 100644 index 81e2ca5f1e4d..000000000000 --- a/test/CXX/dcl.dcl/dcl.attr/dcl.align/p7.cpp +++ /dev/null @@ -1,20 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -verify %s - -template<typename T, typename A, int N> struct X { - alignas(T) alignas(A) T buffer[N]; -}; - -static_assert(alignof(X<char, int, sizeof(int)>) == alignof(int), ""); -static_assert(alignof(X<int, char, 1>) == alignof(int), ""); - - -template<typename T, typename A, int N> struct Y { - alignas(A) T buffer[N]; // expected-error {{requested alignment is less than minimum alignment of 4 for type 'int [1]'}} -}; - -static_assert(alignof(Y<char, int, sizeof(int)>) == alignof(int), ""); -static_assert(alignof(Y<int, char, 1>) == alignof(int), ""); // expected-note {{in instantiation of}} - -void pr16992 () { - int x = alignof int; // expected-error {{expected parentheses around type name in alignof expression}} -} diff --git a/test/CXX/dcl.dcl/dcl.attr/dcl.align/p8.cpp b/test/CXX/dcl.dcl/dcl.attr/dcl.align/p8.cpp deleted file mode 100644 index 686aac2802ad..000000000000 --- a/test/CXX/dcl.dcl/dcl.attr/dcl.align/p8.cpp +++ /dev/null @@ -1,6 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -verify %s - -alignas(double) void f(); // expected-error {{'alignas' attribute only applies to variables, data members and tag types}} -alignas(double) unsigned char c[sizeof(double)]; // expected-note {{previous}} -extern unsigned char c[sizeof(double)]; -alignas(float) extern unsigned char c[sizeof(double)]; // expected-error {{different alignment}} diff --git a/test/CXX/dcl.dcl/dcl.attr/dcl.attr.depend/p1.cpp b/test/CXX/dcl.dcl/dcl.attr/dcl.attr.depend/p1.cpp deleted file mode 100644 index 6cf27af3230b..000000000000 --- a/test/CXX/dcl.dcl/dcl.attr/dcl.attr.depend/p1.cpp +++ /dev/null @@ -1,32 +0,0 @@ -// RUN: %clang_cc1 -verify -std=c++11 %s - -[[carries_dependency, carries_dependency]] int m1(); // expected-error {{attribute 'carries_dependency' cannot appear multiple times in an attribute specifier}} -[[carries_dependency]] [[carries_dependency]] int m2(); // ok -[[carries_dependency()]] int m3(); // expected-error {{attribute 'carries_dependency' cannot have an argument list}} - -[[carries_dependency]] void f1(); // FIXME: warn here -[[carries_dependency]] int f2(); // ok -int f3(int param [[carries_dependency]]); // ok -[[carries_dependency]] int (*f4)(); // expected-error {{'carries_dependency' attribute only applies to parameters, Objective-C methods, and functions}} -int (*f5 [[carries_dependency]])(); // expected-error {{'carries_dependency' attribute only applies to}} -int (*f6)() [[carries_dependency]]; // expected-error {{'carries_dependency' attribute cannot be applied to types}} -int (*f7)(int n [[carries_dependency]]); // expected-error {{'[[carries_dependency]]' attribute only allowed on parameter in a function declaration}} -int (((f8)))(int n [[carries_dependency]]); // ok -int (*f9(int n))(int n [[carries_dependency]]); // expected-error {{'[[carries_dependency]]' attribute only allowed on parameter in a function declaration}} -int typedef f10(int n [[carries_dependency]]); // expected-error {{'[[carries_dependency]]' attribute only allowed on parameter in a function declaration}} -using T = int(int n [[carries_dependency]]); // expected-error {{'[[carries_dependency]]' attribute only allowed on parameter in a function declaration}} -struct S { - [[carries_dependency]] int f(int n [[carries_dependency]]); // ok - int (*p)(int n [[carries_dependency]]); // expected-error {{'[[carries_dependency]]' attribute only allowed on parameter in a function declaration}} -}; -void f() { - [[carries_dependency]] int f(int n [[carries_dependency]]); // ok - [[carries_dependency]] // expected-error {{'carries_dependency' attribute only applies to}} - int (*p)(int n [[carries_dependency]]); // expected-error {{'[[carries_dependency]]' attribute only allowed on parameter in a function declaration}} -} - -auto l1 = [](int n [[carries_dependency]]) {}; -// There's no way to write a lambda such that the return value carries -// a dependency, because an attribute applied to the lambda appertains to -// the *type* of the operator() function, not to the function itself. -auto l2 = []() [[carries_dependency]] {}; // expected-error {{'carries_dependency' attribute cannot be applied to types}} diff --git a/test/CXX/dcl.dcl/dcl.attr/dcl.attr.depend/p2.cpp b/test/CXX/dcl.dcl/dcl.attr/dcl.attr.depend/p2.cpp deleted file mode 100644 index d5b0ebf459f8..000000000000 --- a/test/CXX/dcl.dcl/dcl.attr/dcl.attr.depend/p2.cpp +++ /dev/null @@ -1,14 +0,0 @@ -// RUN: %clang_cc1 -verify -std=c++11 %s - -int f(int); // expected-note 2{{declaration missing '[[carries_dependency]]' attribute is here}} -[[carries_dependency]] int f(int); // expected-error {{function declared '[[carries_dependency]]' after its first declaration}} -int f(int n [[carries_dependency]]); // expected-error {{parameter declared '[[carries_dependency]]' after its first declaration}} - -int g([[carries_dependency]] int n); // expected-note {{declaration missing '[[carries_dependency]]' attribute is here}} -int g(int); -[[carries_dependency]] int g(int); // expected-error {{function declared '[[carries_dependency]]' after its first declaration}} -int g(int n [[carries_dependency]]); - -int h [[carries_dependency]](); -int h(); -[[carries_dependency]] int h(); diff --git a/test/CXX/dcl.dcl/dcl.attr/dcl.attr.deprecated/p1.cpp b/test/CXX/dcl.dcl/dcl.attr/dcl.attr.deprecated/p1.cpp deleted file mode 100644 index 58c7c0cfac8b..000000000000 --- a/test/CXX/dcl.dcl/dcl.attr/dcl.attr.deprecated/p1.cpp +++ /dev/null @@ -1,60 +0,0 @@ -// RUN: %clang_cc1 -std=c++1y -verify %s - -class [[deprecated]] C {}; // expected-note {{'C' has been explicitly marked deprecated here}} -C c; // expected-warning {{'C' is deprecated}} - -typedef int t [[deprecated]]; // expected-note {{'t' has been explicitly marked deprecated here}} -t x = 42; // expected-warning {{'t' is deprecated}} - -[[deprecated]] int old = 42; // expected-note {{'old' has been explicitly marked deprecated here}} -int use = old; // expected-warning {{'old' is deprecated}} - -struct S { [[deprecated]] int member = 42; } s; // expected-note {{'member' has been explicitly marked deprecated here}} -int use2 = s.member; // expected-warning {{'member' is deprecated}} - -[[deprecated]] int f() { return 42; } // expected-note {{'f' has been explicitly marked deprecated here}} -int use3 = f(); // expected-warning {{'f' is deprecated}} - -enum [[deprecated]] e { E }; // expected-note {{'e' has been explicitly marked deprecated here}} -e my_enum; // expected-warning {{'e' is deprecated}} - -template <typename T> class X {}; -template <> class [[deprecated]] X<int> {}; // expected-note {{'X<int>' has been explicitly marked deprecated here}} -X<char> x1; -X<int> x2; // expected-warning {{'X<int>' is deprecated}} - -template <typename T> class [[deprecated]] X2 {}; //expected-note {{'X2<char>' has been explicitly marked deprecated here}} -template <> class X2<int> {}; -X2<char> x3; // expected-warning {{'X2<char>' is deprecated}} -X2<int> x4; // No warning, the specialization removes it. - -template <typename T> class [[deprecated]] X3; //expected-note {{'X3<char>' has been explicitly marked deprecated here}} -template <> class X3<int>; -X3<char> *x5; // expected-warning {{'X3<char>' is deprecated}} -X3<int> *x6; // No warning, the specialization removes it. - -template <typename T> struct A; -A<int> *p; -template <typename T> struct [[deprecated]] A;//expected-note {{'A<int>' has been explicitly marked deprecated here}} expected-note {{'A<float>' has been explicitly marked deprecated here}} -A<int> *q; // expected-warning {{'A<int>' is deprecated}} -A<float> *r; // expected-warning {{'A<float>' is deprecated}} - -template <typename T> struct B; -B<int> *p2; -template <typename T> struct [[deprecated]] B;//expected-note {{'B<int>' has been explicitly marked deprecated here}} expected-note {{'B<float>' has been explicitly marked deprecated here}} -B<int> *q2; // expected-warning {{'B<int>' is deprecated}} -B<float> *r2; // expected-warning {{'B<float>' is deprecated}} - -template <typename T> -T some_func(T t) { - struct [[deprecated]] FunS{}; // expected-note {{'FunS' has been explicitly marked deprecated here}} - FunS f;// expected-warning {{'FunS' is deprecated}} - -} - -template <typename T> -[[deprecated]]T some_func2(T t) { - struct FunS2{}; - FunS2 f;// No warning, entire function is deprecated, so usage here should be fine. - -} diff --git a/test/CXX/dcl.dcl/dcl.attr/dcl.attr.fallthrough/p1.cpp b/test/CXX/dcl.dcl/dcl.attr/dcl.attr.fallthrough/p1.cpp deleted file mode 100644 index f267d9067bcc..000000000000 --- a/test/CXX/dcl.dcl/dcl.attr/dcl.attr.fallthrough/p1.cpp +++ /dev/null @@ -1,70 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -std=c++1z -verify %s - -void f(int n) { - switch (n) { - case 0: - n += 1; - [[fallthrough]]; // ok - case 1: - if (n) { - [[fallthrough]]; // ok - } else { - return; - } - case 2: - for (int n = 0; n != 10; ++n) - [[fallthrough]]; // expected-error {{does not directly precede switch label}} - case 3: - while (true) - [[fallthrough]]; // expected-error {{does not directly precede switch label}} - case 4: - while (false) - [[fallthrough]]; // expected-error {{does not directly precede switch label}} - case 5: - do [[fallthrough]]; while (true); // expected-error {{does not directly precede switch label}} - case 6: - do [[fallthrough]]; while (false); // expected-error {{does not directly precede switch label}} - case 7: - switch (n) { - case 0: - // FIXME: This should be an error, even though the next thing we do is to - // fall through in an outer switch statement. - [[fallthrough]]; - } - case 8: - [[fallthrough]]; // expected-error {{does not directly precede switch label}} - goto label; - label: - case 9: - n += 1; - case 10: // no warning, -Wimplicit-fallthrough is not enabled in this test, and does not need to - // be enabled for these diagnostics to be produced. - break; - } -} - -[[fallthrough]] typedef int n; // expected-error {{'fallthrough' attribute cannot be applied to a declaration}} -typedef int [[fallthrough]] n; // expected-error {{'fallthrough' attribute cannot be applied to types}} -typedef int n [[fallthrough]]; // expected-error {{'fallthrough' attribute cannot be applied to a declaration}} - -enum [[fallthrough]] E {}; // expected-error {{'fallthrough' attribute cannot be applied to a declaration}} -class [[fallthrough]] C {}; // expected-error {{'fallthrough' attribute cannot be applied to a declaration}} - -[[fallthrough]] // expected-error {{'fallthrough' attribute cannot be applied to a declaration}} -void g() { - [[fallthrough]] int n; // expected-error {{'fallthrough' attribute cannot be applied to a declaration}} - [[fallthrough]] ++n; // expected-error-re {{{{^}}fallthrough attribute is only allowed on empty statements}} - - switch (n) { - // FIXME: This should be an error. - [[fallthrough]]; - return; - - case 0: - [[fallthrough, fallthrough]]; // expected-error {{multiple times}} - case 1: - [[fallthrough(0)]]; // expected-error {{argument list}} - case 2: - break; - } -} diff --git a/test/CXX/dcl.dcl/dcl.attr/dcl.attr.grammar/p2-1z.cpp b/test/CXX/dcl.dcl/dcl.attr/dcl.attr.grammar/p2-1z.cpp deleted file mode 100644 index 192fa1261098..000000000000 --- a/test/CXX/dcl.dcl/dcl.attr/dcl.attr.grammar/p2-1z.cpp +++ /dev/null @@ -1,16 +0,0 @@ -// RUN: %clang_cc1 -std=c++1z -verify %s - -[[disable_tail_calls, noduplicate]] void f() {} // expected-warning {{unknown attribute 'disable_tail_calls'}} expected-warning {{unknown attribute 'noduplicate'}} - -[[using clang: disable_tail_calls, noduplicate]] void g() {} // ok - -[[using]] extern int n; // expected-error {{expected identifier}} -[[using foo -] // expected-error {{expected ':'}} -] extern int n; -[[using 42:]] extern int n; // expected-error {{expected identifier}} -[[using clang:]] extern int n; // ok -[[using blah: clang::optnone]] extern int n; // expected-error {{attribute with scope specifier cannot follow}} expected-warning {{only applies to functions}} - -[[using clang: unknown_attr]] extern int n; // expected-warning {{unknown attribute}} -[[using unknown_ns: something]] extern int n; // expected-warning {{unknown attribute}} diff --git a/test/CXX/dcl.dcl/dcl.attr/dcl.attr.grammar/p6.cpp b/test/CXX/dcl.dcl/dcl.attr/dcl.attr.grammar/p6.cpp deleted file mode 100644 index 416aeb49a760..000000000000 --- a/test/CXX/dcl.dcl/dcl.attr/dcl.attr.grammar/p6.cpp +++ /dev/null @@ -1,14 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -verify %s - -namespace std_example { - -int p[10]; -void f() { - int x = 42, y[5]; - // FIXME: Produce a better diagnostic for this case. - int(p[[x] { return x; }()]); // expected-error {{expected ']'}} \ - // expected-warning {{unknown attribute 'x' ignored}} - y[[] { return 2; }()] = 2; // expected-error {{consecutive left square brackets}} -} - -} diff --git a/test/CXX/dcl.dcl/dcl.attr/dcl.attr.nodiscard/p1.cpp b/test/CXX/dcl.dcl/dcl.attr/dcl.attr.nodiscard/p1.cpp deleted file mode 100644 index 4425416650ea..000000000000 --- a/test/CXX/dcl.dcl/dcl.attr/dcl.attr.nodiscard/p1.cpp +++ /dev/null @@ -1,10 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -std=c++1z -verify %s - -struct [[nodiscard]] S1 {}; // ok -struct [[nodiscard nodiscard]] S2 {}; // expected-error {{attribute 'nodiscard' cannot appear multiple times in an attribute specifier}} -struct [[nodiscard("Wrong")]] S3 {}; // expected-error {{'nodiscard' cannot have an argument list}} - -[[nodiscard]] int f(); -enum [[nodiscard]] E {}; - -namespace [[nodiscard]] N {} // expected-warning {{'nodiscard' attribute only applies to Objective-C methods, enums, structs, unions, classes, functions, and function pointers}} diff --git a/test/CXX/dcl.dcl/dcl.attr/dcl.attr.nodiscard/p2.cpp b/test/CXX/dcl.dcl/dcl.attr/dcl.attr.nodiscard/p2.cpp deleted file mode 100644 index 43de9343bd4d..000000000000 --- a/test/CXX/dcl.dcl/dcl.attr/dcl.attr.nodiscard/p2.cpp +++ /dev/null @@ -1,70 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -std=c++17 -verify -Wc++17-extensions %s -// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify -DEXT -Wc++17-extensions %s - -struct [[nodiscard]] S {}; -S get_s(); -S& get_s_ref(); - -enum [[nodiscard]] E {}; -E get_e(); - -[[nodiscard]] int get_i(); -[[nodiscard]] volatile int &get_vi(); - -void f() { - get_s(); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} - get_i(); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} - get_vi(); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} - get_e(); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} - - // Okay, warnings are not encouraged - get_s_ref(); - (void)get_s(); - (void)get_i(); - (void)get_vi(); - (void)get_e(); -} - -[[nodiscard]] volatile char &(*fp)(); -void g() { - fp(); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} - - // OK, warning suppressed. - (void)fp(); -} - -namespace PR31526 { -typedef E (*fp1)(); -typedef S (*fp2)(); - -typedef S S_alias; -typedef S_alias (*fp3)(); - -typedef fp2 fp2_alias; - -void f() { - fp1 one; - fp2 two; - fp3 three; - fp2_alias four; - - one(); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} - two(); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} - three(); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} - four(); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} - - // These are all okay because of the explicit cast to void. - (void)one(); - (void)two(); - (void)three(); - (void)four(); -} -} // namespace PR31526 - -#ifdef EXT -// expected-warning@4 {{use of the 'nodiscard' attribute is a C++17 extension}} -// expected-warning@8 {{use of the 'nodiscard' attribute is a C++17 extension}} -// expected-warning@11 {{use of the 'nodiscard' attribute is a C++17 extension}} -// expected-warning@12 {{use of the 'nodiscard' attribute is a C++17 extension}} -// expected-warning@28 {{use of the 'nodiscard' attribute is a C++17 extension}} -#endif diff --git a/test/CXX/dcl.dcl/dcl.attr/dcl.attr.nodiscard/p3.cpp b/test/CXX/dcl.dcl/dcl.attr/dcl.attr.nodiscard/p3.cpp deleted file mode 100644 index a3543cff7d2c..000000000000 --- a/test/CXX/dcl.dcl/dcl.attr/dcl.attr.nodiscard/p3.cpp +++ /dev/null @@ -1,17 +0,0 @@ -// RUN: %clang_cc1 -std=c++1z -verify %s - -namespace std_example { - struct [[nodiscard]] error_info{ - // ... - }; - - error_info enable_missile_safety_mode(); - void launch_missiles(); - void test_missiles() { - enable_missile_safety_mode(); // expected-warning {{ignoring return value of function declared with 'nodiscard'}} - launch_missiles(); - } - - error_info &foo(); - void f() { foo(); } // no warning -} diff --git a/test/CXX/dcl.dcl/dcl.attr/dcl.attr.noreturn/p1.cpp b/test/CXX/dcl.dcl/dcl.attr/dcl.attr.noreturn/p1.cpp deleted file mode 100644 index 59cac367dbf2..000000000000 --- a/test/CXX/dcl.dcl/dcl.attr/dcl.attr.noreturn/p1.cpp +++ /dev/null @@ -1,44 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -verify -fcxx-exceptions %s - -[[noreturn]] void a() { - return; // expected-warning {{function 'a' declared 'noreturn' should not return}} -} -void a2 [[noreturn]] () { - return; // expected-warning {{function 'a2' declared 'noreturn' should not return}} -} - -[[noreturn, noreturn]] void b() { throw 0; } // expected-error {{attribute 'noreturn' cannot appear multiple times in an attribute specifier}} -[[noreturn]] [[noreturn]] void b2() { throw 0; } // ok - -[[noreturn()]] void c(); // expected-error {{attribute 'noreturn' cannot have an argument list}} - -void d() [[noreturn]]; // expected-error {{'noreturn' attribute cannot be applied to types}} -int d2 [[noreturn]]; // expected-error {{'noreturn' attribute only applies to functions}} - -[[noreturn]] int e() { b2(); } // ok - -int f(); // expected-note {{declaration missing '[[noreturn]]' attribute is here}} -[[noreturn]] int f(); // expected-error {{function declared '[[noreturn]]' after its first declaration}} -int f(); - -[[noreturn]] int g(); -int g() { while (true) b(); } // ok -[[noreturn]] int g(); - -[[gnu::noreturn]] int h(); - -template<typename T> void test_type(T) { T::error; } // expected-error {{has no members}} -template<> void test_type(int (*)()) {} - -void check() { - // We do not consider [[noreturn]] to be part of the function's type. - // However, we do treat [[gnu::noreturn]] as being part of the type. - // - // This isn't quite GCC-compatible; it treats [[gnu::noreturn]] as - // being part of a function *pointer* type, but not being part of - // a function type. - test_type(e); - test_type(f); - test_type(g); - test_type(h); // expected-note {{instantiation}} -} diff --git a/test/CXX/dcl.dcl/dcl.attr/dcl.attr.unused/p1.cpp b/test/CXX/dcl.dcl/dcl.attr/dcl.attr.unused/p1.cpp deleted file mode 100644 index 8da2ca7d6d86..000000000000 --- a/test/CXX/dcl.dcl/dcl.attr/dcl.attr.unused/p1.cpp +++ /dev/null @@ -1,5 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -Wunused -std=c++1z -verify %s - -struct [[maybe_unused]] S1 {}; // ok -struct [[maybe_unused maybe_unused]] S2 {}; // expected-error {{attribute 'maybe_unused' cannot appear multiple times in an attribute specifier}} -struct [[maybe_unused("Wrong")]] S3 {}; // expected-error {{'maybe_unused' cannot have an argument list}} diff --git a/test/CXX/dcl.dcl/dcl.attr/dcl.attr.unused/p2.cpp b/test/CXX/dcl.dcl/dcl.attr/dcl.attr.unused/p2.cpp deleted file mode 100644 index db1886894d74..000000000000 --- a/test/CXX/dcl.dcl/dcl.attr/dcl.attr.unused/p2.cpp +++ /dev/null @@ -1,17 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -Wunused -std=c++1z -verify %s - -struct [[maybe_unused]] S { - int I [[maybe_unused]]; - static int SI [[maybe_unused]]; -}; - -enum [[maybe_unused]] E1 { - EnumVal [[maybe_unused]] -}; - -[[maybe_unused]] void unused_func([[maybe_unused]] int parm) { - typedef int maybe_unused_int [[maybe_unused]]; - [[maybe_unused]] int I; -} - -namespace [[maybe_unused]] N {} // expected-warning {{'maybe_unused' attribute only applies to}} diff --git a/test/CXX/dcl.dcl/dcl.attr/dcl.attr.unused/p3.cpp b/test/CXX/dcl.dcl/dcl.attr/dcl.attr.unused/p3.cpp deleted file mode 100644 index 551df38a8100..000000000000 --- a/test/CXX/dcl.dcl/dcl.attr/dcl.attr.unused/p3.cpp +++ /dev/null @@ -1,26 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -Wunused -Wused-but-marked-unused -std=c++17 -Wc++17-extensions -verify %s -// RUN: %clang_cc1 -fsyntax-only -Wunused -Wused-but-marked-unused -std=c++11 -Wc++17-extensions -verify -DEXT %s - -static_assert(__has_cpp_attribute(maybe_unused) == 201603, ""); - -struct [[maybe_unused]] S {}; - -void f() { - int x; // expected-warning {{unused variable}} - typedef int I; // expected-warning {{unused typedef 'I'}} - - // Should not warn about these due to not being used. - [[maybe_unused]] int y; - typedef int maybe_unused_int [[maybe_unused]]; - - // Should not warn about these uses. - S s; - maybe_unused_int test; - y = 12; -} - -#ifdef EXT -// expected-warning@6 {{use of the 'maybe_unused' attribute is a C++17 extension}} -// expected-warning@13 {{use of the 'maybe_unused' attribute is a C++17 extension}} -// expected-warning@14 {{use of the 'maybe_unused' attribute is a C++17 extension}} -#endif diff --git a/test/CXX/dcl.dcl/dcl.attr/dcl.attr.unused/p4.cpp b/test/CXX/dcl.dcl/dcl.attr/dcl.attr.unused/p4.cpp deleted file mode 100644 index d4a275930d64..000000000000 --- a/test/CXX/dcl.dcl/dcl.attr/dcl.attr.unused/p4.cpp +++ /dev/null @@ -1,8 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -Wunused -std=c++1z -verify %s -// expected-no-diagnostics - -void f(); -[[maybe_unused]] void f(); - -void f() { -} diff --git a/test/CXX/dcl.dcl/dcl.enum/p2.cpp b/test/CXX/dcl.dcl/dcl.enum/p2.cpp deleted file mode 100644 index de826d057042..000000000000 --- a/test/CXX/dcl.dcl/dcl.enum/p2.cpp +++ /dev/null @@ -1,6 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -verify %s - -// expected-no-diagnostics -enum class E : int const volatile { }; -using T = __underlying_type(E); -using T = int; diff --git a/test/CXX/dcl.dcl/dcl.enum/p5.cpp b/test/CXX/dcl.dcl/dcl.enum/p5.cpp deleted file mode 100644 index f26062416cbf..000000000000 --- a/test/CXX/dcl.dcl/dcl.enum/p5.cpp +++ /dev/null @@ -1,56 +0,0 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10.0.0 -fsyntax-only -verify %s -template<typename T> int force_same(T, T); - -// C++ [dcl.enum]p5: -// [...] If the underlying type is not fixed, the type of each enumerator is -// the type of its initializing value: -// - If an initializer is specified for an enumerator, the initializing -// value has the same type as the expression. -enum Bullet1 { - Bullet1Val1 = 'a', - Bullet1Val2 = 10u, - Bullet1Val1IsChar = sizeof(force_same(Bullet1Val1, char(0))), - Bullet1Val2IsUnsigned = sizeof(force_same(Bullet1Val2, unsigned(0))) -}; - -// - If no initializer is specified for the first enumerator, the -// initializing value has an unspecified integral type. -enum Bullet2 { - Bullet2Val, - Bullet2ValIsInt = sizeof(force_same(Bullet2Val, int(0))) -}; - -// - Otherwise the type of the initializing value is the same as the type -// of the initializing value of the preceding enumerator unless the -// incremented value is not representable in that type, in which case the -// type is an unspecified integral type sufficient to contain the -// incremented value. If no such type exists, the program is ill-formed. -enum Bullet3a { - Bullet3aVal1 = 17, - Bullet3aVal2, - Bullet3aVal2IsInt = sizeof(force_same(Bullet3aVal2, int(0))), - Bullet3aVal3 = 2147483647, - Bullet3aVal3IsInt = sizeof(force_same(Bullet3aVal3, int(0))), - Bullet3aVal4, - Bullet3aVal4IsUnsigned = sizeof(force_same(Bullet3aVal4, 0ul)) -}; - -enum Bullet3b { - Bullet3bVal1 = 17u, - Bullet3bVal2, - Bullet3bVal2IsInt = sizeof(force_same(Bullet3bVal2, 0u)), - Bullet3bVal3 = 2147483647u, - Bullet3bVal3IsInt = sizeof(force_same(Bullet3bVal3, 0u)), - Bullet3bVal4, - Bullet3bVal4IsUnsigned = sizeof(force_same(Bullet3bVal4, 0ul)) -}; - -enum Bullet3c { - Bullet3cVal1 = 0xFFFFFFFFFFFFFFFEull, - Bullet3cVal2, - Bullet3cVal3 // expected-warning{{not representable}} -}; - -// Following the closing brace of an enum-specifier, each enumerator has the -// type of its enumeration. -int array0[sizeof(force_same(Bullet3bVal3, Bullet3b(0)))? 1 : -1]; diff --git a/test/CXX/dcl.dcl/dcl.link/p2.cpp b/test/CXX/dcl.dcl/dcl.link/p2.cpp deleted file mode 100644 index d1c3bcb8fa03..000000000000 --- a/test/CXX/dcl.dcl/dcl.link/p2.cpp +++ /dev/null @@ -1,14 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -verify %s - -extern "C" { - extern R"(C++)" { } -} - -#define plusplus "++" -extern "C" plusplus { -} - -extern u8"C" {} // expected-error {{string literal in language linkage specifier cannot have an encoding-prefix}} -extern L"C" {} // expected-error {{string literal in language linkage specifier cannot have an encoding-prefix}} -extern u"C++" {} // expected-error {{string literal in language linkage specifier cannot have an encoding-prefix}} -extern U"C" {} // expected-error {{string literal in language linkage specifier cannot have an encoding-prefix}} diff --git a/test/CXX/dcl.dcl/dcl.link/p7-2.cpp b/test/CXX/dcl.dcl/dcl.link/p7-2.cpp deleted file mode 100644 index 1e8f39338c24..000000000000 --- a/test/CXX/dcl.dcl/dcl.link/p7-2.cpp +++ /dev/null @@ -1,7 +0,0 @@ -// RUN: %clang_cc1 -ast-print -o - %s | FileCheck %s - -extern "C" int f(void); -// CHECK: extern "C" int f() - -extern "C" int v; -// CHECK: extern "C" int v diff --git a/test/CXX/dcl.dcl/dcl.link/p7.cpp b/test/CXX/dcl.dcl/dcl.link/p7.cpp deleted file mode 100644 index 81cb28cef40f..000000000000 --- a/test/CXX/dcl.dcl/dcl.link/p7.cpp +++ /dev/null @@ -1,28 +0,0 @@ -// RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm -o - %s | FileCheck %s - -struct X { }; - -// CHECK: @x1 = {{(dso_local )?}}global %struct.X zeroinitializer -// CHECK: @x4 = {{(dso_local )?}}global %struct.X zeroinitializer -// CHECK: @x2 = external {{(dso_local )?}}global %struct.X -// CHECK: @x3 = external {{(dso_local )?}}global %struct.X -extern "C" { - X x1; -} - -extern "C" X x2; - -extern X x3; - -X x4; - -X& get(int i) { - if (i == 1) - return x1; - else if (i == 2) - return x2; - else if (i == 3) - return x3; - else - return x4; -} diff --git a/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p1.cpp b/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p1.cpp deleted file mode 100644 index 5a4c5c9a9d63..000000000000 --- a/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p1.cpp +++ /dev/null @@ -1,148 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++14 %s -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++1z %s - -struct notlit { // expected-note {{not literal because}} - notlit() {} -}; -struct notlit2 { - notlit2() {} -}; - -// valid declarations -constexpr int i1 = 0; -constexpr int f1() { return 0; } -struct s1 { - constexpr static int mi1 = 0; - const static int mi2; -}; -constexpr int s1::mi2 = 0; - -// invalid declarations -// not a definition of an object -constexpr extern int i2; // expected-error {{constexpr variable declaration must be a definition}} -// not a literal type -constexpr notlit nl1; // expected-error {{constexpr variable cannot have non-literal type 'const notlit'}} -// function parameters -void f2(constexpr int i) {} // expected-error {{function parameter cannot be constexpr}} -// non-static member -struct s2 { - constexpr int mi1; // expected-error {{non-static data member cannot be constexpr; did you intend to make it const?}} - static constexpr int mi2; -#if __cplusplus <= 201402L - // expected-error@-2 {{requires an initializer}} -#else - // expected-error@-4 {{default initialization of an object of const}} -#endif - mutable constexpr int mi3 = 3; // expected-error-re {{non-static data member cannot be constexpr{{$}}}} expected-error {{'mutable' and 'const' cannot be mixed}} -}; -// typedef -typedef constexpr int CI; // expected-error {{typedef cannot be constexpr}} -// tag -constexpr class C1 {}; // expected-error {{class cannot be marked constexpr}} -constexpr struct S1 {}; // expected-error {{struct cannot be marked constexpr}} -constexpr union U1 {}; // expected-error {{union cannot be marked constexpr}} -constexpr enum E1 {}; // expected-error {{enum cannot be marked constexpr}} -template <typename T> constexpr class TC1 {}; // expected-error {{class cannot be marked constexpr}} -template <typename T> constexpr struct TS1 {}; // expected-error {{struct cannot be marked constexpr}} -template <typename T> constexpr union TU1 {}; // expected-error {{union cannot be marked constexpr}} -class C2 {} constexpr; // expected-error {{class cannot be marked constexpr}} -struct S2 {} constexpr; // expected-error {{struct cannot be marked constexpr}} -union U2 {} constexpr; // expected-error {{union cannot be marked constexpr}} -enum E2 {} constexpr; // expected-error {{enum cannot be marked constexpr}} -constexpr class C3 {} c3 = C3(); -constexpr struct S3 {} s3 = S3(); -constexpr union U3 {} u3 = {}; -constexpr enum E3 { V3 } e3 = V3; -class C4 {} constexpr c4 = C4(); -struct S4 {} constexpr s4 = S4(); -union U4 {} constexpr u4 = {}; -enum E4 { V4 } constexpr e4 = V4; -constexpr int; // expected-error {{constexpr can only be used in variable and function declarations}} -// redeclaration mismatch -constexpr int f3(); // expected-note {{previous declaration is here}} -int f3(); // expected-error {{non-constexpr declaration of 'f3' follows constexpr declaration}} -int f4(); // expected-note {{previous declaration is here}} -constexpr int f4(); // expected-error {{constexpr declaration of 'f4' follows non-constexpr declaration}} -template<typename T> constexpr T f5(T); -template<typename T> constexpr T f5(T); // expected-note {{previous}} -template<typename T> T f5(T); // expected-error {{non-constexpr declaration of 'f5' follows constexpr declaration}} -template<typename T> T f6(T); // expected-note {{here}} -template<typename T> constexpr T f6(T); // expected-error {{constexpr declaration of 'f6' follows non-constexpr declaration}} -// destructor -struct ConstexprDtor { - constexpr ~ConstexprDtor() = default; // expected-error {{destructor cannot be marked constexpr}} -}; - -// template stuff -template <typename T> constexpr T ft(T t) { return t; } -template <typename T> T gt(T t) { return t; } -struct S { - template<typename T> constexpr T f(); // expected-warning 0-1{{C++14}} expected-note 0-1{{candidate}} - template <typename T> - T g() const; // expected-note-re {{candidate template ignored: could not match 'T (){{( __attribute__\(\(thiscall\)\))?}} const' against 'char (){{( __attribute__\(\(thiscall\)\))?}}'}} -}; - -// explicit specialization can differ in constepxr -template <> notlit ft(notlit nl) { return nl; } -template <> char ft(char c) { return c; } // expected-note {{previous}} -template <> constexpr char ft(char nl); // expected-error {{constexpr declaration of 'ft<char>' follows non-constexpr declaration}} -template <> constexpr int gt(int nl) { return nl; } -template <> notlit S::f() const { return notlit(); } -#if __cplusplus >= 201402L -// expected-error@-2 {{no function template matches}} -#endif -template <> constexpr int S::g() { return 0; } // expected-note {{previous}} -#if __cplusplus < 201402L -// expected-warning@-2 {{C++14}} -#else -// expected-error@-4 {{does not match any declaration in 'S'}} -#endif -template <> int S::g() const; // expected-error {{non-constexpr declaration of 'g<int>' follows constexpr declaration}} -// specializations can drop the 'constexpr' but not the implied 'const'. -template <> char S::g() { return 0; } // expected-error {{no function template matches}} -template <> double S::g() const { return 0; } // ok - -constexpr int i3 = ft(1); - -void test() { - // ignore constexpr when instantiating with non-literal - notlit2 nl2; - (void)ft(nl2); -} - -// Examples from the standard: -constexpr int square(int x); // expected-note {{declared here}} -constexpr int bufsz = 1024; - -constexpr struct pixel { // expected-error {{struct cannot be marked constexpr}} - int x; - int y; - constexpr pixel(int); -}; - -constexpr pixel::pixel(int a) - : x(square(a)), y(square(a)) // expected-note {{undefined function 'square' cannot be used in a constant expression}} - { } - -constexpr pixel small(2); // expected-error {{must be initialized by a constant expression}} expected-note {{in call to 'pixel(2)'}} - -constexpr int square(int x) { - return x * x; -} - -constexpr pixel large(4); - -int next(constexpr int x) { // expected-error {{function parameter cannot be constexpr}} - return x + 1; -} - -extern constexpr int memsz; // expected-error {{constexpr variable declaration must be a definition}} - -namespace { - struct A { - static constexpr int n = 0; - }; - // FIXME: We should diagnose this prior to C++17. - const int &r = A::n; -} diff --git a/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p2.cpp b/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p2.cpp deleted file mode 100644 index eeb5b6f9c2aa..000000000000 --- a/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p2.cpp +++ /dev/null @@ -1,26 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -emit-llvm -triple %itanium_abi_triple %s -o - | FileCheck %s - -// constexpr functions and constexpr constructors are implicitly inline. -struct S { - constexpr S(int n); - constexpr int g(); - int n; -}; - -constexpr S::S(int n) : n(n) {} - -constexpr S f(S s) { - return s.n * 2; -} - -constexpr int S::g() { - return f(*this).n; -} - -// CHECK: define linkonce_odr {{.*}} @_Z1f1S( -// CHECK: define linkonce_odr {{.*}} @_ZN1SC1Ei( -// CHECK: define linkonce_odr {{.*}} @_ZNK1S1gEv( - -int g() { - return f(42).g(); -} diff --git a/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3.cpp b/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3.cpp deleted file mode 100644 index ffc408cddbf4..000000000000 --- a/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3.cpp +++ /dev/null @@ -1,324 +0,0 @@ -// RUN: %clang_cc1 -verify -fcxx-exceptions -triple=x86_64-linux-gnu -std=c++11 -Werror=c++1y-extensions -Werror=c++2a-extensions %s -// RUN: %clang_cc1 -verify -fcxx-exceptions -triple=x86_64-linux-gnu -std=c++1y -DCXX1Y -Werror=c++2a-extensions %s -// RUN: %clang_cc1 -verify -fcxx-exceptions -triple=x86_64-linux-gnu -std=c++2a -DCXX1Y -DCXX2A %s - -namespace N { - typedef char C; -} - -namespace M { - typedef double D; -} - -struct NonLiteral { // expected-note 3{{no constexpr constructors}} - NonLiteral() {} - NonLiteral(int) {} -}; -struct Literal { - constexpr Literal() {} - operator int() const { return 0; } -}; - -struct S { - virtual int ImplicitlyVirtual() const = 0; // expected-note {{overridden virtual function}} -}; -struct SS : S { - int ImplicitlyVirtual() const; -}; - -// The definition of a constexpr function shall satisfy the following -// constraints: -struct T : SS, NonLiteral { - constexpr T(); - constexpr int f() const; - - // - it shall not be virtual; - virtual constexpr int ExplicitlyVirtual() const { return 0; } // expected-error {{virtual function cannot be constexpr}} - - constexpr int ImplicitlyVirtual() const { return 0; } // expected-error {{virtual function cannot be constexpr}} - - virtual constexpr int OutOfLineVirtual() const; // expected-error {{virtual function cannot be constexpr}} - - // - its return type shall be a literal type; - constexpr NonLiteral NonLiteralReturn() const { return {}; } // expected-error {{constexpr function's return type 'NonLiteral' is not a literal type}} - constexpr void VoidReturn() const { return; } -#ifndef CXX1Y - // expected-error@-2 {{constexpr function's return type 'void' is not a literal type}} -#endif - constexpr ~T(); // expected-error {{destructor cannot be marked constexpr}} - typedef NonLiteral F() const; - constexpr F NonLiteralReturn2; // ok until definition - - // - each of its parameter types shall be a literal type; - constexpr int NonLiteralParam(NonLiteral) const { return 0; } // expected-error {{constexpr function's 1st parameter type 'NonLiteral' is not a literal type}} - typedef int G(NonLiteral) const; - constexpr G NonLiteralParam2; // ok until definition - - // - its function-body shall be = delete, = default, - constexpr int Deleted() const = delete; - // It's not possible for the function-body to legally be "= default" here - // (that is, for a non-constructor function) in C++11. - // Other than constructors, only the copy- and move-assignment operators and - // destructor can be defaulted. Destructors can't be constexpr since they - // don't have a literal return type. Defaulted assignment operators can't be - // constexpr since they can't be const. - constexpr T &operator=(const T&) = default; -#ifndef CXX1Y - // expected-error@-2 {{an explicitly-defaulted copy assignment operator may not have 'const', 'constexpr' or 'volatile' qualifiers}} - // expected-warning@-3 {{C++14}} -#else - // expected-error@-5 {{defaulted definition of copy assignment operator is not constexpr}} -#endif -}; - -constexpr int T::OutOfLineVirtual() const { return 0; } -#ifdef CXX1Y -struct T2 { - int n = 0; - constexpr T2 &operator=(const T2&) = default; // ok -}; -struct T3 { - constexpr T3 &operator=(const T3&) const = default; -#ifndef CXX2A - // expected-error@-2 {{an explicitly-defaulted copy assignment operator may not have 'const' or 'volatile' qualifiers}} -#else - // expected-warning@-4 {{explicitly defaulted copy assignment operator is implicitly deleted}} - // expected-note@-5 {{function is implicitly deleted because its declared type does not match the type of an implicit copy assignment operator}} -#endif -}; -#endif -struct U { - constexpr U SelfReturn() const; - constexpr int SelfParam(U) const; -}; - -struct V : virtual U { // expected-note {{here}} - constexpr int F() const { return 0; } // expected-error {{constexpr member function not allowed in struct with virtual base class}} -}; - -// or a compound-statememt that contains only [CXX11] -constexpr int AllowedStmtsCXX11() { - // - null statements - ; - - // - static_assert-declarations - static_assert(true, "the impossible happened!"); - - // - typedef declarations and alias-declarations that do not define classes - // or enumerations - typedef int I; - typedef struct S T; - using J = int; - using K = int[sizeof(I) + sizeof(J)]; - // Note, the standard requires we reject this. - struct U; - - // - using-declarations - using N::C; - - // - using-directives - using namespace N; - - // - and exactly one return statement - return sizeof(K) + sizeof(C) + sizeof(K); -} - -// or a compound-statement that does not contain [CXX1Y] -constexpr int DisallowedStmtsCXX1Y_1() { - // - an asm-definition - asm("int3"); // expected-error {{statement not allowed in constexpr function}} - return 0; -} -constexpr int DisallowedStmtsCXX1Y_2() { - // - a goto statement - goto x; // expected-error {{statement not allowed in constexpr function}} -x: - return 0; -} -constexpr int DisallowedStmtsCXX1Y_2_1() { - try { - return 0; - } catch (...) { - merp: goto merp; // expected-error {{statement not allowed in constexpr function}} - } -} -constexpr int DisallowedStmtsCXX1Y_3() { - // - a try-block, - try {} catch (...) {} -#ifndef CXX2A - // expected-error@-2 {{use of this statement in a constexpr function is a C++2a extension}} -#ifndef CXX1Y - // expected-error@-4 {{use of this statement in a constexpr function is a C++14 extension}} -#endif -#endif - return 0; -} -constexpr int DisallowedStmtsCXX1Y_4() { - // - a definition of a variable of non-literal type - NonLiteral nl; // expected-error {{variable of non-literal type 'NonLiteral' cannot be defined in a constexpr function}} - return 0; -} -constexpr int DisallowedStmtsCXX1Y_5() { - // - a definition of a variable of static storage duration - static constexpr int n = 123; // expected-error {{static variable not permitted in a constexpr function}} - return n; -} -constexpr int DisallowedStmtsCXX1Y_6() { - // - a definition of a variable of thread storage duration - thread_local constexpr int n = 123; // expected-error {{thread_local variable not permitted in a constexpr function}} - return n; -} -constexpr int DisallowedStmtsCXX1Y_7() { - // - a definition of a variable for which no initialization is performed - int n; // expected-error {{variables defined in a constexpr function must be initialized}} - return 0; -} - -constexpr int ForStmt() { - for (int n = 0; n < 10; ++n) -#ifndef CXX1Y - // expected-error@-2 {{statement not allowed in constexpr function}} -#endif - return 0; -} -constexpr int VarDecl() { - int a = 0; -#ifndef CXX1Y - // expected-error@-2 {{variable declaration in a constexpr function is a C++14 extension}} -#endif - return 0; -} -constexpr int ConstexprVarDecl() { - constexpr int a = 0; -#ifndef CXX1Y - // expected-error@-2 {{variable declaration in a constexpr function is a C++14 extension}} -#endif - return 0; -} -constexpr int VarWithCtorDecl() { - Literal a; -#ifndef CXX1Y - // expected-error@-2 {{variable declaration in a constexpr function is a C++14 extension}} -#endif - return 0; -} -NonLiteral nl; -constexpr NonLiteral &ExternNonLiteralVarDecl() { - extern NonLiteral nl; -#ifndef CXX1Y - // expected-error@-2 {{variable declaration in a constexpr function is a C++14 extension}} -#endif - return nl; -} -static_assert(&ExternNonLiteralVarDecl() == &nl, ""); -constexpr int FuncDecl() { - constexpr int ForwardDecl(int); -#ifndef CXX1Y - // expected-error@-2 {{use of this statement in a constexpr function is a C++14 extension}} -#endif - return ForwardDecl(42); -} -constexpr int ClassDecl1() { - typedef struct { } S1; -#ifndef CXX1Y - // expected-error@-2 {{type definition in a constexpr function is a C++14 extension}} -#endif - return 0; -} -constexpr int ClassDecl2() { - using S2 = struct { }; -#ifndef CXX1Y - // expected-error@-2 {{type definition in a constexpr function is a C++14 extension}} -#endif - return 0; -} -constexpr int ClassDecl3() { - struct S3 { }; -#ifndef CXX1Y - // expected-error@-2 {{type definition in a constexpr function is a C++14 extension}} -#endif - return 0; -} -constexpr int NoReturn() {} // expected-error {{no return statement in constexpr function}} -constexpr int MultiReturn() { - return 0; - return 0; -#ifndef CXX1Y - // expected-error@-2 {{multiple return statements in constexpr function}} - // expected-note@-4 {{return statement}} -#endif -} - -// - every constructor call and implicit conversion used in initializing the -// return value shall be one of those allowed in a constant expression. -// -// We implement the proposed resolution of DR1364 and ignore this bullet. -// However, we implement the spirit of the check as part of the p5 checking that -// a constexpr function must be able to produce a constant expression. -namespace DR1364 { - constexpr int f(int k) { - return k; // ok, even though lvalue-to-rvalue conversion of a function - // parameter is not allowed in a constant expression. - } - int kGlobal; // expected-note {{here}} - constexpr int f() { // expected-error {{constexpr function never produces a constant expression}} - return kGlobal; // expected-note {{read of non-const}} - } -} - -namespace rdar13584715 { - typedef __PTRDIFF_TYPE__ ptrdiff_t; - - template<typename T> struct X { - static T value() {}; - }; - - void foo(ptrdiff_t id) { - switch (id) { - case reinterpret_cast<ptrdiff_t>(&X<long>::value): // expected-error{{case value is not a constant expression}} \ - // expected-note{{reinterpret_cast is not allowed in a constant expression}} - break; - } - } -} - -namespace std_example { - constexpr int square(int x) { - return x * x; - } - constexpr long long_max() { - return 2147483647; - } - constexpr int abs(int x) { - if (x < 0) -#ifndef CXX1Y - // expected-error@-2 {{C++14}} -#endif - x = -x; - return x; - } - constexpr int first(int n) { - static int value = n; // expected-error {{static variable not permitted}} - return value; - } - constexpr int uninit() { - int a; // expected-error {{must be initialized}} - return a; - } - constexpr int prev(int x) { - return --x; - } -#ifndef CXX1Y - // expected-error@-4 {{never produces a constant expression}} - // expected-note@-4 {{subexpression}} -#endif - constexpr int g(int x, int n) { - int r = 1; - while (--n > 0) r *= x; - return r; - } -#ifndef CXX1Y - // expected-error@-5 {{C++14}} - // expected-error@-5 {{statement not allowed}} -#endif -} diff --git a/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p4.cpp b/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p4.cpp deleted file mode 100644 index 54aabe6ef376..000000000000 --- a/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p4.cpp +++ /dev/null @@ -1,343 +0,0 @@ -// RUN: %clang_cc1 -verify -std=c++11 -fcxx-exceptions -Werror=c++1y-extensions -Werror=c++2a-extensions %s -// RUN: %clang_cc1 -verify -std=c++1y -fcxx-exceptions -DCXX1Y -Werror=c++2a-extensions %s -// RUN: %clang_cc1 -verify -std=c++2a -fcxx-exceptions -DCXX1Y -DCXX2A %s - -namespace N { - typedef char C; -} - -namespace M { - typedef double D; -} - -struct NonLiteral { // expected-note 2{{no constexpr constructors}} - NonLiteral() {} - NonLiteral(int) {} -}; -struct Literal { - constexpr Literal() {} - explicit Literal(int); // expected-note 2 {{here}} - operator int() const { return 0; } -}; - -// In the definition of a constexpr constructor, each of the parameter types -// shall be a literal type. -struct S { - constexpr S(int, N::C) {} - constexpr S(int, NonLiteral, N::C) {} // expected-error {{constexpr constructor's 2nd parameter type 'NonLiteral' is not a literal type}} - constexpr S(int, NonLiteral = 42) {} // expected-error {{constexpr constructor's 2nd parameter type 'NonLiteral' is not a literal type}} - - // In addition, either its function-body shall be = delete or = default - constexpr S() = default; - constexpr S(Literal) = delete; -}; - -// or it shall satisfy the following constraints: - -// - the class shall not have any virtual base classes; -struct T : virtual S { // expected-note {{here}} - constexpr T() {} // expected-error {{constexpr constructor not allowed in struct with virtual base class}} -}; -namespace IndirectVBase { - struct A {}; - struct B : virtual A {}; // expected-note {{here}} - class C : public B { - public: - constexpr C() {} // expected-error {{constexpr constructor not allowed in class with virtual base class}} - }; -} - -// - its function-body shall not be a function-try-block; -struct U { - constexpr U() - try -#ifndef CXX2A - // expected-error@-2 {{function try block in constexpr constructor is a C++2a extension}} -#endif - : u() { -#ifndef CXX1Y - // expected-error@-2 {{use of this statement in a constexpr constructor is a C++14 extension}} -#endif - } catch (...) { - throw; - } - int u; -}; - -// - the compound-statememt of its function-body shall contain only -struct V { - constexpr V() { - // - null statements, - ; - - // - static_assert-declarations, - static_assert(true, "the impossible happened!"); - - // - typedef declarations and alias-declarations that do not define classes - // or enumerations, - typedef int I; - typedef struct S T; - using J = int; - using K = int[sizeof(I) + sizeof(J)]; - // Note, the standard requires we reject this. - struct U; - - // - using-declarations, - using N::C; - - // - and using-directives; - using namespace N; - } - - constexpr V(int(&)[1]) { - for (int n = 0; n < 10; ++n) - /**/; -#ifndef CXX1Y - // expected-error@-3 {{statement not allowed in constexpr constructor}} -#endif - } - constexpr V(int(&)[2]) { - constexpr int a = 0; -#ifndef CXX1Y - // expected-error@-2 {{variable declaration in a constexpr constructor is a C++14 extension}} -#endif - } - constexpr V(int(&)[3]) { - constexpr int ForwardDecl(int); -#ifndef CXX1Y - // expected-error@-2 {{use of this statement in a constexpr constructor is a C++14 extension}} -#endif - } - constexpr V(int(&)[4]) { - typedef struct { } S1; -#ifndef CXX1Y - // expected-error@-2 {{type definition in a constexpr constructor is a C++14 extension}} -#endif - } - constexpr V(int(&)[5]) { - using S2 = struct { }; -#ifndef CXX1Y - // expected-error@-2 {{type definition in a constexpr constructor is a C++14 extension}} -#endif - } - constexpr V(int(&)[6]) { - struct S3 { }; -#ifndef CXX1Y - // expected-error@-2 {{type definition in a constexpr constructor is a C++14 extension}} -#endif - } - constexpr V(int(&)[7]) { - return; -#ifndef CXX1Y - // expected-error@-2 {{use of this statement in a constexpr constructor is a C++14 extension}} -#endif - } -}; - -// - every non-static data member and base class sub-object shall be initialized -struct W { - int n; // expected-note {{member not initialized by constructor}} - constexpr W() {} // expected-error {{constexpr constructor must initialize all members}} -}; -struct AnonMembers { - int a; // expected-note {{member not initialized by constructor}} - union { // expected-note 2{{member not initialized by constructor}} - char b; - struct { - double c; - long d; // expected-note {{member not initialized by constructor}} - }; - union { - char e; - void *f; - }; - }; - struct { // expected-note {{member not initialized by constructor}} - long long g; - struct { - int h; // expected-note {{member not initialized by constructor}} - double i; // expected-note {{member not initialized by constructor}} - }; - union { // expected-note 2{{member not initialized by constructor}} - char *j; - AnonMembers *k; - }; - }; - - constexpr AnonMembers(int(&)[1]) : a(), b(), g(), h(), i(), j() {} // ok - // missing d, i, j/k union - constexpr AnonMembers(int(&)[2]) : a(), c(), g(), h() {} // expected-error {{constexpr constructor must initialize all members}} - constexpr AnonMembers(int(&)[3]) : a(), e(), g(), h(), i(), k() {} // ok - // missing h, j/k union - constexpr AnonMembers(int(&)[4]) : a(), c(), d(), g(), i() {} // expected-error {{constexpr constructor must initialize all members}} - // missing b/c/d/e/f union - constexpr AnonMembers(int(&)[5]) : a(), g(), h(), i(), k() {} // expected-error {{constexpr constructor must initialize all members}} - // missing a, b/c/d/e/f union, g/h/i/j/k struct - constexpr AnonMembers(int(&)[6]) {} // expected-error {{constexpr constructor must initialize all members}} -}; - -union Empty { - constexpr Empty() {} // ok -} constexpr empty1; - -struct EmptyVariant { - union {}; - struct {}; - constexpr EmptyVariant() {} // ok -} constexpr empty2; - -template<typename T> using Int = int; -template<typename T> -struct TemplateInit { - T a; - int b; // desired-note {{not initialized}} - Int<T> c; // desired-note {{not initialized}} - struct { - T d; - int e; // desired-note {{not initialized}} - Int<T> f; // desired-note {{not initialized}} - }; - struct { - Literal l; - Literal m; - Literal n[3]; - }; - union { // desired-note {{not initialized}} - T g; - T h; - }; - // FIXME: This is ill-formed (no diagnostic required). We should diagnose it. - constexpr TemplateInit() {} // desired-error {{must initialize all members}} -}; -template<typename T> struct TemplateInit2 { - Literal l; - constexpr TemplateInit2() {} // ok -}; - -template<typename T> struct weak_ptr { - constexpr weak_ptr() : p(0) {} - T *p; -}; -template<typename T> struct enable_shared_from_this { - weak_ptr<T> weak_this; - constexpr enable_shared_from_this() {} // ok -}; -constexpr int f(enable_shared_from_this<int>); - -// - every constructor involved in initializing non-static data members and base -// class sub-objects shall be a constexpr constructor. -struct ConstexprBaseMemberCtors : Literal { - Literal l; - - constexpr ConstexprBaseMemberCtors() : Literal(), l() {} // ok - constexpr ConstexprBaseMemberCtors(char) : // expected-error {{constexpr constructor never produces a constant expression}} - Literal(0), // expected-note {{non-constexpr constructor}} - l() {} - constexpr ConstexprBaseMemberCtors(double) : Literal(), // expected-error {{constexpr constructor never produces a constant expression}} - l(0) // expected-note {{non-constexpr constructor}} - {} -}; - -// - every assignment-expression that is an initializer-clause appearing -// directly or indirectly within a brace-or-equal-initializer for a non-static -// data member that is not named by a mem-initializer-id shall be a constant -// expression; and -// -// Note, we deliberately do not implement this bullet, so that we can allow the -// following example. (See N3308). -struct X { - int a = 0; - int b = 2 * a + 1; // ok, not a constant expression. - - constexpr X() {} - constexpr X(int c) : a(c) {} // ok, b initialized by 2 * c + 1 -}; - -union XU1 { int a; constexpr XU1() = default; }; // expected-error{{not constexpr}} -union XU2 { int a = 1; constexpr XU2() = default; }; - -struct XU3 { - union { - int a; - }; - constexpr XU3() = default; // expected-error{{not constexpr}} -}; -struct XU4 { - union { - int a = 1; - }; - constexpr XU4() = default; -}; - -static_assert(XU2().a == 1, ""); -static_assert(XU4().a == 1, ""); - -// - every implicit conversion used in converting a constructor argument to the -// corresponding parameter type and converting a full-expression to the -// corresponding member type shall be one of those allowed in a constant -// expression. -// -// We implement the proposed resolution of DR1364 and ignore this bullet. -// However, we implement the intent of this wording as part of the p5 check that -// the function must be able to produce a constant expression. -int kGlobal; // expected-note {{here}} -struct Z { - constexpr Z(int a) : n(a) {} - constexpr Z() : n(kGlobal) {} // expected-error {{constexpr constructor never produces a constant expression}} expected-note {{read of non-const}} - int n; -}; - - -namespace StdExample { - struct Length { - explicit constexpr Length(int i = 0) : val(i) { } - private: - int val; - }; -} - -namespace CtorLookup { - // Ensure that we look up which constructor will actually be used. - struct A { - constexpr A(const A&) {} - A(A&) {} - constexpr A(int = 0); - }; - - struct B : A { - B() = default; - constexpr B(const B&); - constexpr B(B&); - }; - constexpr B::B(const B&) = default; - constexpr B::B(B&) = default; // expected-error {{not constexpr}} - - struct C { - A a; - C() = default; - constexpr C(const C&); - constexpr C(C&); - }; - constexpr C::C(const C&) = default; - constexpr C::C(C&) = default; // expected-error {{not constexpr}} -} - -namespace PR14503 { - template<typename> struct V { - union { - int n; - struct { - int x, - y; - }; - }; - constexpr V() : x(0) {} - }; - - // The constructor is still 'constexpr' here, but the result is not intended - // to be a constant expression. The standard is not clear on how this should - // work. - constexpr V<int> v; // expected-error {{constant expression}} expected-note {{subobject of type 'int' is not initialized}} - - constexpr int k = V<int>().x; // FIXME: ok? -} diff --git a/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p5.cpp b/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p5.cpp deleted file mode 100644 index 18b2c6b1d6d1..000000000000 --- a/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p5.cpp +++ /dev/null @@ -1,140 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -triple x86_64-unknown-unknown -verify -std=c++11 -fcxx-exceptions %s -// RUN: %clang_cc1 -fsyntax-only -triple x86_64-unknown-unknown -verify -std=c++14 -fcxx-exceptions %s -// RUN: %clang_cc1 -fsyntax-only -triple x86_64-unknown-unknown -std=c++11 -fcxx-exceptions -Wno-invalid-constexpr %s -DNO_INVALID_CONSTEXPR - -namespace StdExample { - -constexpr int f(void *) { return 0; } -constexpr int f(...) { return 1; } -constexpr int g1() { return f(0); } -constexpr int g2(int n) { return f(n); } -constexpr int g3(int n) { return f(n*0); } - -namespace N { - constexpr int c = 5; - constexpr int h() { return c; } -} -constexpr int c = 0; -constexpr int g4() { return N::h(); } - -static_assert(f(0) == 0, ""); -static_assert(f('0') == 1, ""); -static_assert(g1() == 0, ""); -static_assert(g2(0) == 1, ""); -static_assert(g2(1) == 1, ""); -static_assert(g3(0) == 1, ""); -static_assert(g3(1) == 1, ""); -static_assert(N::h() == 5, ""); -static_assert(g4() == 5, ""); - - -constexpr int f(bool b) - { return b ? throw 0 : 0; } // ok -constexpr int f() { return throw 0, 0; } // expected-error {{constexpr function never produces a constant expression}} expected-note {{subexpression}} - -struct B { - constexpr B(int x) : i(0) { } - int i; -}; - -int global; // expected-note {{declared here}} - -struct D : B { - constexpr D() : B(global) { } // expected-error {{constexpr constructor never produces a constant expression}} expected-note {{read of non-const}} -}; - -} - -namespace PotentialConstant { - -constexpr int Comma(int n) { return // expected-error {{constexpr function never produces a constant expression}} - (void)(n * 2), - throw 0, // expected-note {{subexpression}} - 0; -} - -int ng; // expected-note 6{{here}} -constexpr int BinaryOp1(int n) { return n + ng; } // expected-error {{never produces}} expected-note {{read}} -constexpr int BinaryOp2(int n) { return ng + n; } // expected-error {{never produces}} expected-note {{read}} - -double dg; // expected-note 2{{here}} -constexpr double BinaryOp1(double d) { return d + dg; } // expected-error {{never produces}} expected-note {{read}} -constexpr double BinaryOp2(double d) { return dg + d; } // expected-error {{never produces}} expected-note {{read}} - -constexpr int Add(int a, int b, int c) { return a + b + c; } -constexpr int FunctionArgs(int a) { return Add(a, ng, a); } // expected-error {{never produces}} expected-note {{read}} - -struct S { int a; int b; int c[2]; }; -constexpr S InitList(int a) { return { a, ng }; }; // expected-error {{never produces}} expected-note {{read}} -constexpr S InitList1a(int a) { return S{ a, ng }; }; // expected-error {{never produces}} expected-note {{read}} -constexpr S InitList2(int a) { return { a, a, { ng } }; }; // expected-error {{never produces}} expected-note {{read}} -constexpr S InitList3(int a) { return a ? S{ a, a } : S{ a, ng }; }; // ok - -constexpr int LogicalAnd1(int n) { return n && (throw, 0); } // ok -constexpr int LogicalAnd2(int n) { return 1 && (throw, 0); } // expected-error {{never produces}} expected-note {{subexpression}} - -constexpr int LogicalOr1(int n) { return n || (throw, 0); } // ok -constexpr int LogicalOr2(int n) { return 0 || (throw, 0); } // expected-error {{never produces}} expected-note {{subexpression}} - -constexpr int Conditional1(bool b, int n) { return b ? n : ng; } // ok -constexpr int Conditional2(bool b, int n) { return b ? n * ng : n + ng; } // expected-error {{never produces}} expected-note {{both arms of conditional operator are unable to produce a constant expression}} - -// __builtin_constant_p ? : is magical, and is always a potential constant. -constexpr bool BcpCall(int n) { - return __builtin_constant_p((int*)n != &n) ? (int*)n != &n : (int*)n != &n; // expected-warning 3 {{cast to 'int *' from smaller integer type 'int'}} -} -static_assert(BcpCall(0), ""); - -// DR1311: A function template which can produce a constant expression, but -// for which a particular specialization cannot, is ok. -template<typename T> constexpr T cmin(T a, T b) { - return a < b ? a : b; -} -int n = cmin(3, 5); // ok - -struct X { - constexpr X() {} - bool operator<(X); // not constexpr -}; - -X x = cmin(X(), X()); // ok, not constexpr - -// Same with other temploids. -template<typename T> -struct Y { - constexpr Y() {} - constexpr int get() { return T(); } -#if __cplusplus < 201402L - // expected-warning@-2 {{C++14}} -#endif -}; -struct Z { operator int(); }; - -int y1 = Y<int>().get(); // ok -int y2 = Y<Z>().get(); // ok - -} - -#ifndef NO_INVALID_CONSTEXPR -namespace PR14550 { - // As an "extension", we allow functions which can't produce constant - // expressions to be declared constexpr in system headers (libstdc++ - // marks some functions as constexpr which use builtins which we don't - // support constant folding). Ensure that we don't mark those functions - // as invalid after suppressing the diagnostic. -# 126 "p5.cpp" 1 3 - int n; - struct A { - static constexpr int f() { return n; } - }; - template<typename T> struct B { - B() { g(T::f()); } // expected-error {{undeclared identifier 'g'}} - }; -# 134 "p5.cpp" 2 - template class B<A>; // expected-note {{here}} -} -#endif - -#if __cplusplus >= 201402L -constexpr void f() { throw; } // expected-error {{never produces}} expected-note {{subexpression}} -#endif diff --git a/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p6.cpp b/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p6.cpp deleted file mode 100644 index 88ad6a4a3c4b..000000000000 --- a/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p6.cpp +++ /dev/null @@ -1,68 +0,0 @@ -// RUN: %clang_cc1 -verify -std=c++11 %s - -namespace N { - typedef char C; -} - -namespace M { - typedef double D; -} - -struct NonLiteral { - NonLiteral() {} - NonLiteral(int) {} // expected-note 2{{here}} - operator int() const { return 0; } -}; -struct Literal { - constexpr Literal() {} - operator int() const { return 0; } -}; - -struct S { - virtual int ImplicitlyVirtual() const; -}; -struct T {}; - -template<typename T> struct ImplicitVirtualFromDependentBase : T { - constexpr int ImplicitlyVirtual() const { return 0; } -}; - -constexpr int a = ImplicitVirtualFromDependentBase<S>().ImplicitlyVirtual(); // expected-error {{constant expression}} expected-note {{cannot evaluate virtual function call}} -constexpr int b = ImplicitVirtualFromDependentBase<T>().ImplicitlyVirtual(); // ok -constexpr int c = ImplicitVirtualFromDependentBase<S>().ImplicitVirtualFromDependentBase<S>::ImplicitlyVirtual(); - -template<typename R> struct ConstexprMember { - constexpr R F() const { return 0; } -}; -constexpr int d = ConstexprMember<int>().F(); // ok -constexpr int e = ConstexprMember<NonLiteral>().F(); // expected-error {{constant expression}} expected-note {{non-literal type 'NonLiteral' cannot be used in a constant expression}} - -template<typename ...P> struct ConstexprCtor { - constexpr ConstexprCtor(P...) {} -}; -constexpr ConstexprCtor<> f1() { return {}; } // ok -constexpr ConstexprCtor<int> f2() { return 0; } // ok -constexpr ConstexprCtor<NonLiteral> f3() { return { 0 }; } // expected-error {{never produces a constant expression}} expected-note {{non-constexpr constructor 'NonLiteral}} -constexpr ConstexprCtor<int, NonLiteral> f4() { return { 0, 0 }; } // expected-error {{never produces a constant expression}} expected-note {{non-constexpr constructor 'NonLiteral}} - -struct VirtBase : virtual S {}; // expected-note {{here}} - -namespace TemplateVBase { - template<typename T> struct T1 : virtual Literal { // expected-note {{here}} - constexpr T1() {} // expected-error {{constexpr constructor not allowed in struct with virtual base class}} - }; - - template<typename T> struct T2 : virtual T { - // FIXME: This is ill-formed (no diagnostic required). - // We should diagnose it now rather than waiting until instantiation. - constexpr T2() {} - }; - constexpr T2<Literal> g2() { return {}; } - - template<typename T> class T3 : public T { // expected-note {{class with virtual base class is not a literal type}} - public: - constexpr T3() {} - }; - constexpr T3<Literal> g3() { return {}; } // ok - constexpr T3<VirtBase> g4() { return {}; } // expected-error {{not a literal type}} -} diff --git a/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p8.cpp b/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p8.cpp deleted file mode 100644 index 428fd50b270f..000000000000 --- a/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p8.cpp +++ /dev/null @@ -1,58 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s - -using size_t = decltype(sizeof(int)); - -struct S { - constexpr int f(); // expected-warning {{C++14}} - constexpr int g() const; - constexpr int h(); // expected-warning {{C++14}} - int h(); - static constexpr int Sf(); - /*static*/ constexpr void *operator new(size_t) noexcept; - template<typename T> constexpr T tm(); // expected-warning {{C++14}} - template<typename T> static constexpr T ts(); -}; - -void f(const S &s) { - s.f(); - s.g(); - - int (*Sf)() = &S::Sf; - int (S::*f)() const = &S::f; - int (S::*g)() const = &S::g; - void *(*opNew)(size_t) = &S::operator new; - int (S::*tm)() const = &S::tm; - int (*ts)() = &S::ts; -} - -constexpr int S::f() const { return 0; } -constexpr int S::g() { return 1; } // expected-warning {{C++14}} -constexpr int S::h() { return 0; } // expected-warning {{C++14}} -int S::h() { return 0; } -constexpr int S::Sf() { return 2; } -constexpr void *S::operator new(size_t) noexcept { return 0; } -template<typename T> constexpr T S::tm() { return T(); } // expected-warning {{C++14}} -template<typename T> constexpr T S::ts() { return T(); } - -namespace std_example { - - class debug_flag { - public: - explicit debug_flag(bool); - constexpr bool is_on() const; // ok (dr1684) - private: - bool flag; - }; - - constexpr int bar(int x, int y) // expected-note {{here}} - { return x + y + x*y; } - int bar(int x, int y) // expected-error {{non-constexpr declaration of 'bar' follows constexpr declaration}} - { return x * 2 + 3 * y; } - -} - -// The constexpr specifier is allowed for static member functions of non-literal types. -class NonLiteralClass { - NonLiteralClass(bool); - static constexpr bool isDebugFlag(); -}; diff --git a/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p9.cpp b/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p9.cpp deleted file mode 100644 index 0aaedcc07696..000000000000 --- a/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p9.cpp +++ /dev/null @@ -1,37 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s - -// A constexpr specifier used in an object declaration declares the object as -// const. -constexpr int a = 0; -extern const int a; - -int i; // expected-note 2{{here}} -constexpr int *b = &i; -extern int *const b; - -constexpr int &c = i; -extern int &c; - -constexpr int (*d)(int) = 0; -extern int (*const d)(int); - -// A variable declaration which uses the constexpr specifier shall have an -// initializer and shall be initialized by a constant expression. -constexpr int ni1; // expected-error {{default initialization of an object of const type 'const int'}} -constexpr struct C { C(); } ni2; // expected-error {{cannot have non-literal type 'const struct C'}} expected-note 3{{has no constexpr constructors}} -constexpr double &ni3; // expected-error {{declaration of reference variable 'ni3' requires an initializer}} - -constexpr int nc1 = i; // expected-error {{constexpr variable 'nc1' must be initialized by a constant expression}} expected-note {{read of non-const variable 'i' is not allowed in a constant expression}} -constexpr C nc2 = C(); // expected-error {{cannot have non-literal type 'const C'}} -int &f(); // expected-note {{declared here}} -constexpr int &nc3 = f(); // expected-error {{constexpr variable 'nc3' must be initialized by a constant expression}} expected-note {{non-constexpr function 'f' cannot be used in a constant expression}} -constexpr int nc4(i); // expected-error {{constexpr variable 'nc4' must be initialized by a constant expression}} expected-note {{read of non-const variable 'i' is not allowed in a constant expression}} -constexpr C nc5((C())); // expected-error {{cannot have non-literal type 'const C'}} -int &f(); // expected-note {{here}} -constexpr int &nc6(f()); // expected-error {{constexpr variable 'nc6' must be initialized by a constant expression}} expected-note {{non-constexpr function 'f'}} - -struct pixel { - int x, y; -}; -constexpr pixel ur = { 1294, 1024 }; // ok -constexpr pixel origin; // expected-error {{default initialization of an object of const type 'const pixel' without a user-provided default constructor}} diff --git a/test/CXX/dcl.dcl/dcl.spec/dcl.fct.spec/p3.cpp b/test/CXX/dcl.dcl/dcl.spec/dcl.fct.spec/p3.cpp deleted file mode 100644 index d7b9eff10a80..000000000000 --- a/test/CXX/dcl.dcl/dcl.spec/dcl.fct.spec/p3.cpp +++ /dev/null @@ -1,13 +0,0 @@ -// RUN: %clang_cc1 -verify %s - -void f0a(void) { - inline void f1(); // expected-error {{inline declaration of 'f1' not allowed in block scope}} -} - -void f0b(void) { - void f1(); -} - -// FIXME: Add test for "If the inline specifier is used in a friend declaration, -// that declaration shall be a definition or the function shall have previously -// been declared inline. diff --git a/test/CXX/dcl.dcl/dcl.spec/dcl.fct.spec/p4.cpp b/test/CXX/dcl.dcl/dcl.spec/dcl.fct.spec/p4.cpp deleted file mode 100644 index 6e150ce5a554..000000000000 --- a/test/CXX/dcl.dcl/dcl.spec/dcl.fct.spec/p4.cpp +++ /dev/null @@ -1,34 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s - -void f0() { // expected-note {{previous definition is here}} -} - -inline void f0(); // expected-error {{inline declaration of 'f0' follows non-inline definition}} - -void func_01() {} // expected-note{{previous definition is here}} -struct C01 { - friend void func_01() {} // expected-error{{redefinition of 'func_01'}} -}; - -void func_02() {} // expected-note{{previous definition is here}} -struct C02 { - friend inline void func_02(); // expected-error{{inline declaration of 'func_02' follows non-inline definition}} -}; - -void func_03() {} // expected-note{{previous definition is here}} -struct C03 { - friend inline void func_03() {} // expected-error{{inline declaration of 'func_03' follows non-inline definition}} -}; - -void func_04() {} // expected-note{{previous definition is here}} -inline void func_04() {} // expected-error{{inline declaration of 'func_04' follows non-inline definition}} - -void func_06() {} // expected-note{{previous definition is here}} -template<typename T> struct C06 { - friend inline void func_06() {} // expected-error{{inline declaration of 'func_06' follows non-inline definition}} -}; - -void func_07() {} // expected-note{{previous definition is here}} -template<typename T> struct C07 { - friend inline void func_07(); // expected-error{{inline declaration of 'func_07' follows non-inline definition}} -}; diff --git a/test/CXX/dcl.dcl/dcl.spec/dcl.fct.spec/p6.cpp b/test/CXX/dcl.dcl/dcl.spec/dcl.fct.spec/p6.cpp deleted file mode 100644 index 08b22c118685..000000000000 --- a/test/CXX/dcl.dcl/dcl.spec/dcl.fct.spec/p6.cpp +++ /dev/null @@ -1,28 +0,0 @@ -// RUN: %clang_cc1 -verify %s -// RUN: %clang_cc1 -verify -std=c++98 %s -// RUN: %clang_cc1 -verify -std=c++11 %s - -class A { -public: - explicit A(); - - explicit operator int(); -#if __cplusplus <= 199711L // C++03 or earlier modes - // expected-warning@-2 {{explicit conversion functions are a C++11 extension}} -#endif - - explicit void f0(); // expected-error {{'explicit' can only be applied to a constructor or conversion function}} - - operator bool(); -}; - -explicit A::A() { } // expected-error {{'explicit' can only be specified inside the class definition}} -explicit A::operator bool() { return false; } -#if __cplusplus <= 199711L // C++03 or earlier modes -// expected-warning@-2 {{explicit conversion functions are a C++11 extension}} -#endif -// expected-error@-4 {{'explicit' can only be specified inside the class definition}} - -class B { - friend explicit A::A(); // expected-error {{'explicit' is invalid in friend declarations}} -}; diff --git a/test/CXX/dcl.dcl/dcl.spec/dcl.inline/p1.cpp b/test/CXX/dcl.dcl/dcl.spec/dcl.inline/p1.cpp deleted file mode 100644 index 6db0b04a7496..000000000000 --- a/test/CXX/dcl.dcl/dcl.spec/dcl.inline/p1.cpp +++ /dev/null @@ -1,8 +0,0 @@ -// RUN: %clang_cc1 -std=c++1z -verify %s - -inline int f(); // ok -inline int n; // ok - -inline typedef int t; // expected-error {{'inline' can only appear on functions and non-local variables}} -inline struct S {}; // expected-error {{'inline' can only appear on functions and non-local variables}} -inline struct T {} s; // ok diff --git a/test/CXX/dcl.dcl/dcl.spec/dcl.inline/p5.cpp b/test/CXX/dcl.dcl/dcl.spec/dcl.inline/p5.cpp deleted file mode 100644 index 0ca7bbc5fad3..000000000000 --- a/test/CXX/dcl.dcl/dcl.spec/dcl.inline/p5.cpp +++ /dev/null @@ -1,15 +0,0 @@ -// RUN: %clang_cc1 -std=c++1z -verify %s - -void x() { - inline int f(int); // expected-error {{inline declaration of 'f' not allowed in block scope}} - inline int n; // expected-error {{inline declaration of 'n' not allowed in block scope}} - static inline int m; // expected-error {{inline declaration of 'm' not allowed in block scope}} -} - -inline void g(); -struct X { - inline void f(); - // FIXME: This is ill-formed per [dcl.inline]p5. - inline void g(); - inline void h() {} -}; diff --git a/test/CXX/dcl.dcl/dcl.spec/dcl.stc/p1.cpp b/test/CXX/dcl.dcl/dcl.spec/dcl.stc/p1.cpp deleted file mode 100644 index cbb439ef5fec..000000000000 --- a/test/CXX/dcl.dcl/dcl.spec/dcl.stc/p1.cpp +++ /dev/null @@ -1,32 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s - -// A storage-class-specifier shall not be specified in an explicit -// specialization (14.7.3) or an explicit instantiation (14.7.2) -// directive. -template<typename T> void f(T) {} -template<typename T> static void g(T) {} - - -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-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); -template void g<long>(long); - -template<typename T> -struct X { - static int value; -}; - -template<typename T> -int X<T>::value = 17; - -template static int X<int>::value; // expected-error{{explicit instantiation cannot have a storage class}} - -template<> static int X<float>::value; // expected-error{{'static' can only be specified inside the class definition}} diff --git a/test/CXX/dcl.dcl/dcl.spec/dcl.stc/p10.cpp b/test/CXX/dcl.dcl/dcl.spec/dcl.stc/p10.cpp deleted file mode 100644 index d7e7c52f3f70..000000000000 --- a/test/CXX/dcl.dcl/dcl.spec/dcl.stc/p10.cpp +++ /dev/null @@ -1,13 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s - -typedef const int T0; -typedef int& T1; - -struct s0 { - mutable const int f0; // expected-error{{'mutable' and 'const' cannot be mixed}} - mutable T0 f1; // expected-error{{'mutable' and 'const' cannot be mixed}} - mutable int &f2; // expected-error{{'mutable' cannot be applied to references}} - mutable T1 f3; // expected-error{{'mutable' cannot be applied to references}} - mutable struct s1 {}; // expected-error{{'mutable' can only be applied to member variables}} - mutable void im0(); // expected-error{{'mutable' cannot be applied to functions}} -}; diff --git a/test/CXX/dcl.dcl/dcl.spec/dcl.stc/p2.cpp b/test/CXX/dcl.dcl/dcl.spec/dcl.stc/p2.cpp deleted file mode 100644 index 13721518e6f9..000000000000 --- a/test/CXX/dcl.dcl/dcl.spec/dcl.stc/p2.cpp +++ /dev/null @@ -1,59 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s - -// The auto or register specifiers can be applied only to names of objects -// declared in a block (6.3) or to function parameters (8.4). - -auto int ao; // expected-error {{illegal storage class on file-scoped variable}} -#if __cplusplus >= 201103L // C++11 or later -// expected-warning@-2 {{'auto' storage class specifier is not permitted in C++11, and will not be supported in future releases}} -#endif - -auto void af(); // expected-error {{illegal storage class on function}} -#if __cplusplus >= 201103L // C++11 or later -// expected-warning@-2 {{'auto' storage class specifier is not permitted in C++11, and will not be supported in future releases}} -#endif - -register int ro; // expected-error {{illegal storage class on file-scoped variable}} -#if __cplusplus >= 201103L // C++11 or later -// expected-warning@-2 {{'register' storage class specifier is deprecated}} -#endif - -register void rf(); // expected-error {{illegal storage class on function}} - -struct S { - auto int ao; // expected-error {{storage class specified for a member declaration}} -#if __cplusplus >= 201103L // C++11 or later -// expected-warning@-2 {{'auto' storage class specifier is not permitted in C++11, and will not be supported in future releases}} -#endif - auto void af(); // expected-error {{storage class specified for a member declaration}} -#if __cplusplus >= 201103L // C++11 or later -// expected-warning@-2 {{'auto' storage class specifier is not permitted in C++11, and will not be supported in future releases}} -#endif - - register int ro; // expected-error {{storage class specified for a member declaration}} - register void rf(); // expected-error {{storage class specified for a member declaration}} -}; - -void foo(auto int ap, register int rp) { -#if __cplusplus >= 201103L // C++11 or later -// expected-warning@-2 {{'auto' storage class specifier is not permitted in C++11, and will not be supported in future releases}} -// expected-warning@-3 {{'register' storage class specifier is deprecated}} -#endif - auto int abo; -#if __cplusplus >= 201103L // C++11 or later -// expected-warning@-2 {{'auto' storage class specifier is not permitted in C++11, and will not be supported in future releases}} -#endif - auto void abf(); // expected-error {{illegal storage class on function}} -#if __cplusplus >= 201103L // C++11 or later -// expected-warning@-2 {{'auto' storage class specifier is not permitted in C++11, and will not be supported in future releases}} -#endif - - register int rbo; -#if __cplusplus >= 201103L // C++11 or later -// expected-warning@-2 {{'register' storage class specifier is deprecated}} -#endif - - register void rbf(); // expected-error {{illegal storage class on function}} -} diff --git a/test/CXX/dcl.dcl/dcl.spec/dcl.stc/p9.cpp b/test/CXX/dcl.dcl/dcl.spec/dcl.stc/p9.cpp deleted file mode 100644 index 491ab17802e0..000000000000 --- a/test/CXX/dcl.dcl/dcl.spec/dcl.stc/p9.cpp +++ /dev/null @@ -1,11 +0,0 @@ -// RUN: %clang_cc1 -verify %s - -struct S; // expected-note 2{{forward declaration of 'S'}} -extern S a; -extern S f(); // expected-note {{'f' declared here}} -extern void g(S a); - -void h() { - g(a); // expected-error {{argument type 'S' is incomplete}} - f(); // expected-error {{calling 'f' with incomplete return type 'S'}} -} diff --git a/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p12-1y.cpp b/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p12-1y.cpp deleted file mode 100644 index ff2abf9dfafc..000000000000 --- a/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p12-1y.cpp +++ /dev/null @@ -1,17 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -verify %s -// RUN: %clang_cc1 -std=c++1y -verify %s - -template<typename T> struct S { typedef int type; }; - -template<typename T> void f() { - auto x = [] { return 0; } (); - // FIXME: We should be able to produce a 'missing typename' diagnostic here. - S<decltype(x)>::type n; // expected-error 2{{}} -} - -#if __cplusplus > 201103L -template<typename T> void g() { - auto x = [] () -> auto { return 0; } (); - S<decltype(x)>::type n; // expected-error 2{{}} -} -#endif diff --git a/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p2-1z.cpp b/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p2-1z.cpp deleted file mode 100644 index e41270ee3cd2..000000000000 --- a/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p2-1z.cpp +++ /dev/null @@ -1,47 +0,0 @@ -// RUN: %clang_cc1 -std=c++1z -verify %s - -template<typename T, typename U> constexpr bool same = false; -template<typename T> constexpr bool same<T, T> = true; - -auto a() { - if constexpr (false) - return 0; -} -static_assert(same<decltype(a()), void>); - -auto b() { - if constexpr (false) - return 0; - else - return 0.0; -} -static_assert(same<decltype(b()), double>); - -auto c() { - if constexpr (true) - return "foo"; - else - return 'x'; - if constexpr (false) - return 7.6; - else - return 5; // expected-error {{deduced as 'int' here but deduced as 'const char *' in earlier}} -} - -template<int k> auto d() { - if constexpr(k == 0) - return 0; - if constexpr(k == 1) - return "foo"; - else if constexpr (k == 2) - return 1.0; -} -static_assert(same<decltype(d<0>()), int>); -static_assert(same<decltype(d<1>()), const char *>); -static_assert(same<decltype(d<2>()), double>); -static_assert(same<decltype(d<3>()), void>); - -auto e = []{ if constexpr (false) return 0; }(); // expected-error {{variable has incomplete type 'void'}} - -auto f = []{ if constexpr (true) return 0; }(); -static_assert(same<decltype(e), int>); diff --git a/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p2.cpp b/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p2.cpp deleted file mode 100644 index 83b12d4b2561..000000000000 --- a/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p2.cpp +++ /dev/null @@ -1,49 +0,0 @@ -// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -fsyntax-only -verify %s -std=c++11 - -struct S { - virtual ~S(); - - void g() throw (auto(*)()->int); - - // Note, this is not permitted: conversion-declarator cannot have a trailing return type. - // FIXME: don't issue the second diagnostic for this. - operator auto(*)()->int(); // expected-error{{'auto' not allowed in conversion function type}} expected-error {{C++ requires a type specifier}} -}; - -typedef auto Fun(int a) -> decltype(a + a); -typedef auto (*PFun)(int a) -> decltype(a + a); - -void g(auto (*f)() -> int) { - try { } - catch (auto (&f)() -> int) { } - catch (auto (*const f[10])() -> int) { } -} - -namespace std { - class type_info; -} - -template<typename T> struct U {}; - -void j() { - (void)typeid(auto(*)()->void); - (void)sizeof(auto(*)()->void); - (void)__alignof(auto(*)()->void); - - U<auto(*)()->void> v; - - int n; - (void)static_cast<auto(*)()->void>(&j); - auto p = reinterpret_cast<auto(*)()->int>(&j); - (void)const_cast<auto(**)()->int>(&p); - (void)(auto(*)()->void)(&j); -} - -template <auto (*f)() -> void = &j> class C { }; -struct F : auto(*)()->int {}; // expected-error{{expected class name}} -template<typename T = auto(*)()->int> struct G { }; - -int g(); -auto (*h)() -> auto = &g; // expected-error{{'auto' not allowed in function return type}} -auto (*i)() = &g; // ok; auto deduced as int. -auto (*k)() -> int = i; // ok; no deduction. diff --git a/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p3-1y.cpp b/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p3-1y.cpp deleted file mode 100644 index e8f12156a424..000000000000 --- a/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p3-1y.cpp +++ /dev/null @@ -1,74 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++1y -DCXX1Y -// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11 -Wno-c++1y-extensions - -// FIXME: This is in p11 (?) in C++1y. -void f() { - decltype(auto) a = a; // expected-error{{variable 'a' declared with deduced type 'decltype(auto)' cannot appear in its own initializer}} - if (decltype(auto) b = b) {} // expected-error {{variable 'b' declared with deduced type 'decltype(auto)' cannot appear in its own initializer}} - decltype(auto) c = ({ decltype(auto) d = c; 0; }); // expected-error {{variable 'c' declared with deduced type 'decltype(auto)' cannot appear in its own initializer}} -} - -void g() { - decltype(auto) a; // expected-error{{declaration of variable 'a' with deduced type 'decltype(auto)' requires an initializer}} - - decltype(auto) *b; // expected-error{{cannot form pointer to 'decltype(auto)'}} expected-error{{declaration of variable 'b' with deduced type 'decltype(auto) *' requires an initializer}} - - if (decltype(auto) b) {} // expected-error {{must have an initializer}} - for (;decltype(auto) b;) {} // expected-error {{must have an initializer}} - while (decltype(auto) b) {} // expected-error {{must have an initializer}} - if (decltype(auto) b = true) { (void)b; } -} - -decltype(auto) n(1,2,3); // expected-error{{initializer for variable 'n' with type 'decltype(auto)' contains multiple expressions}} - -namespace N -{ - // All of these are references, because a string literal is an lvalue. - decltype(auto) a = "const char (&)[19]", b = a, c = (a); -} - -void h() { - decltype(auto) b = 42ULL; - - for (decltype(auto) c = 0; c < b; ++c) { - } -} - -template<typename T, typename U> struct same; -template<typename T> struct same<T, T> {}; - -void i() { - decltype(auto) x = 5; - decltype(auto) int r; // expected-error {{cannot combine with previous 'decltype(auto)' declaration specifier}} expected-error {{requires an initializer}} -} - -namespace p3_example { - template<typename T, typename U> struct is_same_impl { - static const bool value = false; - }; - template<typename T> struct is_same_impl<T, T> { - static const bool value = true; - }; - template<typename T, typename U> constexpr bool is_same() { - return is_same_impl<T,U>::value; - } - - auto x = 5; - const auto *v = &x, u = 6; - static auto y = 0.0; - auto int r; // expected-warning {{storage class}} expected-error {{file-scope}} - - static_assert(is_same<decltype(x), int>(), ""); - static_assert(is_same<decltype(v), const int*>(), ""); - static_assert(is_same<decltype(u), const int>(), ""); - static_assert(is_same<decltype(y), double>(), ""); - -#ifdef CXX1Y - auto f() -> int; - auto g() { return 0.0; } - auto h(); - - static_assert(is_same<decltype(f), int()>(), ""); - static_assert(is_same<decltype(g), double()>(), ""); -#endif -} diff --git a/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p3-1z.cpp b/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p3-1z.cpp deleted file mode 100644 index 73caa2de044e..000000000000 --- a/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p3-1z.cpp +++ /dev/null @@ -1,8 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++1z - -// FIXME: This is in p10 (?) in C++1z. -template<typename T> struct A { - A(T); -}; -template<typename T> A(T) -> A<T>; -A a = a; // expected-error{{variable 'a' declared with deduced type 'A' cannot appear in its own initializer}} diff --git a/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p3-generic-lambda-1y.cpp b/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p3-generic-lambda-1y.cpp deleted file mode 100644 index 07bc884e7d5e..000000000000 --- a/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p3-generic-lambda-1y.cpp +++ /dev/null @@ -1,74 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++1y -DCXX1Y - -//FIXME: These tests were written when return type deduction had not been implemented -// for generic lambdas, hence -template<class T> T id(T t); -template<class ... Ts> int vfoo(Ts&& ... ts); -auto GL1 = [](auto a, int i) -> int { return id(a); }; - -auto GL2 = [](auto ... As) -> int { return vfoo(As...); }; -auto GL3 = [](int i, char c, auto* ... As) -> int { return vfoo(As...); }; - -auto GL4 = [](int i, char c, auto* ... As) -> int { return vfoo(As...); }; - - -void foo() { - auto GL1 = [](auto a, int i) -> int { return id(a); }; - - auto GL2 = [](auto ... As) -> int { return vfoo(As...); }; -} - -int main() -{ - auto l1 = [](auto a) -> int { return a + 5; }; - auto l2 = [](auto *p) -> int { return p + 5; }; - - struct A { int i; char f(int) { return 'c'; } }; - auto l3 = [](auto &&ur, - auto &lr, - auto v, - int i, - auto* p, - auto A::*memvar, - auto (A::*memfun)(int), - char c, - decltype (v)* pv - , auto (&array)[5] - ) -> int { return v + i + c - + array[0]; - }; - int arr[5] = {0, 1, 2, 3, 4 }; - int lval = 0; - double d = 3.14; - l3(3, lval, d, lval, &lval, &A::i, &A::f, 'c', &d, arr); - auto l4 = [](decltype(auto) a) -> int { return 0; }; //expected-error{{decltype(auto)}} - { - struct Local { - static int ifi(int i) { return i; } - static char cfi(int) { return 'a'; } - static double dfi(int i) { return i + 3.14; } - static Local localfi(int) { return Local{}; } - }; - auto l4 = [](auto (*fp)(int)) -> int { return fp(3); }; //expected-error{{no viable conversion from returned value of type 'Local' to function return type 'int'}} - l4(&Local::ifi); - l4(&Local::cfi); - l4(&Local::dfi); - l4(&Local::localfi); //expected-note{{in instantiation of function template specialization}} - } - { - auto unnamed_parameter = [](auto, auto) -> void { }; - unnamed_parameter(3, '4'); - } - { - auto l = [](auto - (*)(auto)) { }; //expected-error{{'auto' not allowed}} - //FIXME: These diagnostics might need some work. - auto l2 = [](char auto::*pm) { }; //expected-error{{cannot combine with previous}}\ - expected-error{{'pm' does not point into a class}} - auto l3 = [](char (auto::*pmf)()) { }; //expected-error{{'auto' not allowed}}\ - expected-error{{'pmf' does not point into a class}}\ - expected-error{{function cannot return function type 'char ()'}} - } -} - - diff --git a/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p3.cpp b/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p3.cpp deleted file mode 100644 index 440c78201293..000000000000 --- a/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p3.cpp +++ /dev/null @@ -1,91 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11 -// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++98 -Wno-c++11-extensions -Wc++11-compat -void f() { - auto a = a; // expected-error{{variable 'a' declared with deduced type 'auto' cannot appear in its own initializer}} - auto *b = b; // expected-error{{variable 'b' declared with deduced type 'auto *' cannot appear in its own initializer}} - const auto c = c; // expected-error{{variable 'c' declared with deduced type 'const auto' cannot appear in its own initializer}} - if (auto d = d) {} // expected-error {{variable 'd' declared with deduced type 'auto' cannot appear in its own initializer}} - auto e = ({ auto f = e; 0; }); // expected-error {{variable 'e' declared with deduced type 'auto' cannot appear in its own initializer}} -} - -void g() { - auto a; // expected-error{{declaration of variable 'a' with deduced type 'auto' requires an initializer}} - - auto *b; // expected-error{{declaration of variable 'b' with deduced type 'auto *' requires an initializer}} - - if (auto b) {} // expected-error {{must have an initializer}} - for (;auto b;) {} // expected-error {{must have an initializer}} - while (auto b) {} // expected-error {{must have an initializer}} - if (auto b = true) { (void)b; } -} - -auto n(1,2,3); // expected-error{{initializer for variable 'n' with type 'auto' contains multiple expressions}} - -namespace N -{ - auto a = "const char [16]", *p = &a; -} - -void h() { - auto b = 42ULL; - - for (auto c = 0; c < b; ++c) { - } -} - -template<typename T, typename U> struct same; -template<typename T> struct same<T, T> {}; - -void p3example() { - auto x = 5; - const auto *v = &x, u = 6; - static auto y = 0.0; - // In C++98: 'auto' storage class specifier is redundant and incompatible with C++0x - // In C++0x: 'auto' storage class specifier is not permitted in C++0x, and will not be supported in future releases - auto int r; // expected-warning {{'auto' storage class specifier}} - - same<__typeof(x), int> xHasTypeInt; - same<__typeof(v), const int*> vHasTypeConstIntPtr; - same<__typeof(u), const int> uHasTypeConstInt; - same<__typeof(y), double> yHasTypeDouble; -} - -#if __cplusplus >= 201103L -namespace PR13293 { - // Ensure that dependent declarators have their deduction delayed. - int f(char); - double f(short); - template<typename T> struct S { - static constexpr auto (*p)(T) = &f; - }; - - constexpr int (*f1)(char) = &f; - constexpr double (*f2)(short) = &f; - static_assert(S<char>::p == f1, ""); - static_assert(S<short>::p == f2, ""); - - struct K { int n; }; - template<typename T> struct U { - static constexpr auto (T::*p) = &K::n; - }; - static_assert(U<K>::p == &K::n, ""); - - template<typename T> - using X = auto(int) -> auto(*)(T) -> auto(*)(char) -> long; - X<double> x; - template<typename T> struct V { - //static constexpr auto (*p)(int) -> auto(*)(T) -> auto(*)(char) = &x; // ill-formed - static constexpr auto (*(*(*p)(int))(T))(char) = &x; // ok - }; - V<double> v; - - int *g(double); - template<typename T> void h() { - new (auto(*)(T)) (&g); - } - template void h<double>(); -} -#endif - -auto fail((unknown)); // expected-error{{use of undeclared identifier 'unknown'}} -int& crash = fail; diff --git a/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p4.cpp b/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p4.cpp deleted file mode 100644 index bf1b3092e08e..000000000000 --- a/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p4.cpp +++ /dev/null @@ -1,66 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++1y -// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11 -Wno-c++1y-extensions -// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++98 -Wno-c++11-extensions - -template<typename T> -struct only { - only(T); - template<typename U> only(U) = delete; -}; - -void f() { - if (auto a = true) { - } - - switch (auto a = 0) { - } - - while (auto a = false) { - } - - for (; auto a = false; ) { - } - - new const auto (0); - new (auto) (0.0); - - int arr[] = {1, 2, 3}; - for (auto i : arr) { - } -} - -class X { - static const auto n = 'x'; - - auto m = 0; // expected-error {{'auto' not allowed in non-static class member}} -}; - -struct S { - static const auto a; // expected-error {{declaration of variable 'a' with deduced type 'const auto' requires an initializer}} - static const auto b = 0; - static const int c; -}; -const int S::b; -const auto S::c = 0; - -namespace std { template<typename T> struct initializer_list { initializer_list(); }; } - -// In an initializer of the form ( expression-list ), the expression-list -// shall be a single assigment-expression. -auto parens1(1); -auto parens2(2, 3); // expected-error {{initializer for variable 'parens2' with type 'auto' contains multiple expressions}} -#if __cplusplus >= 201103L -auto parens3({4, 5, 6}); // expected-error {{cannot deduce type for variable 'parens3' with type 'auto' from parenthesized initializer list}} -auto parens4 = [p4(1)] {}; -auto parens5 = [p5(2, 3)] {}; // expected-error {{initializer for lambda capture 'p5' contains multiple expressions}} -auto parens6 = [p6({4, 5, 6})] {}; // expected-error {{cannot deduce type for lambda capture 'p6' from parenthesized initializer list}} -#endif - -#if __cplusplus >= 201402L -namespace std_example { - // The other half of this example is in p3.cpp - auto f() -> int; - auto g() { return 0.0; } - auto h(); -} -#endif 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 deleted file mode 100644 index a260f99f5cf1..000000000000 --- a/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p5.cpp +++ /dev/null @@ -1,67 +0,0 @@ -// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -fsyntax-only -verify %s -std=c++11 - -struct S { - virtual ~S(); - - auto a; // expected-error{{'auto' not allowed in non-static struct member}} - auto *b; // expected-error{{'auto' not allowed in non-static struct member}} - const auto c; // expected-error{{'auto' not allowed in non-static struct member}} - - void f() throw (auto); // expected-error{{'auto' not allowed here}} - - friend auto; // expected-error{{'auto' not allowed in friend declaration}} - - operator auto(); // expected-error{{'auto' not allowed in conversion function type}} -}; - -// PR 9278: auto is not allowed in typedefs, except with a trailing return type. -typedef auto *AutoPtr; // expected-error{{'auto' not allowed in typedef}} -typedef auto (*PFun)(int a); // expected-error{{'auto' not allowed in typedef}} -typedef auto Fun(int a) -> decltype(a + a); - -void g(auto a) { // expected-error{{'auto' not allowed in function prototype}} - try { } - catch (auto &a) { } // expected-error{{'auto' not allowed in exception declaration}} - catch (const auto a) { } // expected-error{{'auto' not allowed in exception declaration}} - try { } catch (auto a) { } // expected-error{{'auto' not allowed in exception declaration}} -} - -void h(auto a[10]) { // expected-error{{'auto' not allowed in function prototype}} -} - -void i(const auto a) { // expected-error{{'auto' not allowed in function prototype}} -} - -namespace std { - class type_info; -} - -template<typename T> struct U {}; - -void j() { - (void)typeid(auto); // expected-error{{'auto' not allowed here}} - (void)sizeof(auto); // expected-error{{'auto' not allowed here}} - (void)__alignof(auto); // expected-error{{'auto' not allowed here}} - - U<auto> v; // expected-error{{'auto' not allowed in template argument}} - - int n; - (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}} - (void)*(auto*)(&n); // expected-error{{'auto' not allowed here}} - (void)auto(n); // expected-error{{expected expression}} - (void)auto{n}; // expected-error{{expected expression}} -} - -template <auto a = 10> class C { }; // expected-error{{'auto' not allowed in template parameter}} -int ints[] = {1, 2, 3}; -template <const auto (*a)[3] = &ints> class D { }; // expected-error{{'auto' not allowed in template parameter}} -enum E : auto {}; // expected-error{{'auto' not allowed here}} -struct F : auto {}; // expected-error{{expected class name}} -template<typename T = auto> struct G { }; // expected-error{{'auto' not allowed in template argument}} - -using A = auto; // expected-error{{'auto' not allowed in type alias}} - -auto k() -> auto; // expected-error{{'auto' not allowed in function return type}} 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 deleted file mode 100644 index 1711aaa8aef9..000000000000 --- a/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p6.cpp +++ /dev/null @@ -1,104 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11 -// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++98 -Wno-c++11-extensions - -template<typename T> -struct only { - only(T); - template<typename U> only(U) = delete; -}; - -namespace N -{ - auto a = "const char [16]", *p = &a; - - only<const char [16]> testA = a; - only<const char **> testP = p; -} - -void h() { - auto b = 42ULL; - only<unsigned long long> testB = b; - - for (auto c = 0; c < 100; ++c) { - only<int> testC = c; - } -} - -void p3example() { - auto x = 5; - const auto *v = &x, u = 6; - static auto y = 0.0; - - only<int> testX = x; - only<const int*> testV = v; - only<const int> testU = u; - only<double> testY = y; -} - -void f() { - if (auto a = true) { - only<bool> testA = a; - } - - switch (auto a = 0) { - case 0: - only<int> testA = a; - } - - while (auto a = false) { - only<bool> testA = a; - } - - for (; auto a = "test"; ) { - only<const char[5]> testA = a; - } - - auto *fail1 = 0; // expected-error {{variable 'fail1' with type 'auto *' has incompatible initializer of type 'int'}} - int **p; - const auto **fail2(p); // expected-error {{variable 'fail2' with type 'const auto **' has incompatible initializer of type 'int **'}} -} - -struct S { - void f(); - char g(int); - float g(double); - int m; - - void test() { - auto p1 = &S::f; - auto S::*p2 = &S::f; - auto (S::*p3)() = &S::f; - auto p4 = &S::g; // expected-error {{incompatible initializer of type '<overloaded function type>'}} - auto S::*p5 = &S::g; // expected-error {{incompatible initializer of type '<overloaded function type>'}} - auto (S::*p6)(int) = &S::g; - auto p7 = &S::m; - auto S::*p8 = &S::m; - - only<void (S::*)()> test1 = p1; - only<void (S::*)()> test2 = p2; - only<void (S::*)()> test3 = p3; - only<char (S::*)(int)> test6 = p6; - only<int (S::*)> test7 = p7; - only<int (S::*)> test8 = p8; - } -}; - -namespace PR10939 { - struct X { - int method(int); // expected-note{{possible target for call}} - int method(float); // expected-note{{possible target for call}} - }; - - template<typename T> T g(T); - - void f(X *x) { - auto value = x->method; // expected-error {{reference to non-static member function must be called}} - if (value) { } - - auto funcptr = &g<int>; - int (*funcptr2)(int) = funcptr; - } -} - -// if the initializer is a braced-init-list, deduce auto as std::initializer_list<T>: -// see SemaCXX/cxx0x-initializer-stdinitializerlist.cpp diff --git a/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p7-1y.cpp b/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p7-1y.cpp deleted file mode 100644 index 60ddabeb4a90..000000000000 --- a/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p7-1y.cpp +++ /dev/null @@ -1,98 +0,0 @@ -// RUN: %clang_cc1 -verify -std=c++1y %s - -namespace std { - template<typename T> struct initializer_list { - const T *p; - unsigned long n; - initializer_list(const T *p, unsigned long n); - }; -} - -int i; -int &&f(); - -template <typename T> -void overloaded_fn(T); // expected-note {{possible target}} - -using Int = int; -using IntLRef = int&; -using IntRRef = int&&; -using InitListInt = std::initializer_list<int>; -using IntPtr = int*; - -auto x3a = i; -decltype(auto) x3d = i; -using Int = decltype(x3a); -using Int = decltype(x3d); - -auto x4a = (i); -decltype(auto) x4d = (i); -using Int = decltype(x4a); -using IntLRef = decltype(x4d); - -auto x5a = f(); -decltype(auto) x5d = f(); -using Int = decltype(x5a); -using IntRRef = decltype(x5d); - -auto x6a = { 1, 2 }; -decltype(auto) x6d = { 1, 2 }; // expected-error {{cannot deduce 'decltype(auto)' from initializer list}} -using InitListInt = decltype(x6a); - -auto *x7a = &i; -decltype(auto) *x7d = &i; // expected-error {{cannot form pointer to 'decltype(auto)'}} -using IntPtr = decltype(x7a); - -struct S {}; - -decltype(auto) f1(); -decltype(auto) (*f2)(); // expected-error {{'decltype(auto)' can only be used as a return type in a function declaration}} expected-error {{requires an initializer}} -decltype(auto) *f3(); // expected-error {{cannot form pointer to 'decltype(auto)'}} -const decltype(auto) f4(); // expected-error {{'decltype(auto)' cannot be combined with other type specifiers}} -typedef decltype(auto) f5(); // expected-error {{'decltype(auto)' not allowed in typedef}} -decltype(auto) ((((((f6))))())); // ok -decltype(auto) f7()(); // expected-error {{'decltype(auto)' can only be used as a return type in a function declaration}} -decltype(auto) (S::*f8)(); // expected-error {{'decltype(auto)' can only be used as a return type in a function declaration}} expected-error {{requires an initializer}} -decltype(auto) &f9(); // expected-error {{cannot form reference to 'decltype(auto)'}} -decltype(auto) (&f10())[10]; // expected-error {{cannot form array of 'decltype(auto)'}} - -decltype(auto) ((((((v1)))))) = 0; // ok -decltype(auto) v2[1] = { 0 }; // expected-error {{cannot form array of 'decltype(auto)'}} -decltype(auto) &v3 = { 0 }; // expected-error {{cannot form reference to 'decltype(auto)'}} -decltype(auto) *v4 = { 0 }; // expected-error {{cannot form pointer to 'decltype(auto)'}} -decltype(auto) v5 = &overloaded_fn; // expected-error {{could not be resolved}} - -auto multi1a = 0, &multi1b = multi1a; -auto multi1c = multi1a, multi1d = multi1b; -decltype(auto) multi1e = multi1a, multi1f = multi1b; // expected-error {{'decltype(auto)' deduced as 'int' in declaration of 'multi1e' and deduced as 'int &' in declaration of 'multi1f'}} - -auto f1a() { return 0; } -decltype(auto) f1d() { return 0; } -using Int = decltype(f1a()); -using Int = decltype(f1d()); - -auto f2a(int n) { return n; } -decltype(auto) f2d(int n) { return n; } -using Int = decltype(f2a(0)); -using Int = decltype(f2d(0)); - -auto f3a(int n) { return (n); } -decltype(auto) f3d(int n) { return (n); } // expected-warning {{reference to stack memory}} -using Int = decltype(f3a(0)); -using IntLRef = decltype(f3d(0)); - -auto f4a(int n) { return f(); } -decltype(auto) f4d(int n) { return f(); } -using Int = decltype(f4a(0)); -using IntRRef = decltype(f4d(0)); - -auto f5aa(int n) { auto x = f(); return x; } -auto f5ad(int n) { decltype(auto) x = f(); return x; } -decltype(auto) f5da(int n) { auto x = f(); return x; } -decltype(auto) f5dd(int n) { decltype(auto) x = f(); return x; } // expected-error {{rvalue reference to type 'int' cannot bind to lvalue}} -using Int = decltype(f5aa(0)); -using Int = decltype(f5ad(0)); -using Int = decltype(f5da(0)); - -auto init_list_1() { return { 1, 2, 3 }; } // expected-error {{cannot deduce return type from initializer list}} -decltype(auto) init_list_2() { return { 1, 2, 3 }; } // expected-error {{cannot deduce return type from initializer list}} diff --git a/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p7.cpp b/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p7.cpp deleted file mode 100644 index e9294d7f4362..000000000000 --- a/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p7.cpp +++ /dev/null @@ -1,66 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++14 -// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11 -// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++98 -Wno-c++11-extensions -void f() { - auto a = 0, b = 0, c = 0; - auto d = 0, e = 0.0; // expected-error {{'int' in declaration of 'd' and deduced as 'double' in declaration of 'e'}} - - auto v1 = 0, *p1 = &v1; - auto *p2 = 0, v2 = *p2; // expected-error {{incompatible initializer}} - - const int k = 0; - auto &f = k, &g = a; // expected-error {{'const int' in declaration of 'f' and deduced as 'int' in declaration of 'g'}} - - typedef int I; - I x; - auto xa = x, xb = 0; - - auto &&ra1 = a, rb1 = b; // expected-error {{'int &' in declaration of 'ra1' and deduced as 'int' in declaration of 'rb1'}} - auto &&ra2 = +a, rb2 = b; -} - -void g() { -#if __has_feature(cxx_trailing_return) - auto a = 0, - (*b)() -> void, // expected-error {{declaration with trailing return type must be the only declaration in its group}} - c = 0; - auto d = 0, - e() -> void, // expected-error {{declaration with trailing return type must be the only declaration in its group}} - f = 0.0; - auto x() -> void, // expected-error {{declaration with trailing return type must be the only declaration in its group}} - y() -> void; -#endif - -#if __has_feature(cxx_decltype) - auto g = 0ull, h = decltype(g)(0); -#endif -} - -#if __has_feature(cxx_trailing_return) -int F(); -auto p = 0, (*q)() -> auto = F; // expected-error {{declaration with trailing return type must be the only declaration in its group}} - #if __cplusplus < 201402L - // expected-error@-2 {{'auto' not allowed in function return type}} - #endif -#endif - -#if __cplusplus >= 201402L -namespace DeducedReturnType { - auto a = 0, - b(), // expected-error {{function with deduced return type must be the only declaration in its group}} - c = 0.0; - auto d(), // expected-error {{function with deduced return type must be the only declaration in its group}} - e = 1; - auto f(), // expected-error {{function with deduced return type must be the only declaration in its group}} - g(); -} -#endif - -template<typename T> void h() { - auto a = T(), *b = &a; -#if __has_feature(cxx_decltype) - auto c = T(), d = decltype(c)(0); -#endif -} -template void h<int>(); -template void h<unsigned long>(); diff --git a/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.class.deduct/p1.cpp b/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.class.deduct/p1.cpp deleted file mode 100644 index 96be58f8eb5f..000000000000 --- a/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.class.deduct/p1.cpp +++ /dev/null @@ -1,19 +0,0 @@ -// RUN: %clang_cc1 -std=c++1z -verify %s - -template<typename T> struct A { constexpr A(int = 0) {} }; -A() -> A<int>; -A(int) -> A<char>; - -static constexpr inline const volatile A a = {}; // ok, specifiers are permitted -A b; -A c [[]] {}; - -A d = {}, e = {}; -A f(0), g{}; // expected-error {{template arguments deduced as 'A<char>' in declaration of 'f' and deduced as 'A<int>' in declaration of 'g'}} - -struct B { - static A a; // expected-error {{requires an initializer}} -}; -extern A x; // expected-error {{requires an initializer}} -static A y; - diff --git a/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.elab/p1.cpp b/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.elab/p1.cpp deleted file mode 100644 index e3982fd6a838..000000000000 --- a/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.elab/p1.cpp +++ /dev/null @@ -1,26 +0,0 @@ -// RUN: %clang_cc1 -verify %s -std=c++11 - -namespace N { - struct A; - template<typename T> struct B {}; -} -template<typename T> struct C {}; -struct D { - template<typename T> struct A {}; -}; -struct N::A; // expected-error {{cannot have a nested name specifier}} - -template<typename T> struct N::B; // expected-error {{cannot have a nested name specifier}} -template<typename T> struct N::B<T*>; // FIXME: This is technically ill-formed, but that's not the intent. -template<> struct N::B<int>; -template struct N::B<float>; - -template<typename T> struct C; -template<typename T> struct C<T*>; // FIXME: This is technically ill-formed, but that's not the intent. -template<> struct C<int>; -template struct C<float>; - -template<typename T> struct D::A; // expected-error {{cannot have a nested name specifier}} -template<typename T> struct D::A<T*>; // FIXME: This is technically ill-formed, but that's not the intent. -template<> struct D::A<int>; -template struct D::A<float>; diff --git a/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.elab/p2-0x.cpp b/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.elab/p2-0x.cpp deleted file mode 100644 index f3e79c0aae44..000000000000 --- a/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.elab/p2-0x.cpp +++ /dev/null @@ -1,19 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s - -struct A { typedef int type; }; -template<typename T> using X = A; // expected-note {{declared here}} -struct X<int>* p2; // expected-error {{type alias template 'X' cannot be referenced with a struct specifier}} - - -template<typename T> using Id = T; // expected-note {{declared here}} -template<template<typename> class F> -struct Y { - struct F<int> i; // expected-error {{type alias template 'Id' cannot be referenced with a struct specifier}} - typename F<A>::type j; // ok - - // FIXME: don't produce the diagnostic both for the definition and the instantiation. - template<typename T> using U = F<char>; // expected-note 2{{declared here}} - struct Y<F>::template U<char> k; // expected-error 2{{type alias template 'U' cannot be referenced with a struct specifier}} - typename Y<F>::template U<char> l; // ok -}; -template struct Y<Id>; // expected-note {{requested here}} diff --git a/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.elab/p3.cpp b/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.elab/p3.cpp deleted file mode 100644 index 19406518402f..000000000000 --- a/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.elab/p3.cpp +++ /dev/null @@ -1,66 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s - -class A {}; // expected-note 4 {{previous use is here}} -enum E {}; - -void a1(struct A); -void a2(class A); -void a3(union A); // expected-error {{use of 'A' with tag type that does not match previous declaration}} -void a4(enum A); // expected-error {{use of 'A' with tag type that does not match previous declaration}} - -class A1 { - friend struct A; - friend class A; - friend union A; // expected-error {{use of 'A' with tag type that does not match previous declaration}} - - friend enum A; // expected-error {{use of 'A' with tag type that does not match previous declaration}} - friend enum E; -#if __cplusplus <= 199711L // C++03 or earlier modes - // expected-warning@-2 {{befriending enumeration type 'enum E' is a C++11 extension}} -#endif -}; - -template <class T> struct B { // expected-note {{previous use is here}} - class Member {}; // expected-note 2 {{previous use is here}} -}; - -template <> class B<int> { - // no type Member -}; - -template <> struct B<A> { - union Member { // expected-note 4 {{previous use is here}} - void* a; - }; -}; - -void b1(struct B<float>); -void b2(class B<float>); -void b3(union B<float>); // expected-error {{use of 'B<float>' with tag type that does not match previous declaration}} -//void b4(enum B<float>); // this just doesn't parse; you can't template an enum directly - -void c1(struct B<float>::Member); -void c2(class B<float>::Member); -void c3(union B<float>::Member); // expected-error {{use of 'Member' with tag type that does not match previous declaration}} -void c4(enum B<float>::Member); // expected-error {{use of 'Member' with tag type that does not match previous declaration}} - -void d1(struct B<int>::Member); // expected-error {{no struct named 'Member' in 'B<int>'}} -void d2(class B<int>::Member); // expected-error {{no class named 'Member' in 'B<int>'}} -void d3(union B<int>::Member); // expected-error {{no union named 'Member' in 'B<int>'}} -void d4(enum B<int>::Member); // expected-error {{no enum named 'Member' in 'B<int>'}} - -void e1(struct B<A>::Member); // expected-error {{use of 'Member' with tag type that does not match previous declaration}} -void e2(class B<A>::Member); // expected-error {{use of 'Member' with tag type that does not match previous declaration}} -void e3(union B<A>::Member); -void e4(enum B<A>::Member); // expected-error {{use of 'Member' with tag type that does not match previous declaration}} - -template <class T> struct C { - void foo(class B<T>::Member); // expected-error{{no class named 'Member' in 'B<int>'}} \ - // expected-error{{use of 'Member' with tag type that does not match previous declaration}} -}; - -C<float> f1; -C<int> f2; // expected-note {{in instantiation of template class}} -C<A> f3; // expected-note {{in instantiation of template class}} diff --git a/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.simple/p4-cxx0x.cpp b/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.simple/p4-cxx0x.cpp deleted file mode 100644 index ee952aeaf0c9..000000000000 --- a/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.simple/p4-cxx0x.cpp +++ /dev/null @@ -1,32 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s - -template<typename T, typename U> -struct is_same { - static const bool value = false; -}; - -template<typename T> -struct is_same<T, T> { - static const bool value = true; -}; - -const int&& foo(); -int i; -struct A { - double x; - static int y; -}; -const A* a = new A(); - -static_assert(is_same<decltype(foo()), const int&&>::value, ""); -static_assert(is_same<decltype(i), int>::value, ""); -static_assert(is_same<decltype(a->x), double>::value, ""); -static_assert(is_same<decltype((a->x)), const double&>::value, ""); -static_assert(is_same<decltype(a->y), int>::value, ""); -static_assert(is_same<decltype((a->y)), int&>::value, ""); -static_assert(is_same<decltype(static_cast<int&&>(i)), int&&>::value, ""); - -int f0(int); // expected-note{{possible target}} -float f0(float); // expected-note{{possible target}} - -decltype(f0) f0_a; // expected-error{{reference to overloaded function could not be resolved; did you mean to call it?}} diff --git a/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.simple/p5-cxx0x.cpp b/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.simple/p5-cxx0x.cpp deleted file mode 100644 index 7f1b3b0f240e..000000000000 --- a/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.simple/p5-cxx0x.cpp +++ /dev/null @@ -1,120 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -verify %s - -namespace std_example { - -template<class T> struct A { ~A() = delete; }; // expected-note {{deleted here}} -template<class T> auto h() -> A<T>; -template<class T> auto i(T) -> T; -template<class T> auto f(T) -> decltype(i(h<T>())); // #1 -template<class T> auto f(T) -> void; // #2 -auto g() -> void { - f(42); // ok, calls #2, since #1 is not viable. -} -template<class T> auto q(T) -> decltype((h<T>())); -void r() { - // Deduction against q succeeds, but results in a temporary which can't be - // destroyed. - q(42); // expected-error {{attempt to use a deleted function}} -} - -} - -class PD { - friend struct A; - ~PD(); // expected-note 5{{here}} -public: - typedef int n; -}; -struct DD { - ~DD() = delete; // expected-note 2{{here}} - typedef int n; -}; - -PD pd(); -DD dd(); - -struct A { - decltype(pd()) s; // ok - decltype(pd())::n n; // ok - decltype(dd()) *p = new decltype(dd()); // ok -}; -A a(); - -// Two errors here: one for the decltype, one for the variable. -decltype( - pd(), // expected-error {{private destructor}} - pd()) pd1; // expected-error {{private destructor}} -decltype(dd(), // expected-error {{deleted function}} - dd()) dd1; -decltype(a(), - dd()) dd2; // expected-error {{deleted function}} -decltype( - pd(), // expected-error {{temporary of type 'PD' has private destructor}} - 0) pd2; - -decltype(((13, ((dd())))))::n dd_parens; // ok -decltype(((((42)), pd())))::n pd_parens_comma; // ok - -// Ensure parens aren't stripped from a decltype node. -extern decltype(pd()) pd_ref; // ok -decltype((pd_ref)) pd_ref3 = pd_ref; // ok, PD & -decltype(pd_ref) pd_ref2 = pd_ref; // expected-error {{private destructor}} - -namespace libcxx_example { - struct nat { - nat() = delete; - nat(const nat&) = delete; - nat &operator=(const nat&) = delete; - ~nat() = delete; - }; - struct any { - any(...); - }; - - template<typename T, typename U> struct is_same { static const bool value = false; }; - template<typename T> struct is_same<T, T> { static const bool value = true; }; - - template<typename T> T declval(); - - void swap(int &a, int &b); - nat swap(any, any); - - template<typename T> struct swappable { - typedef decltype(swap(declval<T&>(), declval<T&>())) type; - static const bool value = !is_same<type, nat>::value; - constexpr operator bool() const { return value; } - }; - - static_assert(swappable<int>(), ""); - static_assert(!swappable<const int>(), ""); -} - -namespace RequireCompleteType { - template<int N, bool OK> struct S { - static_assert(OK, "boom!"); // expected-error 2{{boom!}} - }; - - template<typename T> T make(); - template<int N, bool OK> S<N, OK> make(); - void consume(...); - - decltype(make<0, false>()) *p1; // ok - decltype((make<1, false>())) *p2; // ok - - // A complete type is required here in order to detect an overloaded 'operator,'. - decltype(123, make<2, false>()) *p3; // expected-note {{here}} - - decltype(consume(make<3, false>())) *p4; // expected-note {{here}} - - decltype(make<decltype(make<4, false>())>()) *p5; // ok -} - -namespace Overload { - DD operator+(PD &a, PD &b); - decltype(pd()) *pd_ptr; - decltype(*pd_ptr + *pd_ptr) *dd_ptr; // ok - - decltype(0, *pd_ptr) pd_ref2 = pd_ref; // ok - DD operator,(int a, PD b); - decltype(0, *pd_ptr) *dd_ptr2; // expected-error {{private destructor}} -} diff --git a/test/CXX/dcl.dcl/dcl.spec/dcl.type/p3-0x.cpp b/test/CXX/dcl.dcl/dcl.spec/dcl.type/p3-0x.cpp deleted file mode 100644 index 447f7c5d6cf3..000000000000 --- a/test/CXX/dcl.dcl/dcl.spec/dcl.type/p3-0x.cpp +++ /dev/null @@ -1,46 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s -fcxx-exceptions - -using X = struct { // ok -}; -template<typename T> using Y = struct { // expected-error {{cannot be defined in a type alias template}} -}; - -class K { - virtual ~K(); - operator struct S {} (); // expected-error{{'K::S' cannot be defined in a type specifier}} -}; - -struct A {}; - -void f() { - int arr[3] = {1,2,3}; - - for (struct S { S(int) {} } s : arr) { // expected-error {{types may not be defined in a for range declaration}} - } - - for (struct S { S(int) {} } s : Undeclared); // expected-error{{types may not be defined in a for range declaration}} - // expected-error@-1{{use of undeclared identifier 'Undeclared'}} - - new struct T {}; // expected-error {{'T' cannot be defined in a type specifier}} - new struct A {}; // expected-error {{'A' cannot be defined in a type specifier}} - - try {} catch (struct U {}) {} // expected-error {{'U' cannot be defined in a type specifier}} - - (void)(struct V { V(int); })0; // expected-error {{'V' cannot be defined in a type specifier}} - - (void)dynamic_cast<struct W {}*>((K*)0); // expected-error {{'W' cannot be defined in a type specifier}} - (void)static_cast<struct X {}*>(0); // expected-error {{'X' cannot be defined in a type specifier}} - (void)reinterpret_cast<struct Y {}*>(0); // expected-error {{'Y' cannot be defined in a type specifier}} - (void)const_cast<struct Z {}*>((const Z*)0); // expected-error {{'Z' cannot be defined in a type specifier}} -} - -void g() throw (struct Ex {}) { // expected-error {{'Ex' cannot be defined in a type specifier}} -} - -alignas(struct Aa {}) int x; // expected-error {{'Aa' cannot be defined in a type specifier}} - -int a = sizeof(struct So {}); // expected-error {{'So' cannot be defined in a type specifier}} -int b = alignof(struct Ao {}); // expected-error {{'Ao' cannot be defined in a type specifier}} - -namespace std { struct type_info; } -const std::type_info &ti = typeid(struct Ti {}); // expected-error {{'Ti' cannot be defined in a type specifier}} diff --git a/test/CXX/dcl.dcl/dcl.spec/dcl.typedef/p2-0x.cpp b/test/CXX/dcl.dcl/dcl.spec/dcl.typedef/p2-0x.cpp deleted file mode 100644 index 8c6f6e5ddc79..000000000000 --- a/test/CXX/dcl.dcl/dcl.spec/dcl.typedef/p2-0x.cpp +++ /dev/null @@ -1,156 +0,0 @@ -// RUN: %clang_cc1 -verify -std=c++11 %s - -namespace RedeclAliasTypedef { - typedef int T; - using T = int; - using T = int; - typedef T T; - using T = T; - typedef int T; -} - -namespace IllegalTypeIds { - using A = void(int n = 0); // expected-error {{default arguments can only be specified for parameters in a function declaration}} - using B = inline void(int n); // expected-error {{type name does not allow function specifier}} - using C = virtual void(int n); // expected-error {{type name does not allow function specifier}} - using D = explicit void(int n); // expected-error {{type name does not allow function specifier}} - using E = void(int n) throw(); // expected-error {{exception specifications are not allowed in type aliases}} - using F = void(*)(int n) &&; // expected-error {{pointer to function type cannot have '&&' qualifier}} - using G = __thread void(int n); // expected-error {{type name does not allow storage class to be specified}} - using H = constexpr int; // expected-error {{type name does not allow constexpr specifier}} - - using Y = void(int n); // ok - using Z = void(int n) &&; // ok -} - -namespace IllegalSyntax { - using ::T = void(int n); // expected-error {{name defined in alias declaration must be an identifier}} - using operator int = void(int n); // expected-error {{name defined in alias declaration must be an identifier}} - using typename U = void; // expected-error {{name defined in alias declaration must be an identifier}} - using typename ::V = void(int n); // expected-error {{name defined in alias declaration must be an identifier}} - using typename ::operator bool = void(int n); // expected-error {{name defined in alias declaration must be an identifier}} -} - -namespace VariableLengthArrays { - using T = int[42]; // ok - - int n = 32; - using T = int[n]; // expected-error {{variable length array declaration not allowed at file scope}} - - const int m = 42; - using U = int[m]; - using U = int[42]; // expected-note {{previous definition}} - using U = int; // expected-error {{type alias redefinition with different types ('int' vs 'int [42]')}} - - void f() { - int n = 42; - goto foo; // expected-error {{cannot jump}} - using T = int[n]; // expected-note {{bypasses initialization of VLA type alias}} - foo: ; - } -} - -namespace RedeclFunc { - int f(int, char**); - using T = int; - T f(int, char **); // ok -} - -namespace LookupFilter { - namespace N { struct S; } - using namespace N; - using S = S*; // ok -} - -namespace InFunctions { - template<typename...T> void f0() { - using U = T*; // expected-error {{declaration type contains unexpanded parameter pack 'T'}} - U u; - } - template void f0<int, char>(); - - void f1() { - using T = int; - } - void f2() { - using T = int[-1]; // expected-error {{array size is negative}} - } - - template<typename...T> void f3() { // expected-note {{template parameter is declared here}} - using T = int; // expected-error {{declaration of 'T' shadows template parameter}} - } -} - -namespace ClassNameRedecl { - class C0 { - using C0 = int; // expected-error {{member 'C0' has the same name as its class}} - }; - class C1 { - using C1 = C1; // expected-error {{member 'C1' has the same name as its class}} - }; - class C2 { - using C0 = C1; // ok - }; - template<typename...T> class C3 { - using f = T; // expected-error {{declaration type contains unexpanded parameter pack 'T'}} - }; - template<typename T> class C4 { // expected-note {{template parameter is declared here}} - using T = int; // expected-error {{declaration of 'T' shadows template parameter}} - }; - class C5 { - class c; // expected-note {{previous definition}} - using c = int; // expected-error {{typedef redefinition with different types}} - class d; - using d = d; // ok - }; - class C6 { - class c { using C6 = int; }; // ok - }; -} - -class CtorDtorName { - using X = CtorDtorName; - X(); // expected-error {{expected member name}} - ~X(); // expected-error {{destructor cannot be declared using a type alias}} -}; - -namespace TagName { - using S = struct { int n; }; - using T = class { int n; }; - using U = enum { a, b, c }; - using V = struct V { int n; }; -} - -namespace CWG1044 { - using T = T; // expected-error {{unknown type name 'T'}} -} - -namespace StdExample { - template<typename T, typename U> struct pair; - - using handler_t = void (*)(int); - extern handler_t ignore; - extern void (*ignore)(int); - // FIXME: we know we're parsing a type here; don't recover as if we were - // using operator*. - using cell = pair<void*, cell*>; // expected-error {{use of undeclared identifier 'cell'}} \ - expected-error {{expected expression}} -} - -namespace Access { - class C0 { - using U = int; // expected-note {{declared private here}} - }; - C0::U v; // expected-error {{'U' is a private member}} - class C1 { - public: - using U = int; - }; - C1::U w; // ok -} - -namespace VoidArg { - using V = void; - V f(int); // ok - V g(V); // ok (DR577) -} diff --git a/test/CXX/dcl.dcl/dcl.spec/dcl.typedef/p3.cpp b/test/CXX/dcl.dcl/dcl.spec/dcl.typedef/p3.cpp deleted file mode 100644 index 28f49d083647..000000000000 --- a/test/CXX/dcl.dcl/dcl.spec/dcl.typedef/p3.cpp +++ /dev/null @@ -1,8 +0,0 @@ -// RUN: %clang_cc1 -verify %s - -typedef struct s { int x; } s; -typedef int I; -typedef int I2; -typedef I2 I; // expected-note {{previous definition is here}} - -typedef char I; // expected-error {{typedef redefinition with different types}} diff --git a/test/CXX/dcl.dcl/dcl.spec/dcl.typedef/p4.cpp b/test/CXX/dcl.dcl/dcl.spec/dcl.typedef/p4.cpp deleted file mode 100644 index c16ba201df72..000000000000 --- a/test/CXX/dcl.dcl/dcl.spec/dcl.typedef/p4.cpp +++ /dev/null @@ -1,15 +0,0 @@ -// RUN: %clang_cc1 -verify %s - -struct S { - typedef struct A {} A; // expected-note {{previous definition is here}} - typedef struct B B; - typedef A A; // expected-error {{redefinition of 'A'}} - - struct C { }; - typedef struct C OtherC; - typedef OtherC C; - - typedef struct D { } D2; - typedef D2 D; -}; - diff --git a/test/CXX/dcl.dcl/p4-0x.cpp b/test/CXX/dcl.dcl/p4-0x.cpp deleted file mode 100644 index 1f4cdda1a1f5..000000000000 --- a/test/CXX/dcl.dcl/p4-0x.cpp +++ /dev/null @@ -1,21 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -verify -fsyntax-only %s - -struct S { - constexpr S(bool b) : b(b) {} - constexpr explicit operator bool() const { return b; } - bool b; -}; -struct T { - constexpr operator int() const { return 1; } -}; -struct U { - constexpr operator int() const { return 1; } // expected-note {{candidate}} - constexpr operator long() const { return 0; } // expected-note {{candidate}} -}; - -static_assert(S(true), ""); -static_assert(S(false), "not so fast"); // expected-error {{not so fast}} -static_assert(T(), ""); -static_assert(U(), ""); // expected-error {{ambiguous}} - -static_assert(false, L"\x14hi" "!" R"x(")x"); // expected-error {{static_assert failed L"\024hi!\""}} diff --git a/test/CXX/dcl.decl/dcl.decomp/p2.cpp b/test/CXX/dcl.decl/dcl.decomp/p2.cpp deleted file mode 100644 index 211719a7e9c6..000000000000 --- a/test/CXX/dcl.decl/dcl.decomp/p2.cpp +++ /dev/null @@ -1,34 +0,0 @@ -// RUN: %clang_cc1 -std=c++1z -verify %s -Wpedantic - -struct X { - X(int); - X(const X&) = delete; -}; - -int array() { - static int arr[3] = {}; - auto [a, b, c] = arr; - static_assert(&a != &arr[0]); - - using I3 = int[3]; - auto [a2, b2, c2] = I3{1, 2, 3}; - - using X3 = X[3]; - auto [a3, b3, c3] = X3{1, 2, 3}; - - auto &[d, e] = arr; // expected-error {{type 'int [3]' decomposes into 3 elements, but only 2 names were provided}} - auto &[f, g, h, i] = arr; // expected-error {{type 'int [3]' decomposes into 3 elements, but 4 names were provided}} - - auto &[r0, r1, r2] = arr; - const auto &[cr0, cr1, cr2] = arr; - - static_assert(&arr[0] == &r0); - static_assert(&arr[0] == &cr0); - - using T = int; - using T = decltype(r0); - using U = const int; - using U = decltype(cr0); - - return r1 + cr2; -} diff --git a/test/CXX/dcl.decl/dcl.decomp/p3.cpp b/test/CXX/dcl.decl/dcl.decomp/p3.cpp deleted file mode 100644 index b3f0cf187446..000000000000 --- a/test/CXX/dcl.decl/dcl.decomp/p3.cpp +++ /dev/null @@ -1,297 +0,0 @@ -// RUN: %clang_cc1 -std=c++1z -verify %s - -using size_t = decltype(sizeof(0)); - -struct A { int x, y; }; -struct B { int x, y; }; - -void no_tuple_size_1() { auto [x, y] = A(); } // ok, decompose elementwise - -namespace std { template<typename T> struct tuple_size; } -void no_tuple_size_2() { auto [x, y] = A(); } // ok, decompose elementwise - -struct Bad1 { int a, b; }; -template<> struct std::tuple_size<Bad1> {}; -void no_tuple_size_3() { auto [x, y] = Bad1(); } // expected-error {{cannot decompose this type; 'std::tuple_size<Bad1>::value' is not a valid integral constant expression}} - -struct Bad2 {}; -template<> struct std::tuple_size<Bad2> { const int value = 5; }; -void no_tuple_size_4() { auto [x, y] = Bad2(); } // expected-error {{cannot decompose this type; 'std::tuple_size<Bad2>::value' is not a valid integral constant expression}} - -template<> struct std::tuple_size<A> { static const int value = 3; }; -template<> struct std::tuple_size<B> { enum { value = 3 }; }; - -void no_get_1() { - { - auto [a0, a1] = A(); // expected-error {{decomposes into 3 elements}} - auto [b0, b1] = B(); // expected-error {{decomposes into 3 elements}} - } - auto [a0, a1, a2] = A(); // expected-error {{undeclared identifier 'get'}} expected-note {{in implicit initialization of binding declaration 'a0'}} -} - -int get(A); - -void no_get_2() { - // FIXME: This diagnostic is not great. - auto [a0, a1, a2] = A(); // expected-error {{undeclared identifier 'get'}} expected-note {{in implicit initialization of binding declaration 'a0'}} -} - -template<int> float &get(A); // expected-note 2 {{no known conversion}} - -void no_tuple_element_1() { - auto [a0, a1, a2] = A(); // expected-error-re {{'std::tuple_element<0U{{L*}}, A>::type' does not name a type}} expected-note {{in implicit}} -} - -namespace std { template<size_t, typename> struct tuple_element; } // expected-note 2{{here}} - -void no_tuple_element_2() { - auto [a0, a1, a2] = A(); // expected-error {{implicit instantiation of undefined template 'std::tuple_element<0, A>'}} expected-note {{in implicit}} -} - -template<> struct std::tuple_element<0, A> { typedef float type; }; - -void no_tuple_element_3() { - auto [a0, a1, a2] = A(); // expected-error {{implicit instantiation of undefined template 'std::tuple_element<1, A>'}} expected-note {{in implicit}} -} - -template<> struct std::tuple_element<1, A> { typedef float &type; }; -template<> struct std::tuple_element<2, A> { typedef const float &type; }; - -template<int N> auto get(B) -> int (&)[N + 1]; // expected-note 2 {{no known conversion}} -template<int N> struct std::tuple_element<N, B> { typedef int type[N +1 ]; }; - -template<typename T> struct std::tuple_size<const T> : std::tuple_size<T> {}; -template<size_t N, typename T> struct std::tuple_element<N, const T> { - typedef const typename std::tuple_element<N, T>::type type; -}; - -void referenced_type() { - auto [a0, a1, a2] = A(); - auto [b0, b1, b2] = B(); - - A a; - B b; - auto &[ar0, ar1, ar2] = a; - auto &[br0, br1, br2] = b; - - auto &&[arr0, arr1, arr2] = A(); - auto &&[brr0, brr1, brr2] = B(); - - const auto &[acr0, acr1, acr2] = A(); - const auto &[bcr0, bcr1, bcr2] = B(); - - - using Float = float; - using Float = decltype(a0); - using Float = decltype(ar0); - using Float = decltype(arr0); - - using ConstFloat = const float; - using ConstFloat = decltype(acr0); - - using FloatRef = float&; - using FloatRef = decltype(a1); - using FloatRef = decltype(ar1); - using FloatRef = decltype(arr1); - using FloatRef = decltype(acr1); - - using ConstFloatRef = const float&; - using ConstFloatRef = decltype(a2); - using ConstFloatRef = decltype(ar2); - using ConstFloatRef = decltype(arr2); - using ConstFloatRef = decltype(acr2); - - - using Int1 = int[1]; - using Int1 = decltype(b0); - using Int1 = decltype(br0); - using Int1 = decltype(brr0); - - using ConstInt1 = const int[1]; - using ConstInt1 = decltype(bcr0); - - using Int2 = int[2]; - using Int2 = decltype(b1); - using Int2 = decltype(br1); - using Int2 = decltype(brr1); - - using ConstInt2 = const int[2]; - using ConstInt2 = decltype(bcr1); - - using Int3 = int[3]; - using Int3 = decltype(b2); - using Int3 = decltype(br2); - using Int3 = decltype(brr2); - - using ConstInt3 = const int[3]; - using ConstInt3 = decltype(bcr2); -} - -struct C { template<int> int get(); }; -template<> struct std::tuple_size<C> { static const int value = 1; }; -template<> struct std::tuple_element<0, C> { typedef int type; }; - -int member_get() { - auto [c] = C(); - using T = int; - using T = decltype(c); - return c; -} - -struct D { - // FIXME: Emit a note here explaining why this was ignored. - template<int> struct get {}; -}; -template<> struct std::tuple_size<D> { static const int value = 1; }; -template<> struct std::tuple_element<0, D> { typedef D::get<0> type; }; -void member_get_class_template() { - auto [d] = D(); // expected-error {{no matching function for call to 'get'}} expected-note {{in implicit init}} -} - -struct E { - // FIXME: Emit a note here explaining why this was ignored. - int get(); -}; -template<> struct std::tuple_size<E> { static const int value = 1; }; -template<> struct std::tuple_element<0, E> { typedef int type; }; -void member_get_non_template() { - // FIXME: This diagnostic is not very good. - auto [e] = E(); // expected-error {{no matching function for call to 'get'}} expected-note {{in implicit init}} -} - -namespace ADL { - struct X {}; -}; -template<int> int get(ADL::X); -template<> struct std::tuple_size<ADL::X> { static const int value = 1; }; -template<> struct std::tuple_element<0, ADL::X> { typedef int type; }; -void adl_only_bad() { - auto [x] = ADL::X(); // expected-error {{undeclared identifier 'get'}} expected-note {{in implicit init}} -} - -template<typename ElemType, typename GetTypeLV, typename GetTypeRV> -struct wrap { - template<size_t> GetTypeLV get() &; - template<size_t> GetTypeRV get() &&; -}; -template<typename ET, typename GTL, typename GTR> -struct std::tuple_size<wrap<ET, GTL, GTR>> { - static const int value = 1; -}; -template<typename ET, typename GTL, typename GTR> -struct std::tuple_element<0, wrap<ET, GTL, GTR>> { - using type = ET; -}; - -template<typename T> T &lvalue(); - -void test_value_category() { - // If the declared variable is an lvalue reference, the operand to get is an - // lvalue. Otherwise it's an xvalue. - { auto [a] = wrap<int, void, int>(); } - { auto &[a] = lvalue<wrap<int, int, void>>(); } - { auto &&[a] = wrap<int, void, int>(); } - // If the initializer (call to get) is an lvalue, the binding is an lvalue - // reference to the element type. Otherwise it's an rvalue reference to the - // element type. - { auto [a] = wrap<int, void, int&>(); } - { auto [a] = wrap<int&, void, int&>(); } - { auto [a] = wrap<int&&, void, int&>(); } // ok, reference collapse to int& - - { auto [a] = wrap<int, void, int&&>(); } - { auto [a] = wrap<int&, void, int&&>(); } // expected-error {{non-const lvalue reference to type 'int' cannot bind}} expected-note {{in implicit}} - { auto [a] = wrap<const int&, void, int&&>(); } - { auto [a] = wrap<int&&, void, int&&>(); } - - { auto [a] = wrap<int, void, float&>(); } // expected-error {{cannot bind}} expected-note {{implicit}} - { auto [a] = wrap<const int, void, float&>(); } // ok, const int &a can bind to float - { auto [a] = wrap<int, void, float>(); } // ok, int &&a can bind to float -} - -namespace constant { - struct Q {}; - template<int N> constexpr int get(Q &&) { return N * N; } -} -template<> struct std::tuple_size<constant::Q> { static const int value = 3; }; -template<int N> struct std::tuple_element<N, constant::Q> { typedef int type; }; -namespace constant { - Q q; - // This creates and lifetime-extends a temporary to hold the result of each get() call. - auto [a, b, c] = q; // expected-note {{temporary}} - static_assert(a == 0); // expected-error {{constant expression}} expected-note {{temporary}} - - constexpr bool f() { - auto [a, b, c] = q; - return a == 0 && b == 1 && c == 4; - } - static_assert(f()); - - constexpr int g() { - int *p = nullptr; - { - auto [a, b, c] = q; - p = &c; - } - return *p; // expected-note {{read of object outside its lifetime}} - } - static_assert(g() == 4); // expected-error {{constant}} expected-note {{in call to 'g()'}} -} - -// P0961R1 -struct InvalidMemberGet { - int get(); - template <class T> int get(); - struct get {}; -}; -template <> struct std::tuple_size<InvalidMemberGet> { static constexpr size_t value = 1; }; -template <> struct std::tuple_element<0, InvalidMemberGet> { typedef float type; }; -template <size_t> float get(InvalidMemberGet) { return 0; } -int f() { - InvalidMemberGet img; - auto [x] = img; - typedef decltype(x) same_as_float; - typedef float same_as_float; -} - -struct ValidMemberGet { - int get(); - template <class T> int get() { return 0; } - template <size_t N> float get() { return 0; } -}; -template <> struct std::tuple_size<ValidMemberGet> { static constexpr size_t value = 1; }; -template <> struct std::tuple_element<0, ValidMemberGet> { typedef float type; }; -// Don't use this one; we should use the member get. -template <size_t N> int get(ValidMemberGet) { static_assert(N && false, ""); } -int f2() { - ValidMemberGet img; - auto [x] = img; - typedef decltype(x) same_as_float; - typedef float same_as_float; -} - -struct Base1 { - int get(); // expected-note{{member found by ambiguous name lookup}} -}; -struct Base2 { - template<int> int get(); // expected-note{{member found by ambiguous name lookup}} -}; -struct Derived : Base1, Base2 {}; - -template <> struct std::tuple_size<Derived> { static constexpr size_t value = 1; }; -template <> struct std::tuple_element<0, Derived> { typedef int type; }; - -auto [x] = Derived(); // expected-error{{member 'get' found in multiple base classes of different types}} - -struct Base { - template<int> int get(); -}; -struct UsingGet : Base { - using Base::get; -}; - -template <> struct std::tuple_size<UsingGet> { - static constexpr size_t value = 1; -}; -template <> struct std::tuple_element<0, UsingGet> { typedef int type; }; - -auto [y] = UsingGet(); diff --git a/test/CXX/dcl.decl/dcl.decomp/p4.cpp b/test/CXX/dcl.decl/dcl.decomp/p4.cpp deleted file mode 100644 index f14c0d02c16e..000000000000 --- a/test/CXX/dcl.decl/dcl.decomp/p4.cpp +++ /dev/null @@ -1,241 +0,0 @@ -// RUN: %clang_cc1 -std=c++1z -verify -triple i686-linux-gnu %s - -template<typename T, typename U> struct same; -template<typename T> struct same<T, T> { ~same(); }; - -struct Empty {}; - -struct A { - int a; -}; - -namespace NonPublicMembers { - struct NonPublic1 { - protected: - int a; // expected-note {{declared protected here}} - }; - - struct NonPublic2 { - private: - int a; // expected-note 2{{declared private here}} - }; - - struct NonPublic3 : private A {}; // expected-note {{declared private here}} - - struct NonPublic4 : NonPublic2 {}; - - void test() { - auto [a1] = NonPublic1(); // expected-error {{cannot decompose protected member 'a' of 'NonPublicMembers::NonPublic1'}} - auto [a2] = NonPublic2(); // expected-error {{cannot decompose private member 'a' of 'NonPublicMembers::NonPublic2'}} - auto [a3] = NonPublic3(); // expected-error {{cannot decompose members of inaccessible base class 'A' of 'NonPublicMembers::NonPublic3'}} - auto [a4] = NonPublic4(); // expected-error {{cannot decompose private member 'a' of 'NonPublicMembers::NonPublic2'}} - } -} - -namespace AnonymousMember { - struct Struct { - struct { // expected-note {{declared here}} - int i; - }; - }; - - struct Union { - union { // expected-note {{declared here}} - int i; - }; - }; - - void test() { - auto [a1] = Struct(); // expected-error {{cannot decompose class type 'AnonymousMember::Struct' because it has an anonymous struct member}} - auto [a2] = Union(); // expected-error {{cannot decompose class type 'AnonymousMember::Union' because it has an anonymous union member}} - } -} - -namespace MultipleClasses { - struct B : A { - int a; - }; - - struct C { int a; }; - struct D : A, C {}; - - struct E : virtual A {}; - struct F : A, E {}; // expected-warning {{direct base 'A' is inaccessible due to ambiguity}} - - struct G : virtual A {}; - struct H : E, G {}; - - struct I { int i; }; - struct J : I {}; - struct K : I, virtual J {}; // expected-warning {{direct base 'MultipleClasses::I' is inaccessible due to ambiguity}} - - struct L : virtual J {}; - struct M : virtual J, L {}; - - void test() { - auto [b] = B(); // expected-error {{cannot decompose class type 'B': both it and its base class 'A' have non-static data members}} - auto [d] = D(); // expected-error {{cannot decompose class type 'D': its base classes 'A' and 'MultipleClasses::C' have non-static data members}} - auto [e] = E(); - auto [f] = F(); // expected-error-re {{cannot decompose members of ambiguous base class 'A' of 'F':{{.*}}struct MultipleClasses::F -> struct A{{.*}}struct MultipleClasses::F -> struct MultipleClasses::E -> struct A}} - auto [h] = H(); // ok, only one (virtual) base subobject even though there are two paths to it - auto [k] = K(); // expected-error {{cannot decompose members of ambiguous base class 'MultipleClasses::I'}} - auto [m] = M(); // ok, all paths to I are through the same virtual base subobject J - - same<decltype(m), int>(); - } -} - -namespace BindingTypes { - struct A { - int i = 0; - int &r = i; - const float f = i; - mutable volatile int mvi; - }; - void e() { - auto [i,r,f,mvi] = A(); - - same<decltype(i), int>(); - same<decltype(r), int&>(); - same<decltype(f), const float>(); - same<decltype(mvi), volatile int>(); - - same<decltype((i)), int&>(); - same<decltype((r)), int&>(); - same<decltype((f)), const float&>(); - same<decltype((mvi)), volatile int&>(); - } - void f() { - auto &&[i,r,f,mvi] = A(); - - same<decltype(i), int>(); - same<decltype(r), int&>(); - same<decltype(f), const float>(); - same<decltype(mvi), volatile int>(); - - same<decltype((i)), int&>(); - same<decltype((r)), int&>(); - same<decltype((f)), const float&>(); - same<decltype((mvi)), volatile int&>(); - } - void g() { - const auto [i,r,f,mvi] = A(); - - same<decltype(i), const int>(); - same<decltype(r), int&>(); - same<decltype(f), const float>(); - same<decltype(mvi), volatile int>(); // not 'const volatile int', per expected resolution of DRxxx - - same<decltype((i)), const int&>(); - same<decltype((r)), int&>(); - same<decltype((f)), const float&>(); - same<decltype((mvi)), volatile int&>(); // not 'const volatile int&', per expected resolution of DRxxx - } - void h() { - typedef const A CA; - auto &[i,r,f,mvi] = CA(); // type of var is 'const A &' - - same<decltype(i), const int>(); // not 'int', per expected resolution of DRxxx - same<decltype(r), int&>(); - same<decltype(f), const float>(); - same<decltype(mvi), volatile int>(); // not 'const volatile int', per expected resolution of DRxxx - - same<decltype((i)), const int&>(); // not 'int&', per expected resolution of DRxxx - same<decltype((r)), int&>(); - same<decltype((f)), const float&>(); - same<decltype((mvi)), volatile int&>(); // not 'const volatile int&', per expected resolution of DRxxx - } - struct B { - mutable int i; - }; - void mut() { - auto [i] = B(); - const auto [ci] = B(); - volatile auto [vi] = B(); - same<decltype(i), int>(); - same<decltype(ci), int>(); - same<decltype(vi), volatile int>(); - } -} - -namespace Bitfield { - struct S { unsigned long long x : 4, y : 32; int z; }; // expected-note 2{{here}} - int f(S s) { - auto [a, b, c] = s; - unsigned long long &ra = a; // expected-error {{bit-field 'x'}} - unsigned long long &rb = b; // expected-error {{bit-field 'y'}} - int &rc = c; - - // the type of the binding is the type of the field - same<decltype(a), unsigned long long>(); - same<decltype(b), unsigned long long>(); - - // the type of the expression is an lvalue of the field type - // (even though a reference can't bind to the field) - same<decltype((a)), unsigned long long&>(); - same<decltype((b)), unsigned long long&>(); - - // the expression promotes to a type large enough to hold the result - same<decltype(+a), int>(); - same<decltype(+b), unsigned int>(); - return rc; - } -} - -namespace Constexpr { - struct Q { int a, b; constexpr Q() : a(1), b(2) {} }; - constexpr Q q; - auto &[qa, qb] = q; - static_assert(&qa == &q.a && &qb == &q.b); - static_assert(qa == 1 && qb == 2); -} - -namespace std_example { - struct S { int x1 : 2; volatile double y1; }; - S f(); - const auto [x, y] = f(); - - same<decltype((x)), const int&> same1; - same<decltype((y)), const volatile double&> same2; -} - -namespace p0969r0 { - struct A { - int x; - int y; - }; - struct B : private A { // expected-note {{declared private here}} - void test_member() { - auto &[x, y] = *this; - } - friend void test_friend(B); - }; - void test_friend(B b) { - auto &[x, y] = b; - } - void test_external(B b) { - auto &[x, y] = b; // expected-error {{cannot decompose members of inaccessible base class 'p0969r0::A' of 'p0969r0::B'}} - } - - struct C { - int x; - protected: - int y; // expected-note {{declared protected here}} expected-note {{can only access this member on an object of type 'p0969r0::D'}} - void test_member() { - auto &[x, y] = *this; - } - friend void test_friend(struct D); - }; - struct D : C { - static void test_member(D d, C c) { - auto &[x1, y1] = d; - auto &[x2, y2] = c; // expected-error {{cannot decompose protected member 'y' of 'p0969r0::C'}} - } - }; - void test_friend(D d) { - auto &[x, y] = d; - } - void test_external(D d) { - auto &[x, y] = d; // expected-error {{cannot decompose protected member 'y' of 'p0969r0::C'}} - } -} diff --git a/test/CXX/dcl.decl/dcl.fct.def/dcl.fct.def.default/p1.cpp b/test/CXX/dcl.decl/dcl.fct.def/dcl.fct.def.default/p1.cpp deleted file mode 100644 index 3f2bc569edf6..000000000000 --- a/test/CXX/dcl.decl/dcl.fct.def/dcl.fct.def.default/p1.cpp +++ /dev/null @@ -1,72 +0,0 @@ -// RUN: %clang_cc1 -verify %s -std=c++11 -// RUN: %clang_cc1 -verify %s -std=c++17 -// RUN: %clang_cc1 -verify %s -std=c++2a - -// A function that is explicitly defaulted shall -struct A { - // -- be a special member function, - A(int) = default; // expected-error {{only special member functions may be defaulted}} - A(A) = default; // expected-error {{must pass its first argument by reference}} - - // -- have the same declared function type as if it had been implicitly - // declared - void operator=(const A &) = default; // expected-error {{must return 'A &'}} - A(...) = default; - A(const A &, ...) = default; - A &operator=(const A&) const = default; - A &operator=(A) const = default; // expected-error {{must be an lvalue refe}} -#if __cplusplus <= 201703L - // expected-error@-5 {{cannot be variadic}} - // expected-error@-5 {{cannot be variadic}} - // expected-error@-5 {{may not have 'const'}} - // expected-error@-5 {{may not have 'const'}} -#else - // expected-warning@-10 {{implicitly deleted}} expected-note@-10 {{declared type does not match the type of an implicit default constructor}} - // expected-warning@-10 {{implicitly deleted}} expected-note@-10 {{declared type does not match the type of an implicit copy constructor}} - // expected-warning@-10 {{implicitly deleted}} expected-note@-10 {{declared type does not match the type of an implicit copy assignment}} -#endif - - // (except for possibly differing ref-qualifiers - A &operator=(A &&) & = default; - - // and except that in the case of a copy constructor or copy assignment - // operator, the parameter type may be "reference to non-const T") - A(A &) = default; - A &operator=(A &) = default; - - // -- not have default arguments - A(double = 0.0) = default; // expected-error {{cannot have default arguments}} - A(const A & = 0) = default; // expected-error {{cannot have default arguments}} -}; - -struct A2 { - A2(...); - A2(const A2 &, ...); - A2 &operator=(const A2&) const; -}; -A2::A2(...) = default; // expected-error {{cannot be variadic}} -A2::A2(const A2&, ...) = default; // expected-error {{cannot be variadic}} -A2 &A2::operator=(const A2&) const = default; // expected-error {{may not have 'const'}} - -struct B { - B(B&); - B &operator=(B&); -}; -struct C : B { - C(const C&) = default; - C &operator=(const C&) = default; -#if __cplusplus <= 201703L - // expected-error@-3 {{is const, but a member or base requires it to be non-const}} - // expected-error@-3 {{is const, but a member or base requires it to be non-const}} -#else - // expected-warning@-6 {{implicitly deleted}} expected-note@-6 {{type does not match}} - // expected-warning@-6 {{implicitly deleted}} expected-note@-6 {{type does not match}} -#endif -}; - -struct D : B { // expected-note 2{{base class}} - D(const D&); - D &operator=(const D&); -}; -D::D(const D&) = default; // expected-error {{would delete}} expected-error {{is const, but}} -D &D::operator=(const D&) = default; // expected-error {{would delete}} expected-error {{is const, but}} diff --git a/test/CXX/dcl.decl/dcl.fct.def/dcl.fct.def.default/p2.cpp b/test/CXX/dcl.decl/dcl.fct.def/dcl.fct.def.default/p2.cpp deleted file mode 100644 index c2f3b5a04574..000000000000 --- a/test/CXX/dcl.decl/dcl.fct.def/dcl.fct.def.default/p2.cpp +++ /dev/null @@ -1,125 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify -fcxx-exceptions %s - -// An explicitly-defaulted function may be declared constexpr only if it would -// have been implicitly declared as constexpr. -struct S1 { - constexpr S1() = default; // expected-error {{defaulted definition of default constructor is not constexpr}} - constexpr S1(const S1&) = default; - constexpr S1(S1&&) = default; - constexpr S1 &operator=(const S1&) const = default; // expected-error {{explicitly-defaulted copy assignment operator may not have}} - constexpr S1 &operator=(S1&&) const = default; // expected-error {{explicitly-defaulted move assignment operator may not have}} - constexpr ~S1() = default; // expected-error {{destructor cannot be marked constexpr}} - int n; -}; -struct NoCopyMove { - constexpr NoCopyMove() {} - NoCopyMove(const NoCopyMove&); - NoCopyMove(NoCopyMove&&); -}; -struct S2 { - constexpr S2() = default; - constexpr S2(const S2&) = default; // expected-error {{defaulted definition of copy constructor is not constexpr}} - constexpr S2(S2&&) = default; // expected-error {{defaulted definition of move constructor is not constexpr}} - NoCopyMove ncm; -}; - -// If a function is explicitly defaulted on its first declaration -// -- it is implicitly considered to be constexpr if the implicit declaration -// would be -struct S3 { - S3() = default; - S3(const S3&) = default; - S3(S3&&) = default; - constexpr S3(int n) : n(n) {} - int n; -}; -constexpr S3 s3a = S3(0); -constexpr S3 s3b = s3a; -constexpr S3 s3c = S3(); -constexpr S3 s3d; // expected-error {{default initialization of an object of const type 'const S3' without a user-provided default constructor}} - -struct S4 { - S4() = default; - S4(const S4&) = default; // expected-note {{here}} - S4(S4&&) = default; // expected-note {{here}} - NoCopyMove ncm; -}; -constexpr S4 s4a{}; // ok -constexpr S4 s4b = S4(); // expected-error {{constant expression}} expected-note {{non-constexpr constructor}} -constexpr S4 s4c = s4a; // expected-error {{constant expression}} expected-note {{non-constexpr constructor}} - -struct S5 { - constexpr S5(); - int n = 1, m = n + 3; -}; -constexpr S5::S5() = default; -static_assert(S5().m == 4, ""); - - -// An explicitly-defaulted function may have an exception specification only if -// it is compatible with the exception specification on an implicit declaration. -struct E1 { - E1() noexcept = default; - E1(const E1&) noexcept = default; - E1(E1&&) noexcept = default; - E1 &operator=(const E1&) noexcept = default; - E1 &operator=(E1&&) noexcept = default; - ~E1() noexcept = default; -}; -struct E2 { - E2() noexcept(false) = default; // expected-error {{exception specification of explicitly defaulted default constructor does not match the calculated one}} - E2(const E2&) noexcept(false) = default; // expected-error {{exception specification of explicitly defaulted copy constructor does not match the calculated one}} - E2(E2&&) noexcept(false) = default; // expected-error {{exception specification of explicitly defaulted move constructor does not match the calculated one}} - E2 &operator=(const E2&) noexcept(false) = default; // expected-error {{exception specification of explicitly defaulted copy assignment operator does not match the calculated one}} - E2 &operator=(E2&&) noexcept(false) = default; // expected-error {{exception specification of explicitly defaulted move assignment operator does not match the calculated one}} - ~E2() noexcept(false) = default; // expected-error {{exception specification of explicitly defaulted destructor does not match the calculated one}} -}; - -// If a function is explicitly defaulted on its first declaration -// -- it is implicitly considered to have the same exception-specification as -// if it had been implicitly declared -struct E3 { - E3() = default; - E3(const E3&) = default; - E3(E3&&) = default; - E3 &operator=(const E3&) = default; - E3 &operator=(E3&&) = default; - ~E3() = default; -}; -E3 e3; -static_assert(noexcept(E3(), E3(E3()), E3(e3), e3 = E3(), e3 = e3), ""); -struct E4 { - E4() noexcept(false); - E4(const E4&) noexcept(false); - E4(E4&&) noexcept(false); - E4 &operator=(const E4&) noexcept(false); - E4 &operator=(E4&&) noexcept(false); - ~E4() noexcept(false); -}; -struct E5 { - E5() = default; - E5(const E5&) = default; - E5(E5&&) = default; - E5 &operator=(const E5&) = default; - E5 &operator=(E5&&) = default; - ~E5() = default; - - E4 e4; -}; -E5 e5; -static_assert(!noexcept(E5()), ""); -static_assert(!noexcept(E5(static_cast<E5&&>(e5))), ""); -static_assert(!noexcept(E5(e5)), ""); -static_assert(!noexcept(e5 = E5()), ""); -static_assert(!noexcept(e5 = e5), ""); - -namespace PR13492 { - struct B { - B() = default; - int field; - }; - - void f() { - const B b; // expected-error {{default initialization of an object of const type 'const PR13492::B' without a user-provided default constructor}} - } -} diff --git a/test/CXX/dcl.decl/dcl.fct.def/dcl.fct.def.delete/p4.cpp b/test/CXX/dcl.decl/dcl.fct.def/dcl.fct.def.delete/p4.cpp deleted file mode 100644 index 16fd5e6dbda1..000000000000 --- a/test/CXX/dcl.decl/dcl.fct.def/dcl.fct.def.delete/p4.cpp +++ /dev/null @@ -1,8 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s - -template<typename> void func(); -template<> void func<int>() = delete; - -template<typename> void func2(); -template<> void func2<int>(); // expected-note {{previous declaration is here}} -template<> void func2<int>() = delete; // expected-error {{deleted definition must be first declaration}} diff --git a/test/CXX/dcl.decl/dcl.fct.def/dcl.fct.def.general/p8.cpp b/test/CXX/dcl.decl/dcl.fct.def/dcl.fct.def.general/p8.cpp deleted file mode 100644 index ff5d3dec3083..000000000000 --- a/test/CXX/dcl.decl/dcl.fct.def/dcl.fct.def.general/p8.cpp +++ /dev/null @@ -1,18 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 %s -verify -// expected-no-diagnostics - -using size_t = decltype(sizeof(0)); -template<typename T> struct check; -template<size_t N> struct check<const char[N]> {}; - -constexpr bool startswith(const char *p, const char *q) { - return !*q || (*p == *q && startswith(p + 1, q + 1)); -} -constexpr bool contains(const char *p, const char *q) { - return *p && (startswith(p, q) || contains(p + 1, q)); -} - -void foo() { - check<decltype(__func__)>(); - static_assert(contains(__func__, "foo"), ""); -} diff --git a/test/CXX/dcl.decl/dcl.init/dcl.init.aggr/p1.cpp b/test/CXX/dcl.decl/dcl.init/dcl.init.aggr/p1.cpp deleted file mode 100644 index e9e9ce57fa7f..000000000000 --- a/test/CXX/dcl.decl/dcl.init/dcl.init.aggr/p1.cpp +++ /dev/null @@ -1,165 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++14 %s -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++1z %s - -// An aggregate is an array or a class... -struct Aggr { -private: - static const int n; - void f(); -protected: - struct Inner { int m; }; -public: - bool &br; -}; -bool b; -Aggr ag = { b }; - -// with no user-provided constructors, ... -struct NonAggr1a { // expected-note 2 {{candidate constructor}} - NonAggr1a(int, int); // expected-note {{candidate constructor}} - int k; -}; -NonAggr1a na1a = { 42 }; // expected-error {{no matching constructor for initialization of 'NonAggr1a'}} - -struct NonAggr1b { - NonAggr1b(const NonAggr1b &); // expected-note {{candidate constructor}} - int k; -}; -NonAggr1b na1b = { 42 }; // expected-error {{no matching constructor for initialization of 'NonAggr1b'}} - -// no brace-or-equal-initializers for non-static data members, ... -// Note, this bullet was removed in C++1y. -struct NonAggr2 { - int m = { 123 }; -}; -NonAggr2 na2 = { 42 }; -#if __cplusplus < 201402L -// expected-error@-2 {{no matching constructor for initialization of 'NonAggr2'}} -// expected-note@-6 3 {{candidate constructor}} -#endif - -// no private... -struct NonAggr3 { // expected-note 3 {{candidate constructor}} -private: - int n; -}; -NonAggr3 na3 = { 42 }; // expected-error {{no matching constructor for initialization of 'NonAggr3'}} - -// or protected non-static data members, ... -struct NonAggr4 { // expected-note 3 {{candidate constructor}} -protected: - int n; -}; -NonAggr4 na4 = { 42 }; // expected-error {{no matching constructor for initialization of 'NonAggr4'}} - -// [pre-C++1z] no base classes, ... -struct NonAggr5 : Aggr { -}; -NonAggr5 na5 = { b }; -#if __cplusplus <= 201402L -// expected-error@-2 {{no matching constructor for initialization of 'NonAggr5'}} -// expected-note@-5 3 {{candidate constructor}} -#endif -template<typename...BaseList> -struct MaybeAggr5a : BaseList... {}; -MaybeAggr5a<> ma5a0 = {}; // ok -MaybeAggr5a<Aggr> ma5a1 = {}; // ok in C++17 -MaybeAggr5a<NonAggr2> m5a2 = {}; // ok, aggregate init in C++17, default ctor in C++11 and C++14 -MaybeAggr5a<NonAggr2> m5a3 = {0}; // ok in C++17, overrides default member initializer in base class -#if __cplusplus <= 201402L -// expected-error@-4 {{call to implicitly-deleted default constructor of 'MaybeAggr5a<Aggr>'}} -// expected-note@-7 {{default constructor of 'MaybeAggr5a<Aggr>' is implicitly deleted because base class 'Aggr' has a deleted default constructor}} -// expected-note@13 {{default constructor of 'Aggr' is implicitly deleted because field 'br' of reference type 'bool &' would not be initialized}} -// expected-error@-5 {{no matching constructor}} expected-note@-9 3{{candidate}} -#else -// expected-error@-9 {{reference member of type 'bool &' uninitialized}} -// expected-note@13 {{uninitialized reference member is here}} -#endif - -// [C++1z] no virtual, protected, or private base classes, ... -struct NonAggr5b : virtual Aggr {}; // expected-note 3{{candidate}} -NonAggr5b na5b = { b }; // expected-error {{no matching constructor}} -struct NonAggr5c : NonAggr5b {}; // expected-note 3{{candidate}} -NonAggr5c na5c = { b }; // expected-error {{no matching constructor}} -struct NonAggr5d : protected Aggr {}; // expected-note 3{{candidate}} -NonAggr5d na5d = { b }; // expected-error {{no matching constructor}} -struct NonAggr5e : private Aggr {}; // expected-note 3{{candidate}} -NonAggr5e na5e = { b }; // expected-error {{no matching constructor}} -class NonAggr5f : Aggr {}; // expected-note 3{{candidate}} -NonAggr5f na5f = { b }; // expected-error {{no matching constructor}} - -// [C++1z] (the base class need not itself be an aggregate) -struct MaybeAggr5g : NonAggr1a {}; -MaybeAggr5g ma5g1 = { 1 }; -MaybeAggr5g ma5g2 = { {1, 2} }; -MaybeAggr5g ma5g3 = {}; -#if __cplusplus <= 201402L -// expected-error@-4 {{no matching constructor}} // expected-note@-5 3{{candidate}} -// expected-error@-4 {{no matching constructor}} // expected-note@-6 3{{candidate}} -// expected-error@-4 {{implicitly-deleted default constructor}} expected-note@-7 {{no default constructor}} -#else -// expected-error@-8 {{no viable conversion from 'int' to 'NonAggr1a'}} expected-note@19 2{{candidate}} -// (ok) -// expected-error@-8 {{no matching constructor}} expected-note@19 2{{candidate}} expected-note@20 {{candidate}} -#endif - -// and no virtual functions. -struct NonAggr6 { // expected-note 3 {{candidate constructor}} - virtual void f(); - int n; -}; -NonAggr6 na6 = { 42 }; // expected-error {{no matching constructor for initialization of 'NonAggr6'}} - -struct NonAggr7 : NonAggr6 { // expected-note 3 {{candidate constructor}} - int n; -}; -NonAggr7 na7 = {{}, 42}; // expected-error {{no matching constructor for initialization of 'NonAggr7'}} - -struct DefaultedAggr { - int n; - - DefaultedAggr() = default; - DefaultedAggr(const DefaultedAggr &) = default; - DefaultedAggr(DefaultedAggr &&) = default; - DefaultedAggr &operator=(const DefaultedAggr &) = default; - DefaultedAggr &operator=(DefaultedAggr &&) = default; - ~DefaultedAggr() = default; -}; -DefaultedAggr da = { 42 } ; - -struct ExplicitDefaultedAggr { - int n; - explicit ExplicitDefaultedAggr() = default; // expected-note {{candidate}} - ExplicitDefaultedAggr(const ExplicitDefaultedAggr &) = default; // expected-note {{candidate}} - ExplicitDefaultedAggr(ExplicitDefaultedAggr &&) = default; // expected-note {{candidate}} -}; -ExplicitDefaultedAggr eda = { 42 }; // expected-error {{no matching constructor}} -ExplicitDefaultedAggr eda2{}; - -struct DefaultedBase { - int n; - DefaultedBase() = default; - DefaultedBase(DefaultedBase const&) = default; - DefaultedBase(DefaultedBase &&) = default; -}; - -struct InheritingConstructors : DefaultedBase { // expected-note 3 {{candidate}} - using DefaultedBase::DefaultedBase; -}; -InheritingConstructors ic = { 42 }; // expected-error {{no matching constructor}} - -struct NonInheritingConstructors : DefaultedBase {}; // expected-note 0+ {{candidate}} -NonInheritingConstructors nic = { 42 }; -#if __cplusplus <= 201402L -// expected-error@-2 {{no matching constructor}} -#endif - -struct NonAggrBase { - NonAggrBase(int) {} -}; -struct HasNonAggrBase : NonAggrBase {}; // expected-note 0+ {{candidate}} -HasNonAggrBase hnab = {42}; -#if __cplusplus <= 201402L -// expected-error@-2 {{no matching constructor}} -#endif diff --git a/test/CXX/dcl.decl/dcl.init/dcl.init.aggr/p4.cpp b/test/CXX/dcl.decl/dcl.init/dcl.init.aggr/p4.cpp deleted file mode 100644 index 2342807692e6..000000000000 --- a/test/CXX/dcl.decl/dcl.init/dcl.init.aggr/p4.cpp +++ /dev/null @@ -1,24 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 -pedantic -Werror %s -int a1[] = { 1, 3, 5 }; -void f() { - int a2[] = { 1, 3, 5 }; -} -template <typename T> -void tf() { - T t; - // Element type may be dependent - T a3[] = { 1, 3, 5 }; - // As might be the initializer list, value - int a5[] = { sizeof(T) }; - // or even type. - int a6[] = { t.get() }; -} - -// Allowed by GNU extension -int a4[] = {}; // expected-error {{zero size arrays}} - -struct Incomplete; // expected-note {{forward declaration of 'Incomplete'}} -struct A { - Incomplete i; // expected-error {{field has incomplete type 'Incomplete'}} -}; -A a[] = { 0 }; // PR13971: don't hang. diff --git a/test/CXX/dcl.decl/dcl.init/dcl.init.aggr/p7.cpp b/test/CXX/dcl.decl/dcl.init/dcl.init.aggr/p7.cpp deleted file mode 100644 index 22667ac14bb5..000000000000 --- a/test/CXX/dcl.decl/dcl.init/dcl.init.aggr/p7.cpp +++ /dev/null @@ -1,23 +0,0 @@ -// RUN: %clang_cc1 -Wno-uninitialized -std=c++1y %s -verify - -// expected-no-diagnostics - -struct S { int a; const char *b; int c; int d = b[a]; }; -constexpr S ss = { 1, "asdf" }; - -static_assert(ss.a == 1, ""); -static_assert(ss.b[2] == 'd', ""); -static_assert(ss.c == 0, ""); -static_assert(ss.d == 's', ""); - -struct X { int i, j, k = 42; }; -constexpr X a[] = { 1, 2, 3, 4, 5, 6 }; -constexpr X b[2] = { { 1, 2, 3 }, { 4, 5, 6 } }; - -constexpr bool operator==(X a, X b) { - return a.i == b.i && a.j == b.j && a.k == b.k; -} - -static_assert(sizeof(a) == sizeof(b), ""); -static_assert(a[0] == b[0], ""); -static_assert(a[1] == b[1], ""); diff --git a/test/CXX/dcl.decl/dcl.init/dcl.init.list/basic.cpp b/test/CXX/dcl.decl/dcl.init/dcl.init.list/basic.cpp deleted file mode 100644 index b44b2c7d1566..000000000000 --- a/test/CXX/dcl.decl/dcl.init/dcl.init.list/basic.cpp +++ /dev/null @@ -1,17 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s - -void f0() { - int &ir = { 17 }; // expected-error{{reference to type 'int' cannot bind to an initializer list}} -} - -namespace PR12453 { - template<typename T> - void f(int i) { - T x{i}; // expected-error{{non-constant-expression cannot be narrowed from type 'int' to 'float' in initializer list}} \ - // expected-note{{insert an explicit cast to silence this issue}} - T y{i}; // expected-error{{non-constant-expression cannot be narrowed from type 'int' to 'float' in initializer list}} \ - // expected-note{{insert an explicit cast to silence this issue}} - } - - template void f<float>(int); // expected-note{{in instantiation of function template specialization 'PR12453::f<float>' requested here}} -} diff --git a/test/CXX/dcl.decl/dcl.init/dcl.init.list/p3.cpp b/test/CXX/dcl.decl/dcl.init/dcl.init.list/p3.cpp deleted file mode 100644 index ade327485773..000000000000 --- a/test/CXX/dcl.decl/dcl.init/dcl.init.list/p3.cpp +++ /dev/null @@ -1,272 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s -// RUN: %clang_cc1 -std=c++14 -fsyntax-only -verify %s -// FIXME: Remove the triple when PR27098 is fixed. -// RUN: %clang_cc1 -std=c++1z -fsyntax-only -verify %s -triple %itanium_abi_triple - -namespace std { - typedef decltype(sizeof(int)) size_t; - - template <typename E> - struct initializer_list - { - const E *p; - size_t n; - initializer_list(const E *p, size_t n) : p(p), n(n) {} - }; - - struct string { - string(const char *); - }; - - template<typename A, typename B> - struct pair { - pair(const A&, const B&); - }; -} - -namespace bullet1 { - double ad[] = { 1, 2.0 }; - int ai[] = { 1, 2.0 }; // expected-error {{type 'double' cannot be narrowed to 'int' in initializer list}} expected-note {{silence}} - - struct S2 { - int m1; - double m2, m3; - }; - - S2 s21 = { 1, 2, 3.0 }; - S2 s22 { 1.0, 2, 3 }; // expected-error {{type 'double' cannot be narrowed to 'int' in initializer list}} expected-note {{silence}} - S2 s23 { }; -} - -namespace bullet4_example1 { - struct S { - S(std::initializer_list<double> d) {} - S(std::initializer_list<int> i) {} - S() {} - }; - - S s1 = { 1.0, 2.0, 3.0 }; - S s2 = { 1, 2, 3 }; - S s3 = { }; -} - -namespace bullet4_example2 { - struct Map { - Map(std::initializer_list<std::pair<std::string,int>>) {} - }; - - Map ship = {{"Sophie",14}, {"Surprise",28}}; -} - -namespace bullet4_example3 { - struct S { - S(int, double, double) {} - S() {} - }; - - S s1 = { 1, 2, 3.0 }; - S s2 { 1.0, 2, 3 }; // expected-error {{type 'double' cannot be narrowed to 'int' in initializer list}} expected-note {{silence}} - S s3 {}; -} - -namespace bullet5 { - int x1 {2}; - int x2 {2.0}; // expected-error {{type 'double' cannot be narrowed to 'int' in initializer list}} expected-note {{silence}} -} - -namespace bullet6 { - struct S { - S(std::initializer_list<double>) {} - S(const std::string &) {} - }; - - const S& r1 = { 1, 2, 3.0 }; - const S& r2 = { "Spinach" }; - S& r3 = { 1, 2, 3 }; // expected-error {{non-const lvalue reference to type 'bullet6::S' cannot bind to an initializer list temporary}} - const int& i1 = { 1 }; - const int& i2 = { 1.1 }; // expected-error {{type 'double' cannot be narrowed to 'int' in initializer list}} expected-note {{silence}} expected-warning {{implicit conversion}} - const int (&iar)[2] = { 1, 2 }; -} - -namespace bullet7 { - int** pp {}; -} - -namespace bullet8 { - struct A { int i; int j; }; - A a1 { 1, 2 }; - A a2 { 1.2 }; // expected-error {{type 'double' cannot be narrowed to 'int' in initializer list}} expected-note {{silence}} expected-warning {{implicit conversion}} - - struct B { - B(std::initializer_list<int> i) {} - }; - B b1 { 1, 2 }; - B b2 { 1, 2.0 }; // expected-error {{type 'double' cannot be narrowed to 'int' in initializer list}} expected-note {{silence}} - - struct C { - C(int i, double j) {} - }; - C c1 = { 1, 2.2 }; - // FIXME: Suppress the narrowing warning in the cases where we issue a narrowing error. - C c2 = { 1.1, 2 }; // expected-error {{type 'double' cannot be narrowed to 'int' in initializer list}} expected-note {{silence}} expected-warning {{implicit conversion}} - - int j { 1 }; - int k { }; -} - -namespace rdar13395022 { - struct MoveOnly { // expected-note {{candidate}} - MoveOnly(MoveOnly&&); // expected-note 2{{copy constructor is implicitly deleted because}} expected-note {{candidate}} - }; - - void test(MoveOnly mo) { - auto &&list1 = {mo}; // expected-error {{call to implicitly-deleted copy constructor}} expected-note {{in initialization of temporary of type 'std::initializer_list}} - MoveOnly (&&list2)[1] = {mo}; // expected-error {{call to implicitly-deleted copy constructor}} expected-note {{in initialization of temporary of type 'rdar13395022::MoveOnly [1]'}} - std::initializer_list<MoveOnly> &&list3 = {}; - MoveOnly (&&list4)[1] = {}; // expected-error {{no matching constructor}} - // expected-note@-1 {{in implicit initialization of array element 0 with omitted initializer}} - // expected-note@-2 {{in initialization of temporary of type 'rdar13395022::MoveOnly [1]' created to list-initialize this reference}} - } -} - -namespace cxx1z_direct_enum_init { - enum A {}; - enum B : char {}; - enum class C {}; - enum class D : char {}; - enum class E : char { k = 5 }; - - template<typename T> void good() { - (void)T{0}; - T t1{0}; - T t2 = T{0}; - - struct S { T t; }; - S s{T{0}}; - - struct U { T t{0}; } u; // expected-note 0+{{instantiation of}} - - struct V { T t; V() : t{0} {} }; // expected-note 0+{{instantiation of}} - - void f(T); - f(T{0}); - - char c; - auto t3 = T{c}; - } -#if __cplusplus <= 201402L - // expected-error@-18 5{{cannot initialize}} - // expected-error@-18 5{{cannot initialize}} - // expected-error@-18 5{{cannot initialize}} - // - // - // expected-error@-18 5{{cannot initialize}} - // - // expected-error@-18 5{{cannot initialize}} - // - // expected-error@-18 5{{cannot initialize}} - // - // - // expected-error@-18 5{{cannot initialize}} - // - // - // expected-error@-18 5{{cannot initialize}} -#else - // expected-error@-35 {{cannot initialize}} - // expected-error@-35 {{cannot initialize}} - // expected-error@-35 {{cannot initialize}} - // - // - // expected-error@-35 {{cannot initialize}} - // - // expected-error@-35 {{cannot initialize}} - // - // expected-error@-35 {{cannot initialize}} - // - // - // expected-error@-35 {{cannot initialize}} - // - // - // expected-error@-35 {{cannot initialize}} -#endif - - template<typename T> void bad() { - T t = {0}; - - struct S { T t; }; - S s1{0}; - S s2{{0}}; - - struct U { T t = {0}; } u; // expected-note 0+{{instantiation of}} - - struct V { T t; V() : t({0}) {} }; // expected-note 0+{{instantiation of}} - - void f(T); // expected-note 0+{{passing argument}} - f({0}); - } - // expected-error@-13 5{{cannot initialize}} - // - // - // expected-error@-13 5{{cannot initialize}} - // expected-error@-13 5{{cannot initialize}} - // - // expected-error@-13 5{{cannot initialize}} - // - // expected-error@-13 5{{cannot initialize}} - // - // - // expected-error@-13 5{{cannot initialize}} - - template<typename T> void ugly() { - extern char c; - T t1{char('0' + c)}; - T t2{'0' + c}; - T t3{1234}; - } -#if __cplusplus <= 201402L - // expected-error@-5 4{{cannot initialize}} - // expected-error@-5 4{{cannot initialize}} - // expected-error@-5 4{{cannot initialize}} -#else - // expected-error@-8 3{{non-constant-expression cannot be narrowed}} - // expected-error@-8 3{{constant expression evaluates to 1234 which cannot be narrowed}} expected-warning@-8 {{changes value}} -#endif - - void test() { - good<A>(); // expected-note 4{{instantiation of}} - good<B>(); - good<C>(); - good<D>(); - good<E>(); -#if __cplusplus <= 201402L - // expected-note@-5 4{{instantiation of}} - // expected-note@-5 4{{instantiation of}} - // expected-note@-5 4{{instantiation of}} - // expected-note@-5 4{{instantiation of}} -#endif - - bad<A>(); // expected-note 4{{instantiation of}} - bad<B>(); // expected-note 4{{instantiation of}} - bad<C>(); // expected-note 4{{instantiation of}} - bad<D>(); // expected-note 4{{instantiation of}} - bad<E>(); // expected-note 4{{instantiation of}} - - ugly<B>(); // expected-note {{instantiation of}} - ugly<C>(); // ok - ugly<D>(); // expected-note {{instantiation of}} - ugly<E>(); // expected-note {{instantiation of}} -#if __cplusplus <= 201402L - // expected-note@-4 {{instantiation of}} -#else - (void)B{0.0}; // expected-error {{type 'double' cannot be narrowed}} -#endif - } - -#if __cplusplus > 201402L - enum class F : unsigned {}; - F f1(unsigned x) { return F{x}; } - F f2(const unsigned x) { return F{x}; } - F f3(bool x) { return F{x}; } - F f4(const bool x) { return F{x}; } -#endif -} diff --git a/test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x-fixits.cpp b/test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x-fixits.cpp deleted file mode 100644 index d66494fa2c2c..000000000000 --- a/test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x-fixits.cpp +++ /dev/null @@ -1,33 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -std=c++98 -Wc++11-compat -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s - -// Verify that the appropriate fixits are emitted for narrowing conversions in -// initializer lists. - -typedef short int16_t; - -void fixits() { - int x = 999; - struct {char c;} c2 = {x}; - // CHECK: warning:{{.*}} cannot be narrowed - // CHECK: fix-it:{{.*}}:26}:"static_cast<char>(" - // CHECK: fix-it:{{.*}}:27}:")" - struct {int16_t i;} i16 = {70000}; - // CHECK: warning:{{.*}} cannot be narrowed - // CHECK: fix-it:{{.*}}:30}:"static_cast<int16_t>(" - // CHECK: fix-it:{{.*}}:35}:")" -} - -template<typename T> -void maybe_shrink_int(T t) { - struct {T t;} t2 = {700}; -} - -void test_template() { - maybe_shrink_int((char)3); - // CHECK: warning:{{.*}} cannot be narrowed - // CHECK: note:{{.*}} in instantiation - // CHECK: note:{{.*}} silence - // FIXME: This should be static_cast<T>. - // CHECK: fix-it:{{.*}}"static_cast<char>(" - // CHECK: fix-it:{{.*}}")" -} diff --git a/test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x.cpp b/test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x.cpp deleted file mode 100644 index 4436cb0aac60..000000000000 --- a/test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x.cpp +++ /dev/null @@ -1,242 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -std=c++11 -triple x86_64-apple-macosx10.6.7 -verify %s - -// Verify that narrowing conversions in initializer lists cause errors in C++0x -// mode. - -void std_example() { - int x = 999; // x is not a constant expression - const int y = 999; - const int z = 99; - char c1 = x; // OK, though it might narrow (in this case, it does narrow) - char c2{x}; // expected-error {{ cannot be narrowed }} expected-note {{silence}} - char c3{y}; // expected-error {{ cannot be narrowed }} expected-note {{silence}} expected-warning {{changes value}} - char c4{z}; // OK: no narrowing needed - unsigned char uc1 = {5}; // OK: no narrowing needed - unsigned char uc2 = {-1}; // expected-error {{ cannot be narrowed }} expected-note {{silence}} - unsigned int ui1 = {-1}; // expected-error {{ cannot be narrowed }} expected-note {{silence}} - signed int si1 = - { (unsigned int)-1 }; // expected-error {{ cannot be narrowed }} expected-note {{silence}} - int ii = {2.0}; // expected-error {{ cannot be narrowed }} expected-note {{silence}} - float f1 { x }; // expected-error {{ cannot be narrowed }} expected-note {{silence}} - float f2 { 7 }; // OK: 7 can be exactly represented as a float - int f(int); - int a[] = - { 2, f(2), f(2.0) }; // OK: the double-to-int conversion is not at the top level -} - -enum UnscopedEnum { - EnumVal = 300 -}; - -// Test each rule individually. - -template<typename T> -struct Agg { - T t; -}; - -template<typename T> -struct Convert { - constexpr Convert(T v) : v(v) {} - constexpr operator T() const { return v; } - T v; -}; -template<typename T> Convert<T> ConvertVar(); - -// C++0x [dcl.init.list]p7: A narrowing conversion is an implicit conversion -// -// * from a floating-point type to an integer type, or - -void float_to_int() { - Agg<char> a1 = {1.0F}; // expected-error {{type 'float' cannot be narrowed to 'char'}} expected-note {{silence}} - Agg<char> a2 = {1.0}; // expected-error {{ cannot be narrowed }} expected-note {{silence}} - Agg<char> a3 = {1.0L}; // expected-error {{ cannot be narrowed }} expected-note {{silence}} - - float f = 1.0; - double d = 1.0; - long double ld = 1.0; - Agg<char> a4 = {f}; // expected-error {{ cannot be narrowed }} expected-note {{silence}} - Agg<char> a5 = {d}; // expected-error {{ cannot be narrowed }} expected-note {{silence}} - Agg<char> a6 = {ld}; // expected-error {{ cannot be narrowed }} expected-note {{silence}} - - Agg<char> ce1 = { Convert<float>(1.0) }; // expected-error {{type 'float' cannot be narrowed to 'char'}} expected-note {{silence}} - Agg<char> ce2 = { ConvertVar<double>() }; // expected-error {{type 'double' cannot be narrowed to 'char'}} expected-note {{silence}} - - bool b{1.0}; // expected-error {{type 'double' cannot be narrowed to 'bool'}} expected-note {{silence}} - Agg<bool> ab = {0.0}; // expected-error {{type 'double' cannot be narrowed to 'bool'}} expected-note {{silence}} -} - -// * from long double to double or float, or from double to float, except where -// the source is a constant expression and the actual value after conversion -// is within the range of values that can be represented (even if it cannot be -// represented exactly), or - -void shrink_float() { - // These aren't constant expressions. - float f = 1.0; - double d = 1.0; - long double ld = 1.0; - - // Variables. - Agg<float> f1 = {f}; // OK (no-op) - Agg<float> f2 = {d}; // expected-error {{non-constant-expression cannot be narrowed from type 'double' to 'float'}} expected-note {{silence}} - Agg<float> f3 = {ld}; // expected-error {{ cannot be narrowed }} expected-note {{silence}} - // Exact constants. - Agg<float> f4 = {1.0}; // OK (double constant represented exactly) - Agg<float> f5 = {1.0L}; // OK (long double constant represented exactly) - // Inexact but in-range constants. - Agg<float> f6 = {0.1}; // OK (double constant in range but rounded) - Agg<float> f7 = {0.1L}; // OK (long double constant in range but rounded) - // Out of range constants. - Agg<float> f8 = {1E50}; // expected-error {{constant expression evaluates to 1.000000e+50 which cannot be narrowed to type 'float'}} expected-note {{silence}} - Agg<float> f9 = {1E50L}; // expected-error {{ cannot be narrowed }} expected-note {{silence}} - // More complex constant expression. - constexpr long double e40 = 1E40L, e30 = 1E30L, e39 = 1E39L; - Agg<float> f10 = {e40 - 5 * e39 + e30 - 5 * e39}; // OK - - // Variables. - Agg<double> d1 = {f}; // OK (widening) - Agg<double> d2 = {d}; // OK (no-op) - Agg<double> d3 = {ld}; // expected-error {{ cannot be narrowed }} expected-note {{silence}} - // Exact constant. - Agg<double> d4 = {1.0L}; // OK (long double constant represented exactly) - // Inexact but in-range constant. - Agg<double> d5 = {0.1L}; // OK (long double constant in range but rounded) - // Out of range constant. - Agg<double> d6 = {1E315L}; // expected-error {{ cannot be narrowed }} expected-note {{silence}} - // More complex constant expression. - constexpr long double e315 = 1E315L, e305 = 1E305L, e314 = 1E314L; - Agg<double> d7 = {e315 - 5 * e314 + e305 - 5 * e314}; // OK - - Agg<float> ce1 = { Convert<double>(1e300) }; // expected-error {{constant expression evaluates to 1.000000e+300 which cannot be narrowed to type 'float'}} expected-note {{silence}} - Agg<double> ce2 = { ConvertVar<long double>() }; // expected-error {{non-constant-expression cannot be narrowed from type 'long double' to 'double'}} expected-note {{silence}} -} - -// * from an integer type or unscoped enumeration type to a floating-point type, -// except where the source is a constant expression and the actual value after -// conversion will fit into the target type and will produce the original -// value when converted back to the original type, or -void int_to_float() { - // Not a constant expression. - char c = 1; - UnscopedEnum e = EnumVal; - - // Variables. Yes, even though all char's will fit into any floating type. - Agg<float> f1 = {c}; // expected-error {{ cannot be narrowed }} expected-note {{silence}} - Agg<double> f2 = {c}; // expected-error {{ cannot be narrowed }} expected-note {{silence}} - Agg<long double> f3 = {c}; // expected-error {{ cannot be narrowed }} expected-note {{silence}} - - Agg<float> f4 = {e}; // expected-error {{ cannot be narrowed }} expected-note {{silence}} - Agg<double> f5 = {e}; // expected-error {{ cannot be narrowed }} expected-note {{silence}} - Agg<long double> f6 = {e}; // expected-error {{ cannot be narrowed }} expected-note {{silence}} - - // Constants. - Agg<float> f7 = {12345678}; // OK (exactly fits in a float) - Agg<float> f8 = {EnumVal}; // OK - Agg<float> f9 = {123456789}; // expected-error {{ cannot be narrowed }} expected-note {{silence}} - - Agg<float> ce1 = { Convert<int>(123456789) }; // expected-error {{constant expression evaluates to 123456789 which cannot be narrowed to type 'float'}} expected-note {{silence}} - Agg<double> ce2 = { ConvertVar<long long>() }; // expected-error {{non-constant-expression cannot be narrowed from type 'long long' to 'double'}} expected-note {{silence}} -} - -// * from an integer type or unscoped enumeration type to an integer type that -// cannot represent all the values of the original type, except where the -// source is a constant expression and the actual value after conversion will -// fit into the target type and will produce the original value when converted -// back to the original type. -void shrink_int() { - // Not a constant expression. - short s = 1; - UnscopedEnum e = EnumVal; - unsigned short us = 1; - Agg<char> c1 = {s}; // expected-error {{ cannot be narrowed }} expected-note {{silence}} - Agg<char> c2 = {e}; // expected-error {{ cannot be narrowed }} expected-note {{silence}} - Agg<unsigned short> s1 = {s}; // expected-error {{ cannot be narrowed }} expected-note {{silence}} - Agg<short> s2 = {us}; // expected-error {{ cannot be narrowed }} expected-note {{silence}} - - // "that cannot represent all the values of the original type" means that the - // validity of the program depends on the relative sizes of integral types. - // This test compiles with -m64, so sizeof(int)<sizeof(long)==sizeof(long - // long). - long l1 = 1; - Agg<int> i1 = {l1}; // expected-error {{ cannot be narrowed }} expected-note {{silence}} - Agg<int> i2 = {e}; // OK - long long ll = 1; - Agg<long> l2 = {ll}; // OK - - // Constants. - Agg<char> c3 = {127}; // OK - Agg<char> c4 = {300}; // expected-error {{ cannot be narrowed }} expected-note {{silence}} expected-warning {{changes value}} - Agg<char> c5 = {EnumVal}; // expected-error {{ cannot be narrowed }} expected-note {{silence}} expected-warning {{changes value}} - - Agg<int> i3 = {0x7FFFFFFFU}; // OK - Agg<int> i4 = {EnumVal}; // OK - Agg<int> i5 = {0x80000000U}; // expected-error {{ cannot be narrowed }} expected-note {{silence}} - Agg<unsigned int> i6 = {-0x80000000L}; // expected-error {{ cannot be narrowed }} expected-note {{silence}} - - // Bool is also an integer type, but conversions to it are a different AST - // node. - Agg<bool> b1 = {0}; // OK - Agg<bool> b2 = {1}; // OK - Agg<bool> b3 = {-1}; // expected-error {{ cannot be narrowed }} expected-note {{silence}} - - // Conversions from pointers to booleans aren't narrowing conversions. - Agg<bool>* ptr = &b1; - Agg<bool> b = {ptr}; // OK - - Agg<short> ce1 = { Convert<int>(100000) }; // expected-error {{constant expression evaluates to 100000 which cannot be narrowed to type 'short'}} expected-note {{silence}} expected-warning {{changes value from 100000 to -31072}} - Agg<char> ce2 = { ConvertVar<short>() }; // expected-error {{non-constant-expression cannot be narrowed from type 'short' to 'char'}} expected-note {{silence}} - - // Negative -> larger unsigned type. - unsigned long long ll1 = { -1 }; // expected-error {{ -1 which cannot be narrowed}} expected-note {{silence}} - unsigned long long ll2 = { 1 }; // OK - unsigned long long ll3 = { s }; // expected-error {{cannot be narrowed from type 'short'}} expected-note {{silence}} - unsigned long long ll4 = { us }; // OK - unsigned long long ll5 = { ll }; // expected-error {{cannot be narrowed from type 'long long'}} expected-note {{silence}} - Agg<unsigned long long> ll6 = { -1 }; // expected-error {{ -1 which cannot be narrowed}} expected-note {{silence}} - Agg<unsigned long long> ll7 = { 18446744073709551615ULL }; // OK - Agg<unsigned long long> ll8 = { __int128(18446744073709551615ULL) + 1 }; // expected-error {{ 18446744073709551616 which cannot be narrowed}} expected-note {{silence}} expected-warning {{changes value}} - signed char c = 'x'; - unsigned short usc1 = { c }; // expected-error {{non-constant-expression cannot be narrowed from type 'signed char'}} expected-note {{silence}} - unsigned short usc2 = { (signed char)'x' }; // OK - unsigned short usc3 = { (signed char)-1 }; // expected-error {{ -1 which cannot be narrowed}} expected-note {{silence}} -} - -// Be sure that type- and value-dependent expressions in templates get the error -// too. - -template<int I, typename T> -void maybe_shrink_int(T t) { - Agg<short> s1 = {t}; // expected-error {{ cannot be narrowed }} expected-note {{silence}} - Agg<short> s2 = {I}; // expected-error {{ cannot be narrowed }} expected-note {{silence}} expected-warning {{changes value}} - Agg<T> t2 = {700}; // expected-error {{ cannot be narrowed }} expected-note {{silence}} expected-warning {{changes value}} -} - -void test_template() { - maybe_shrink_int<15>((int)3); // expected-note {{in instantiation}} - maybe_shrink_int<70000>((char)3); // expected-note {{in instantiation}} -} - - -// We don't want qualifiers on the types in the diagnostic. - -void test_qualifiers(int i) { - const int j = i; - struct {const unsigned char c;} c1 = {j}; // expected-error {{from type 'int' to 'unsigned char' in}} expected-note {{silence}} - // Template arguments make it harder to avoid printing qualifiers: - Agg<const unsigned char> c2 = {j}; // expected-error {{from type 'int' to 'const unsigned char' in}} expected-note {{silence}} -} - -// Test SFINAE checks. -template<unsigned> struct Value { }; - -template<typename T> -int &check_narrowed(Value<sizeof((T){1.1})>); - -template<typename T> -float &check_narrowed(...); - -void test_narrowed(Value<sizeof(int)> vi, Value<sizeof(double)> vd) { - int &ir = check_narrowed<double>(vd); - float &fr = check_narrowed<int>(vi); -} diff --git a/test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-cxx11-nowarn.cpp b/test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-cxx11-nowarn.cpp deleted file mode 100644 index d4d8198d4fc8..000000000000 --- a/test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-cxx11-nowarn.cpp +++ /dev/null @@ -1,211 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -std=c++11 -Wno-error=c++11-narrowing -triple x86_64-apple-macosx10.6.7 -verify %s -// RUN: %clang_cc1 -fsyntax-only -std=c++11 -Wno-error=narrowing -triple x86_64-apple-macosx10.6.7 -verify %s - -// Verify that narrowing conversions in initializer lists cause errors in C++0x -// mode. - -void std_example() { - int x = 999; // x is not a constant expression - const int y = 999; - const int z = 99; - char c1 = x; // OK, though it might narrow (in this case, it does narrow) - char c2{x}; // expected-warning {{ cannot be narrowed }} expected-note {{silence}} - char c3{y}; // expected-warning {{ cannot be narrowed }} expected-note {{silence}} expected-warning {{changes value}} - char c4{z}; // OK: no narrowing needed - unsigned char uc1 = {5}; // OK: no narrowing needed - unsigned char uc2 = {-1}; // expected-warning {{ cannot be narrowed }} expected-note {{silence}} - unsigned int ui1 = {-1}; // expected-warning {{ cannot be narrowed }} expected-note {{silence}} - signed int si1 = - { (unsigned int)-1 }; // expected-warning {{ cannot be narrowed }} expected-note {{silence}} - int ii = {2.0}; // expected-warning {{ cannot be narrowed }} expected-note {{silence}} - float f1 { x }; // expected-warning {{ cannot be narrowed }} expected-note {{silence}} - float f2 { 7 }; // OK: 7 can be exactly represented as a float - int f(int); - int a[] = - { 2, f(2), f(2.0) }; // OK: the double-to-int conversion is not at the top level -} - -// Test each rule individually. - -template<typename T> -struct Agg { - T t; -}; - -template<typename T> -struct Convert { - constexpr Convert(T v) : v(v) {} - constexpr operator T() const { return v; } - T v; -}; -template<typename T> Convert<T> ConvertVar(); - -// C++0x [dcl.init.list]p7: A narrowing conversion is an implicit conversion -// -// * from a floating-point type to an integer type, or - -void float_to_int() { - Agg<char> a1 = {1.0F}; // expected-warning {{type 'float' cannot be narrowed to 'char'}} expected-note {{silence}} - Agg<char> a2 = {1.0}; // expected-warning {{ cannot be narrowed }} expected-note {{silence}} - Agg<char> a3 = {1.0L}; // expected-warning {{ cannot be narrowed }} expected-note {{silence}} - - float f = 1.0; - double d = 1.0; - long double ld = 1.0; - Agg<char> a4 = {f}; // expected-warning {{ cannot be narrowed }} expected-note {{silence}} - Agg<char> a5 = {d}; // expected-warning {{ cannot be narrowed }} expected-note {{silence}} - Agg<char> a6 = {ld}; // expected-warning {{ cannot be narrowed }} expected-note {{silence}} - - Agg<char> ce1 = { Convert<float>(1.0) }; // expected-warning {{type 'float' cannot be narrowed to 'char'}} expected-note {{silence}} - Agg<char> ce2 = { ConvertVar<double>() }; // expected-warning {{type 'double' cannot be narrowed to 'char'}} expected-note {{silence}} -} - -// * from long double to double or float, or from double to float, except where -// the source is a constant expression and the actual value after conversion -// is within the range of values that can be represented (even if it cannot be -// represented exactly), or - -void shrink_float() { - // These aren't constant expressions. - float f = 1.0; - double d = 1.0; - long double ld = 1.0; - - // Variables. - Agg<float> f1 = {f}; // OK (no-op) - Agg<float> f2 = {d}; // expected-warning {{non-constant-expression cannot be narrowed from type 'double' to 'float'}} expected-note {{silence}} - Agg<float> f3 = {ld}; // expected-warning {{ cannot be narrowed }} expected-note {{silence}} - // Exact constants. - Agg<float> f4 = {1.0}; // OK (double constant represented exactly) - Agg<float> f5 = {1.0L}; // OK (long double constant represented exactly) - // Inexact but in-range constants. - Agg<float> f6 = {0.1}; // OK (double constant in range but rounded) - Agg<float> f7 = {0.1L}; // OK (long double constant in range but rounded) - // Out of range constants. - Agg<float> f8 = {1E50}; // expected-warning {{constant expression evaluates to 1.000000e+50 which cannot be narrowed to type 'float'}} expected-note {{silence}} - Agg<float> f9 = {1E50L}; // expected-warning {{ cannot be narrowed }} expected-note {{silence}} - // More complex constant expression. - constexpr long double e40 = 1E40L, e30 = 1E30L, e39 = 1E39L; - Agg<float> f10 = {e40 - 5 * e39 + e30 - 5 * e39}; // OK - - // Variables. - Agg<double> d1 = {f}; // OK (widening) - Agg<double> d2 = {d}; // OK (no-op) - Agg<double> d3 = {ld}; // expected-warning {{ cannot be narrowed }} expected-note {{silence}} - // Exact constant. - Agg<double> d4 = {1.0L}; // OK (long double constant represented exactly) - // Inexact but in-range constant. - Agg<double> d5 = {0.1L}; // OK (long double constant in range but rounded) - // Out of range constant. - Agg<double> d6 = {1E315L}; // expected-warning {{ cannot be narrowed }} expected-note {{silence}} - // More complex constant expression. - constexpr long double e315 = 1E315L, e305 = 1E305L, e314 = 1E314L; - Agg<double> d7 = {e315 - 5 * e314 + e305 - 5 * e314}; // OK - - Agg<float> ce1 = { Convert<double>(1e300) }; // expected-warning {{constant expression evaluates to 1.000000e+300 which cannot be narrowed to type 'float'}} expected-note {{silence}} - Agg<double> ce2 = { ConvertVar<long double>() }; // expected-warning {{non-constant-expression cannot be narrowed from type 'long double' to 'double'}} expected-note {{silence}} -} - -// * from an integer type or unscoped enumeration type to a floating-point type, -// except where the source is a constant expression and the actual value after -// conversion will fit into the target type and will produce the original -// value when converted back to the original type, or -void int_to_float() { - // Not a constant expression. - char c = 1; - - // Variables. Yes, even though all char's will fit into any floating type. - Agg<float> f1 = {c}; // expected-warning {{ cannot be narrowed }} expected-note {{silence}} - Agg<double> f2 = {c}; // expected-warning {{ cannot be narrowed }} expected-note {{silence}} - Agg<long double> f3 = {c}; // expected-warning {{ cannot be narrowed }} expected-note {{silence}} - - // Constants. - Agg<float> f4 = {12345678}; // OK (exactly fits in a float) - Agg<float> f5 = {123456789}; // expected-warning {{ cannot be narrowed }} expected-note {{silence}} - - Agg<float> ce1 = { Convert<int>(123456789) }; // expected-warning {{constant expression evaluates to 123456789 which cannot be narrowed to type 'float'}} expected-note {{silence}} - Agg<double> ce2 = { ConvertVar<long long>() }; // expected-warning {{non-constant-expression cannot be narrowed from type 'long long' to 'double'}} expected-note {{silence}} -} - -// * from an integer type or unscoped enumeration type to an integer type that -// cannot represent all the values of the original type, except where the -// source is a constant expression and the actual value after conversion will -// fit into the target type and will produce the original value when converted -// back to the original type. -void shrink_int() { - // Not a constant expression. - short s = 1; - unsigned short us = 1; - Agg<char> c1 = {s}; // expected-warning {{ cannot be narrowed }} expected-note {{silence}} - Agg<unsigned short> s1 = {s}; // expected-warning {{ cannot be narrowed }} expected-note {{silence}} - Agg<short> s2 = {us}; // expected-warning {{ cannot be narrowed }} expected-note {{silence}} - - // "that cannot represent all the values of the original type" means that the - // validity of the program depends on the relative sizes of integral types. - // This test compiles with -m64, so sizeof(int)<sizeof(long)==sizeof(long - // long). - long l1 = 1; - Agg<int> i1 = {l1}; // expected-warning {{ cannot be narrowed }} expected-note {{silence}} - long long ll = 1; - Agg<long> l2 = {ll}; // OK - - // Constants. - Agg<char> c2 = {127}; // OK - Agg<char> c3 = {300}; // expected-warning {{ cannot be narrowed }} expected-note {{silence}} expected-warning {{changes value}} - - Agg<int> i2 = {0x7FFFFFFFU}; // OK - Agg<int> i3 = {0x80000000U}; // expected-warning {{ cannot be narrowed }} expected-note {{silence}} - Agg<unsigned int> i4 = {-0x80000000L}; // expected-warning {{ cannot be narrowed }} expected-note {{silence}} - - // Bool is also an integer type, but conversions to it are a different AST - // node. - Agg<bool> b1 = {0}; // OK - Agg<bool> b2 = {1}; // OK - Agg<bool> b3 = {-1}; // expected-warning {{ cannot be narrowed }} expected-note {{silence}} - - // Conversions from pointers to booleans aren't narrowing conversions. - Agg<bool>* ptr = &b1; - Agg<bool> b = {ptr}; // OK - - Agg<short> ce1 = { Convert<int>(100000) }; // expected-warning {{constant expression evaluates to 100000 which cannot be narrowed to type 'short'}} expected-note {{silence}} expected-warning {{changes value from 100000 to -31072}} - Agg<char> ce2 = { ConvertVar<short>() }; // expected-warning {{non-constant-expression cannot be narrowed from type 'short' to 'char'}} expected-note {{silence}} -} - -// Be sure that type- and value-dependent expressions in templates get the warning -// too. - -template<int I, typename T> -void maybe_shrink_int(T t) { - Agg<short> s1 = {t}; // expected-warning {{ cannot be narrowed }} expected-note {{silence}} - Agg<short> s2 = {I}; // expected-warning {{ cannot be narrowed }} expected-note {{silence}} expected-warning {{changes value}} - Agg<T> t2 = {700}; // expected-warning {{ cannot be narrowed }} expected-note {{silence}} expected-warning {{changes value}} -} - -void test_template() { - maybe_shrink_int<15>((int)3); // expected-note {{in instantiation}} - maybe_shrink_int<70000>((char)3); // expected-note {{in instantiation}} -} - - -// We don't want qualifiers on the types in the diagnostic. - -void test_qualifiers(int i) { - const int j = i; - struct {const unsigned char c;} c1 = {j}; // expected-warning {{from type 'int' to 'unsigned char' in}} expected-note {{silence}} - // Template arguments make it harder to avoid printing qualifiers: - Agg<const unsigned char> c2 = {j}; // expected-warning {{from type 'int' to 'const unsigned char' in}} expected-note {{silence}} -} - -// Make sure we still get the right SFINAE behavior. -template<unsigned> struct Value { }; - -template<typename T> -int &check_narrowed(Value<sizeof((T){1.1})>); - -template<typename T> -float &check_narrowed(...); - -void test_narrowed(Value<sizeof(int)> vi, Value<sizeof(double)> vd) { - int &ir = check_narrowed<double>(vd); - float &fr = check_narrowed<int>(vi); -} diff --git a/test/CXX/dcl.decl/dcl.init/dcl.init.ref/basic.cpp b/test/CXX/dcl.decl/dcl.init/dcl.init.ref/basic.cpp deleted file mode 100644 index 2c9cd88e40bf..000000000000 --- a/test/CXX/dcl.decl/dcl.init/dcl.init.ref/basic.cpp +++ /dev/null @@ -1,20 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -// expected-no-diagnostics - -// PR5787 -class C { - public: - ~C() {} -}; - -template <typename T> -class E { - public: - E& Foo(const C&); - E& Bar() { return Foo(C()); } -}; - -void Test() { - E<int> e; - e.Bar(); -} diff --git a/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p1.cpp b/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p1.cpp deleted file mode 100644 index 76053f028e2b..000000000000 --- a/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p1.cpp +++ /dev/null @@ -1,15 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s -// expected-no-diagnostics -int g(int); -void f() { - int i; - int& r = i; - r = 1; - int* p = &r; - int &rr=r; - int (&rg)(int) = g; - rg(i); - int a[3]; - int (&ra)[3] = a; - ra[1] = i; -} diff --git a/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p3.cpp b/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p3.cpp deleted file mode 100644 index 47e215a0a904..000000000000 --- a/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p3.cpp +++ /dev/null @@ -1,3 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -int& r1; // expected-error{{declaration of reference variable 'r1' requires an initializer}} -extern int& r2; diff --git a/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p4.cpp b/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p4.cpp deleted file mode 100644 index 1a3732d99ea6..000000000000 --- a/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p4.cpp +++ /dev/null @@ -1,13 +0,0 @@ -// RUN: %clang_cc1 -std=c++1z -verify %s - -void f() noexcept; -void (&r)() = f; -void (&s)() noexcept = r; // expected-error {{cannot bind}} - -void (&cond1)() noexcept = true ? r : f; // expected-error {{cannot bind}} -void (&cond2)() noexcept = true ? f : r; // expected-error {{cannot bind}} -// FIXME: Strictly, the rules in p4 don't allow this, because the operand types -// are not of the same type other than cv-qualifiers, but we consider that to -// be a defect, and instead allow reference-compatible types here. -void (&cond3)() = true ? r : f; -void (&cond4)() = true ? f : r; diff --git a/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-0x.cpp b/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-0x.cpp deleted file mode 100644 index a4d7d63754b9..000000000000 --- a/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-0x.cpp +++ /dev/null @@ -1,236 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify -pedantic %s - -// Test the c++0x-specific reference initialization rules, e.g., the -// rules for rvalue references. -template<typename T> T prvalue(); -template<typename T> T&& xvalue(); -template<typename T> T& lvalue(); - -struct Base { }; -struct Derived : Base { }; - -struct HasArray { - int array[5]; -}; - -int f(int); - -template<typename T> -struct ConvertsTo { - operator T(); // expected-note 2{{candidate function}} -}; - -void test_rvalue_refs() { - // If the initializer expression... - // - is an xvalue, class prvalue, array prvalue or function lvalue - // and "cv1 T1" is reference-compatible with "cv2 T2", or - - // xvalue case - Base&& base0 = xvalue<Base>(); - Base&& base1 = xvalue<Derived>(); - int&& int0 = xvalue<int>(); - - // class prvalue case - Base&& base2 = prvalue<Base>(); - Base&& base3 = prvalue<Derived>(); - - // array prvalue case - int (&&array0)[5] = HasArray().array; - - // function lvalue case - int (&&function0)(int) = f; - - // - has a class type (i.e., T2 is a class type), where T1 is not - // reference-related to T2, and can be implicitly converted to - // an xvalue, class prvalue, or function lvalue of type "cv3 - // T3", where "cv1 T1" is reference-compatible with "cv3 T3", - - // xvalue - Base&& base4 = ConvertsTo<Base&&>(); - Base&& base5 = ConvertsTo<Derived&&>(); - int && int1 = ConvertsTo<int&&>(); - - // class prvalue - Base&& base6 = ConvertsTo<Base>(); - Base&& base7 = ConvertsTo<Derived>(); - - // function lvalue - int (&&function1)(int) = ConvertsTo<int(&)(int)>(); - - // In the second case, if the reference is an rvalue reference and - // the second standard conversion sequence of the user-defined - // conversion sequence includes an lvalue-to-rvalue conversion, the - // program is ill-formed. - int &&int2 = ConvertsTo<int&>(); // expected-error{{no viable conversion from 'ConvertsTo<int &>' to 'int'}} - int &&int3 = ConvertsTo<float&>(); // expected-error{{no viable conversion from 'ConvertsTo<float &>' to 'int'}} -} - -class NonCopyable { - NonCopyable(const NonCopyable&); -}; - -class NonCopyableDerived : public NonCopyable { - NonCopyableDerived(const NonCopyableDerived&); -}; - -// Make sure we get direct bindings with no copies. -void test_direct_binding() { - NonCopyable &&nc0 = prvalue<NonCopyable>(); - NonCopyable &&nc1 = prvalue<NonCopyableDerived>(); - NonCopyable &&nc2 = xvalue<NonCopyable>(); - NonCopyable &&nc3 = xvalue<NonCopyableDerived>(); - const NonCopyable &nc4 = prvalue<NonCopyable>(); - const NonCopyable &nc5 = prvalue<NonCopyableDerived>(); - const NonCopyable &nc6 = xvalue<NonCopyable>(); - const NonCopyable &nc7 = xvalue<NonCopyableDerived>(); - NonCopyable &&nc8 = ConvertsTo<NonCopyable&&>(); - NonCopyable &&nc9 = ConvertsTo<NonCopyableDerived&&>(); - const NonCopyable &nc10 = ConvertsTo<NonCopyable&&>(); - const NonCopyable &nc11 = ConvertsTo<NonCopyableDerived&&>(); -} - -namespace std_example_1 { - double d = 2.0; - double& rd = d; - const double& rcd = d; - struct A { }; - struct B : A { - operator int&(); - } b; - A& ra = b; - const A& rca = b; - int& ir = B(); -} - -namespace std_example_2 { - double& rd2 = 2.0; // expected-error{{non-const lvalue reference to type 'double' cannot bind to a temporary of type 'double'}} - int i = 2; - double& rd3 = i; // expected-error{{non-const lvalue reference to type 'double' cannot bind to a value of unrelated type 'int'}} - struct A { }; - struct B : A { } b; - extern B f(); - const A& rca = f(); - A&& rra = f(); - struct X { - operator B(); // expected-note{{candidate function}} - operator int&(); // expected-note{{candidate function}} - } x; - const A& r = x; - int&& rri = static_cast<int&&>(i); - B&& rrb = x; - int&& rri2 = X(); // expected-error{{no viable conversion from 'std_example_2::X' to 'int'}} - - const double& rcd2 = 2; - double&& rrd = 2; - const volatile int cvi = 1; - const int& r2 = cvi; // expected-error{{binding value of type 'const volatile int' to reference to type 'const int' drops 'volatile' qualifier}} - - double d; - double&& rrd2 = d; // expected-error{{rvalue reference to type 'double' cannot bind to lvalue of type 'double'}} - double&& rrd3 = i; -} - -namespace argument_passing { - void base_rvalue_ref(Base&&); - void int_rvalue_ref(int&&); // expected-note{{candidate function not viable: no known conversion from 'ConvertsTo<int &>' to 'int &&' for 1st argument}} \ - // expected-note{{candidate function not viable: no known conversion from 'ConvertsTo<float &>' to 'int &&' for 1st argument}} - - void array_rvalue_ref(int (&&)[5]); - void function_rvalue_ref(int (&&)(int)); - - void test() { - base_rvalue_ref(xvalue<Base>()); - base_rvalue_ref(xvalue<Derived>()); - int_rvalue_ref(xvalue<int>()); - - base_rvalue_ref(prvalue<Base>()); - base_rvalue_ref(prvalue<Derived>()); - - array_rvalue_ref(HasArray().array); - - function_rvalue_ref(f); - - base_rvalue_ref(ConvertsTo<Base&&>()); - base_rvalue_ref(ConvertsTo<Derived&&>()); - int_rvalue_ref(ConvertsTo<int&&>()); - - base_rvalue_ref(ConvertsTo<Base>()); - base_rvalue_ref(ConvertsTo<Derived>()); - - function_rvalue_ref(ConvertsTo<int(&)(int)>()); - - int_rvalue_ref(ConvertsTo<int&>()); // expected-error{{no matching function for call to 'int_rvalue_ref'}} - int_rvalue_ref(ConvertsTo<float&>()); // expected-error{{no matching function for call to 'int_rvalue_ref'}} - } - -} - -namespace pr10644 { - struct string { - string(const char* __s); - }; - class map { - int& operator[](const string& __k); - public: - int& operator[](const string&& __k); - }; - void foo() { - static map key_map; - key_map["line"]; - } -} - -namespace PR11003 { - class Value { - }; - struct MoveRef { - operator Value &() const ; - }; - MoveRef Move(int); - void growTo() { - Value x = Move(0); - Value y(Move(0)); - } -} - -namespace rdar13278115 { - struct X { }; - struct Y : X { }; - X &&f0(X &x) { return x; } // expected-error{{rvalue reference to type 'rdar13278115::X' cannot bind to lvalue of type 'rdar13278115::X'}} - X &&f1(Y &y) { return y; } // expected-error{{rvalue reference to type 'rdar13278115::X' cannot bind to lvalue of type 'rdar13278115::Y'}} - const X &&f2(Y &y) { return y; } // expected-error{{rvalue reference to type 'const rdar13278115::X' cannot bind to lvalue of type 'rdar13278115::Y'}} -} - -namespace bitfields { - struct IntBitfield { - int i : 17; // expected-note 3 {{bit-field is declared here}} - }; - - // A simplified version of std::move. - template <typename T> - T &&move(T &obj) { - return static_cast<T &&>(obj); - } - - void test() { - int & ir1 = (lvalue<IntBitfield>().i); // expected-error{{non-const reference cannot bind to bit-field 'i'}} - int & ir2 = (xvalue<IntBitfield>().i); // expected-error{{non-const lvalue reference to type 'int' cannot bind to a temporary of type 'int'}} - int && ir3 = (xvalue<IntBitfield>().i); // no-warning - int && ir4 = move(lvalue<IntBitfield>()).i; // no-warning - - volatile int & vir1 = (lvalue<IntBitfield>().i); // expected-error{{non-const reference cannot bind to bit-field 'i'}} - volatile int & vir2 = (xvalue<IntBitfield>().i); // expected-error{{volatile lvalue reference to type 'volatile int' cannot bind to a temporary of type 'int'}} - volatile int && vir3 = (xvalue<IntBitfield>().i); // no-warning - volatile int && vir4 = move(lvalue<IntBitfield>()).i; // no-warning - - const int & cir1 = (lvalue<IntBitfield>().i); // no-warning - const int & cir2 = (xvalue<IntBitfield>().i); // no-warning - const int && cir3 = (xvalue<IntBitfield>().i); // no-warning - const int && cir4 = move(lvalue<IntBitfield>()).i; // no-warning - - const volatile int & cvir1 = (lvalue<IntBitfield>().i); // expected-error{{non-const reference cannot bind to bit-field 'i'}} - const volatile int & cvir2 = (xvalue<IntBitfield>().i); // expected-error{{volatile lvalue reference to type 'const volatile int' cannot bind to a temporary of type 'int'}} - const volatile int && cvir3 = (xvalue<IntBitfield>().i); // no-warning - const volatile int && cvir4 = move(lvalue<IntBitfield>()).i; // no-warning - } -} diff --git a/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-cxx03-extra-copy.cpp b/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-cxx03-extra-copy.cpp deleted file mode 100644 index 7a5caef36e73..000000000000 --- a/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-cxx03-extra-copy.cpp +++ /dev/null @@ -1,77 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -std=c++03 -fdiagnostics-show-option -Wbind-to-temporary-copy -verify %s - -// C++03 requires that we check for a copy constructor when binding a -// reference to a temporary, since we are allowed to make a copy, Even -// though we don't actually make that copy, make sure that we diagnose -// cases where that copy constructor is somehow unavailable. As an -// extension, this is only a warning. - -struct X1 { - X1(); - explicit X1(const X1&); -}; - -struct X2 { - X2(); - -private: - X2(const X2&); // expected-note{{declared private here}} -}; - -struct X3 { - X3(); // expected-note{{requires 0 arguments, but 1 was provided}} - -private: - X3(X3&); // expected-note{{candidate constructor not viable: expects an l-value for 1st argument}} -}; - -// Check for instantiation of default arguments -template<typename T> -T get_value_badly() { - double *dp = 0; - // The extension doesn't extend far enough to turn this error into a warning. - T *tp = dp; // expected-error{{cannot initialize a variable of type 'int *' with an lvalue of type 'double *'}} - return T(); -} - -template<typename T> -struct X4 { - X4(); - X4(const X4&, T = get_value_badly<T>()); // expected-note{{in instantiation of}} -}; - -// Check for "dangerous" default arguments that could cause recursion. -struct X5 { - X5(); // expected-note {{requires 0 arguments}} - X5(const X5&, const X5& = X5()); // expected-warning{{no viable constructor copying parameter of type 'X5'}} expected-note {{requires 2 arguments}} -}; - -void g1(const X1&); -void g2(const X2&); -void g3(const X3&); -void g4(const X4<int>&); -void g5(const X5&); - -void test() { - g1(X1()); - g2(X2()); // expected-warning{{C++98 requires an accessible copy constructor for class 'X2' when binding a reference to a temporary; was private}} - g3(X3()); // expected-warning{{no viable constructor copying parameter of type 'X3'}} - g4(X4<int>()); - g5(X5()); // Generates a warning in the default argument. -} - -// Check that unavailable copy constructors still cause SFINAE failures. -template<int> struct int_c { }; - -template<typename T> T f(const T&); - -// Would be ambiguous with the next g(), except the instantiation failure in -// sizeof() prevents that. -template<typename T> -int &g(int_c<sizeof(f(T()))> * = 0); - -template<typename T> float &g(); - -void h() { - float &fp2 = g<X3>(); // Not ambiguous. -} diff --git a/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-cxx0x-no-extra-copy.cpp b/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-cxx0x-no-extra-copy.cpp deleted file mode 100644 index 27eb6d1c078f..000000000000 --- a/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-cxx0x-no-extra-copy.cpp +++ /dev/null @@ -1,64 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s - -// C++03 requires that we check for a copy constructor when binding a -// reference to a reference-compatible rvalue, since we are allowed to -// make a copy. C++0x does not permit the copy, so ensure that we -// don't diagnose cases where the copy constructor is unavailable. - -struct X1 { - X1(); - explicit X1(const X1&); -}; - -struct X2 { - X2(); - -private: - X2(const X2&); -}; - -struct X3 { - X3(); - -private: - X3(X3&); -}; - -template<typename T> -T get_value_badly() { - double *dp = 0; - T *tp = dp; - return T(); -} - -template<typename T> -struct X4 { - X4(); - X4(const X4&, T = get_value_badly<T>()); -}; - -void g1(const X1&); -void g2(const X2&); -void g3(const X3&); -void g4(const X4<int>&); - -void test() { - g1(X1()); - g2(X2()); - g3(X3()); - g4(X4<int>()); -} - -// Check that unavailable copy constructors do not cause SFINAE failures. -template<int> struct int_c { }; - -template<typename T> T f(const T&); - -template<typename T> -int &g(int_c<sizeof(f(T()))> * = 0); // expected-note{{candidate function [with T = X3]}} - -template<typename T> float &g(); // expected-note{{candidate function [with T = X3]}} - -void h() { - float &fp = g<X3>(); // expected-error{{call to 'g' is ambiguous}} -} diff --git a/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-examples.cpp b/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-examples.cpp deleted file mode 100644 index 46593b7e2adb..000000000000 --- a/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-examples.cpp +++ /dev/null @@ -1,56 +0,0 @@ -// RUN: %clang_cc1 -ast-dump %s 2>&1 | FileCheck %s
-
-// CHECK-LABEL: example0
-void example0() {
- double d = 2.0;
- // CHECK: VarDecl{{.*}}rd 'double &'
- // CHECK-NEXT: DeclRefExpr
- double &rd = d;
- // CHECK: VarDecl{{.*}}rcd 'const double &'
- // CHECK-NEXT: ImplicitCastExpr{{.*}}'const double' lvalue <NoOp>
- const double &rcd = d;
-}
-
-struct A { };
-struct B : A { } b;
-
-// CHECK-LABEL: example1
-void example1() {
- // CHECK: VarDecl{{.*}}ra 'A &'
- // CHECK: ImplicitCastExpr{{.*}}'A' lvalue <DerivedToBase (A)>
- A &ra = b;
- // CHECK: VarDecl{{.*}}rca 'const A &'
- // CHECK: ImplicitCastExpr{{.*}}'const A' lvalue <DerivedToBase (A)>
- // CHECK-NOT: MaterializeTemporaryExpr
- // CHECK: ImplicitCastExpr{{.*}}'const B' lvalue <NoOp>
- const A& rca = b;
-}
-
-extern B f();
-
-struct X {
- operator B();
-} x;
-
-// CHECK-LABEL: example2
-void example2() {
- // CHECK: VarDecl{{.*}}rca 'const A &'
- // CHECK: ImplicitCastExpr{{.*}}'const A' lvalue <DerivedToBase (A)>
- // CHECK: MaterializeTemporaryExpr{{.*}}'const B'
- // CHECK: ImplicitCastExpr{{.*}}'const B' <NoOp>
- // CHECK: CallExpr{{.*}}B
- const A &rca = f();
- // CHECK: VarDecl{{.*}}r 'const A &'
- // CHECK: ImplicitCastExpr{{.*}}'const A' lvalue <DerivedToBase (A)>
- // CHECK: MaterializeTemporaryExpr{{.*}}'const B'
- // CHECK: ImplicitCastExpr{{.*}}'const B' <NoOp>
- // CHECK: CXXMemberCallExpr{{.*}}'B'
- const A& r = x;
-}
-
-// CHECK-LABEL: example3
-void example3() {
- // CHECK: VarDecl{{.*}}rcd2 'const double &'
- // CHECK: ImplicitCastExpr{{.*}} <IntegralToFloating>
- const double& rcd2 = 2;
-}
diff --git a/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-var.cpp b/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-var.cpp deleted file mode 100644 index 382212269772..000000000000 --- a/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-var.cpp +++ /dev/null @@ -1,140 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s - -struct Base { }; -struct Derived : Base { }; // expected-note{{candidate constructor (the implicit copy constructor) not viable}} -#if __cplusplus >= 201103L // C++11 or later -// expected-note@-2 {{candidate constructor (the implicit move constructor) not viable}} -#endif -struct Unrelated { }; -struct Derived2 : Base { }; -struct Diamond : Derived, Derived2 { }; - -struct ConvertibleToBaseRef { - operator Base&() const; -}; - -struct ConvertibleToDerivedRef { - operator Derived&() const; -}; - -struct ConvertibleToBothDerivedRef { - operator Derived&(); // expected-note{{candidate function}} - operator Derived2&(); // expected-note{{candidate function}} -}; - -struct ConvertibleToIntRef { - operator int&(); -}; - -struct ConvertibleToBase { - operator Base() const; -}; - -struct ConvertibleToDerived { - operator Derived() const; -}; - -struct ConvertibleToBothDerived { - operator Derived(); // expected-note{{candidate function}} - operator Derived2(); // expected-note{{candidate function}} -}; - -struct ConvertibleToInt { - operator int(); -}; - -template<typename T> T create(); - -// First bullet: lvalue references binding to lvalues (the simple cases). -void bind_lvalue_to_lvalue(Base b, Derived d, - const Base bc, const Derived dc, - Diamond diamond, - int i) { - // Reference-compatible - Base &br1 = b; - Base &br2 = d; - Derived &dr1 = d; - Derived &dr2 = b; // expected-error{{non-const lvalue reference to type 'Derived' cannot bind to a value of unrelated type 'Base'}} - Base &br3 = bc; // expected-error{{drops 'const' qualifier}} - Base &br4 = dc; // expected-error{{drops 'const' qualifier}} - Base &br5 = diamond; // expected-error{{ambiguous conversion from derived class 'Diamond' to base class 'Base':}} - int &ir = i; - long &lr = i; // expected-error{{non-const lvalue reference to type 'long' cannot bind to a value of unrelated type 'int'}} -} - -void bind_lvalue_quals(volatile Base b, volatile Derived d, - volatile const Base bvc, volatile const Derived dvc, - volatile const int ivc) { - volatile Base &bvr1 = b; - volatile Base &bvr2 = d; - volatile Base &bvr3 = bvc; // expected-error{{binding value of type 'const volatile Base' to reference to type 'volatile Base' drops 'const' qualifier}} - volatile Base &bvr4 = dvc; // expected-error{{binding value of type 'const volatile Derived' to reference to type 'volatile Base' drops 'const' qualifier}} - - volatile int &ir = ivc; // expected-error{{binding value of type 'const volatile int' to reference to type 'volatile int' drops 'const' qualifier}} - - const volatile Base &bcvr1 = b; - const volatile Base &bcvr2 = d; -} - -void bind_lvalue_to_rvalue() { - Base &br1 = Base(); // expected-error{{non-const lvalue reference to type 'Base' cannot bind to a temporary of type 'Base'}} - Base &br2 = Derived(); // expected-error{{non-const lvalue reference to type 'Base' cannot bind to a temporary of type 'Derived'}} - const volatile Base &br3 = Base(); // expected-error{{volatile lvalue reference to type 'const volatile Base' cannot bind to a temporary of type 'Base'}} - const volatile Base &br4 = Derived(); // expected-error{{volatile lvalue reference to type 'const volatile Base' cannot bind to a temporary of type 'Derived'}} - - int &ir = 17; // expected-error{{non-const lvalue reference to type 'int' cannot bind to a temporary of type 'int'}} -} - -void bind_lvalue_to_unrelated(Unrelated ur) { - Base &br1 = ur; // expected-error{{non-const lvalue reference to type 'Base' cannot bind to a value of unrelated type 'Unrelated'}} - const volatile Base &br2 = ur; // expected-error{{volatile lvalue reference to type 'const volatile Base' cannot bind to a value of unrelated type 'Unrelated'}} -} - -void bind_lvalue_to_conv_lvalue() { - // Not reference-related, but convertible - Base &nbr1 = ConvertibleToBaseRef(); - Base &nbr2 = ConvertibleToDerivedRef(); - Derived &ndr1 = ConvertibleToDerivedRef(); - int &ir = ConvertibleToIntRef(); -} - -void bind_lvalue_to_conv_lvalue_ambig(ConvertibleToBothDerivedRef both) { - Derived &dr1 = both; - Base &br1 = both; // expected-error{{reference initialization of type 'Base &' with initializer of type 'ConvertibleToBothDerivedRef' is ambiguous}} -} - -struct IntBitfield { - int i : 17; // expected-note{{bit-field is declared here}} -}; - -void test_bitfield(IntBitfield ib) { - int & ir1 = (ib.i); // expected-error{{non-const reference cannot bind to bit-field 'i'}} -} - -// Second bullet: const lvalue reference binding to an rvalue with -// similar type (both of which are class types). -void bind_const_lvalue_to_rvalue() { - const Base &br1 = create<Base>(); - const Base &br2 = create<Derived>(); - const Derived &dr1 = create<Base>(); // expected-error{{no viable conversion}} - - const Base &br3 = create<const Base>(); - const Base &br4 = create<const Derived>(); - - const Base &br5 = create<const volatile Base>(); // expected-error{{binding value of type 'const volatile Base' to reference to type 'const Base' drops 'volatile' qualifier}} - const Base &br6 = create<const volatile Derived>(); // expected-error{{binding value of type 'const volatile Derived' to reference to type 'const Base' drops 'volatile' qualifier}} - - const int &ir = create<int>(); -} - -// Second bullet: const lvalue reference binds to the result of a conversion. -void bind_const_lvalue_to_class_conv_temporary() { - const Base &br1 = ConvertibleToBase(); - const Base &br2 = ConvertibleToDerived(); -} -void bind_lvalue_to_conv_rvalue_ambig(ConvertibleToBothDerived both) { - const Derived &dr1 = both; - const Base &br1 = both; // expected-error{{reference initialization of type 'const Base &' with initializer of type 'ConvertibleToBothDerived' is ambiguous}} -} diff --git a/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5.cpp b/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5.cpp deleted file mode 100644 index 869fc4f01493..000000000000 --- a/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5.cpp +++ /dev/null @@ -1,72 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s - -namespace PR5909 { - struct Foo { - int x : 20; - }; - - bool Test(const int& foo); - - const Foo f = { 0 }; // It compiles without the 'const'. - bool z = Test(f.x); -} - -namespace PR6264 { - typedef int (&T)[3]; - struct S - { - operator T (); - }; - void f() - { - T bar = S(); - } -} - -namespace PR6066 { - struct B { }; - struct A : B { - operator B*(); - operator B&(); // expected-warning{{conversion function converting 'PR6066::A' to its base class 'PR6066::B' will never be used}} - }; - - void f(B&); // no rvalues accepted - void f(B*); - - int g() { - f(A()); // calls f(B*) - return 0; - } -} - -namespace test3 { - struct A { - unsigned bitX : 4; // expected-note 3 {{bit-field is declared here}} - unsigned bitY : 4; // expected-note {{bit-field is declared here}} - unsigned var; - - void foo(); - }; - - void test(A *a) { - unsigned &t0 = a->bitX; // expected-error {{non-const reference cannot bind to bit-field 'bitX'}} - unsigned &t1 = (unsigned&) a->bitX; // expected-error {{C-style cast from bit-field lvalue to reference type 'unsigned int &'}} - unsigned &t2 = const_cast<unsigned&>(a->bitX); // expected-error {{const_cast from bit-field lvalue to reference type 'unsigned int &'}} - unsigned &t3 = (a->foo(), a->bitX); // expected-error {{non-const reference cannot bind to bit-field 'bitX'}} - unsigned &t4 = (a->var ? a->bitX : a->bitY); // expected-error {{non-const reference cannot bind to bit-field}} - unsigned &t5 = (a->var ? a->bitX : a->bitX); // expected-error {{non-const reference cannot bind to bit-field}} - unsigned &t6 = (a->var ? a->bitX : a->var); // expected-error {{non-const reference cannot bind to bit-field}} - unsigned &t7 = (a->var ? a->var : a->bitY); // expected-error {{non-const reference cannot bind to bit-field}} - unsigned &t8 = (a->bitX = 3); // expected-error {{non-const reference cannot bind to bit-field 'bitX'}} - unsigned &t9 = (a->bitY += 3); // expected-error {{non-const reference cannot bind to bit-field 'bitY'}} - } -} - -namespace explicit_ctor { - struct A {}; - struct B { // expected-note 2{{candidate}} - explicit B(const A&); - }; - A a; - const B &b(a); // expected-error {{no viable conversion}} -} diff --git a/test/CXX/dcl.decl/dcl.init/dcl.init.string/p1.cpp b/test/CXX/dcl.decl/dcl.init/dcl.init.string/p1.cpp deleted file mode 100644 index 878d2c68ec33..000000000000 --- a/test/CXX/dcl.decl/dcl.init/dcl.init.string/p1.cpp +++ /dev/null @@ -1,20 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -// expected-no-diagnostics - -char x1[]("hello"); -extern char x1[6]; - -char x2[] = "hello"; -extern char x2[6]; - -char x3[] = { "hello" }; -extern char x3[6]; - -wchar_t x4[](L"hello"); -extern wchar_t x4[6]; - -wchar_t x5[] = L"hello"; -extern wchar_t x5[6]; - -wchar_t x6[] = { L"hello" }; -extern wchar_t x6[6]; diff --git a/test/CXX/dcl.decl/dcl.init/dcl.init.string/p2.cpp b/test/CXX/dcl.decl/dcl.init/dcl.init.string/p2.cpp deleted file mode 100644 index 3d67fccb4282..000000000000 --- a/test/CXX/dcl.decl/dcl.init/dcl.init.string/p2.cpp +++ /dev/null @@ -1,2 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -char test1[1]="f"; // expected-error {{initializer-string for char array is too long}} diff --git a/test/CXX/dcl.decl/dcl.init/p14-0x.cpp b/test/CXX/dcl.decl/dcl.init/p14-0x.cpp deleted file mode 100644 index 419f2bff1282..000000000000 --- a/test/CXX/dcl.decl/dcl.init/p14-0x.cpp +++ /dev/null @@ -1,44 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s - -struct NoDefault { - NoDefault() = delete; // expected-note {{here}} - NoDefault(int); -}; -struct Explicit { // expected-note 2 {{candidate}} expected-note {{here}} - explicit Explicit(int); -}; -struct NoCopy { - NoCopy(); - NoCopy(const NoCopy &) = delete; // expected-note {{here}} -}; -struct NoMove { - NoMove(); - NoMove(NoMove &&) = delete; // expected-note {{here}} -}; -class Private { - Private(int); // expected-note {{here}} -public: - Private(); -}; -class Friend { - friend class S; - Friend(int); -}; - - -class S { - NoDefault nd1; - NoDefault nd2 = 42; - Explicit e1; // expected-note {{here}} - Explicit e2 = 42; // expected-error {{no viable conversion}} - NoCopy nc = NoCopy(); // expected-error {{call to deleted}} - NoMove nm = NoMove(); // expected-error {{call to deleted}} - Private p = 42; // expected-error {{private constructor}} - Friend f = 42; - - S() {} // expected-error {{call to deleted constructor of 'NoDefault'}} \ - expected-error {{must explicitly initialize the member 'e1' which does not have a default constructor}} - S(int) : nd1(42), e1(42) {} -}; - -// FIXME: test the other forms which use copy-initialization diff --git a/test/CXX/dcl.decl/dcl.init/p5.cpp b/test/CXX/dcl.decl/dcl.init/p5.cpp deleted file mode 100644 index 76e53edf3357..000000000000 --- a/test/CXX/dcl.decl/dcl.init/p5.cpp +++ /dev/null @@ -1,73 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s -// RUN: %clang_cc1 -fsyntax-only -verify %s - -// A program that calls for default-initialization or value-initialization of -// an entity of reference type is illformed. If T is a cv-qualified type, the -// cv-unqualified version of T is used for these definitions of -// zero-initialization, default-initialization, and value-initialization. - -typedef int &IR; -IR r; // expected-error {{declaration of reference variable 'r' requires an initializer}} -int n = IR(); // expected-error {{reference to type 'int' requires an initializer}} - -#if __cplusplus < 201103L -struct S { // expected-error {{implicit default constructor for 'S' must explicitly initialize the reference member}} - int &x; // expected-note {{declared here}} expected-error 3{{reference to type 'int' requires an initializer}} -}; -S s; // expected-note {{implicit default constructor for 'S' first required here}} -S f() { - return S(); // expected-note {{in value-initialization of type 'S' here}} -} - -struct T - : S { // expected-note 2{{in value-initialization of type 'S' here}} -}; -T t = T(); // expected-note {{in value-initialization of type 'T' here}} - -struct U { - T t[3]; // expected-note {{in value-initialization of type 'T' here}} -}; -U u = U(); // expected-note {{in value-initialization of type 'U' here}} -#else -struct S { - int &x; // expected-note 4{{because field 'x' of reference type 'int &' would not be initialized}} -}; -S s; // expected-error {{deleted default constructor}} -S f() { - return S(); // expected-error {{deleted default constructor}} -} - -struct T - : S { // expected-note 2{{because base class 'S' has a deleted default constructor}} -}; -T t = T(); // expected-error {{deleted default constructor}} - -struct U { - T t[3]; // expected-note {{because field 't' has a deleted default constructor}} -}; -U u = U(); // expected-error {{deleted default constructor}} -#endif - -// Ensure that we handle C++11 in-class initializers properly as an extension. -// In this case, there is no user-declared default constructor, so we -// recursively apply the value-initialization checks, but we will emit a -// constructor call anyway, because the default constructor is not trivial. -struct V { - int n; - int &r = n; // expected-warning 0-1{{C++11}} -}; -V v = V(); // ok -struct W { - int n; - S s = { n }; // expected-warning 0-1{{C++11}} -}; -W w = W(); // ok - -// Ensure we're not faking this up by making the default constructor -// non-trivial. -_Static_assert(__has_trivial_constructor(S), ""); -_Static_assert(__has_trivial_constructor(T), ""); -_Static_assert(__has_trivial_constructor(U), ""); -_Static_assert(!__has_trivial_constructor(V), ""); -_Static_assert(!__has_trivial_constructor(W), ""); diff --git a/test/CXX/dcl.decl/dcl.init/p6.cpp b/test/CXX/dcl.decl/dcl.init/p6.cpp deleted file mode 100644 index b646ba776a9c..000000000000 --- a/test/CXX/dcl.decl/dcl.init/p6.cpp +++ /dev/null @@ -1,28 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s - -// FIXME: Very incomplete! - -// If a program calls for the default initialization of an object of a -// const-qualified type T, T shall be a class type with a -// user-provided default constructor, except if T has no uninitialized fields. -struct MakeNonPOD { MakeNonPOD(); }; -struct NoUserDefault : public MakeNonPOD { int field; }; -struct HasUserDefault { HasUserDefault(); }; - -void test_const_default_init() { - const NoUserDefault x1; // expected-error{{default initialization of an object of const type 'const NoUserDefault' without a user-provided default constructor}} - const HasUserDefault x2; - const int x3; // expected-error{{default initialization of an object of const type 'const int'}} -} - -// rdar://8501008 -struct s0 { int field; }; -struct s1 { static const s0 foo; }; -const struct s0 s1::foo; // expected-error{{default initialization of an object of const type 'const struct s0' without a user-provided default constructor}} - -template<typename T> -struct s2 { - static const s0 foo; -}; - -template<> const struct s0 s2<int>::foo; // okay diff --git a/test/CXX/dcl.decl/dcl.init/p7.cpp b/test/CXX/dcl.decl/dcl.init/p7.cpp deleted file mode 100644 index 1c1d793e8a5e..000000000000 --- a/test/CXX/dcl.decl/dcl.init/p7.cpp +++ /dev/null @@ -1,16 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -verify %s - -struct NotAggregateBase {}; - -struct A : NotAggregateBase { -private: - A() = default; // expected-note {{here}} -}; -A a = {}; // expected-error {{calling a private constructor}} - -struct B : NotAggregateBase { - explicit B() = default; // expected-note {{here}} -}; -B b = {}; // expected-error {{chosen constructor is explicit}} -B b2{}; -B b3; diff --git a/test/CXX/dcl.decl/dcl.meaning/dcl.array/p1-cxx0x.cpp b/test/CXX/dcl.decl/dcl.meaning/dcl.array/p1-cxx0x.cpp deleted file mode 100644 index 102746c3db29..000000000000 --- a/test/CXX/dcl.decl/dcl.meaning/dcl.array/p1-cxx0x.cpp +++ /dev/null @@ -1,7 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11 - -void f() { - int b[5]; - auto a[5] = b; // expected-error{{'a' declared as array of 'auto'}} - auto *c[5] = b; // expected-error{{'c' declared as array of 'auto *'}} -} diff --git a/test/CXX/dcl.decl/dcl.meaning/dcl.array/p1.cpp b/test/CXX/dcl.decl/dcl.meaning/dcl.array/p1.cpp deleted file mode 100644 index bb4a48eb5b91..000000000000 --- a/test/CXX/dcl.decl/dcl.meaning/dcl.array/p1.cpp +++ /dev/null @@ -1,54 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -pedantic -verify %s - -// Simple form -int ar1[10]; - -// Element type cannot be: -// - (cv) void -volatile void ar2[10]; // expected-error {{incomplete element type 'volatile void'}} -// - a reference -int& ar3[10]; // expected-error {{array of references}} -// - a function type -typedef void Fn(); -Fn ar4[10]; // expected-error {{array of functions}} -// - an abstract class -struct Abstract { virtual void fn() = 0; }; // expected-note {{pure virtual}} -Abstract ar5[10]; // expected-error {{abstract class}} - -// If we have a size, it must be greater than zero. -int ar6[-1]; // expected-error {{array with a negative size}} -int ar7[0u]; // expected-warning {{zero size arrays are an extension}} - -// An array with unknown bound is incomplete. -int ar8[]; // expected-error {{needs an explicit size or an initializer}} -// So is an array with an incomplete element type. -struct Incomplete; // expected-note {{forward declaration}} -Incomplete ar9[10]; // expected-error {{incomplete type}} -// Neither of which should be a problem in situations where no complete type -// is required. (PR5048) -void fun(int p1[], Incomplete p2[10]); -extern int ear1[]; -extern Incomplete ear2[10]; - -// cv migrates to element type -typedef const int cint; -extern cint car1[10]; -typedef int intar[10]; -// thus this is a valid redeclaration -extern const intar car1; - -// Check that instantiation works properly when the element type is a template. -template <typename T> struct S { - typename T::type x; // expected-error {{has no members}} -}; -S<int> ar10[10]; // expected-note {{requested here}} - -// Ensure that negative array size errors include the name of the declared -// array as this is often used to simulate static_assert with template -// instantiations, placing the 'error message' in the declarator name. -int -user_error_message -[-1]; // expected-error {{user_error_message}} -typedef int -another_user_error_message -[-1]; // expected-error {{another_user_error_message}} diff --git a/test/CXX/dcl.decl/dcl.meaning/dcl.array/p3.cpp b/test/CXX/dcl.decl/dcl.meaning/dcl.array/p3.cpp deleted file mode 100644 index 188a0a2c7eed..000000000000 --- a/test/CXX/dcl.decl/dcl.meaning/dcl.array/p3.cpp +++ /dev/null @@ -1,213 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++1y -triple x86_64-linux-gnu %s - -// If there is a preceding declaration of the entity *in the same scope* in -// which the bound was specified, an omitted array bound is taken to be the -// same as in that earlier declaration - -// rdar://13535367 -namespace test0 { - extern "C" int array[]; - void declare() { extern int array[100]; } - int value1 = sizeof(array); // expected-error {{invalid application of 'sizeof' to an incomplete type 'int []'}} - extern "C" int array[]; - int value2 = sizeof(array); // expected-error {{invalid application of 'sizeof' to an incomplete type 'int []'}} -} - -namespace test1 { - extern "C" int array[]; - void test() { - { extern int array[100]; } - extern int array[]; - int x = sizeof(array); // expected-error {{invalid application of 'sizeof' to an incomplete type 'int []'}} - } -} - -namespace test2 { - void declare() { extern int array[100]; } - extern int array[]; - int value = sizeof(array); // expected-error {{invalid application of 'sizeof' to an incomplete type 'int []'}} -} - -namespace test3 { - void test() { - { extern int array[100]; } - extern int array[]; - int x = sizeof(array); // expected-error {{invalid application of 'sizeof' to an incomplete type 'int []'}} - } -} - -namespace test4 { - extern int array[]; - void test() { - extern int array[100]; - int x = sizeof(array); - } - int y = sizeof(array); // expected-error {{invalid application of 'sizeof' to an incomplete type 'int []'}} -} - -namespace test5 { - void test() { - extern int array[100]; - extern int array[]; - int x = sizeof(array); - } -} - -namespace test6 { - void test() { - extern int array[100]; - { - extern int array[]; - int x = sizeof(array); // expected-error {{invalid application of 'sizeof' to an incomplete type 'int []'}} - } - int y = sizeof(array); - extern int array[]; - int z = sizeof(array); - } -} - -namespace test7 { - extern int array[100]; - void test() { - extern int array[]; - int x = sizeof(array); // expected-error {{invalid application of 'sizeof' to an incomplete type 'int []'}} - } - int y = sizeof(array); - extern int array[]; - int z = sizeof(array); -} - -namespace test8 { - extern int array[]; - void test() { - extern int array[100]; - int x = sizeof(array); - } - int y = sizeof(array); // expected-error {{invalid application of 'sizeof' to an incomplete type 'int []'}} - extern int array[]; - int z = sizeof(array); // expected-error {{invalid application of 'sizeof' to an incomplete type 'int []'}} -} - -namespace dependent { - template<typename T> void f() { - extern int arr1[]; - extern T arr1; - extern T arr2; - extern int arr2[]; - static_assert(sizeof(arr1) == 12, ""); - static_assert(sizeof(arr2) == 12, ""); - - // Use a failing test to ensure the type isn't considered dependent. - static_assert(sizeof(arr2) == 13, ""); // expected-error {{failed}} - } - - void g() { f<int[3]>(); } // expected-note {{in instantiation of}} - - template<typename T> void h1() { - extern T arr3; - { - int arr3; - { - extern int arr3[]; - // Detected in template definition. - (void)sizeof(arr3); // expected-error {{incomplete}} - } - } - } - - template<typename T> void h2() { - extern int arr4[3]; - { - int arr4; - { - extern T arr4; - // Detected in template instantiation. - (void)sizeof(arr4); // expected-error {{incomplete}} - } - } - } - - void i() { - h1<int[3]>(); - h2<int[]>(); // expected-note {{in instantiation of}} - } - - int arr5[3]; - template<typename T> void j() { - extern T arr5; - extern T arr6; - (void)sizeof(arr5); // expected-error {{incomplete}} - (void)sizeof(arr6); // expected-error {{incomplete}} - } - int arr6[3]; - - void k() { j<int[]>(); } // expected-note {{in instantiation of}} - - template<typename T, typename U> void l() { - extern T arrX; // expected-note {{previous}} - extern U arrX; // expected-error {{different type: 'int [4]' vs 'int [3]'}} - (void)sizeof(arrX); // expected-error {{incomplete}} - } - - void m() { - l<int[], int[3]>(); // ok - l<int[3], int[]>(); // ok - l<int[3], int[3]>(); // ok - l<int[3], int[4]>(); // expected-note {{in instantiation of}} - l<int[], int[]>(); // expected-note {{in instantiation of}} - } - - template<typename T> void n() { - extern T n_var; // expected-error {{redeclaration of 'n_var' with a different type: 'double' vs 'int'}} expected-note {{previous}} - extern T n_fn(); // expected-error {{functions that differ only in their return type cannot be overloaded}} expected-note {{previous}} - } - template void n<int>(); - template void n<double>(); // expected-note {{in instantiation of}} - - template<typename T> void o() { - extern T o_var; // expected-note {{previous}} - extern T o_fn(); // expected-note {{previous}} - } - template void o<int>(); - float o_var; // expected-error {{redefinition of 'o_var' with a different type: 'float' vs 'int'}} - float o_fn(); // expected-error {{functions that differ only in their return type cannot be overloaded}} - - int p_var; - int p_fn(); - template<typename T> void p() { - extern T p_var; - extern T p_fn(); - } -} - -namespace use_outside_ns { - namespace A { - extern int a[3]; - extern int b[]; - extern int c[3]; - void f() { - extern int a[]; - extern int b[3]; - } - template<typename T> void x() { - extern T c; - extern T d; - } - extern int d[3]; - template void x<int[]>(); - } - int w = sizeof(A::a); - int x = sizeof(A::b); // expected-error {{incomplete}} - int y = sizeof(A::c); - int z = sizeof(A::d); - namespace A { - int g() { return sizeof(a); } - int h() { return sizeof(b); } // expected-error {{incomplete}} - int i() { return sizeof(c); } - int j() { return sizeof(d); } - } -} - -extern int arr[]; -void f1() { extern int arr[2]; } // expected-note {{previous}} -void f2() { extern int arr[3]; } // expected-error {{different type: 'int [3]' vs 'int [2]'}} diff --git a/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p10.cpp b/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p10.cpp deleted file mode 100644 index 27ebb8e036f0..000000000000 --- a/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p10.cpp +++ /dev/null @@ -1,16 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s - -struct A { - virtual void f(int a = 7); // expected-note{{'A::f' declared here}} -}; - -struct B : public A { - void f(int a); -}; - -void m() { - B* pb = new B; - A* pa = pb; - pa->f(); // OK, calls pa->B::f(7) - pb->f(); // expected-error{{too few arguments to function call, expected 1, have 0; did you mean 'A::f'?}} -} diff --git a/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p2.cpp b/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p2.cpp deleted file mode 100644 index 68aabca71eac..000000000000 --- a/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p2.cpp +++ /dev/null @@ -1,10 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -// expected-no-diagnostics - -void point(int = 3, int = 4); - -void test_point() { - point(1,2); - point(1); - point(); -} diff --git a/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p3.cpp b/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p3.cpp deleted file mode 100644 index 11c17f32728a..000000000000 --- a/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p3.cpp +++ /dev/null @@ -1,19 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s - -void nondecl(int (*f)(int x = 5)) // expected-error {{default arguments can only be specified}} -{ - void (*f2)(int = 17) // expected-error {{default arguments can only be specified}} - = (void (*)(int = 42))f; // expected-error {{default arguments can only be specified}} -} - -struct X0 { - int (*f)(int = 17); // expected-error{{default arguments can only be specified for parameters in a function declaration}} - void (*g())(int = 22); // expected-error{{default arguments can only be specified for parameters in a function declaration}} - void (*h(int = 49))(int); - auto i(int) -> void (*)(int = 9); // expected-error{{default arguments can only be specified for parameters in a function declaration}} - - void mem8(int (*fp)(int) = (int (*)(int = 17))0); // expected-error{{default arguments can only be specified for parameters in a function declaration}} -}; - -template <typename... Ts> -void defaultpack(Ts... = 0) {} // expected-error{{parameter pack cannot have a default argument}} diff --git a/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p4.cpp b/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p4.cpp deleted file mode 100644 index 6014268a1860..000000000000 --- a/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p4.cpp +++ /dev/null @@ -1,108 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s - -void f0(int i, int j, int k = 3); -void f0(int i, int j, int k); -void f0(int i, int j = 2, int k); -void f0(int i, int j, int k); -void f0(int i = 1, // expected-note{{previous definition}} - int j, int k); -void f0(int i, int j, int k); // want 2 decls before next default arg -void f0(int i, int j, int k); - -namespace N0 { - void f0(int, int, int); // expected-note{{candidate}} - - void test_f0_inner_scope() { - f0(); // expected-error{{no matching}} - } -} - -void test_f0_outer_scope() { - f0(); // okay -} - -void f0(int i = 1, // expected-error{{redefinition of default argument}} - int, int); - -template<typename T> void f1(T); // expected-note{{previous}} - -template<typename T> -void f1(T = T()); // expected-error{{cannot be added}} - - -namespace N1 { - // example from C++03 standard - // FIXME: make these "f2"s into "f"s, then fix our scoping issues - void f2(int, int); - void f2(int, int = 7); - void h() { - f2(3); // OK, calls f(3, 7) - void f(int = 1, int); // expected-error{{missing default argument}} - } - - void m() - { - void f(int, int); // expected-note{{'f' declared here}} - f(4); // expected-error{{too few arguments to function call}} - void f(int, int = 5); // expected-note{{previous definition}} - f(4); // okay - void f(int, int = 5); // expected-error{{redefinition of default argument}} - } - - void n() - { - f2(6); // okay - } -} - - -namespace PR18432 { - -struct A { - struct B { - static void Foo (int = 0); - }; - - // should not hide default args - friend void B::Foo (int); -}; - -void Test () -{ - A::B::Foo (); -} - -} // namespace - -namespace pr12724 { - -void func_01(bool param = true); -class C01 { -public: - friend void func_01(bool param); -}; - -void func_02(bool param = true); -template<typename T> -class C02 { -public: - friend void func_02(bool param); -}; -C02<int> c02; - -void func_03(bool param); -template<typename T> -class C03 { -public: - friend void func_03(bool param); -}; -void func_03(bool param = true); -C03<int> c03; - -void main() { - func_01(); - func_02(); - func_03(); -} - -} // namespace pr12724 diff --git a/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p5.cpp b/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p5.cpp deleted file mode 100644 index 3100e56a080e..000000000000 --- a/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p5.cpp +++ /dev/null @@ -1,19 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s - -float global_f; - -void f0(int *ip = &global_f); // expected-error{{cannot initialize}} \ -// expected-note{{passing argument to parameter 'ip' here}} - -// Example from C++03 standard -int a = 1; -int f(int); -int g(int x = f(a)); - -void h() { - a = 2; - { - int *a = 0; - g(); // FIXME: check that a is called with a value of 2 - } -} diff --git a/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p6.cpp b/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p6.cpp deleted file mode 100644 index 9ab0b489a2c4..000000000000 --- a/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p6.cpp +++ /dev/null @@ -1,33 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s - -class C { -public: - void f(int i = 3); // expected-note{{here}} - void g(int i, int j = 99); -}; - -void C::f(int i = 3) { } // expected-error{{redefinition of default argument}} - -void C::g(int i = 88, int j) { } - -void test_C(C c) { - c.f(); - c.g(); -} - -template<typename T> -struct X0 { - void f(int); - - struct Inner { - void g(int); - }; -}; - -// DR217 -template<typename T> -void X0<T>::f(int = 17) { } // expected-error{{cannot be added}} - -// DR217 + DR205 (reading tea leaves) -template<typename T> -void X0<T>::Inner::g(int = 17) { } // expected-error{{cannot be added}} diff --git a/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p7.cpp b/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p7.cpp deleted file mode 100644 index 164eb3682f31..000000000000 --- a/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p7.cpp +++ /dev/null @@ -1,7 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s - -void h() -{ - int i; - extern void h2(int x = sizeof(i)); // expected-error {{default argument references local variable 'i' of enclosing function}} -} diff --git a/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p8.cpp b/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p8.cpp deleted file mode 100644 index 1a08ab733287..000000000000 --- a/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p8.cpp +++ /dev/null @@ -1,4 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -class A { - void f(A* p = this) { } // expected-error{{invalid use of 'this'}} -}; diff --git a/test/CXX/dcl.decl/dcl.meaning/dcl.fct/dcl.fct.def.default/p1.cpp b/test/CXX/dcl.decl/dcl.meaning/dcl.fct/dcl.fct.def.default/p1.cpp deleted file mode 100644 index 21f71f05419c..000000000000 --- a/test/CXX/dcl.decl/dcl.meaning/dcl.fct/dcl.fct.def.default/p1.cpp +++ /dev/null @@ -1,16 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -verify %s - -// A function that is explicitly defaulted shall -// [...] -// -- not have default arguments -struct DefArg { - static DefArg &&make(); - DefArg(int n = 5) = default; // expected-error {{an explicitly-defaulted constructor cannot have default arguments}} - DefArg(const DefArg &DA = make()) = default; // expected-error {{an explicitly-defaulted constructor cannot have default arguments}} - DefArg(const DefArg &DA, int k = 3) = default; // expected-error {{an explicitly-defaulted copy constructor cannot have default arguments}} - DefArg(DefArg &&DA = make()) = default; // expected-error {{an explicitly-defaulted constructor cannot have default arguments}} - DefArg(DefArg &&DA, int k = 3) = default; // expected-error {{an explicitly-defaulted move constructor cannot have default arguments}} - DefArg &operator=(const DefArg&, int k = 4) = default; // expected-error {{parameter of overloaded 'operator=' cannot have a default argument}} - DefArg &operator=(DefArg&&, int k = 4) = default; // expected-error {{parameter of overloaded 'operator=' cannot have a default argument}} - ~DefArg(int k = 5) = default; // expected-error {{destructor cannot have any parameters}} -}; diff --git a/test/CXX/dcl.decl/dcl.meaning/dcl.fct/dcl.fct.def.default/p2.cpp b/test/CXX/dcl.decl/dcl.meaning/dcl.fct/dcl.fct.def.default/p2.cpp deleted file mode 100644 index 4227d82e7753..000000000000 --- a/test/CXX/dcl.decl/dcl.meaning/dcl.fct/dcl.fct.def.default/p2.cpp +++ /dev/null @@ -1,75 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s - -// FIXME: test with non-std qualifiers - -namespace move { - struct Const { - Const(const Const&&) = default; // expected-error {{the parameter for an explicitly-defaulted move constructor may not be const}} - Const& operator=(const Const&&) = default; // expected-error {{the parameter for an explicitly-defaulted move assignment operator may not be const}} - }; - - struct Volatile { - Volatile(volatile Volatile&&) = default; // expected-error {{the parameter for an explicitly-defaulted move constructor may not be volatile}} - Volatile& operator=(volatile Volatile&&) = default; // expected-error {{the parameter for an explicitly-defaulted move assignment operator may not be volatile}} - }; - - struct AssignmentRet1 { - AssignmentRet1&& operator=(AssignmentRet1&&) = default; // expected-error {{explicitly-defaulted move assignment operator must return 'move::AssignmentRet1 &'}} - }; - - struct AssignmentRet2 { - const AssignmentRet2& operator=(AssignmentRet2&&) = default; // expected-error {{explicitly-defaulted move assignment operator must return 'move::AssignmentRet2 &'}} - }; - - struct ConstAssignment { - ConstAssignment& operator=(ConstAssignment&&) const = default; // expected-error {{an explicitly-defaulted move assignment operator may not have 'const', 'constexpr' or 'volatile' qualifiers}} - }; -} - -namespace copy { - struct Volatile { - Volatile(const volatile Volatile&) = default; // expected-error {{the parameter for an explicitly-defaulted copy constructor may not be volatile}} - Volatile& operator=(const volatile Volatile&) = default; // expected-error {{the parameter for an explicitly-defaulted copy assignment operator may not be volatile}} - }; - - struct Const { - Const(const Const&) = default; - Const& operator=(const Const&) = default; - }; - - struct NonConst { - NonConst(NonConst&) = default; - NonConst& operator=(NonConst&) = default; - }; - - struct NonConst2 { - NonConst2(NonConst2&); - NonConst2& operator=(NonConst2&); - }; - NonConst2::NonConst2(NonConst2&) = default; - NonConst2 &NonConst2::operator=(NonConst2&) = default; - - struct NonConst3 { - NonConst3(NonConst3&) = default; - NonConst3& operator=(NonConst3&) = default; - NonConst nc; - }; - - struct BadConst { - BadConst(const BadConst&) = default; // expected-error {{is const, but}} - BadConst& operator=(const BadConst&) = default; // expected-error {{is const, but}} - NonConst nc; // makes implicit copy non-const - }; - - struct AssignmentRet1 { - AssignmentRet1&& operator=(const AssignmentRet1&) = default; // expected-error {{explicitly-defaulted copy assignment operator must return 'copy::AssignmentRet1 &'}} - }; - - struct AssignmentRet2 { - const AssignmentRet2& operator=(const AssignmentRet2&) = default; // expected-error {{explicitly-defaulted copy assignment operator must return 'copy::AssignmentRet2 &'}} - }; - - struct ConstAssignment { - ConstAssignment& operator=(const ConstAssignment&) const = default; // expected-error {{an explicitly-defaulted copy assignment operator may not have 'const', 'constexpr' or 'volatile' qualifiers}} - }; -} diff --git a/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p13.cpp b/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p13.cpp deleted file mode 100644 index de1c5a708db6..000000000000 --- a/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p13.cpp +++ /dev/null @@ -1,79 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -fsyntax-only -fcxx-exceptions -fexceptions -verify %s - -// When it is part of a parameter-declaration-clause, the parameter -// pack is a function parameter pack. -template<typename ...Types> -void f0(Types ...args); - -template<typename ...Types> -void f1(const Types &...args); - -// [ Note: Otherwise, the parameter-declaration is part of a -// template-parameter-list and the parameter pack is a template -// parameter pack; see 14.1. -- end note ] -template<int ...N> -struct X0 { }; - -template<typename ...Types> -struct X1 { - template<Types ...Values> struct Inner; -}; - -// A declarator-id or abstract-declarator containing an ellipsis shall -// only be used in a parameter-declaration. -int (...f2)(int); // expected-error{{only function and template parameters can be parameter packs}} - -void f3() { - int ...x; // expected-error{{only function and template parameters can be parameter packs}} - if (int ...y = 17) { } // expected-error{{only function and template parameters can be parameter packs}} - - for (int ...z = 0; z < 10; ++z) { } // expected-error{{only function and template parameters can be parameter packs}} - - try { - } catch (int ...e) { // expected-error{{only function and template parameters can be parameter packs}} - } -} - -template<typename ...Types> -struct X2 { - Types ...members; // expected-error{{only function and template parameters can be parameter packs}} \ - // expected-error{{data member type contains unexpanded parameter pack}} -}; - -// The type T of the declarator-id of the function parameter pack -// shall contain a template parameter pack; each template parameter -// pack in T is expanded by the function parameter pack. -template<typename T> -void f4(T ...args); // expected-error{{type 'T' of function parameter pack does not contain any unexpanded parameter packs}} - -void f4i(int ... x); // expected-error{{type 'int' of function parameter pack does not contain any unexpanded parameter packs}} -void f4i0(int ...); - -namespace array_type { -template<typename T> -void a(T[] ... x); // expected-error{{expected ')'}} expected-note{{to match this '('}} - -template<typename T> -void b(T[] ...); - -template<typename T> -void c(T ... []); // expected-error{{type 'T []' of function parameter pack does not contain any unexpanded parameter packs}} - -template<typename T> -void d(T ... x[]); // expected-error{{type 'T []' of function parameter pack does not contain any unexpanded parameter packs}} - -void ai(int[] ... x); // expected-error{{expected ')'}} expected-note{{to match this '('}} -void bi(int[] ...); -void ci(int ... []); // expected-error{{type 'int []' of function parameter pack does not contain any unexpanded parameter packs}} -void di(int ... x[]); // expected-error{{type 'int []' of function parameter pack does not contain any unexpanded parameter packs}} -} - -void f5a(auto fp(int)->unk ...) {} // expected-error{{unknown type name 'unk'}} -void f5b(auto fp(int)->auto ...) {} // expected-error{{'auto' not allowed in function return type}} -void f5c(auto fp()->...) {} // expected-error{{expected a type}} - -// FIXME: Expand for function and member pointer types. - - - - diff --git a/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p14.cpp b/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p14.cpp deleted file mode 100644 index ac9344dea1c1..000000000000 --- a/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p14.cpp +++ /dev/null @@ -1,31 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s - -template<typename T> struct identity; -template<typename ...Types> struct tuple; - -template<typename T, typename U> struct is_same { - static const bool value = false; -}; - -template<typename T> struct is_same<T, T> { - static const bool value = true; -}; - -// There is a syntactic ambiguity when an ellipsis occurs at the end -// of a parameter-declaration-clause without a preceding comma. In -// this case, the ellipsis is parsed as part of the -// abstract-declarator if the type of the parameter names a template -// parameter pack that has not been expanded; otherwise, it is parsed -// as part of the parameter-declaration-clause. - -template<typename T, typename ...Types> -struct X0 { - typedef identity<T(Types...)> function_pack_1; - typedef identity<T(Types......)> variadic_function_pack_1; // expected-warning {{varargs}} expected-note {{pack}} expected-note {{insert ','}} - typedef identity<T(T...)> variadic_1; - typedef tuple<T(Types, ...)...> template_arg_expansion_1; -}; - - - -// FIXME: Once function parameter packs are implemented, we can test all of the disambiguation diff --git a/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p2-cxx0x.cpp b/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p2-cxx0x.cpp deleted file mode 100644 index ce9072886160..000000000000 --- a/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p2-cxx0x.cpp +++ /dev/null @@ -1,7 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s - -auto a() -> int; // ok -const auto b() -> int; // expected-error {{function with trailing return type must specify return type 'auto', not 'const auto'}} -auto *c() -> int; // expected-error {{function with trailing return type must specify return type 'auto', not 'auto *'}} -auto (d() -> int); // expected-error {{trailing return type may not be nested within parentheses}} -auto e() -> auto (*)() -> auto (*)() -> void; // ok: same as void (*(*e())())(); diff --git a/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p3.cpp b/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p3.cpp deleted file mode 100644 index ad827fb7b314..000000000000 --- a/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p3.cpp +++ /dev/null @@ -1,3 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -void f(int) { } // expected-note {{previous definition is here}} -void f(const int) { } // expected-error {{redefinition of 'f'}} diff --git a/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p6-0x.cpp b/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p6-0x.cpp deleted file mode 100644 index d93cc8b90874..000000000000 --- a/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p6-0x.cpp +++ /dev/null @@ -1,74 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s -// RUN: %clang_cc1 -std=c++1z -fsyntax-only -verify %s - -void f0() &; // expected-error {{non-member function cannot have '&' qualifier}} -void f1() &&; // expected-error {{non-member function cannot have '&&' qualifier}} -void f2() const volatile &&; // expected-error {{non-member function cannot have 'const volatile &&' qualifier}} - -struct X { - void f0() &; - void f1() &&; - static void f2() &; // expected-error{{static member function cannot have '&' qualifier}} - static void f3() &&; // expected-error{{static member function cannot have '&&' qualifier}} -}; - -typedef void func_type_lvalue() &; -typedef void func_type_rvalue() &&; - -typedef func_type_lvalue *func_type_lvalue_ptr; // expected-error{{pointer to function type 'func_type_lvalue' (aka 'void () &') cannot have '&' qualifier}} -typedef func_type_rvalue *func_type_rvalue_ptr; // expected-error{{pointer to function type 'func_type_rvalue' (aka 'void () &&') cannot have '&&' qualifier}} - -typedef func_type_lvalue &func_type_lvalue_ref; // expected-error{{reference to function type 'func_type_lvalue' (aka 'void () &') cannot have '&' qualifier}} -typedef func_type_rvalue &func_type_rvalue_ref; // expected-error{{reference to function type 'func_type_rvalue' (aka 'void () &&') cannot have '&&' qualifier}} - -template<typename T = func_type_lvalue> struct wrap { - typedef T val; - typedef T *ptr; // expected-error-re 2{{pointer to function type '{{.*}}' cannot have '{{&|&&}}' qualifier}} - typedef T &ref; // expected-error-re 2{{reference to function type '{{.*}}' cannot have '{{&|&&}}' qualifier}} -}; - -using func_type_lvalue = wrap<>::val; // expected-note{{in instantiation of}} -using func_type_lvalue = wrap<func_type_lvalue>::val; -using func_type_rvalue = wrap<func_type_rvalue>::val; // expected-note{{in instantiation of}} - -using func_type_lvalue_ptr = wrap<>::ptr; -using func_type_lvalue_ptr = wrap<func_type_lvalue>::ptr; -using func_type_rvalue_ptr = wrap<func_type_rvalue>::ptr; - -using func_type_lvalue_ref = wrap<>::ref; -using func_type_lvalue_ref = wrap<func_type_lvalue>::ref; -using func_type_rvalue_ref = wrap<func_type_rvalue>::ref; - -func_type_lvalue f2; // expected-error{{non-member function of type 'func_type_lvalue' (aka 'void () &') cannot have '&' qualifier}} -func_type_rvalue f3; // expected-error{{non-member function of type 'func_type_rvalue' (aka 'void () &&') cannot have '&&' qualifier}} - -struct Y { - func_type_lvalue f0; - func_type_rvalue f1; -}; - -void (X::*mpf1)() & = &X::f0; -void (X::*mpf2)() && = &X::f1; - - -void (f() &&); // expected-error{{non-member function cannot have '&&' qualifier}} - -// FIXME: These are ill-formed. -template<typename T> struct pass { - void f(T); -}; -pass<func_type_lvalue> pass0; -pass<func_type_lvalue> pass1; - -template<typename T, typename U> struct is_same { static const bool value = false; }; -template<typename T> struct is_same<T, T> { static const bool value = true; }; -constexpr bool cxx1z = __cplusplus > 201402L; - -void noexcept_true() noexcept(true); -void noexcept_false() noexcept(false); -using func_type_noexcept_true = wrap<decltype(noexcept_true)>; -using func_type_noexcept_false = wrap<decltype(noexcept_false)>; -static_assert(is_same<func_type_noexcept_false, func_type_noexcept_true>::value == !cxx1z, ""); -static_assert(is_same<func_type_noexcept_false::val, func_type_noexcept_true::val>::value == !cxx1z, ""); -static_assert(is_same<func_type_noexcept_false::ptr, func_type_noexcept_true::ptr>::value == !cxx1z, ""); -static_assert(is_same<func_type_noexcept_false::ref, func_type_noexcept_true::ref>::value == !cxx1z, ""); diff --git a/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p6.cpp b/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p6.cpp deleted file mode 100644 index a035086c9a12..000000000000 --- a/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p6.cpp +++ /dev/null @@ -1,33 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s - -typedef void F() const; - -void f() const; // expected-error {{non-member function cannot have 'const' qualifier}} -F g; // expected-error {{non-member function of type 'F' (aka 'void () const') cannot have 'const' qualifier}} - -struct X { - void f() const; - friend void g() const; // expected-error {{non-member function cannot have 'const' qualifier}} - static void h() const; // expected-error {{static member function cannot have 'const' qualifier}} - F i; // ok - friend F j; // expected-error {{non-member function of type 'F' (aka 'void () const') cannot have 'const' qualifier}} - static F k; // expected-error {{static member function of type 'F' (aka 'void () const') cannot have 'const' qualifier}} -}; - -struct Y { - friend void X::f() const; - friend void ::f() const; // expected-error {{non-member function cannot have 'const' qualifier}} -}; - -template<typename T> struct S { - typedef T F; - typedef T *P; // expected-error {{pointer to function type 'void () const' cannot have 'const' qualifier}} - typedef T &R; // expected-error {{reference to function type 'void () const' cannot have 'const' qualifier}} -}; -S<F> s; // expected-note {{in instantiation of}} - -// FIXME: This is ill-formed. -template<typename T> struct U { - void f(T); -}; -U<F> u; diff --git a/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p8-0x.cpp b/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p8-0x.cpp deleted file mode 100644 index 11926f1bd6cb..000000000000 --- a/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p8-0x.cpp +++ /dev/null @@ -1,6 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s - -auto f() -> int[32]; // expected-error{{function cannot return array}} -auto g() -> int(int); // expected-error{{function cannot return function}} -auto h() -> auto() -> int; // expected-error{{function cannot return function}} -auto i() -> auto(*)() -> int; diff --git a/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p8.cpp b/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p8.cpp deleted file mode 100644 index 0454412229fa..000000000000 --- a/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p8.cpp +++ /dev/null @@ -1,8 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s - -struct A { }; -A::A (enum { e1 }) {} // expected-error{{cannot be defined in a parameter}} -void A::f(enum { e2 }) {} // expected-error{{cannot be defined in a parameter}} - -enum { e3 } A::g() { } // expected-error{{cannot be defined in the result type}} \ -// expected-error{{out-of-line definition}} diff --git a/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p9-0x.cpp b/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p9-0x.cpp deleted file mode 100644 index 719aeeddebcc..000000000000 --- a/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p9-0x.cpp +++ /dev/null @@ -1,7 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s - -// FIXME: We should catch the case of tag with an incomplete type here (which -// will necessarily be ill-formed as a trailing return type for a function -// definition), and recover with a "type cannot be defined in a trailing return -// type" error. -auto j() -> enum { e3 }; // expected-error{{unnamed enumeration must be a definition}} expected-error {{expected a type}} diff --git a/test/CXX/dcl.decl/dcl.meaning/dcl.mptr/p3.cpp b/test/CXX/dcl.decl/dcl.meaning/dcl.mptr/p3.cpp deleted file mode 100644 index e159ab729d5f..000000000000 --- a/test/CXX/dcl.decl/dcl.meaning/dcl.mptr/p3.cpp +++ /dev/null @@ -1,26 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -class A { -public: - int& i; - - A(int& i) : i(i) { } - - static int s; -}; - -template<typename T> void ft(T& t) { - t.*&T::i = 10; // expected-error{{cannot form a pointer-to-member to member 'i' of reference type 'int &'}} -} - -void f() { - int b; - A a(b); - - int A::*ip = &A::s; // expected-error {{cannot initialize a variable of type 'int A::*' with an rvalue of type 'int *'}} - a.*&A::s = 10; // expected-error{{right hand operand to .* has non-pointer-to-member type 'int *'}} - - a.*&A::i = 10; // expected-error{{cannot form a pointer-to-member to member 'i' of reference type 'int &'}} - ft(a); // expected-note{{in instantiation of function template specialization 'ft<A>' requested here}} - - void A::*p = 0; // expected-error{{'p' declared as a member pointer to void}} -} diff --git a/test/CXX/dcl.decl/dcl.meaning/dcl.ref/p5.cpp b/test/CXX/dcl.decl/dcl.meaning/dcl.ref/p5.cpp deleted file mode 100644 index c02105ca76cf..000000000000 --- a/test/CXX/dcl.decl/dcl.meaning/dcl.ref/p5.cpp +++ /dev/null @@ -1,145 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s - -// C++ [dcl.ref]p5: -// There shall be no references to references, no arrays of -// references, and no pointers to references. - -// The crazy formatting in here is to enforce the exact report locations. - -typedef int &intref; -typedef intref &intrefref; - -template <class T> class RefMem { // expected-warning{{class 'RefMem<int &>' does not declare any constructor to initialize its non-modifiable members}} - T - & - member; // expected-note{{reference member 'member' will never be initialized}} -}; - -struct RefRef { - int - & - & // expected-error {{declared as a reference to a reference}} - refref0; - - intref - & - refref1; // collapses - - intrefref - & - refref2; // collapses - - RefMem - < - int - & - > - refref3; // collapses expected-note{{in instantiation of template class 'RefMem<int &>' requested here}} -}; - - -template <class T> class PtrMem { - T - * // expected-error {{declared as a pointer to a reference}} - member; -}; - -struct RefPtr { - typedef - int - & - * // expected-error {{declared as a pointer to a reference}} - intrefptr; - - typedef - intref - * // expected-error {{declared as a pointer to a reference}} - intrefptr2; - - int - & - * // expected-error {{declared as a pointer to a reference}} - refptr0; - - intref - * // expected-error {{declared as a pointer to a reference}} - refptr1; - - PtrMem - < - int - & - > - refptr2; // expected-note {{in instantiation}} -}; - -template <class T> class ArrMem { - T - member - [ // expected-error {{declared as array of references}} - 10 - ]; -}; -template <class T, unsigned N> class DepArrMem { - T - member - [ // expected-error {{declared as array of references}} - N - ]; -}; - -struct RefArr { - typedef - int - & - intrefarr - [ // expected-error {{declared as array of references}} - 2 - ]; - - typedef - intref - intrefarr - [ // expected-error {{declared as array of references}} - 2 - ]; - - int - & - refarr0 - [ // expected-error {{declared as array of references}} - 2 - ]; - intref - refarr1 - [ // expected-error {{declared as array of references}} - 2 - ]; - ArrMem - < - int - & - > - refarr2; // expected-note {{in instantiation}} - DepArrMem - < - int - &, - 10 - > - refarr3; // expected-note {{in instantiation}} -}; - - -// The declaration of a reference shall contain an initializer -// (8.5.3) except when the declaration contains an explicit extern -// specifier (7.1.1), is a class member (9.2) declaration within a -// class definition, or is the declaration of a parameter or a -// return type (8.3.5); see 3.1. A reference shall be initialized to -// refer to a valid object or function. [ Note: in particular, a -// null reference cannot exist in a well-defined program, because -// the only way to create such a reference would be to bind it to -// the "object" obtained by dereferencing a null pointer, which -// causes undefined behavior. As described in 9.6, a reference -// cannot be bound directly to a bit-field. - diff --git a/test/CXX/dcl.decl/dcl.meaning/dcl.ref/p6-0x.cpp b/test/CXX/dcl.decl/dcl.meaning/dcl.ref/p6-0x.cpp deleted file mode 100644 index 0f76e1f3c79b..000000000000 --- a/test/CXX/dcl.decl/dcl.meaning/dcl.ref/p6-0x.cpp +++ /dev/null @@ -1,26 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s - -template<typename T, typename U> -struct is_same { - static const bool value = false; -}; - -template<typename T> -struct is_same<T, T> { - static const bool value = true; -}; -#define JOIN2(X,Y) X##Y -#define JOIN(X,Y) JOIN2(X,Y) -#define CHECK_EQUAL_TYPES(T1, T2) \ - int JOIN(array,__LINE__)[is_same<T1, T2>::value? 1 : -1] - -int i; -typedef int& LRI; -typedef int&& RRI; - -typedef LRI& r1; CHECK_EQUAL_TYPES(r1, int&); -typedef const LRI& r2; CHECK_EQUAL_TYPES(r2, int&); // expected-warning {{'const' qualifier on reference type 'LRI' (aka 'int &') has no effect}} -typedef const LRI&& r3; CHECK_EQUAL_TYPES(r3, int&); // expected-warning {{'const' qualifier on reference type 'LRI' (aka 'int &') has no effect}} - -typedef RRI& r4; CHECK_EQUAL_TYPES(r4, int&); -typedef RRI&& r5; CHECK_EQUAL_TYPES(r5, int&&); diff --git a/test/CXX/dcl.decl/dcl.meaning/p1-0x.cpp b/test/CXX/dcl.decl/dcl.meaning/p1-0x.cpp deleted file mode 100644 index fbe9c0895aea..000000000000 --- a/test/CXX/dcl.decl/dcl.meaning/p1-0x.cpp +++ /dev/null @@ -1,125 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s - -// The nested-name-specifier of a qualified declarator-id shall not begin with a decltype-specifier. -class foo { - static int i; - void func(); -}; - -int decltype(foo())::i; // expected-error{{'decltype' cannot be used to name a declaration}} -void decltype(foo())::func() { // expected-error{{'decltype' cannot be used to name a declaration}} -} - - -template<typename T> -class tfoo { - static int i; - void func(); -}; - -template<typename T> -int decltype(tfoo<T>())::i; // expected-error{{nested name specifier 'decltype(tfoo<T>())::' for declaration does not refer into a class, class template or class template partial specialization}} -template<typename T> -void decltype(tfoo<T>())::func() { // expected-error{{nested name specifier 'decltype(tfoo<T>())::' for declaration does not refer into a class, class template or class template partial specialization}} -} - -// An init-declarator named with a qualified-id can refer to an element of the -// inline namespace set of the named namespace. -namespace inline_namespaces { - namespace N { - inline namespace M { - void f(); // expected-note {{possible target}} - void g(); - extern int m; // expected-note {{candidate}} - extern int n; - struct S; // expected-note {{candidate}} - struct T; - enum E : int; // expected-note {{candidate}} - enum F : int; - template<typename T> void ft(); // expected-note {{here}} - template<typename T> void gt(); // expected-note {{here}} - template<typename T> extern int mt; // expected-note {{here}} expected-warning {{extension}} - template<typename T> extern int nt; // expected-note {{here}} expected-warning {{extension}} - template<typename T> struct U; // expected-note {{here}} - template<typename T> struct V; // expected-note {{here}} - } - - // When named by unqualified-id, we do *not* look in the inline namespace - // set. - void f() {} // expected-note {{possible target}} - int m; // expected-note {{candidate}} - struct S {}; // expected-note {{candidate}} - enum E : int {}; // expected-note {{candidate}} - - static_assert(&f != &M::f, ""); // expected-error {{reference to overloaded function could not be resolved}} - static_assert(&m != &M::m, ""); // expected-error {{ambiguous}} - typedef S X; // expected-error {{ambiguous}} - typedef E Y; // expected-error {{ambiguous}} - - // When named by (unqualified) template-id, we do look in the inline - // namespace set. See [namespace.def]p8, [temp.explicit]p3, - // [temp.expl.spec]p2. - // - // This is not explicitly specified for partial specializations, but - // that is just a language defect. - template<> void ft<int>() {} - template void ft<char>(); // expected-error {{undefined}} - - template<typename T> int mt<T*>; - template<> int mt<int>; - template int mt<int*>; - template int mt<char>; // expected-error {{undefined}} - - template<typename T> struct U<T*> {}; - template<> struct U<int> {}; - template struct U<int*>; - template struct U<char>; // expected-error {{undefined}} - } - - // When named by qualified-id, we *do* look in the inline namespace set. - void N::g() {} - int N::n; - struct N::T {}; - enum N::F : int {}; - - static_assert(&N::g == &N::M::g, ""); - static_assert(&N::n == &N::M::n, ""); - typedef N::T X; - typedef N::M::T X; - typedef N::F Y; - typedef N::M::F Y; - - template<> void N::gt<int>() {} - template void N::gt<char>(); // expected-error {{undefined}} - - template<typename T> int N::nt<T*>; - template<> int N::nt<int>; - template int N::nt<int*>; - template int N::nt<char>; // expected-error {{undefined}} - - template<typename T> struct N::V<T*> {}; - template<> struct N::V<int> {}; - template struct N::V<int*>; - template struct N::V<char>; // expected-error {{undefined}} - - struct Q {}; - - // Perversely, inline anonymous namespaces can cause an ostensibly - // external-linkage declaration to acquire internal linkage when - // redeclared with a qualified name. - inline namespace { - struct Q {} q; - int f_in_inline(); - extern int v_in_inline; - typedef int t_in_inline; - } - // FIXME: These "extra qualification" warnings are bogus: the qualification - // changes the meaning of the program. - int inline_namespaces::f_in_inline() { // expected-warning {{extra qualification}} - // Finds <anon>::Q, not inline_namespaces::Q - Q x = q; - return 0; - } - int inline_namespaces::v_in_inline = // expected-warning {{extra qualification}} - (Q(q), 0); -} diff --git a/test/CXX/dcl.decl/dcl.meaning/p1.cpp b/test/CXX/dcl.decl/dcl.meaning/p1.cpp deleted file mode 100644 index cefee7b8dc41..000000000000 --- a/test/CXX/dcl.decl/dcl.meaning/p1.cpp +++ /dev/null @@ -1,49 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s - -namespace PR8019 { - struct x; - template<typename T> struct x2; - struct y { - struct PR8019::x { int x; }; // expected-error{{non-friend class member 'x' cannot have a qualified name}} - - struct inner; - struct y::inner { }; // expected-error{{extra qualification on member 'inner'}} - - template<typename T> - struct PR8019::x2 { }; // expected-error{{non-friend class member 'x2' cannot have a qualified name}} - - template<typename T> - struct inner_template; - - template<typename T> - struct y::inner_template { }; // expected-error{{extra qualification on member 'inner_template'}} - }; - -} - -namespace NS { - void foo(); - extern int bar; - struct X; - template<typename T> struct Y; - template<typename T> void wibble(T); - struct Z; -} -namespace NS { - // Under DR482, these are all valid, except for forward-declaring a struct - // with a nested-name-specifier. - void NS::foo(); // expected-warning {{extra qualification}} - extern int NS::bar; // expected-warning {{extra qualification}} - struct NS::X; // expected-error {{forward declaration of struct cannot have a nested name specifier}} expected-warning {{extra qualification}} - template<typename T> struct NS::Y; // expected-error {{forward declaration of struct cannot have a nested name specifier}} expected-warning {{extra qualification}} - template<typename T> void NS::wibble(T); // expected-warning {{extra qualification}} - - void NS::foo() {} // expected-warning{{extra qualification on member 'foo'}} - int NS::bar; // expected-warning{{extra qualification on member 'bar'}} - struct NS::X { }; // expected-warning{{extra qualification on member 'X'}} - template<typename T> struct NS::Y { }; // expected-warning{{extra qualification on member 'Y'}} - template<typename T> void NS::wibble(T) { } // expected-warning{{extra qualification on member 'wibble'}} -} - -struct ::{} a; // expected-error{{expected identifier}} -struct NS::Z:: {} b; // expected-error{{expected identifier}} diff --git a/test/CXX/dcl.decl/dcl.name/p1.cpp b/test/CXX/dcl.decl/dcl.name/p1.cpp deleted file mode 100644 index e032a7f92a5c..000000000000 --- a/test/CXX/dcl.decl/dcl.name/p1.cpp +++ /dev/null @@ -1,21 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -// expected-no-diagnostics - -namespace pr6200 { - struct v {}; - enum E { e }; - struct s { - int i; - operator struct v() { return v(); }; - operator enum E() { return e; } - }; - - void f() - { - // None of these is a declaration. - (void)new struct s; - (void)new enum E; - (void)&s::operator struct v; - (void)&s::operator enum E; - } -} diff --git a/test/CXX/dcl.decl/p4-0x.cpp b/test/CXX/dcl.decl/p4-0x.cpp deleted file mode 100644 index 35177a038697..000000000000 --- a/test/CXX/dcl.decl/p4-0x.cpp +++ /dev/null @@ -1,9 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s -// expected-no-diagnostics - -struct X { - void f() &; - void g() &&; -}; - -void (X::*pmf)() & = &X::f; diff --git a/test/CXX/drs/dr0xx.cpp b/test/CXX/drs/dr0xx.cpp deleted file mode 100644 index 048187814db6..000000000000 --- a/test/CXX/drs/dr0xx.cpp +++ /dev/null @@ -1,1144 +0,0 @@ -// RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -Wno-bind-to-temporary-copy -// RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -triple %itanium_abi_triple -// RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -triple %itanium_abi_triple -// RUN: %clang_cc1 -std=c++17 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -triple %itanium_abi_triple - -namespace dr1 { // dr1: no - namespace X { extern "C" void dr1_f(int a = 1); } - namespace Y { extern "C" void dr1_f(int a = 1); } - using X::dr1_f; using Y::dr1_f; - void g() { - dr1_f(0); - // FIXME: This should be rejected, due to the ambiguous default argument. - dr1_f(); - } - namespace X { - using Y::dr1_f; - void h() { - dr1_f(0); - // FIXME: This should be rejected, due to the ambiguous default argument. - dr1_f(); - } - } - - namespace X { - void z(int); - } - void X::z(int = 1) {} // expected-note {{previous}} - namespace X { - void z(int = 1); // expected-error {{redefinition of default argument}} - } - - void i(int = 1); - void j() { - void i(int = 1); - using dr1::i; - i(0); - // FIXME: This should be rejected, due to the ambiguous default argument. - i(); - } - void k() { - using dr1::i; - void i(int = 1); - i(0); - // FIXME: This should be rejected, due to the ambiguous default argument. - i(); - } -} - -namespace dr3 { // dr3: yes - template<typename T> struct A {}; - template<typename T> void f(T) { A<T> a; } // expected-note {{implicit instantiation}} - template void f(int); - template<> struct A<int> {}; // expected-error {{explicit specialization of 'dr3::A<int>' after instantiation}} -} - -namespace dr4 { // dr4: yes - extern "C" { - static void dr4_f(int) {} - static void dr4_f(float) {} - void dr4_g(int) {} // expected-note {{previous}} - void dr4_g(float) {} // expected-error {{conflicting types}} - } -} - -namespace dr5 { // dr5: yes - struct A {} a; - struct B { - B(const A&); - B(const B&); - }; - const volatile B b = a; - - struct C { C(C&); }; - struct D : C {}; - struct E { operator D&(); } e; - const C c = e; -} - -namespace dr7 { // dr7: yes - class A { public: ~A(); }; - class B : virtual private A {}; // expected-note 2 {{declared private here}} - class C : public B {} c; // expected-error 2 {{inherited virtual base class 'dr7::A' has private destructor}} \ - // expected-note {{implicit default constructor for 'dr7::C' first required here}} \ - // expected-note {{implicit destructor for 'dr7::C' first required here}} - class VeryDerivedC : public B, virtual public A {} vdc; - - class X { ~X(); }; // expected-note {{here}} - class Y : X { ~Y() {} }; // expected-error {{private destructor}} - - namespace PR16370 { // This regressed the first time DR7 was fixed. - struct S1 { virtual ~S1(); }; - struct S2 : S1 {}; - struct S3 : S2 {}; - struct S4 : virtual S2 {}; - struct S5 : S3, S4 { - S5(); - ~S5(); - }; - S5::S5() {} - } -} - -namespace dr8 { // dr8: dup 45 - class A { - struct U; - static const int k = 5; - void f(); - template<typename, int, void (A::*)()> struct T; - - T<U, k, &A::f> *g(); - }; - A::T<A::U, A::k, &A::f> *A::g() { return 0; } -} - -namespace dr9 { // dr9: yes - struct B { - protected: - int m; // expected-note {{here}} - friend int R1(); - }; - struct N : protected B { // expected-note 2{{protected}} - friend int R2(); - } n; - int R1() { return n.m; } // expected-error {{protected base class}} expected-error {{protected member}} - int R2() { return n.m; } -} - -namespace dr10 { // dr10: dup 45 - class A { - struct B { - A::B *p; - }; - }; -} - -namespace dr11 { // dr11: yes - template<typename T> struct A : T { - using typename T::U; - U u; - }; - template<typename T> struct B : T { - using T::V; - V v; // expected-error {{unknown type name}} - }; - struct X { typedef int U; }; - A<X> ax; -} - -namespace dr12 { // dr12: sup 239 - enum E { e }; - E &f(E, E = e); - void g() { - int &f(int, E = e); - // Under DR12, these call two different functions. - // Under DR239, they call the same function. - int &b = f(e); - int &c = f(1); - } -} - -namespace dr13 { // dr13: no - extern "C" void f(int); - void g(char); - - template<typename T> struct A { - A(void (*fp)(T)); - }; - template<typename T> int h(void (T)); - - A<int> a1(f); // FIXME: We should reject this. - A<char> a2(g); - int a3 = h(f); // FIXME: We should reject this. - int a4 = h(g); -} - -namespace dr14 { // dr14: yes - namespace X { extern "C" int dr14_f(); } - namespace Y { extern "C" int dr14_f(); } - using namespace X; - using namespace Y; - int k = dr14_f(); - - class C { - int k; - friend int Y::dr14_f(); - } c; - namespace Z { - extern "C" int dr14_f() { return c.k; } - } - - namespace X { typedef int T; typedef int U; } // expected-note {{candidate}} - namespace Y { typedef int T; typedef long U; } // expected-note {{candidate}} - T t; // ok, same type both times - U u; // expected-error {{ambiguous}} -} - -namespace dr15 { // dr15: yes - template<typename T> void f(int); // expected-note {{previous}} - template<typename T> void f(int = 0); // expected-error {{default arguments cannot be added}} -} - -namespace dr16 { // dr16: yes - class A { // expected-note {{here}} - void f(); // expected-note {{here}} - friend class C; - }; - class B : A {}; // expected-note 4{{here}} - class C : B { - void g() { - f(); // expected-error {{private member}} expected-error {{private base}} - A::f(); // expected-error {{private member}} expected-error {{private base}} - } - }; -} - -namespace dr17 { // dr17: yes - class A { - int n; - int f(); - struct C; - }; - struct B : A {} b; - int A::f() { return b.n; } - struct A::C : A { - int g() { return n; } - }; -} - -// dr18: sup 577 - -namespace dr19 { // dr19: yes - struct A { - int n; // expected-note {{here}} - }; - struct B : protected A { // expected-note {{here}} - }; - struct C : B {} c; - struct D : B { - int get1() { return c.n; } // expected-error {{protected member}} - int get2() { return ((A&)c).n; } // ok, A is an accessible base of B from here - }; -} - -namespace dr20 { // dr20: yes - class X { - public: - X(); - private: - X(const X&); // expected-note {{here}} - }; - X &f(); - X x = f(); // expected-error {{private}} -} - -namespace dr21 { // dr21: yes - template<typename T> struct A; - struct X { - template<typename T = int> friend struct A; // expected-error {{default template argument not permitted on a friend template}} - template<typename T = int> friend struct B; // expected-error {{default template argument not permitted on a friend template}} - }; -} - -namespace dr22 { // dr22: sup 481 - template<typename dr22_T = dr22_T> struct X; // expected-error {{unknown type name 'dr22_T'}} - typedef int T; - template<typename T = T> struct Y; -} - -namespace dr23 { // dr23: yes - template<typename T> void f(T, T); // expected-note {{candidate}} - template<typename T> void f(T, int); // expected-note {{candidate}} - void g() { f(0, 0); } // expected-error {{ambiguous}} -} - -// dr24: na - -namespace dr25 { // dr25: yes - struct A { - void f() throw(int); // expected-error 0-1{{ISO C++17 does not allow}} expected-note 0-1{{use 'noexcept}} - }; - void (A::*f)() throw (int); // expected-error 0-1{{ISO C++17 does not allow}} expected-note 0-1{{use 'noexcept}} - void (A::*g)() throw () = f; -#if __cplusplus <= 201402L - // expected-error@-2 {{is not superset of source}} -#else - // expected-error@-4 {{different exception specifications}} -#endif - void (A::*g2)() throw () = 0; - void (A::*h)() throw (int, char) = f; // expected-error 0-1{{ISO C++17 does not allow}} expected-note 0-1{{use 'noexcept}} - void (A::*i)() throw () = &A::f; -#if __cplusplus <= 201402L - // expected-error@-2 {{is not superset of source}} -#else - // expected-error@-4 {{different exception specifications}} -#endif - void (A::*i2)() throw () = 0; - void (A::*j)() throw (int, char) = &A::f; // expected-error 0-1{{ISO C++17 does not allow}} expected-note 0-1{{use 'noexcept}} - void x() { - g2 = f; -#if __cplusplus <= 201402L - // expected-error@-2 {{is not superset of source}} -#else - // expected-error@-4 {{different exception specifications}} -#endif - h = f; - i2 = &A::f; -#if __cplusplus <= 201402L - // expected-error@-2 {{is not superset of source}} -#else - // expected-error@-4 {{different exception specifications}} -#endif - j = &A::f; - } -} - -namespace dr26 { // dr26: yes - struct A { A(A, const A & = A()); }; // expected-error {{must pass its first argument by reference}} - struct B { - B(); // expected-note 0-1{{candidate}} - B(const B &, B = B()); -#if __cplusplus <= 201402L - // expected-error@-2 {{no matching constructor}} expected-note@-2 {{candidate}} expected-note@-2 {{here}} -#endif - }; - struct C { - static C &f(); - C(const C &, C = f()); // expected-error {{no matching constructor}} expected-note {{candidate}} expected-note {{here}} - }; -} - -namespace dr27 { // dr27: yes - enum E { e } n; - E &m = true ? n : n; -} - -// dr28: na lib - -namespace dr29 { // dr29: 3.4 - void dr29_f0(); // expected-note {{here}} - void g0() { void dr29_f0(); } - extern "C++" void g0_cxx() { void dr29_f0(); } - extern "C" void g0_c() { void dr29_f0(); } // expected-error {{different language linkage}} - - extern "C" void dr29_f1(); // expected-note {{here}} - void g1() { void dr29_f1(); } - extern "C" void g1_c() { void dr29_f1(); } - extern "C++" void g1_cxx() { void dr29_f1(); } // expected-error {{different language linkage}} - - void g2() { void dr29_f2(); } // expected-note {{here}} - extern "C" void dr29_f2(); // expected-error {{different language linkage}} - - extern "C" void g3() { void dr29_f3(); } // expected-note {{here}} - extern "C++" void dr29_f3(); // expected-error {{different language linkage}} - - extern "C++" void g4() { void dr29_f4(); } // expected-note {{here}} - extern "C" void dr29_f4(); // expected-error {{different language linkage}} - - extern "C" void g5(); - extern "C++" void dr29_f5(); - void g5() { - void dr29_f5(); // ok, g5 is extern "C" but we're not inside the linkage-specification here. - } - - extern "C++" void g6(); - extern "C" void dr29_f6(); - void g6() { - void dr29_f6(); // ok, g6 is extern "C" but we're not inside the linkage-specification here. - } - - extern "C" void g7(); - extern "C++" void dr29_f7(); // expected-note {{here}} - extern "C" void g7() { - void dr29_f7(); // expected-error {{different language linkage}} - } - - extern "C++" void g8(); - extern "C" void dr29_f8(); // expected-note {{here}} - extern "C++" void g8() { - void dr29_f8(); // expected-error {{different language linkage}} - } -} - -namespace dr30 { // dr30: sup 468 c++11 - struct A { - template<int> static int f(); - } a, *p = &a; - int x = A::template f<0>(); - int y = a.template f<0>(); - int z = p->template f<0>(); -#if __cplusplus < 201103L - // FIXME: It's not clear whether DR468 applies to C++98 too. - // expected-error@-5 {{'template' keyword outside of a template}} - // expected-error@-5 {{'template' keyword outside of a template}} - // expected-error@-5 {{'template' keyword outside of a template}} -#endif -} - -namespace dr31 { // dr31: yes - class X { - private: - void operator delete(void*); // expected-note {{here}} - }; - // We would call X::operator delete if X() threw (even though it can't, - // and even though we allocated the X using ::operator delete). - X *p = new X; // expected-error {{private}} -} - -// dr32: na - -namespace dr33 { // dr33: yes - namespace X { struct S; void f(void (*)(S)); } // expected-note {{candidate}} - namespace Y { struct T; void f(void (*)(T)); } // expected-note {{candidate}} - void g(X::S); - template<typename Z> Z g(Y::T); - void h() { f(&g); } // expected-error {{ambiguous}} -} - -// dr34: na -// dr35: dup 178 -// dr37: sup 475 - -namespace dr38 { // dr38: yes - template<typename T> struct X {}; - template<typename T> X<T> operator+(X<T> a, X<T> b) { return a; } - template X<int> operator+<int>(X<int>, X<int>); -} - -namespace dr39 { // dr39: no - namespace example1 { - struct A { int &f(int); }; - struct B : A { - using A::f; - float &f(float); - } b; - int &r = b.f(0); - } - - namespace example2 { - struct A { - int &x(int); // expected-note {{found}} - static int &y(int); // expected-note {{found}} - }; - struct V { - int &z(int); - }; - struct B : A, virtual V { - using A::x; // expected-note {{found}} - float &x(float); - using A::y; // expected-note {{found}} - static float &y(float); - using V::z; - float &z(float); - }; - struct C : A, B, virtual V {} c; // expected-warning {{direct base 'dr39::example2::A' is inaccessible due to ambiguity:\n struct dr39::example2::C -> struct dr39::example2::A\n struct dr39::example2::C -> struct dr39::example2::B -> struct dr39::example2::A}} - int &x = c.x(0); // expected-error {{found in multiple base classes}} - // FIXME: This is valid, because we find the same static data member either way. - int &y = c.y(0); // expected-error {{found in multiple base classes}} - int &z = c.z(0); - } - - namespace example3 { - struct A { static int f(); }; - struct B : virtual A { using A::f; }; - struct C : virtual A { using A::f; }; - struct D : B, C {} d; - int k = d.f(); - } - - namespace example4 { - struct A { int n; }; // expected-note {{found}} - struct B : A {}; - struct C : A {}; - struct D : B, C { int f() { return n; } }; // expected-error {{found in multiple base-class}} - } - - namespace PR5916 { - // FIXME: This is valid. - struct A { int n; }; // expected-note +{{found}} - struct B : A {}; - struct C : A {}; - struct D : B, C {}; - int k = sizeof(D::n); // expected-error {{found in multiple base}} expected-error {{unknown type name}} -#if __cplusplus >= 201103L - decltype(D::n) n; // expected-error {{found in multiple base}} -#endif - } -} - -// dr40: na - -namespace dr41 { // dr41: yes - struct S f(S); -} - -namespace dr42 { // dr42: yes - struct A { static const int k = 0; }; - struct B : A { static const int k = A::k; }; -} - -// dr43: na - -namespace dr44 { // dr44: sup 727 - struct A { - template<int> void f(); - template<> void f<0>(); - }; -} - -namespace dr45 { // dr45: yes - class A { - class B {}; - class C : B {}; - C c; - }; -} - -namespace dr46 { // dr46: yes - template<typename> struct A { template<typename> struct B {}; }; - template template struct A<int>::B<int>; // expected-error {{expected unqualified-id}} -} - -namespace dr47 { // dr47: sup 329 - template<typename T> struct A { - friend void f() { T t; } // expected-error {{redefinition}} expected-note {{previous}} - }; - A<int> a; - A<float> b; // expected-note {{instantiation of}} - - void f(); - void g() { f(); } -} - -namespace dr48 { // dr48: yes - namespace { - struct S { - static const int m = 0; - static const int n = 0; - static const int o = 0; - }; - } - int a = S::m; - // FIXME: We should produce a 'has internal linkage but is not defined' - // diagnostic for 'S::n'. - const int &b = S::n; - const int S::o; - const int &c = S::o; -} - -namespace dr49 { // dr49: yes - template<int*> struct A {}; // expected-note 0-2{{here}} - int k; -#if __has_feature(cxx_constexpr) - constexpr -#endif - int *const p = &k; // expected-note 0-2{{here}} - A<&k> a; - A<p> b; -#if __cplusplus <= 201402L - // expected-error@-2 {{must have its address taken}} -#endif -#if __cplusplus < 201103L - // expected-error@-5 {{internal linkage}} -#endif - int *q = &k; - A<q> c; -#if __cplusplus < 201103L - // expected-error@-2 {{must have its address taken}} -#else - // expected-error@-4 {{constant expression}} - // expected-note@-5 {{read of non-constexpr}} - // expected-note@-7 {{declared here}} -#endif -} - -namespace dr50 { // dr50: yes - struct X; // expected-note {{forward}} - extern X *p; - X *q = (X*)p; - X *r = static_cast<X*>(p); - X *s = const_cast<X*>(p); - X *t = reinterpret_cast<X*>(p); - X *u = dynamic_cast<X*>(p); // expected-error {{incomplete}} -} - -namespace dr51 { // dr51: yes - struct A {}; - struct B : A {}; - struct S { - operator A&(); - operator B&(); - } s; - A &a = s; -} - -namespace dr52 { // dr52: yes - struct A { int n; }; // expected-note {{here}} - struct B : private A {} b; // expected-note 2{{private}} - // FIXME: This first diagnostic is very strangely worded, and seems to be bogus. - int k = b.A::n; // expected-error {{'A' is a private member of 'dr52::A'}} - // expected-error@-1 {{cannot cast 'struct B' to its private base}} -} - -namespace dr53 { // dr53: yes - int n = 0; - enum E { e } x = static_cast<E>(n); -} - -namespace dr54 { // dr54: yes - struct A { int a; } a; - struct V { int v; } v; - struct B : private A, virtual V { int b; } b; // expected-note 6{{private here}} - - A &sab = static_cast<A&>(b); // expected-error {{private base}} - A *spab = static_cast<A*>(&b); // expected-error {{private base}} - int A::*smab = static_cast<int A::*>(&B::b); // expected-error {{private base}} - B &sba = static_cast<B&>(a); // expected-error {{private base}} - B *spba = static_cast<B*>(&a); // expected-error {{private base}} - int B::*smba = static_cast<int B::*>(&A::a); // expected-error {{private base}} - - V &svb = static_cast<V&>(b); - V *spvb = static_cast<V*>(&b); - int V::*smvb = static_cast<int V::*>(&B::b); // expected-error {{virtual base}} - B &sbv = static_cast<B&>(v); // expected-error {{virtual base}} - B *spbv = static_cast<B*>(&v); // expected-error {{virtual base}} - int B::*smbv = static_cast<int B::*>(&V::v); // expected-error {{virtual base}} - - A &cab = (A&)(b); - A *cpab = (A*)(&b); - int A::*cmab = (int A::*)(&B::b); - B &cba = (B&)(a); - B *cpba = (B*)(&a); - int B::*cmba = (int B::*)(&A::a); - - V &cvb = (V&)(b); - V *cpvb = (V*)(&b); - int V::*cmvb = (int V::*)(&B::b); // expected-error {{virtual base}} - B &cbv = (B&)(v); // expected-error {{virtual base}} - B *cpbv = (B*)(&v); // expected-error {{virtual base}} - int B::*cmbv = (int B::*)(&V::v); // expected-error {{virtual base}} -} - -namespace dr55 { // dr55: yes - enum E { e = 5 }; - int test[(e + 1 == 6) ? 1 : -1]; -} - -namespace dr56 { // dr56: yes - struct A { - typedef int T; // expected-note {{previous}} - typedef int T; // expected-error {{redefinition}} - }; - struct B { - struct X; - typedef X X; // expected-note {{previous}} - typedef X X; // expected-error {{redefinition}} - }; -} - -namespace dr58 { // dr58: yes - // FIXME: Ideally, we should have a CodeGen test for this. -#if __cplusplus >= 201103L - enum E1 { E1_0 = 0, E1_1 = 1 }; - enum E2 { E2_0 = 0, E2_m1 = -1 }; - struct X { E1 e1 : 1; E2 e2 : 1; }; - static_assert(X{E1_1, E2_m1}.e1 == 1, ""); - static_assert(X{E1_1, E2_m1}.e2 == -1, ""); -#endif -} - -namespace dr59 { // dr59: yes - template<typename T> struct convert_to { operator T() const; }; - struct A {}; // expected-note 5+{{candidate}} - struct B : A {}; // expected-note 0+{{candidate}} - - A a1 = convert_to<A>(); - A a2 = convert_to<A&>(); - A a3 = convert_to<const A>(); - A a4 = convert_to<const volatile A>(); -#if __cplusplus <= 201402L - // expected-error@-2 {{no viable}} -#endif - A a5 = convert_to<const volatile A&>(); // expected-error {{no viable}} - - B b1 = convert_to<B>(); - B b2 = convert_to<B&>(); - B b3 = convert_to<const B>(); - B b4 = convert_to<const volatile B>(); -#if __cplusplus <= 201402L - // expected-error@-2 {{no viable}} -#endif - B b5 = convert_to<const volatile B&>(); // expected-error {{no viable}} - - A c1 = convert_to<B>(); - A c2 = convert_to<B&>(); - A c3 = convert_to<const B>(); - A c4 = convert_to<const volatile B>(); // expected-error {{no viable}} - A c5 = convert_to<const volatile B&>(); // expected-error {{no viable}} - - int n1 = convert_to<int>(); - int n2 = convert_to<int&>(); - int n3 = convert_to<const int>(); - int n4 = convert_to<const volatile int>(); - int n5 = convert_to<const volatile int&>(); -} - -namespace dr60 { // dr60: yes - void f(int &); - int &f(...); - const int k = 0; - int &n = f(k); -} - -namespace dr61 { // dr61: yes - struct X { - static void f(); - } x; - struct Y { - static void f(); - static void f(int); - } y; - // This is (presumably) valid, because x.f does not refer to an overloaded - // function name. - void (*p)() = &x.f; - void (*q)() = &y.f; // expected-error {{cannot create a non-constant pointer to member function}} - void (*r)() = y.f; // expected-error {{cannot create a non-constant pointer to member function}} -} - -namespace dr62 { // dr62: yes - struct A { - struct { int n; } b; - }; - template<typename T> struct X {}; - template<typename T> T get() { return get<T>(); } - template<typename T> int take(T) { return 0; } - - X<A> x1; - A a = get<A>(); - - typedef struct { } *NoNameForLinkagePtr; -#if __cplusplus < 201103L - // expected-note@-2 5{{here}} -#endif - NoNameForLinkagePtr noNameForLinkagePtr; - - struct Danger { - NoNameForLinkagePtr p; - }; - - X<NoNameForLinkagePtr> x2; - X<const NoNameForLinkagePtr> x3; - NoNameForLinkagePtr p1 = get<NoNameForLinkagePtr>(); - NoNameForLinkagePtr p2 = get<const NoNameForLinkagePtr>(); - int n1 = take(noNameForLinkagePtr); -#if __cplusplus < 201103L - // expected-error@-6 {{uses unnamed type}} - // expected-error@-6 {{uses unnamed type}} - // expected-error@-6 {{uses unnamed type}} - // expected-error@-6 {{uses unnamed type}} - // expected-error@-6 {{uses unnamed type}} -#endif - - X<Danger> x4; - - void f() { - struct NoLinkage {}; - X<NoLinkage> a; - X<const NoLinkage> b; - get<NoLinkage>(); - get<const NoLinkage>(); - X<void (*)(NoLinkage A::*)> c; - X<int NoLinkage::*> d; -#if __cplusplus < 201103L - // expected-error@-7 {{uses local type}} - // expected-error@-7 {{uses local type}} - // expected-error@-7 {{uses local type}} - // expected-error@-7 {{uses local type}} - // expected-error@-7 {{uses local type}} - // expected-error@-7 {{uses local type}} -#endif - } -} - -namespace dr63 { // dr63: yes - template<typename T> struct S { typename T::error e; }; - extern S<int> *p; - void *q = p; -} - -namespace dr64 { // dr64: yes - template<class T> void f(T); - template<class T> void f(T*); - template<> void f(int*); - template<> void f<int>(int*); - template<> void f(int); -} - -// dr65: na - -namespace dr66 { // dr66: no - namespace X { - int f(int n); // expected-note 2{{candidate}} - } - using X::f; - namespace X { - int f(int n = 0); - int f(int, int); - } - // FIXME: The first two calls here should be accepted. - int a = f(); // expected-error {{no matching function}} - int b = f(1); - int c = f(1, 2); // expected-error {{no matching function}} -} - -// dr67: na - -namespace dr68 { // dr68: yes - template<typename T> struct X {}; - struct ::dr68::X<int> x1; - struct ::dr68::template X<int> x2; -#if __cplusplus < 201103L - // expected-error@-2 {{'template' keyword outside of a template}} -#endif - struct Y { - friend struct X<int>; - friend struct ::dr68::X<char>; - friend struct ::dr68::template X<double>; -#if __cplusplus < 201103L - // expected-error@-2 {{'template' keyword outside of a template}} -#endif - }; - template<typename> - struct Z { - friend struct ::dr68::template X<double>; - friend typename ::dr68::X<double>; -#if __cplusplus < 201103L - // expected-error@-2 {{C++11 extension}} -#endif - }; -} - -namespace dr69 { // dr69: yes - template<typename T> static void f() {} - // FIXME: Should we warn here? - inline void g() { f<int>(); } - // FIXME: This should be rejected, per [temp.explicit]p11. - extern template void f<char>(); -#if __cplusplus < 201103L - // expected-error@-2 {{C++11 extension}} -#endif - template<void(*)()> struct Q {}; - Q<&f<int> > q; -#if __cplusplus < 201103L - // expected-error@-2 {{internal linkage}} expected-note@-11 {{here}} -#endif -} - -namespace dr70 { // dr70: yes - template<int> struct A {}; - template<int I, int J> int f(int (&)[I + J], A<I>, A<J>); - int arr[7]; - int k = f(arr, A<3>(), A<4>()); -} - -// dr71: na -// dr72: dup 69 - -#if __cplusplus >= 201103L -namespace dr73 { // dr73: no - // The resolution to dr73 is unworkable. Consider: - int a, b; - static_assert(&a + 1 != &b, ""); // expected-error {{not an integral constant expression}} -} -#endif - -namespace dr74 { // dr74: yes - enum E { k = 5 }; - int (*p)[k] = new int[k][k]; -} - -namespace dr75 { // dr75: yes - struct S { - static int n = 0; // expected-error {{non-const}} - }; -} - -namespace dr76 { // dr76: yes - const volatile int n = 1; - int arr[n]; // expected-error +{{variable length array}} -} - -namespace dr77 { // dr77: yes - struct A { - struct B {}; - friend struct B; - }; -} - -namespace dr78 { // dr78: sup ???? - // Under DR78, this is valid, because 'k' has static storage duration, so is - // zero-initialized. - const int k; // expected-error {{default initialization of an object of const}} -} - -// dr79: na - -namespace dr80 { // dr80: yes - struct A { - int A; - }; - struct B { - static int B; // expected-error {{same name as its class}} - }; - struct C { - int C; // expected-error {{same name as its class}} - C(); - }; - struct D { - D(); - int D; // expected-error {{same name as its class}} - }; -} - -// dr81: na -// dr82: dup 48 - -namespace dr83 { // dr83: yes - int &f(const char*); - char &f(char *); - int &k = f("foo"); -} - -namespace dr84 { // dr84: yes - struct B; - struct A { operator B() const; }; - struct C {}; - struct B { - B(B&); // expected-note 0-1{{candidate}} - B(C); // expected-note 0-1{{no known conversion from 'dr84::B' to 'dr84::C'}} - operator C() const; - }; - A a; - // Cannot use B(C) / operator C() pair to construct the B from the B temporary - // here. In C++17, we initialize the B object directly using 'A::operator B()'. - B b = a; -#if __cplusplus <= 201402L - // expected-error@-2 {{no viable}} -#endif -} - -namespace dr85 { // dr85: yes - struct A { - struct B; - struct B {}; // expected-note{{previous declaration is here}} - struct B; // expected-error{{class member cannot be redeclared}} - - union U; - union U {}; // expected-note{{previous declaration is here}} - union U; // expected-error{{class member cannot be redeclared}} - -#if __cplusplus >= 201103L - enum E1 : int; - enum E1 : int { e1 }; // expected-note{{previous declaration is here}} - enum E1 : int; // expected-error{{class member cannot be redeclared}} - - enum class E2; - enum class E2 { e2 }; // expected-note{{previous declaration is here}} - enum class E2; // expected-error{{class member cannot be redeclared}} -#endif - }; - - template <typename T> - struct C { - struct B {}; // expected-note{{previous declaration is here}} - struct B; // expected-error{{class member cannot be redeclared}} - }; -} - -// dr86: dup 446 - -namespace dr87 { // dr87: no - // FIXME: Superseded by dr1975 - template<typename T> struct X {}; - // FIXME: This is invalid. - X<void() throw()> x; - // This is valid under dr87 but not under dr1975. - X<void(void() throw())> y; -} - -namespace dr88 { // dr88: yes - template<typename T> struct S { - static const int a = 1; // expected-note {{previous}} - static const int b; - }; - template<> const int S<int>::a = 4; // expected-error {{already has an initializer}} - template<> const int S<int>::b = 4; -} - -// dr89: na - -namespace dr90 { // dr90: yes - struct A { - template<typename T> friend void dr90_f(T); - }; - struct B : A { - template<typename T> friend void dr90_g(T); - struct C {}; - union D {}; - }; - struct E : B {}; - struct F : B::C {}; - - void test() { - dr90_f(A()); - dr90_f(B()); - dr90_f(B::C()); // expected-error {{undeclared identifier}} - dr90_f(B::D()); // expected-error {{undeclared identifier}} - dr90_f(E()); - dr90_f(F()); // expected-error {{undeclared identifier}} - - dr90_g(A()); // expected-error {{undeclared identifier}} - dr90_g(B()); - dr90_g(B::C()); - dr90_g(B::D()); - dr90_g(E()); - dr90_g(F()); // expected-error {{undeclared identifier}} - } -} - -namespace dr91 { // dr91: yes - union U { friend int f(U); }; - int k = f(U()); -} - -namespace dr92 { // dr92: 4 c++17 - void f() throw(int, float); // expected-error 0-1{{ISO C++17 does not allow}} expected-note 0-1{{use 'noexcept}} - void (*p)() throw(int) = &f; // expected-error 0-1{{ISO C++17 does not allow}} expected-note 0-1{{use 'noexcept}} -#if __cplusplus <= 201402L - // expected-error@-2 {{target exception specification is not superset of source}} -#else - // expected-warning@-4 {{target exception specification is not superset of source}} -#endif - void (*q)() throw(int); // expected-error 0-1{{ISO C++17 does not allow}} expected-note 0-1{{use 'noexcept}} - void (**pp)() throw() = &q; -#if __cplusplus <= 201402L - // expected-error@-2 {{exception specifications are not allowed}} -#else - // expected-error@-4 {{cannot initialize}} -#endif - - void g(void() throw()); // expected-note 0-2 {{no known conversion}} expected-warning 0-1{{mangled name of 'g' will change in C++17}} - void h() throw() { - g(f); // expected-error-re {{{{is not superset|no matching function}}}} - g(q); // expected-error-re {{{{is not superset|no matching function}}}} - } - - // Prior to C++17, this is OK because the exception specification is not - // considered in this context. In C++17, we *do* perform an implicit - // conversion (which performs initialization), and the exception specification - // is part of the type of the parameter, so this is invalid. - template<void() throw()> struct X {}; - X<&f> xp; -#if __cplusplus > 201402L - // expected-error@-2 {{not implicitly convertible}} -#endif - - template<void() throw(int)> struct Y {}; // expected-error 0-1{{ISO C++17 does not allow}} expected-note 0-1{{use 'noexcept}} - Y<&h> yp; // ok -} - -// dr93: na - -namespace dr94 { // dr94: yes - struct A { static const int n = 5; }; - int arr[A::n]; -} - -namespace dr95 { // dr95: yes - struct A; - struct B; - namespace N { - class C { - friend struct A; - friend struct B; - static void f(); // expected-note {{here}} - }; - struct A *p; // dr95::A, not dr95::N::A. - } - A *q = N::p; // ok, same type - struct B { void f() { N::C::f(); } }; // expected-error {{private}} -} - -namespace dr96 { // dr96: no - struct A { - void f(int); - template<typename T> int f(T); - template<typename T> struct S {}; - } a; - template<template<typename> class X> struct B {}; - - template<typename T> - void test() { - int k1 = a.template f<int>(0); - // FIXME: This is ill-formed, because 'f' is not a template-id and does not - // name a class template. - // FIXME: What about alias templates? - int k2 = a.template f(1); - A::template S<int> s; - B<A::template S> b; - } -} - -namespace dr97 { // dr97: yes - struct A { - static const int a = false; - static const int b = !a; - }; -} - -namespace dr98 { // dr98: yes - void test(int n) { - switch (n) { - try { // expected-note 2{{bypasses}} - case 0: // expected-error {{cannot jump}} - x: - throw n; - } catch (...) { // expected-note 2{{bypasses}} - case 1: // expected-error {{cannot jump}} - y: - throw n; - } - case 2: - goto x; // expected-error {{cannot jump}} - case 3: - goto y; // expected-error {{cannot jump}} - } - } -} - -namespace dr99 { // dr99: sup 214 - template<typename T> void f(T&); - template<typename T> int &f(const T&); - const int n = 0; - int &r = f(n); -} diff --git a/test/CXX/drs/dr10xx.cpp b/test/CXX/drs/dr10xx.cpp deleted file mode 100644 index 7f5fd8c7ec27..000000000000 --- a/test/CXX/drs/dr10xx.cpp +++ /dev/null @@ -1,85 +0,0 @@ -// RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++1z %s -verify -fexceptions -fcxx-exceptions -pedantic-errors - -namespace std { - __extension__ typedef __SIZE_TYPE__ size_t; - - template<typename T> struct initializer_list { - const T *p; size_t n; - initializer_list(const T *p, size_t n); - }; -} - -namespace dr1004 { // dr1004: 5 - template<typename> struct A {}; - template<typename> struct B1 {}; - template<template<typename> class> struct B2 {}; - template<typename X> void f(); // expected-note {{[with X = dr1004::A<int>]}} - template<template<typename> class X> void f(); // expected-note {{[with X = A]}} - template<template<typename> class X> void g(); // expected-note {{[with X = A]}} - template<typename X> void g(); // expected-note {{[with X = dr1004::A<int>]}} - struct C : A<int> { - B1<A> b1a; - B2<A> b2a; - void h() { - f<A>(); // expected-error {{ambiguous}} - g<A>(); // expected-error {{ambiguous}} - } - }; - - // This example (from the standard) is actually ill-formed, because - // name lookup of "T::template A" names the constructor. - template<class T, template<class> class U = T::template A> struct Third { }; // expected-error {{is a constructor name}} - Third<A<int> > t; // expected-note {{in instantiation of default argument}} -} - -namespace dr1048 { // dr1048: 3.6 - struct A {}; - const A f(); - A g(); - typedef const A CA; -#if __cplusplus >= 201103L - // ok: we deduce non-const A in each case. - A &&a = [] (int n) { - while (1) switch (n) { - case 0: return f(); - case 1: return g(); - case 2: return A(); - case 3: return CA(); - } - } (0); -#endif -} - -namespace dr1054 { // dr1054: no - // FIXME: Test is incomplete. - struct A {} volatile a; - void f() { - // FIXME: This is wrong: an lvalue-to-rvalue conversion is applied here, - // which copy-initializes a temporary from 'a'. Therefore this is - // ill-formed because A does not have a volatile copy constructor. - // (We might want to track this aspect under dr1383 instead?) - a; // expected-warning {{assign into a variable to force a volatile load}} - } -} - -namespace dr1070 { // dr1070: 3.5 -#if __cplusplus >= 201103L - struct A { - A(std::initializer_list<int>); - }; - struct B { - int i; - A a; - }; - B b = {1}; - struct C { - std::initializer_list<int> a; - B b; - std::initializer_list<double> c; - }; - C c = {}; -#endif -} diff --git a/test/CXX/drs/dr118.cpp b/test/CXX/drs/dr118.cpp deleted file mode 100644 index 58aa3912c801..000000000000 --- a/test/CXX/drs/dr118.cpp +++ /dev/null @@ -1,26 +0,0 @@ -// RUN: %clang_cc1 -triple x86_64-linux -std=c++98 %s -pedantic-errors -emit-llvm -o - | FileCheck %s --implicit-check-not " call " -// RUN: %clang_cc1 -triple x86_64-linux -std=c++11 %s -pedantic-errors -emit-llvm -o - | FileCheck %s --implicit-check-not " call " -// RUN: %clang_cc1 -triple x86_64-linux -std=c++14 %s -pedantic-errors -emit-llvm -o - | FileCheck %s --implicit-check-not " call " -// RUN: %clang_cc1 -triple x86_64-linux -std=c++1z %s -pedantic-errors -emit-llvm -o - | FileCheck %s --implicit-check-not " call " - -// dr118: yes - -struct S { - virtual void f(); -}; -void (S::*pmf)(); - -// CHECK-LABEL: define {{.*}} @_Z1g -void g(S *sp) { - // CHECK: call void % - sp->f(); // 1: polymorphic - // CHECK: call void @ - sp->S::f(); // 2: non-polymorphic - // CHECK: call void @ - (sp->S::f)(); // 3: non-polymorphic - // CHECK: call void % - (sp->*pmf)(); // 4: polymorphic - // CHECK: call void % - (sp->*&S::f)(); // 5: polymorphic -} - diff --git a/test/CXX/drs/dr11xx.cpp b/test/CXX/drs/dr11xx.cpp deleted file mode 100644 index 81fbc1e3ef1b..000000000000 --- a/test/CXX/drs/dr11xx.cpp +++ /dev/null @@ -1,30 +0,0 @@ -// RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++17 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++2a %s -verify -fexceptions -fcxx-exceptions -pedantic-errors - -namespace dr1113 { // dr1113: partial - namespace named { - extern int a; // expected-note {{previous}} - static int a; // expected-error {{static declaration of 'a' follows non-static}} - } - namespace { - extern int a; - static int a; // ok, both declarations have internal linkage - int b = a; - } - - // FIXME: Per DR1113 and DR4, this is ill-formed due to ambiguity: the second - // 'f' has internal linkage, and so does not have C language linkage, so is - // not a redeclaration of the first 'f'. - // - // To avoid a breaking change here, Clang ignores the "internal linkage" effect - // of anonymous namespaces on declarations declared within an 'extern "C"' - // linkage-specification. - extern "C" void f(); - namespace { - extern "C" void f(); - } - void g() { f(); } -} diff --git a/test/CXX/drs/dr12xx.cpp b/test/CXX/drs/dr12xx.cpp deleted file mode 100644 index 1bc4c3973443..000000000000 --- a/test/CXX/drs/dr12xx.cpp +++ /dev/null @@ -1,80 +0,0 @@ -// RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++1z %s -verify -fexceptions -fcxx-exceptions -pedantic-errors - -namespace dr1213 { // dr1213: 7 -#if __cplusplus >= 201103L - using T = int[3]; - int &&r = T{}[1]; - - using T = decltype((T{})); - using U = decltype((T{}[2])); - using U = int &&; - - // Same thing but in a case where we consider overloaded operator[]. - struct ConvertsToInt { - operator int(); - }; - struct X { int array[1]; }; - using U = decltype(X().array[ConvertsToInt()]); - - // We apply the same rule to vector subscripting. - typedef int V4Int __attribute__((__vector_size__(sizeof(int) * 4))); - typedef int EV4Int __attribute__((__ext_vector_type__(4))); - using U = decltype(V4Int()[0]); - using U = decltype(EV4Int()[0]); -#endif -} - -namespace dr1250 { // dr1250: 3.9 -struct Incomplete; - -struct Base { - virtual const Incomplete *meow() = 0; -}; - -struct Derived : Base { - virtual Incomplete *meow(); -}; -} - -namespace dr1265 { // dr1265: 5 -#if __cplusplus >= 201103L - auto a = 0, b() -> int; // expected-error {{declaration with trailing return type must be the only declaration in its group}} - auto b() -> int, d = 0; // expected-error {{declaration with trailing return type must be the only declaration in its group}} - auto e() -> int, f() -> int; // expected-error {{declaration with trailing return type must be the only declaration in its group}} -#endif - -#if __cplusplus >= 201402L - auto g(), h = 0; // expected-error {{function with deduced return type must be the only declaration in its group}} - auto i = 0, j(); // expected-error {{function with deduced return type must be the only declaration in its group}} - auto k(), l(); // expected-error {{function with deduced return type must be the only declaration in its group}} -#endif -} - -namespace dr1295 { // dr1295: 4 - struct X { - unsigned bitfield : 4; - }; - - X x = {1}; - - unsigned const &r1 = static_cast<X &&>(x).bitfield; // expected-error 0-1{{C++11}} - unsigned const &r2 = static_cast<unsigned &&>(x.bitfield); // expected-error 0-1{{C++11}} - - template<unsigned &r> struct Y {}; - Y<x.bitfield> y; -#if __cplusplus <= 201402L - // expected-error@-2 {{does not refer to any declaration}} expected-note@-3 {{here}} -#else - // expected-error@-4 {{refers to subobject}} -#endif - -#if __cplusplus >= 201103L - const unsigned other = 0; - using T = decltype(true ? other : x.bitfield); - using T = unsigned; -#endif -} - diff --git a/test/CXX/drs/dr13xx.cpp b/test/CXX/drs/dr13xx.cpp deleted file mode 100644 index 208ab8a03b0a..000000000000 --- a/test/CXX/drs/dr13xx.cpp +++ /dev/null @@ -1,414 +0,0 @@ -// RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++17 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors - -__extension__ typedef __SIZE_TYPE__ size_t; - -namespace std { - template<typename T> struct initializer_list { - const T *ptr; - size_t n; - initializer_list(const T*, size_t); - }; -} - -namespace dr1310 { // dr1310: 5 - struct S {} * sp = new S::S; // expected-error {{qualified reference to 'S' is a constructor name}} - void f() { - S::S(a); // expected-error {{qualified reference to 'S' is a constructor name}} - } - struct T { int n; typedef int U; typedef T V; }; - int k = T().T::T::n; - T::V v; - - struct U { int U; }; - int u = U().U::U; - struct U::U w; - - struct V : T::T { - // FIXME: This is technically ill-formed, but we consider that to be a defect. - V() : T::T() {} - }; - template<typename T> struct VT : T::T { - VT() : T::T() {} - }; - template struct VT<T>; - - template<template<typename> class> class TT {}; - template<typename> class TTy {}; - - template<typename T> struct WBase {}; - template<typename T> struct W : WBase<T> { typedef int X; int n; }; - - void w_test() { - W<int>::W w1a; // expected-error {{qualified reference to 'W' is a constructor name}} - W<int>::W::X w1ax; - W<int>::W<int> w1b; // expected-error {{qualified reference to 'W' is a constructor name}} - W<int>::W<int>::X w1bx; - typename W<int>::W w2a; // expected-error {{qualified reference to 'W' is a constructor name}} expected-error 0-1{{outside of a template}} - typename W<int>::W::X w2ax; // expected-error 0-1{{outside of a template}} - typename W<int>::W<int> w2b; // expected-error {{qualified reference to 'W' is a constructor name}} expected-error 0-1{{outside of a template}} - typename W<int>::W<int>::X w2bx; // expected-error 0-1{{outside of a template}} - W<int>::template W<int> w3; // expected-error {{qualified reference to 'W' is a constructor name}} expected-error 0-1{{outside of a template}} - W<int>::template W<int>::X w3x; // expected-error 0-1{{outside of a template}} - typename W<int>::template W<int> w4; // expected-error {{qualified reference to 'W' is a constructor name}} expected-error 0-2{{outside of a template}} - typename W<int>::template W<int>::X w4x; // expected-error 0-2{{outside of a template}} - - TT<W<int>::W> tt1; // expected-error {{qualified reference to 'W' is a constructor name}} - TTy<W<int>::W> tt1a; // expected-error {{qualified reference to 'W' is a constructor name}} - TT<W<int>::template W> tt2; // expected-error {{qualified reference to 'W' is a constructor name}} expected-error 0-1{{outside of a template}} - TT<W<int>::WBase> tt3; - TTy<W<int>::WBase> tt3a; - TT<W<int>::template WBase> tt4; // expected-error 0-1{{outside of a template}} - - W<int> w; - (void)w.W::W::n; - (void)w.W<int>::W::n; - (void)w.W<int>::W<int>::n; - (void)w.W<int>::template W<int>::n; // expected-error 0-1{{outside of a template}} - } - - template<typename W> - void wt_test() { - typename W::W w2a; // expected-error {{qualified reference to 'W' is a constructor name}} - typename W::template W<int> w4; // expected-error {{qualified reference to 'W' is a constructor name}} - TTy<typename W::W> tt2; // expected-error {{qualified reference to 'W' is a constructor name}} - TT<W::template W> tt3; // expected-error {{qualified reference to 'W' is a constructor name}} - } - template<typename W> - void wt_test_good() { - typename W::W::X w2ax; - typename W::template W<int>::X w4x; - TTy<typename W::WBase> tt4; - TT<W::template WBase> tt5; - - W w; - (void)w.W::W::n; - (void)w.W::template W<int>::n; - (void)w.template W<int>::W::n; - (void)w.template W<int>::template W<int>::n; - } - template void wt_test<W<int> >(); // expected-note {{instantiation of}} - template void wt_test_good<W<int> >(); -} - -namespace dr1315 { // dr1315: partial - template <int I, int J> struct A {}; - template <int I> // expected-note {{non-deducible template parameter 'I'}} - struct A<I + 5, I * 2> {}; // expected-error {{contains a template parameter that cannot be deduced}} - template <int I> struct A<I, I> {}; - - template <int I, int J, int K> struct B; - template <int I, int K> struct B<I, I * 2, K> {}; // expected-note {{matches}} - B<1, 2, 3> b1; - - // Multiple declarations with the same dependent expression are equivalent - // for partial ordering purposes. - template <int I> struct B<I, I * 2, 2> { typedef int type; }; - B<1, 2, 2>::type b2; - - // Multiple declarations with differing dependent expressions are unordered. - template <int I, int K> struct B<I, I + 1, K> {}; // expected-note {{matches}} - B<1, 2, 4> b3; // expected-error {{ambiguous}} - - // FIXME: Under dr1315, this is perhaps valid, but that is not clear: this - // fails the "more specialized than the primary template" test because the - // dependent type of T::value is not the same as 'int'. - // A core issue will be opened to decide what is supposed to happen here. - template <typename T, int I> struct C; - template <typename T> struct C<T, T::value>; - // expected-error@-1 {{type of specialized non-type template argument depends on a template parameter of the partial specialization}} -} - -namespace dr1330 { // dr1330: 4 c++11 - // exception-specifications are parsed in a context where the class is complete. - struct A { - void f() throw(T) {} // expected-error 0-1{{C++17}} expected-note 0-1{{noexcept}} - struct T {}; - -#if __cplusplus >= 201103L - void g() noexcept(&a == b) {} - static int a; - static constexpr int *b = &a; -#endif - }; - - void (A::*af1)() throw(A::T) = &A::f; // expected-error 0-1{{C++17}} expected-note 0-1{{noexcept}} - void (A::*af2)() throw() = &A::f; // expected-error-re {{{{not superset|different exception spec}}}} - -#if __cplusplus >= 201103L - static_assert(noexcept(A().g()), ""); -#endif - - // Likewise, they're instantiated separately from an enclosing class template. - template<typename U> - struct B { - void f() throw(T, typename U::type) {} // expected-error 0-1{{C++17}} expected-note 0-1{{noexcept}} - struct T {}; - -#if __cplusplus >= 201103L - void g() noexcept(&a == b && U::value) {} - static int a; - static constexpr int *b = &a; -#endif - }; - - B<int> bi; // ok - - struct P { - typedef int type; - static const int value = true; - }; - - void (B<P>::*bpf1)() throw(B<P>::T, int) = &B<P>::f; // expected-error 0-1{{C++17}} expected-note 0-1{{noexcept}} -#if __cplusplus < 201103L - // expected-error@-2 {{not superset}} - // FIXME: We only delay instantiation in C++11 onwards. In C++98, something - // weird happens: instantiation of B<P> fails because it references T before - // it's instantiated, but the diagnostic is suppressed in - // Sema::FindInstantiatedDecl because we've already hit an error. This is - // obviously a bad way to react to this situation; we should still producing - // the "T has not yet been instantiated" error here, rather than giving - // confusing errors later on. -#endif - void (B<P>::*bpf2)() throw(int) = &B<P>::f; // expected-error 0-1{{C++17}} expected-note 0-1{{noexcept}} -#if __cplusplus <= 201402L - // expected-error@-2 {{not superset}} -#else - // expected-warning@-4 {{not superset}} -#endif - void (B<P>::*bpf3)() = &B<P>::f; - void (B<P>::*bpf4)() throw() = &B<P>::f; -#if __cplusplus <= 201402L - // expected-error@-2 {{not superset}} -#else - // expected-error@-4 {{different exception specifications}} -#endif - -#if __cplusplus >= 201103L - static_assert(noexcept(B<P>().g()), ""); - struct Q { static const int value = false; }; - static_assert(!noexcept(B<Q>().g()), ""); -#endif - - template<typename T> int f() throw(typename T::error) { return 0; } // expected-error 1-4{{prior to '::'}} expected-note 0-1{{prior to '::'}} expected-note 0-1{{requested here}} -#if __cplusplus > 201402L - // expected-error@-2 0-1{{C++17}} expected-note@-2 0-1{{noexcept}} -#endif - // An exception-specification is needed even if the function is only used in - // an unevaluated operand. - int f1 = sizeof(f<int>()); // expected-note {{instantiation of}} -#if __cplusplus >= 201103L - decltype(f<char>()) f2; // expected-note {{instantiation of}} - bool f3 = noexcept(f<float>()); // expected-note {{instantiation of}} -#endif - // In C++17 onwards, substituting explicit template arguments into the - // function type substitutes into the exception specification (because it's - // part of the type). In earlier languages, we don't notice there's a problem - // until we've already started to instantiate. - template int f<short>(); -#if __cplusplus >= 201703L - // expected-error@-2 {{does not refer to a function template}} -#else - // expected-note@-4 {{instantiation of}} -#endif - - template<typename T> struct C { - C() throw(typename T::type); // expected-error 1-2{{prior to '::'}} -#if __cplusplus > 201402L - // expected-error@-2 0-1{{C++17}} expected-note@-2 0-1{{noexcept}} -#endif - }; - struct D : C<void> {}; // ok -#if __cplusplus < 201103L - // expected-note@-2 {{instantiation of}} -#endif - void f(D &d) { d = d; } // ok - - struct E : C<int> {}; // expected-note {{in instantiation of}} -#if __cplusplus >= 201103L - E e; // expected-note {{needed here}} -#endif -} - -namespace dr1346 { // dr1346: 3.5 - auto a(1); // expected-error 0-1{{extension}} - auto b(1, 2); // expected-error {{multiple expressions}} expected-error 0-1{{extension}} -#if __cplusplus >= 201103L - auto c({}); // expected-error {{parenthesized initializer list}} - auto d({1}); // expected-error {{parenthesized initializer list}} - auto e({1, 2}); // expected-error {{parenthesized initializer list}} -#endif - template<typename...Ts> void f(Ts ...ts) { // expected-error 0-1{{extension}} - auto x(ts...); // expected-error {{empty}} expected-error 0-1{{extension}} - } - template void f(); // expected-note {{instantiation}} - -#if __cplusplus >= 201103L - void init_capture() { - [a(1)] {} (); // expected-error 0-1{{extension}} - [b(1, 2)] {} (); // expected-error {{multiple expressions}} expected-error 0-1{{extension}} -#if __cplusplus >= 201103L - [c({})] {} (); // expected-error {{parenthesized initializer list}} expected-error 0-1{{extension}} - [d({1})] {} (); // expected-error {{parenthesized initializer list}} expected-error 0-1{{extension}} - [e({1, 2})] {} (); // expected-error {{parenthesized initializer list}} expected-error 0-1{{extension}} -#endif - } -#endif -} - -namespace dr1347 { // dr1347: yes - auto x = 5, *y = &x; // expected-error 0-1{{extension}} - auto z = y, *q = y; // expected-error {{'auto' deduced as 'int *' in declaration of 'z' and deduced as 'int' in declaration of 'q'}} expected-error 0-1{{extension}} -#if __cplusplus >= 201103L - auto a = 5, b = {1, 2}; // expected-error {{'auto' deduced as 'int' in declaration of 'a' and deduced as 'std::initializer_list<int>' in declaration of 'b'}} - auto (*fp)(int) -> int, i = 0; // expected-error {{declaration with trailing return type must be the only declaration in its group}} -#endif -} - -namespace dr1359 { // dr1359: 3.5 -#if __cplusplus >= 201103L - union A { constexpr A() = default; }; - union B { constexpr B() = default; int a; }; // expected-error {{not constexpr}} expected-note 2{{candidate}} - union C { constexpr C() = default; int a, b; }; // expected-error {{not constexpr}} expected-note 2{{candidate}} - struct X { constexpr X() = default; union {}; }; - struct Y { constexpr Y() = default; union { int a; }; }; // expected-error {{not constexpr}} expected-note 2{{candidate}} - - constexpr A a = A(); - constexpr B b = B(); // expected-error {{no matching}} - constexpr C c = C(); // expected-error {{no matching}} - constexpr X x = X(); - constexpr Y y = Y(); // expected-error {{no matching}} -#endif -} - -namespace dr1388 { // dr1388: 4 - template<typename A, typename ...T> void f(T..., A); // expected-note 1+{{candidate}} expected-error 0-1{{C++11}} - template<typename ...T> void g(T..., int); // expected-note 1+{{candidate}} expected-error 0-1{{C++11}} - template<typename ...T, typename A> void h(T..., A); // expected-note 1+{{candidate}} expected-error 0-1{{C++11}} - - void test_f() { - f(0); // ok, trailing parameter pack deduced to empty - f(0, 0); // expected-error {{no matching}} - f<int>(0); - f<int>(0, 0); // expected-error {{no matching}} - f<int, int>(0, 0); - f<int, int, int>(0, 0); // expected-error {{no matching}} - - g(0); - g(0, 0); // expected-error {{no matching}} - g<>(0); - g<int>(0); // expected-error {{no matching}} - g<int>(0, 0); - - h(0); - h(0, 0); // expected-error {{no matching}} - h<int>(0, 0); - h<int, int>(0, 0); // expected-error {{no matching}} - } - - // A non-trailing parameter pack is still a non-deduced context, even though - // we know exactly how many arguments correspond to it. - template<typename T, typename U> struct pair {}; - template<typename ...T> struct tuple { typedef char type; }; // expected-error 0-2{{C++11}} - template<typename ...T, typename ...U> void f_pair_1(pair<T, U>..., int); // expected-error 0-2{{C++11}} expected-note {{different lengths (2 vs. 0)}} - template<typename ...T, typename U> void f_pair_2(pair<T, char>..., U); // expected-error 0-2{{C++11}} - template<typename ...T, typename ...U> void f_pair_3(pair<T, U>..., tuple<U...>); // expected-error 0-2{{C++11}} expected-note {{different lengths (2 vs. 1)}} - template<typename ...T> void f_pair_4(pair<T, char>..., T...); // expected-error 0-2{{C++11}} expected-note {{<int, long> vs. <int, long, const char *>}} - void g(pair<int, char> a, pair<long, char> b, tuple<char, char> c) { - f_pair_1<int, long>(a, b, 0); // expected-error {{no match}} - f_pair_2<int, long>(a, b, 0); - f_pair_3<int, long>(a, b, c); - f_pair_3<int, long>(a, b, tuple<char>()); // expected-error {{no match}} - f_pair_4<int, long>(a, b, 0, 0L); - f_pair_4<int, long>(a, b, 0, 0L, "foo"); // expected-error {{no match}} - } -} - -namespace dr1391 { // dr1391: partial - struct A {}; struct B : A {}; - template<typename T> struct C { C(int); typename T::error error; }; // expected-error 2{{'::'}} - template<typename T> struct D {}; - - // No deduction is performed for parameters with no deducible template-parameters, therefore types do not need to match. - template<typename T> void a(T, int T::*); - void test_a(int A::*p) { a(A(), p); } // ok, type of second parameter does not need to match - - namespace dr_example_1 { - template<typename T, typename U> void f(C<T>); - template<typename T> void f(D<T>); - - void g(D<int> d) { - f(d); // ok, first 'f' eliminated by deduction failure - f<int>(d); // ok, first 'f' eliminated because 'U' cannot be deduced - } - } - - namespace dr_example_2 { - template<typename T> typename C<T>::error f(int, T); - template<typename T> T f(T, T); - - void g(A a) { - f(a, a); // ok, no conversion from A to int for first parameter of first candidate - } - } - - namespace std_example { - template<typename T> struct Z { - typedef typename T::x xx; - }; - template<typename T> typename Z<T>::xx f(void *, T); - template<typename T> void f(int, T); - struct A {} a; - void g() { f(1, a); } - } - - template<typename T> void b(C<int> ci, T *p); - void b(...); - void test_b() { - b(0, 0); // ok, deduction fails prior to forming a conversion sequence and instantiating C<int> - // FIXME: The "while substituting" note should point at the overload candidate. - b<int>(0, 0); // expected-note {{instantiation of}} expected-note {{while substituting}} - } - - template<typename T> struct Id { typedef T type; }; - template<typename T> void c(T, typename Id<C<T> >::type); - void test_c() { - // Implicit conversion sequences for dependent types are checked later. - c(0.0, 0); // expected-note {{instantiation of}} - } - - namespace partial_ordering { - // FIXME: Second template should be considered more specialized because non-dependent parameter is ignored. - template<typename T> int a(T, short) = delete; // expected-error 0-1{{extension}} expected-note {{candidate}} - template<typename T> int a(T*, char); // expected-note {{candidate}} - int test_a = a((int*)0, 0); // FIXME: expected-error {{ambiguous}} - - // FIXME: Second template should be considered more specialized: - // deducing #1 from #2 ignores the second P/A pair, so deduction succeeds, - // deducing #2 from #1 fails to deduce T, so deduction fails. - template<typename T> int b(T, int) = delete; // expected-error 0-1{{extension}} expected-note {{candidate}} - template<typename T, typename U> int b(T*, U); // expected-note {{candidate}} - int test_b = b((int*)0, 0); // FIXME: expected-error {{ambiguous}} - - // Unintended consequences: because partial ordering does not consider - // explicit template arguments, and deduction from a non-dependent type - // vacuously succeeds, a non-dependent template is less specialized than - // anything else! - // According to DR1391, this is ambiguous! - template<typename T> int c(int); - template<typename T> int c(T); - int test_c1 = c(0); // ok - int test_c2 = c<int>(0); // FIXME: apparently ambiguous - } -} - -namespace dr1399 { // dr1399: dup 1388 - template<typename ...T> void f(T..., int, T...) {} // expected-note {{candidate}} expected-error 0-1{{C++11}} - void g() { - f(0); - f<int>(0, 0, 0); - f(0, 0, 0); // expected-error {{no match}} - } -} diff --git a/test/CXX/drs/dr14xx.cpp b/test/CXX/drs/dr14xx.cpp deleted file mode 100644 index eb5ba3db448e..000000000000 --- a/test/CXX/drs/dr14xx.cpp +++ /dev/null @@ -1,375 +0,0 @@ -// RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++1z %s -verify -fexceptions -fcxx-exceptions -pedantic-errors - -#if __cplusplus < 201103L -// expected-no-diagnostics -#endif - -// dr1425: na abi - -namespace dr1460 { // dr1460: 3.5 -#if __cplusplus >= 201103L - namespace DRExample { - union A { - union {}; - union {}; - constexpr A() {} - }; - constexpr A a = A(); - - union B { - union {}; - union {}; - constexpr B() = default; - }; - constexpr B b = B(); - - union C { - union {}; - union {}; - }; - constexpr C c = C(); -#if __cplusplus > 201103L - constexpr void f() { C c; } - static_assert((f(), true), ""); -#endif - } - - union A {}; - union B { int n; }; // expected-note +{{here}} - union C { int n = 0; }; - struct D { union {}; }; - struct E { union { int n; }; }; // expected-note +{{here}} - struct F { union { int n = 0; }; }; - - struct X { - friend constexpr A::A() noexcept; - friend constexpr B::B() noexcept; // expected-error {{follows non-constexpr declaration}} - friend constexpr C::C() noexcept; - friend constexpr D::D() noexcept; - friend constexpr E::E() noexcept; // expected-error {{follows non-constexpr declaration}} - friend constexpr F::F() noexcept; - }; - - // These are OK, because value-initialization doesn't actually invoke the - // constructor. - constexpr A a = A(); - constexpr B b = B(); - constexpr C c = C(); - constexpr D d = D(); - constexpr E e = E(); - constexpr F f = F(); - - namespace Defaulted { - union A { constexpr A() = default; }; - union B { int n; constexpr B() = default; }; // expected-error {{not constexpr}} - union C { int n = 0; constexpr C() = default; }; - struct D { union {}; constexpr D() = default; }; - struct E { union { int n; }; constexpr E() = default; }; // expected-error {{not constexpr}} - struct F { union { int n = 0; }; constexpr F() = default; }; - - struct G { union { int n = 0; }; union { int m; }; constexpr G() = default; }; // expected-error {{not constexpr}} - struct H { - union { - int n = 0; - }; - union { // expected-note 2{{member not initialized}} - int m; - }; - constexpr H() {} // expected-error {{must initialize all members}} - constexpr H(bool) : m(1) {} - constexpr H(char) : n(1) {} // expected-error {{must initialize all members}} - constexpr H(double) : m(1), n(1) {} - }; - } - -#if __cplusplus > 201103L - template<typename T> constexpr bool check() { - T t; // expected-note-re 2{{non-constexpr constructor '{{[BE]}}'}} - return true; - } - static_assert(check<A>(), ""); - static_assert(check<B>(), ""); // expected-error {{constant}} expected-note {{in call}} - static_assert(check<C>(), ""); - static_assert(check<D>(), ""); - static_assert(check<E>(), ""); // expected-error {{constant}} expected-note {{in call}} - static_assert(check<F>(), ""); -#endif - - union G { - int a = 0; // expected-note {{previous initialization is here}} - int b = 0; // expected-error {{initializing multiple members of union}} - }; - union H { - union { - int a = 0; // expected-note {{previous initialization is here}} - }; - union { - int b = 0; // expected-error {{initializing multiple members of union}} - }; - }; - struct I { - union { - int a = 0; // expected-note {{previous initialization is here}} - int b = 0; // expected-error {{initializing multiple members of union}} - }; - }; - struct J { - union { int a = 0; }; - union { int b = 0; }; - }; - - namespace Overriding { - struct A { - int a = 1, b, c = 3; - constexpr A() : b(2) {} - }; - static_assert(A().a == 1 && A().b == 2 && A().c == 3, ""); - - union B { - int a, b = 2, c; - constexpr B() : a(1) {} - constexpr B(char) : b(4) {} - constexpr B(int) : c(3) {} - constexpr B(const char*) {} - }; - static_assert(B().a == 1, ""); - static_assert(B().b == 2, ""); // expected-error {{constant}} expected-note {{read of}} - static_assert(B('x').a == 0, ""); // expected-error {{constant}} expected-note {{read of}} - static_assert(B('x').b == 4, ""); - static_assert(B(123).b == 2, ""); // expected-error {{constant}} expected-note {{read of}} - static_assert(B(123).c == 3, ""); - static_assert(B("").a == 1, ""); // expected-error {{constant}} expected-note {{read of}} - static_assert(B("").b == 2, ""); - static_assert(B("").c == 3, ""); // expected-error {{constant}} expected-note {{read of}} - - struct C { - union { int a, b = 2, c; }; - union { int d, e = 5, f; }; - constexpr C() : a(1) {} - constexpr C(char) : c(3) {} - constexpr C(int) : d(4) {} - constexpr C(float) : f(6) {} - constexpr C(const char*) {} - }; - - static_assert(C().a == 1, ""); - static_assert(C().b == 2, ""); // expected-error {{constant}} expected-note {{read of}} - static_assert(C().d == 4, ""); // expected-error {{constant}} expected-note {{read of}} - static_assert(C().e == 5, ""); - - static_assert(C('x').b == 2, ""); // expected-error {{constant}} expected-note {{read of}} - static_assert(C('x').c == 3, ""); - static_assert(C('x').d == 4, ""); // expected-error {{constant}} expected-note {{read of}} - static_assert(C('x').e == 5, ""); - - static_assert(C(1).b == 2, ""); - static_assert(C(1).c == 3, ""); // expected-error {{constant}} expected-note {{read of}} - static_assert(C(1).d == 4, ""); - static_assert(C(1).e == 5, ""); // expected-error {{constant}} expected-note {{read of}} - - static_assert(C(1.f).b == 2, ""); - static_assert(C(1.f).c == 3, ""); // expected-error {{constant}} expected-note {{read of}} - static_assert(C(1.f).e == 5, ""); // expected-error {{constant}} expected-note {{read of}} - static_assert(C(1.f).f == 6, ""); - - static_assert(C("").a == 1, ""); // expected-error {{constant}} expected-note {{read of}} - static_assert(C("").b == 2, ""); - static_assert(C("").c == 3, ""); // expected-error {{constant}} expected-note {{read of}} - static_assert(C("").d == 4, ""); // expected-error {{constant}} expected-note {{read of}} - static_assert(C("").e == 5, ""); - static_assert(C("").f == 6, ""); // expected-error {{constant}} expected-note {{read of}} - - struct D; - extern const D d; - struct D { - int a; - union { - int b = const_cast<D&>(d).a = 1; // not evaluated - int c; - }; - constexpr D() : a(0), c(0) {} - }; - constexpr D d {}; - static_assert(d.a == 0, ""); - } -#endif -} - -#if __cplusplus >= 201103L -namespace std { - typedef decltype(sizeof(int)) size_t; - - // libc++'s implementation - template <class _E> - class initializer_list - { - const _E* __begin_; - size_t __size_; - - initializer_list(const _E* __b, size_t __s) - : __begin_(__b), __size_(__s) {} - - public: - typedef _E value_type; - typedef const _E& reference; - typedef const _E& const_reference; - typedef size_t size_type; - - typedef const _E* iterator; - typedef const _E* const_iterator; - - initializer_list() : __begin_(nullptr), __size_(0) {} - - size_t size() const {return __size_;} - const _E* begin() const {return __begin_;} - const _E* end() const {return __begin_ + __size_;} - }; -} // std - -namespace dr1467 { // dr1467: 3.7 c++11 - // List-initialization of aggregate from same-type object - - namespace basic0 { - struct S { - int i = 42; - }; - - S a; - S b(a); - S c{a}; - - struct SS : public S { } x; - S y(x); - S z{x}; - } // basic0 - - namespace basic1 { - struct S { - int i{42}; - }; - - S a; - S b(a); - S c{a}; - - struct SS : public S { } x; - S y(x); - S z{x}; - } // basic1 - - namespace basic2 { - struct S { - int i = {42}; - }; - - S a; - S b(a); - S c{a}; - - struct SS : public S { } x; - S y(x); - S z{x}; - } // basic2 - - namespace dr_example { - struct OK { - OK() = default; - OK(const OK&) = default; - OK(int) { } - }; - - OK ok; - OK ok2{ok}; - - struct X { - X() = default; - X(const X&) = default; - }; - - X x; - X x2{x}; - } // dr_example - - namespace nonaggregate { - struct NonAggregate { - NonAggregate() {} - }; - - struct WantsIt { - WantsIt(NonAggregate); - }; - - void f(NonAggregate); - void f(WantsIt); - - void test1() { - NonAggregate n; - f({n}); - } - - void test2() { - NonAggregate x; - NonAggregate y{x}; - NonAggregate z{{x}}; - } - } // nonaggregate - - namespace SelfInitIsNotListInit { - struct S { - S(); - explicit S(S &); - S(const S &); - }; - S s1; - S s2 = {s1}; // ok, not list-initialization so we pick the non-explicit constructor - } - - struct NestedInit { int a, b, c; }; - NestedInit ni[1] = {{NestedInit{1, 2, 3}}}; - - namespace NestedInit2 { - struct Pair { int a, b; }; - struct TwoPairs { TwoPairs(Pair, Pair); }; - struct Value { Value(Pair); Value(TwoPairs); }; - void f() { Value{{{1,2},{3,4}}}; } - } -} // dr1467 - -namespace dr1490 { // dr1490: 3.7 c++11 - // List-initialization from a string literal - - char s[4]{"abc"}; // Ok - std::initializer_list<char>{"abc"}; // expected-error {{expected unqualified-id}}} -} // dr190 - -namespace dr1495 { // dr1495: 4 - // Deduction succeeds in both directions. - template<typename T, typename U> struct A {}; // expected-note {{template is declared here}} - template<typename T, typename U> struct A<U, T> {}; // expected-error {{class template partial specialization is not more specialized}} - - // Primary template is more specialized. - template<typename, typename...> struct B {}; // expected-note {{template is declared here}} - template<typename ...Ts> struct B<Ts...> {}; // expected-error {{not more specialized}} - - // Deduction fails in both directions. - template<int, typename, typename ...> struct C {}; // expected-note {{template is declared here}} - template<typename ...Ts> struct C<0, Ts...> {}; // expected-error {{not more specialized}} - -#if __cplusplus >= 201402L - // Deduction succeeds in both directions. - template<typename T, typename U> int a; // expected-note {{template is declared here}} - template<typename T, typename U> int a<U, T>; // expected-error {{variable template partial specialization is not more specialized}} - - // Primary template is more specialized. - template<typename, typename...> int b; // expected-note {{template is declared here}} - template<typename ...Ts> int b<Ts...>; // expected-error {{not more specialized}} - - // Deduction fails in both directions. - template<int, typename, typename ...> int c; // expected-note {{template is declared here}} - template<typename ...Ts> int c<0, Ts...>; // expected-error {{not more specialized}} -#endif -} -#endif diff --git a/test/CXX/drs/dr158.cpp b/test/CXX/drs/dr158.cpp deleted file mode 100644 index 33f837ca0627..000000000000 --- a/test/CXX/drs/dr158.cpp +++ /dev/null @@ -1,27 +0,0 @@ -// RUN: %clang_cc1 -triple x86_64-linux -std=c++98 %s -O3 -disable-llvm-passes -pedantic-errors -emit-llvm -o - | FileCheck %s -// RUN: %clang_cc1 -triple x86_64-linux -std=c++11 %s -O3 -disable-llvm-passes -pedantic-errors -emit-llvm -o - | FileCheck %s -// RUN: %clang_cc1 -triple x86_64-linux -std=c++14 %s -O3 -disable-llvm-passes -pedantic-errors -emit-llvm -o - | FileCheck %s -// RUN: %clang_cc1 -triple x86_64-linux -std=c++1z %s -O3 -disable-llvm-passes -pedantic-errors -emit-llvm -o - | FileCheck %s - -// dr158: yes - -// CHECK-LABEL: define {{.*}} @_Z1f -const int *f(const int * const *p, int **q) { - // CHECK: load i32**, {{.*}}, !tbaa ![[INTPTR_TBAA:[^,]*]] - const int *x = *p; - // CHECK: store i32* null, {{.*}}, !tbaa ![[INTPTR_TBAA]] - *q = 0; - return x; -} - -struct A {}; - -// CHECK-LABEL: define {{.*}} @_Z1g -const int *(A::*const *g(const int *(A::* const **p)[3], int *(A::***q)[3]))[3] { - // CHECK: load i64**, {{.*}}, !tbaa ![[MEMPTR_TBAA:[^,]*]] - const int *(A::*const *x)[3] = *p; - // CHECK: store i64* null, {{.*}}, !tbaa ![[MEMPTR_TBAA]] - *q = 0; - return x; -} - diff --git a/test/CXX/drs/dr15xx.cpp b/test/CXX/drs/dr15xx.cpp deleted file mode 100644 index cca4509fa0c1..000000000000 --- a/test/CXX/drs/dr15xx.cpp +++ /dev/null @@ -1,483 +0,0 @@ -// RUN: %clang_cc1 -std=c++98 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++1z -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors - -namespace dr1512 { // dr1512: 4 - void f(char *p) { - if (p > 0) {} // expected-error {{ordered comparison between pointer and zero}} -#if __cplusplus >= 201103L - if (p > nullptr) {} // expected-error {{invalid operands}} -#endif - } - bool g(int **x, const int **y) { - return x < y; - } - - template<typename T> T val(); - - template<typename A, typename B, typename C> void composite_pointer_type_is_base() { - typedef __typeof(true ? val<A>() : val<B>()) type; - typedef C type; - - typedef __typeof(val<A>() == val<B>()) cmp; - typedef __typeof(val<A>() != val<B>()) cmp; - typedef bool cmp; - } - - template<typename A, typename B, typename C> void composite_pointer_type_is_ord() { - composite_pointer_type_is_base<A, B, C>(); - - typedef __typeof(val<A>() < val<B>()) cmp; - typedef __typeof(val<A>() <= val<B>()) cmp; - typedef __typeof(val<A>() > val<B>()) cmp; - typedef __typeof(val<A>() >= val<B>()) cmp; - typedef bool cmp; - } - - template <typename A, typename B, typename C> - void composite_pointer_type_is_unord(int = 0) { - composite_pointer_type_is_base<A, B, C>(); - } - template <typename A, typename B, typename C> - void composite_pointer_type_is_unord(__typeof(val<A>() < val<B>()) * = 0); - template <typename A, typename B, typename C> - void composite_pointer_type_is_unord(__typeof(val<A>() <= val<B>()) * = 0); - template <typename A, typename B, typename C> - void composite_pointer_type_is_unord(__typeof(val<A>() > val<B>()) * = 0); - template <typename A, typename B, typename C> - void composite_pointer_type_is_unord(__typeof(val<A>() >= val<B>()) * = 0); - - // A call to this is ambiguous if a composite pointer type exists. - template<typename A, typename B> - void no_composite_pointer_type(__typeof((true ? val<A>() : val<B>()), void()) * = 0); - template<typename A, typename B> void no_composite_pointer_type(int = 0); - - struct A {}; - struct B : A {}; - struct C {}; - - void test() { -#if __cplusplus >= 201103L - using nullptr_t = decltype(nullptr); - composite_pointer_type_is_unord<nullptr_t, nullptr_t, nullptr_t>(); - no_composite_pointer_type<nullptr_t, int>(); - - composite_pointer_type_is_unord<nullptr_t, const char**, const char**>(); - composite_pointer_type_is_unord<const char**, nullptr_t, const char**>(); -#endif - - composite_pointer_type_is_ord<const int *, volatile void *, const volatile void*>(); - composite_pointer_type_is_ord<const void *, volatile int *, const volatile void*>(); - - composite_pointer_type_is_ord<const A*, volatile B*, const volatile A*>(); - composite_pointer_type_is_ord<const B*, volatile A*, const volatile A*>(); - - composite_pointer_type_is_unord<const int *A::*, volatile int *B::*, const volatile int *const B::*>(); - composite_pointer_type_is_unord<const int *B::*, volatile int *A::*, const volatile int *const B::*>(); - no_composite_pointer_type<int (A::*)(), int (C::*)()>(); - no_composite_pointer_type<const int (A::*)(), volatile int (C::*)()>(); - -#if __cplusplus > 201402 - composite_pointer_type_is_ord<int (*)() noexcept, int (*)(), int (*)()>(); - composite_pointer_type_is_ord<int (*)(), int (*)() noexcept, int (*)()>(); - composite_pointer_type_is_unord<int (A::*)() noexcept, int (A::*)(), int (A::*)()>(); - composite_pointer_type_is_unord<int (A::*)(), int (A::*)() noexcept, int (A::*)()>(); - // FIXME: This looks like a standard defect; these should probably all have type 'int (B::*)()'. - composite_pointer_type_is_unord<int (B::*)(), int (A::*)() noexcept, int (B::*)()>(); - composite_pointer_type_is_unord<int (A::*)() noexcept, int (B::*)(), int (B::*)()>(); - composite_pointer_type_is_unord<int (B::*)() noexcept, int (A::*)(), int (B::*)()>(); - composite_pointer_type_is_unord<int (A::*)(), int (B::*)() noexcept, int (B::*)()>(); - - // FIXME: It would be reasonable to permit these, with a common type of 'int (*const *)()'. - no_composite_pointer_type<int (**)() noexcept, int (**)()>(); - no_composite_pointer_type<int (**)(), int (**)() noexcept>(); - - // FIXME: It would be reasonable to permit these, with a common type of 'int (A::*)()'. - no_composite_pointer_type<int (A::*)() const, int (A::*)()>(); - no_composite_pointer_type<int (A::*)(), int (A::*)() const>(); - - // FIXME: It would be reasonable to permit these, with a common type of - // 'int (A::*)() &' and 'int (A::*)() &&', respectively. - no_composite_pointer_type<int (A::*)() &, int (A::*)()>(); - no_composite_pointer_type<int (A::*)(), int (A::*)() &>(); - no_composite_pointer_type<int (A::*)() &&, int (A::*)()>(); - no_composite_pointer_type<int (A::*)(), int (A::*)() &&>(); - - no_composite_pointer_type<int (A::*)() &&, int (A::*)() &>(); - no_composite_pointer_type<int (A::*)() &, int (A::*)() &&>(); - - no_composite_pointer_type<int (C::*)(), int (A::*)() noexcept>(); - no_composite_pointer_type<int (A::*)() noexcept, int (C::*)()>(); -#endif - } - -#if __cplusplus >= 201103L - template<typename T> struct Wrap { operator T(); }; // expected-note 4{{converted to type 'nullptr_t'}} expected-note 4{{converted to type 'int *'}} - void test_overload() { - using nullptr_t = decltype(nullptr); - void(Wrap<nullptr_t>() == Wrap<nullptr_t>()); - void(Wrap<nullptr_t>() != Wrap<nullptr_t>()); - void(Wrap<nullptr_t>() < Wrap<nullptr_t>()); // expected-error {{invalid operands}} - void(Wrap<nullptr_t>() > Wrap<nullptr_t>()); // expected-error {{invalid operands}} - void(Wrap<nullptr_t>() <= Wrap<nullptr_t>()); // expected-error {{invalid operands}} - void(Wrap<nullptr_t>() >= Wrap<nullptr_t>()); // expected-error {{invalid operands}} - - // Under dr1213, this is ill-formed: we select the builtin operator<(int*, int*) - // but then only convert as far as 'nullptr_t', which we then can't convert to 'int*'. - void(Wrap<nullptr_t>() == Wrap<int*>()); - void(Wrap<nullptr_t>() != Wrap<int*>()); - void(Wrap<nullptr_t>() < Wrap<int*>()); // expected-error {{invalid operands to binary expression ('Wrap<nullptr_t>' and 'Wrap<int *>')}} - void(Wrap<nullptr_t>() > Wrap<int*>()); // expected-error {{invalid operands}} - void(Wrap<nullptr_t>() <= Wrap<int*>()); // expected-error {{invalid operands}} - void(Wrap<nullptr_t>() >= Wrap<int*>()); // expected-error {{invalid operands}} - } -#endif -} - -namespace dr1518 { // dr1518: 4 -#if __cplusplus >= 201103L -struct Z0 { // expected-note 0+ {{candidate}} - explicit Z0() = default; // expected-note 0+ {{here}} -}; -struct Z { // expected-note 0+ {{candidate}} - explicit Z(); // expected-note 0+ {{here}} - explicit Z(int); - explicit Z(int, int); // expected-note 0+ {{here}} -}; -template <class T> int Eat(T); // expected-note 0+ {{candidate}} -Z0 a; -Z0 b{}; -Z0 c = {}; // expected-error {{explicit in copy-initialization}} -int i = Eat<Z0>({}); // expected-error {{no matching function for call to 'Eat'}} - -Z c2 = {}; // expected-error {{explicit in copy-initialization}} -int i2 = Eat<Z>({}); // expected-error {{no matching function for call to 'Eat'}} -Z a1 = 1; // expected-error {{no viable conversion}} -Z a3 = Z(1); -Z a2(1); -Z *p = new Z(1); -Z a4 = (Z)1; -Z a5 = static_cast<Z>(1); -Z a6 = {4, 3}; // expected-error {{explicit in copy-initialization}} - -struct UserProvidedBaseCtor { // expected-note 0+ {{candidate}} - UserProvidedBaseCtor() {} -}; -struct DoesntInheritCtor : UserProvidedBaseCtor { // expected-note 0+ {{candidate}} - int x; -}; -DoesntInheritCtor I{{}, 42}; -#if __cplusplus <= 201402L -// expected-error@-2 {{no matching constructor}} -#endif - -struct BaseCtor { BaseCtor() = default; }; // expected-note 0+ {{candidate}} -struct InheritsCtor : BaseCtor { // expected-note 1+ {{candidate}} - using BaseCtor::BaseCtor; // expected-note 2 {{inherited here}} - int x; -}; -InheritsCtor II = {{}, 42}; // expected-error {{no matching constructor}} - -namespace std_example { - struct A { - explicit A() = default; // expected-note 2{{declared here}} - }; - - struct B : A { - explicit B() = default; // expected-note 2{{declared here}} - }; - - struct C { - explicit C(); // expected-note 2{{declared here}} - }; - - struct D : A { - C c; - explicit D() = default; // expected-note 2{{declared here}} - }; - - template <typename T> void f() { - T t; // ok - T u{}; // ok - T v = {}; // expected-error 4{{explicit}} - } - template <typename T> void g() { - void x(T t); // expected-note 4{{parameter}} - x({}); // expected-error 4{{explicit}} - } - - void test() { - f<A>(); // expected-note {{instantiation of}} - f<B>(); // expected-note {{instantiation of}} - f<C>(); // expected-note {{instantiation of}} - f<D>(); // expected-note {{instantiation of}} - g<A>(); // expected-note {{instantiation of}} - g<B>(); // expected-note {{instantiation of}} - g<C>(); // expected-note {{instantiation of}} - g<D>(); // expected-note {{instantiation of}} - } -} -#endif // __cplusplus >= 201103L -} - -namespace dr1550 { // dr1550: yes - int f(bool b, int n) { - return (b ? (throw 0) : n) + (b ? n : (throw 0)); - } -} - -namespace dr1560 { // dr1560: 3.5 - void f(bool b, int n) { - (b ? throw 0 : n) = (b ? n : throw 0) = 0; - } - class X { X(const X&); }; - const X &get(); - const X &x = true ? get() : throw 0; -} - -namespace dr1573 { // dr1573: 3.9 -#if __cplusplus >= 201103L - // ellipsis is inherited (p0136r1 supersedes this part). - struct A { A(); A(int, char, ...); }; - struct B : A { using A::A; }; - B b(1, 'x', 4.0, "hello"); // ok - - // inherited constructor is effectively constexpr if the user-written constructor would be - struct C { C(); constexpr C(int) {} }; - struct D : C { using C::C; }; - constexpr D d = D(0); // ok - struct E : C { using C::C; A a; }; // expected-note {{non-literal type}} - constexpr E e = E(0); // expected-error {{non-literal type}} - // FIXME: This diagnostic is pretty bad; we should explain that the problem - // is that F::c would be initialized by a non-constexpr constructor. - struct F : C { using C::C; C c; }; // expected-note {{here}} - constexpr F f = F(0); // expected-error {{constant expression}} expected-note {{constructor inherited from base class 'C'}} - - // inherited constructor is effectively deleted if the user-written constructor would be - struct G { G(int); }; - struct H : G { using G::G; G g; }; // expected-note {{constructor inherited by 'H' is implicitly deleted because field 'g' has no default constructor}} - H h(0); // expected-error {{constructor inherited by 'H' from base class 'G' is implicitly deleted}} -#endif -} - -#if __cplusplus >= 201103L -namespace std { - typedef decltype(sizeof(int)) size_t; - - // libc++'s implementation - template <class _E> - class initializer_list - { - const _E* __begin_; - size_t __size_; - - initializer_list(const _E* __b, size_t __s) - : __begin_(__b), __size_(__s) {} - - public: - typedef _E value_type; - typedef const _E& reference; - typedef const _E& const_reference; - typedef size_t size_type; - - typedef const _E* iterator; - typedef const _E* const_iterator; - - initializer_list() : __begin_(nullptr), __size_(0) {} - - size_t size() const {return __size_;} - const _E* begin() const {return __begin_;} - const _E* end() const {return __begin_ + __size_;} - }; - - template < class _T1, class _T2 > struct pair { _T2 second; }; - - template<typename T> struct basic_string { - basic_string(const T* x) {} - ~basic_string() {}; - }; - typedef basic_string<char> string; - -} // std - -namespace dr1579 { // dr1579: 3.9 -template<class T> -struct GenericMoveOnly { - GenericMoveOnly(); - template<class U> GenericMoveOnly(const GenericMoveOnly<U> &) = delete; // expected-note 5 {{marked deleted here}} - GenericMoveOnly(const int &) = delete; // expected-note 2 {{marked deleted here}} - template<class U> GenericMoveOnly(GenericMoveOnly<U> &&); - GenericMoveOnly(int &&); -}; - -GenericMoveOnly<float> DR1579_Eligible(GenericMoveOnly<char> CharMO) { - int i; - GenericMoveOnly<char> GMO; - - if (0) - return i; - else if (0) - return GMO; - else if (0) - return ((GMO)); - else - return CharMO; -} - -GenericMoveOnly<char> GlobalMO; - -GenericMoveOnly<float> DR1579_Ineligible(int &AnInt, - GenericMoveOnly<char> &CharMO) { - static GenericMoveOnly<char> StaticMove; - extern GenericMoveOnly<char> ExternMove; - - if (0) - return AnInt; // expected-error{{invokes a deleted function}} - else if (0) - return GlobalMO; // expected-error{{invokes a deleted function}} - else if (0) - return StaticMove; // expected-error{{invokes a deleted function}} - else if (0) - return ExternMove; // expected-error{{invokes a deleted function}} - else if (0) - return AnInt; // expected-error{{invokes a deleted function}} - else - return CharMO; // expected-error{{invokes a deleted function}} -} - -auto DR1579_lambda_valid = [](GenericMoveOnly<float> mo) -> - GenericMoveOnly<char> { - return mo; -}; - -auto DR1579_lambda_invalid = []() -> GenericMoveOnly<char> { - static GenericMoveOnly<float> mo; - return mo; // expected-error{{invokes a deleted function}} -}; -} // end namespace dr1579 - -namespace dr1584 { - // Deducing function types from cv-qualified types - template<typename T> void f(const T *); // expected-note {{candidate template ignored}} - template<typename T> void g(T *, const T * = 0); - template<typename T> void h(T *) { T::error; } // expected-error {{no members}} - template<typename T> void h(const T *); - void i() { - f(&i); // expected-error {{no matching function}} - g(&i); - h(&i); // expected-note {{here}} - } -} - -namespace dr1589 { // dr1589: 3.7 c++11 - // Ambiguous ranking of list-initialization sequences - - void f0(long, int=0); // Would makes selection of #0 ambiguous - void f0(long); // #0 - void f0(std::initializer_list<int>); // #00 - void g0() { f0({1L}); } // chooses #00 - - void f1(int, int=0); // Would make selection of #1 ambiguous - void f1(int); // #1 - void f1(std::initializer_list<long>); // #2 - void g1() { f1({42}); } // chooses #2 - - void f2(std::pair<const char*, const char*>, int = 0); // Would makes selection of #3 ambiguous - void f2(std::pair<const char*, const char*>); // #3 - void f2(std::initializer_list<std::string>); // #4 - void g2() { f2({"foo","bar"}); } // chooses #4 - - namespace with_error { - void f0(long); // #0 expected-note {{candidate function}} - void f0(std::initializer_list<int>); // #00 expected-note {{candidate function}} - void f0(std::initializer_list<int>, int = 0); // Makes selection of #00 ambiguous \ - // expected-note {{candidate function}} - void g0() { f0({1L}); } // chooses #00 expected-error{{call to 'f0' is ambiguous}} - - void f1(int); // #1 expected-note {{candidate function}} - void f1(std::initializer_list<long>); // #2 expected-note {{candidate function}} - void f1(std::initializer_list<long>, int = 0); // Makes selection of #00 ambiguous \ - // expected-note {{candidate function}} - void g1() { f1({42}); } // chooses #2 expected-error{{call to 'f1' is ambiguous}} - - void f2(std::pair<const char*, const char*>); // #3 TODO: expected- note {{candidate function}} - void f2(std::initializer_list<std::string>); // #4 expected-note {{candidate function}} - void f2(std::initializer_list<std::string>, int = 0); // Makes selection of #00 ambiguous \ - // expected-note {{candidate function}} - void g2() { f2({"foo","bar"}); } // chooses #4 expected-error{{call to 'f2' is ambiguous}} - } - -} // dr1589 - -namespace dr1591 { //dr1591. Deducing array bound and element type from initializer list - template<class T, int N> int h(T const(&)[N]); - int X = h({1,2,3}); // T deduced to int, N deduced to 3 - - template<class T> int j(T const(&)[3]); - int Y = j({42}); // T deduced to int, array bound not considered - - struct Aggr { int i; int j; }; - template<int N> int k(Aggr const(&)[N]); //expected-note{{not viable}} - int Y0 = k({1,2,3}); //expected-error{{no matching function}} - int Z = k({{1},{2},{3}}); // OK, N deduced to 3 - - template<int M, int N> int m(int const(&)[M][N]); - int X0 = m({{1,2},{3,4}}); // M and N both deduced to 2 - - template<class T, int N> int n(T const(&)[N], T); - int X1 = n({{1},{2},{3}},Aggr()); // OK, T is Aggr, N is 3 - - - namespace check_multi_dim_arrays { - template<class T, int N, int M, int O> int ***f(const T (&a)[N][M][O]); //expected-note{{deduced conflicting values}} - template<class T, int N, int M> int **f(const T (&a)[N][M]); //expected-note{{couldn't infer}} - - template<class T, int N> int *f(const T (&a)[N]); //expected-note{{couldn't infer}} - int ***p3 = f({ { {1,2}, {3, 4} }, { {5,6}, {7, 8} }, { {9,10}, {11, 12} } }); - int ***p33 = f({ { {1,2}, {3, 4} }, { {5,6}, {7, 8} }, { {9,10}, {11, 12, 13} } }); //expected-error{{no matching}} - int **p2 = f({ {1,2,3}, {3, 4, 5} }); - int **p22 = f({ {1,2}, {3, 4} }); - int *p1 = f({1, 2, 3}); - } - namespace check_multi_dim_arrays_rref { - template<class T, int N, int M, int O> int ***f(T (&&a)[N][M][O]); //expected-note{{deduced conflicting values}} - template<class T, int N, int M> int **f(T (&&a)[N][M]); //expected-note{{couldn't infer}} - - template<class T, int N> int *f(T (&&a)[N]); //expected-note{{couldn't infer}} - int ***p3 = f({ { {1,2}, {3, 4} }, { {5,6}, {7, 8} }, { {9,10}, {11, 12} } }); - int ***p33 = f({ { {1,2}, {3, 4} }, { {5,6}, {7, 8} }, { {9,10}, {11, 12, 13} } }); //expected-error{{no matching}} - int **p2 = f({ {1,2,3}, {3, 4, 5} }); - int **p22 = f({ {1,2}, {3, 4} }); - int *p1 = f({1, 2, 3}); - } - - namespace check_arrays_of_init_list { - template<class T, int N> float *f(const std::initializer_list<T> (&)[N]); - template<class T, int N> double *f(const T(&)[N]); - double *p = f({1, 2, 3}); - float *fp = f({{1}, {1, 2}, {1, 2, 3}}); - } - namespace core_reflector_28543 { - - template<class T, int N> int *f(T (&&)[N]); // #1 - template<class T> char *f(std::initializer_list<T> &&); //#2 - template<class T, int N, int M> int **f(T (&&)[N][M]); //#3 expected-note{{candidate}} - template<class T, int N> char **f(std::initializer_list<T> (&&)[N]); //#4 expected-note{{candidate}} - - template<class T> short *f(T (&&)[2]); //#5 - - template<class T> using Arr = T[]; - - char *pc = f({1, 2, 3}); // OK prefer #2 via 13.3.3.2 [over.ics.rank] - char *pc2 = f({1, 2}); // #2 also - int *pi = f(Arr<int>{1, 2, 3}); // OK prefer #1 - - void *pv1 = f({ {1, 2, 3}, {4, 5, 6} }); // expected-error{{ambiguous}} btw 3 & 4 - char **pcc = f({ {1}, {2, 3} }); // OK #4 - - short *ps = f(Arr<int>{1, 2}); // OK #5 - } -} // dr1591 - -#endif diff --git a/test/CXX/drs/dr16xx.cpp b/test/CXX/drs/dr16xx.cpp deleted file mode 100644 index 4f2f06e0d020..000000000000 --- a/test/CXX/drs/dr16xx.cpp +++ /dev/null @@ -1,367 +0,0 @@ -// RUN: %clang_cc1 -std=c++98 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++2a -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors - -#if __cplusplus < 201103L -// expected-error@+1 {{variadic macro}} -#define static_assert(...) __extension__ _Static_assert(__VA_ARGS__) -#endif - -#if __cplusplus >= 201103L -namespace std { - typedef decltype(sizeof(int)) size_t; - - template<typename E> class initializer_list { - const E *begin; - size_t size; - - public: - initializer_list(); - }; -} // std -#endif - -namespace dr1611 { // dr1611: dup 1658 - struct A { A(int); }; - struct B : virtual A { virtual void f() = 0; }; - struct C : B { C() : A(0) {} void f(); }; - C c; -} - -namespace dr1684 { // dr1684: 3.6 -#if __cplusplus >= 201103L - struct NonLiteral { // expected-note {{because}} - NonLiteral(); - constexpr int f() { return 0; } // expected-warning 0-1{{will not be implicitly 'const'}} - }; - constexpr int f(NonLiteral &) { return 0; } - constexpr int f(NonLiteral) { return 0; } // expected-error {{not a literal type}} -#endif -} - -namespace dr1631 { // dr1631: 3.7 -#if __cplusplus >= 201103L - // Incorrect overload resolution for single-element initializer-list - - struct A { int a[1]; }; - struct B { B(int); }; - void f(B, int); - void f(B, int, int = 0); - void f(int, A); - - void test() { - f({0}, {{1}}); // expected-warning {{braces around scalar init}} - } - - namespace with_error { - void f(B, int); // TODO: expected- note {{candidate function}} - void f(int, A); // expected-note {{candidate function}} - void f(int, A, int = 0); // expected-note {{candidate function}} - - void test() { - f({0}, {{1}}); // expected-error{{call to 'f' is ambiguous}} - } - } -#endif -} - -namespace dr1638 { // dr1638: yes -#if __cplusplus >= 201103L - template<typename T> struct A { - enum class E; // expected-note {{previous}} - enum class F : T; // expected-note 2{{previous}} - }; - - template<> enum class A<int>::E; - template<> enum class A<int>::E {}; - template<> enum class A<int>::F : int; - template<> enum class A<int>::F : int {}; - - template<> enum class A<short>::E : int; - template<> enum class A<short>::E : int {}; - - template<> enum class A<short>::F; // expected-error {{different underlying type}} - template<> enum class A<char>::E : char; // expected-error {{different underlying type}} - template<> enum class A<char>::F : int; // expected-error {{different underlying type}} - - enum class A<unsigned>::E; // expected-error {{template specialization requires 'template<>'}} expected-error {{nested name specifier}} - template enum class A<unsigned>::E; // expected-error {{enumerations cannot be explicitly instantiated}} - enum class A<unsigned>::E *e; // expected-error {{must use 'enum' not 'enum class'}} - - struct B { - friend enum class A<unsigned>::E; // expected-error {{must use 'enum' not 'enum class'}} - }; -#endif -} - -namespace dr1645 { // dr1645: 3.9 -#if __cplusplus >= 201103L - struct A { - constexpr A(int, float = 0); // expected-note 2{{candidate}} - explicit A(int, int = 0); // expected-note 2{{candidate}} - A(int, int, int = 0) = delete; // expected-note {{candidate}} - }; - - struct B : A { // expected-note 2{{candidate}} - using A::A; // expected-note 5{{inherited here}} - }; - - constexpr B a(0); // expected-error {{ambiguous}} - constexpr B b(0, 0); // expected-error {{ambiguous}} -#endif -} - -namespace dr1653 { // dr1653: 4 c++17 - void f(bool b) { - ++b; - b++; -#if __cplusplus <= 201402L - // expected-warning@-3 {{deprecated}} expected-warning@-2 {{deprecated}} -#else - // expected-error@-5 {{incrementing expression of type bool}} expected-error@-4 {{incrementing expression of type bool}} -#endif - --b; // expected-error {{cannot decrement expression of type bool}} - b--; // expected-error {{cannot decrement expression of type bool}} - b += 1; // ok - b -= 1; // ok - } -} - -namespace dr1658 { // dr1658: 5 - namespace DefCtor { - class A { A(); }; // expected-note 0-2{{here}} - class B { ~B(); }; // expected-note 0-2{{here}} - - // The stars align! An abstract class does not construct its virtual bases. - struct C : virtual A { C(); virtual void foo() = 0; }; - C::C() = default; // ok, not deleted, expected-error 0-1{{extension}} - struct D : virtual B { D(); virtual void foo() = 0; }; - D::D() = default; // ok, not deleted, expected-error 0-1{{extension}} - - // In all other cases, we are not so lucky. - struct E : A { E(); virtual void foo() = 0; }; -#if __cplusplus < 201103L - E::E() = default; // expected-error {{private default constructor}} expected-error {{extension}} expected-note {{here}} -#else - E::E() = default; // expected-error {{would delete}} expected-note@-4{{inaccessible default constructor}} -#endif - struct F : virtual A { F(); }; -#if __cplusplus < 201103L - F::F() = default; // expected-error {{private default constructor}} expected-error {{extension}} expected-note {{here}} -#else - F::F() = default; // expected-error {{would delete}} expected-note@-4{{inaccessible default constructor}} -#endif - - struct G : B { G(); virtual void foo() = 0; }; -#if __cplusplus < 201103L - G::G() = default; // expected-error@-2 {{private destructor}} expected-error {{extension}} expected-note {{here}} -#else - G::G() = default; // expected-error {{would delete}} expected-note@-4{{inaccessible destructor}} -#endif - struct H : virtual B { H(); }; -#if __cplusplus < 201103L - H::H() = default; // expected-error@-2 {{private destructor}} expected-error {{extension}} expected-note {{here}} -#else - H::H() = default; // expected-error {{would delete}} expected-note@-4{{inaccessible destructor}} -#endif - } - - namespace Dtor { - class B { ~B(); }; // expected-note 0-2{{here}} - - struct D : virtual B { ~D(); virtual void foo() = 0; }; - D::~D() = default; // ok, not deleted, expected-error 0-1{{extension}} - - struct G : B { ~G(); virtual void foo() = 0; }; -#if __cplusplus < 201103L - G::~G() = default; // expected-error@-2 {{private destructor}} expected-error {{extension}} expected-note {{here}} -#else - G::~G() = default; // expected-error {{would delete}} expected-note@-4{{inaccessible destructor}} -#endif - struct H : virtual B { ~H(); }; -#if __cplusplus < 201103L - H::~H() = default; // expected-error@-2 {{private destructor}} expected-error {{extension}} expected-note {{here}} -#else - H::~H() = default; // expected-error {{would delete}} expected-note@-4{{inaccessible destructor}} -#endif - } - - namespace MemInit { - struct A { A(int); }; // expected-note {{here}} - struct B : virtual A { - B() {} - virtual void f() = 0; - }; - struct C : virtual A { - C() {} // expected-error {{must explicitly initialize}} - }; - } - - namespace CopyCtorParamType { - struct A { A(A&); }; - struct B : virtual A { virtual void f() = 0; }; - struct C : virtual A { virtual void f(); }; - struct D : A { virtual void f() = 0; }; - - struct X { - friend B::B(const B&) throw(); - friend C::C(C&); - friend D::D(D&); - }; - } - - namespace CopyCtor { - class A { A(const A&); A(A&&); }; // expected-note 0-4{{here}} expected-error 0-1{{extension}} - - struct C : virtual A { C(const C&); C(C&&); virtual void foo() = 0; }; // expected-error 0-1{{extension}} - C::C(const C&) = default; // expected-error 0-1{{extension}} - C::C(C&&) = default; // expected-error 0-2{{extension}} - - struct E : A { E(const E&); E(E&&); virtual void foo() = 0; }; // expected-error 0-1{{extension}} -#if __cplusplus < 201103L - E::E(const E&) = default; // expected-error {{private copy constructor}} expected-error {{extension}} expected-note {{here}} - E::E(E&&) = default; // expected-error {{private move constructor}} expected-error 2{{extension}} expected-note {{here}} -#else - E::E(const E&) = default; // expected-error {{would delete}} expected-note@-5{{inaccessible copy constructor}} - E::E(E&&) = default; // expected-error {{would delete}} expected-note@-6{{inaccessible move constructor}} -#endif - struct F : virtual A { F(const F&); F(F&&); }; // expected-error 0-1{{extension}} -#if __cplusplus < 201103L - F::F(const F&) = default; // expected-error {{private copy constructor}} expected-error {{extension}} expected-note {{here}} - F::F(F&&) = default; // expected-error {{private move constructor}} expected-error 2{{extension}} expected-note {{here}} -#else - F::F(const F&) = default; // expected-error {{would delete}} expected-note@-5{{inaccessible copy constructor}} - F::F(F&&) = default; // expected-error {{would delete}} expected-note@-6{{inaccessible move constructor}} -#endif - } - - // assignment case is superseded by dr2180 -} - -namespace dr1672 { // dr1672: 7 - struct Empty {}; - struct A : Empty {}; - struct B { Empty e; }; - struct C : A { B b; int n; }; - struct D : A { int n; B b; }; - - static_assert(!__is_standard_layout(C), ""); - static_assert(__is_standard_layout(D), ""); - - struct E { B b; int n; }; - struct F { int n; B b; }; - union G { B b; int n; }; - union H { int n; B b; }; - - struct X {}; - template<typename T> struct Y : X, A { T t; }; - - static_assert(!__is_standard_layout(Y<E>), ""); - static_assert(__is_standard_layout(Y<F>), ""); - static_assert(!__is_standard_layout(Y<G>), ""); - static_assert(!__is_standard_layout(Y<H>), ""); - static_assert(!__is_standard_layout(Y<X>), ""); -} - -namespace dr1687 { // dr1687: 7 - template<typename T> struct To { - operator T(); // expected-note 2{{first operand was implicitly converted to type 'int *'}} - // expected-note@-1 {{second operand was implicitly converted to type 'double'}} -#if __cplusplus > 201703L - // expected-note@-3 2{{operand was implicitly converted to type 'dr1687::E}} -#endif - }; - - int *a = To<int*>() + 100.0; // expected-error {{invalid operands to binary expression ('To<int *>' and 'double')}} - int *b = To<int*>() + To<double>(); // expected-error {{invalid operands to binary expression ('To<int *>' and 'To<double>')}} - -#if __cplusplus > 201703L - enum E1 {}; - enum E2 {}; - auto c = To<E1>() <=> To<E2>(); // expected-error {{invalid operands to binary expression ('To<dr1687::E1>' and 'To<dr1687::E2>')}} -#endif -} - -namespace dr1696 { // dr1696: 7 - namespace std_examples { -#if __cplusplus >= 201402L - extern struct A a; - struct A { - const A &x = { A{a, a} }; - const A &y = { A{} }; // expected-error {{default member initializer for 'y' needed within definition of enclosing class 'A' outside of member functions}} expected-note {{here}} - }; - A a{a, a}; -#endif - } - - struct A { A(); ~A(); }; -#if __cplusplus >= 201103L - struct B { - A &&a; // expected-note {{declared here}} - B() : a{} {} // expected-error {{reference member 'a' binds to a temporary object whose lifetime would be shorter than the lifetime of the constructed object}} - } b; -#endif - - struct C { - C(); - const A &a; // expected-note {{declared here}} - }; - C::C() : a(A()) {} // expected-error {{reference member 'a' binds to a temporary object whose lifetime would be shorter than the lifetime of the constructed object}} - -#if __cplusplus >= 201103L - // This is OK in C++14 onwards, per DR1815, though we don't support that yet: - // D1 d1 = {}; - // is equivalent to - // D1 d1 = {A()}; - // ... which lifetime-extends the A temporary. - struct D1 { -#if __cplusplus < 201402L - // expected-error@-2 {{binds to a temporary}} -#endif - const A &a = A(); // expected-note {{default member init}} - }; - D1 d1 = {}; -#if __cplusplus < 201402L - // expected-note@-2 {{first required here}} -#else - // expected-warning-re@-4 {{sorry, lifetime extension {{.*}} not supported}} -#endif - - struct D2 { - const A &a = A(); // expected-note {{default member init}} - D2() {} // expected-error {{binds to a temporary}} - }; - - struct D3 { // expected-error {{binds to a temporary}} - const A &a = A(); // expected-note {{default member init}} - }; - D3 d3; // expected-note {{first required here}} - - struct haslist1 { - std::initializer_list<int> il; // expected-note {{'std::initializer_list' member}} - haslist1(int i) : il{i, 2, 3} {} // expected-error {{backing array for 'std::initializer_list' member 'il' is a temporary object}} - }; - - struct haslist2 { - std::initializer_list<int> il; // expected-note {{'std::initializer_list' member}} - haslist2(); - }; - haslist2::haslist2() : il{1, 2} {} // expected-error {{backing array for 'std::initializer_list' member 'il' is a temporary object}} - - struct haslist3 { - std::initializer_list<int> il = {1, 2, 3}; - }; - - struct haslist4 { // expected-error {{backing array for 'std::initializer_list' member 'il' is a temporary object}} - std::initializer_list<int> il = {1, 2, 3}; // expected-note {{default member initializer}} - }; - haslist4 hl4; // expected-note {{in implicit default constructor}} - - struct haslist5 { - std::initializer_list<int> il = {1, 2, 3}; // expected-note {{default member initializer}} - haslist5() {} // expected-error {{backing array for 'std::initializer_list' member 'il' is a temporary object}} - }; -#endif -} diff --git a/test/CXX/drs/dr1748.cpp b/test/CXX/drs/dr1748.cpp deleted file mode 100644 index 7e04f402d266..000000000000 --- a/test/CXX/drs/dr1748.cpp +++ /dev/null @@ -1,35 +0,0 @@ -// RUN: %clang_cc1 -std=c++98 %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | FileCheck %s -// RUN: %clang_cc1 -std=c++11 %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | FileCheck %s -// RUN: %clang_cc1 -std=c++14 %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | FileCheck %s -// RUN: %clang_cc1 -std=c++1z %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | FileCheck %s - -// dr1748: 3.7 - -// FIXME: __SIZE_TYPE__ expands to 'long long' on some targets. -__extension__ typedef __SIZE_TYPE__ size_t; - -void *operator new(size_t, void *); -void *operator new[](size_t, void *); - -struct X { X(); }; - -// The reserved placement allocation functions get inlined -// even if we can't see their definitions. They do not -// perform a null check. - -// CHECK-LABEL: define {{.*}} @_Z1fPv( -// CHECK-NOT: call -// CHECK-NOT: icmp{{.*}} null -// CHECK-NOT: br i1 -// CHECK: call void @_ZN1XC1Ev( -// CHECK: } -X *f(void *p) { return new (p) X; } - -// CHECK-LABEL: define {{.*}} @_Z1gPv( -// CHECK-NOT: call -// CHECK-NOT: icmp{{.*}} null -// CHECK-NOT: br i1 -// CHECK: call void @_ZN1XC1Ev( -// CHECK: br i1 -// CHECK: } -X *g(void *p) { return new (p) X[5]; } diff --git a/test/CXX/drs/dr17xx.cpp b/test/CXX/drs/dr17xx.cpp deleted file mode 100644 index a917412adcbd..000000000000 --- a/test/CXX/drs/dr17xx.cpp +++ /dev/null @@ -1,78 +0,0 @@ -// RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++1z %s -verify -fexceptions -fcxx-exceptions -pedantic-errors - -#if __cplusplus < 201103L -// expected-no-diagnostics -#endif - -namespace dr1715 { // dr1715: 3.9 -#if __cplusplus >= 201103L - struct B { - template<class T> B(T, typename T::Q); - }; - - class S { - using Q = int; - template<class T> friend B::B(T, typename T::Q); - }; - - struct D : B { - using B::B; - }; - struct E : B { // expected-note 2{{candidate}} - template<class T> E(T t, typename T::Q q) : B(t, q) {} // expected-note {{'Q' is a private member}} - }; - - B b(S(), 1); - D d(S(), 2); - E e(S(), 3); // expected-error {{no match}} -#endif -} - -namespace dr1736 { // dr1736: 3.9 -#if __cplusplus >= 201103L -struct S { - template <class T> S(T t) { - struct L : S { - using S::S; - }; - typename T::type value; // expected-error {{no member}} - L l(value); // expected-note {{instantiation of}} - } -}; -struct Q { typedef int type; } q; -S s(q); // expected-note {{instantiation of}} -#endif -} - -namespace dr1756 { // dr1756: 3.7 -#if __cplusplus >= 201103L - // Direct-list-initialization of a non-class object - - int a{0}; - - struct X { operator int(); } x; - int b{x}; -#endif -} - -namespace dr1758 { // dr1758: 3.7 -#if __cplusplus >= 201103L - // Explicit conversion in copy/move list initialization - - struct X { X(); }; - struct Y { explicit operator X(); } y; - X x{y}; - - struct A { - A() {} - A(const A &) {} - }; - struct B { - operator A() { return A(); } - } b; - A a{b}; -#endif -} diff --git a/test/CXX/drs/dr18xx.cpp b/test/CXX/drs/dr18xx.cpp deleted file mode 100644 index 16f967b65654..000000000000 --- a/test/CXX/drs/dr18xx.cpp +++ /dev/null @@ -1,75 +0,0 @@ -// RUN: %clang_cc1 -std=c++98 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++1z -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors - -#if __cplusplus < 201103L -// expected-error@+1 {{variadic macro}} -#define static_assert(...) __extension__ _Static_assert(__VA_ARGS__) -#endif - -namespace dr1813 { // dr1813: 7 - struct B { int i; }; - struct C : B {}; - struct D : C {}; - struct E : D { char : 4; }; - - static_assert(__is_standard_layout(B), ""); - static_assert(__is_standard_layout(C), ""); - static_assert(__is_standard_layout(D), ""); - static_assert(!__is_standard_layout(E), ""); - - struct Q {}; - struct S : Q {}; - struct T : Q {}; - struct U : S, T {}; - - static_assert(__is_standard_layout(Q), ""); - static_assert(__is_standard_layout(S), ""); - static_assert(__is_standard_layout(T), ""); - static_assert(!__is_standard_layout(U), ""); -} - -namespace dr1815 { // dr1815: no -#if __cplusplus >= 201402L - // FIXME: needs codegen test - struct A { int &&r = 0; }; // expected-note {{default member init}} - A a = {}; // FIXME expected-warning {{not supported}} - - struct B { int &&r = 0; }; // expected-error {{binds to a temporary}} expected-note {{default member init}} - B b; // expected-note {{here}} -#endif -} - -namespace dr1881 { // dr1881: 7 - struct A { int a : 4; }; - struct B : A { int b : 3; }; - static_assert(__is_standard_layout(A), ""); - static_assert(!__is_standard_layout(B), ""); - - struct C { int : 0; }; - struct D : C { int : 0; }; - static_assert(__is_standard_layout(C), ""); - static_assert(!__is_standard_layout(D), ""); -} - -void dr1891() { // dr1891: 4 -#if __cplusplus >= 201103L - int n; - auto a = []{}; // expected-note 2{{candidate}} expected-note 2{{here}} - auto b = [=]{ return n; }; // expected-note 2{{candidate}} expected-note 2{{here}} - typedef decltype(a) A; - typedef decltype(b) B; - - static_assert(!__has_trivial_constructor(A), ""); - static_assert(!__has_trivial_constructor(B), ""); - - A x; // expected-error {{no matching constructor}} - B y; // expected-error {{no matching constructor}} - - a = a; // expected-error {{copy assignment operator is implicitly deleted}} - a = static_cast<A&&>(a); // expected-error {{copy assignment operator is implicitly deleted}} - b = b; // expected-error {{copy assignment operator is implicitly deleted}} - b = static_cast<B&&>(b); // expected-error {{copy assignment operator is implicitly deleted}} -#endif -} diff --git a/test/CXX/drs/dr19xx.cpp b/test/CXX/drs/dr19xx.cpp deleted file mode 100644 index e6cf337da0ba..000000000000 --- a/test/CXX/drs/dr19xx.cpp +++ /dev/null @@ -1,193 +0,0 @@ -// RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++1z %s -verify -fexceptions -fcxx-exceptions -pedantic-errors - -namespace std { struct type_info; } - -namespace dr1902 { // dr1902: 3.7 - struct A {}; - struct B { - B(A); -#if __cplusplus >= 201103L - // expected-note@-2 {{candidate}} -#endif - - B() = delete; -#if __cplusplus < 201103L - // expected-error@-2 {{extension}} -#endif - - B(const B&) // expected-note {{deleted here}} -#if __cplusplus >= 201103L - // expected-note@-2 {{candidate}} -#else - // expected-error@+2 {{extension}} -#endif - = delete; - - operator A(); - }; - - extern B b1; - B b2(b1); // expected-error {{call to deleted}} - -#if __cplusplus >= 201103L - // This is ambiguous, even though calling the B(const B&) constructor would - // both directly and indirectly call a deleted function. - B b({}); // expected-error {{ambiguous}} -#endif -} - -namespace dr1903 { - namespace A { - struct a {}; - int a; - namespace B { - int b; - } - using namespace B; - namespace { - int c; - } - namespace D { - int d; - } - using D::d; - } - namespace X { - using A::a; - using A::b; - using A::c; - using A::d; - struct a *p; - } -} - -namespace dr1909 { // dr1909: yes - struct A { - template<typename T> struct A {}; // expected-error {{member 'A' has the same name as its class}} - }; - struct B { - template<typename T> void B() {} // expected-error {{constructor cannot have a return type}} - }; - struct C { - template<typename T> static int C; // expected-error {{member 'C' has the same name as its class}} expected-error 0-1{{extension}} - }; - struct D { - template<typename T> using D = int; // expected-error {{member 'D' has the same name as its class}} expected-error 0-1{{extension}} - }; -} - -namespace dr1940 { // dr1940: yes -#if __cplusplus >= 201103L -static union { - static_assert(true, ""); // ok - static_assert(false, ""); // expected-error {{static_assert failed}} -}; -#endif -} - -namespace dr1941 { // dr1941: 3.9 -#if __cplusplus >= 201402L -template<typename X> -struct base { - template<typename T> - base(T a, T b, decltype(void(*T()), 0) = 0) { - while (a != b) (void)*a++; - } - - template<typename T> - base(T a, X x, decltype(void(T(0) * 1), 0) = 0) { - for (T n = 0; n != a; ++n) (void)X(x); - } -}; - -struct derived : base<int> { - using base::base; -}; - -struct iter { - iter operator++(int); - int operator*(); - friend bool operator!=(iter, iter); -} it, end; - -derived d1(it, end); -derived d2(42, 9); -#endif -} - -namespace dr1947 { // dr1947: yes -#if __cplusplus >= 201402L -unsigned o = 0'01; // ok -unsigned b = 0b'01; // expected-error {{invalid digit 'b' in octal constant}} -unsigned x = 0x'01; // expected-error {{invalid suffix 'x'01' on integer constant}} -#endif -} - -#if __cplusplus >= 201103L -// dr1948: yes -// FIXME: This diagnostic could be improved. -void *operator new(__SIZE_TYPE__) noexcept { return nullptr; } // expected-error{{exception specification in declaration does not match previous declaration}} -#endif - -namespace dr1959 { // dr1959: 3.9 -#if __cplusplus >= 201103L - struct b; - struct c; - struct a { - a() = default; - a(const a &) = delete; // expected-note {{deleted}} - a(const b &) = delete; // not inherited - a(c &&) = delete; // expected-note {{not viable}} - template<typename T> a(T) = delete; // expected-note {{would take its own class type by value}} - }; - - struct b : a { // expected-note {{cannot bind}} expected-note {{deleted because}} - using a::a; // expected-note 2{{inherited here}} - }; - - a x; - // FIXME: As a resolution to an open DR against P0136R0, we disallow - // use of inherited constructors to construct from a single argument - // where the base class is reference-related to the argument type. - b y = x; // expected-error {{no viable conversion}} - b z = z; // expected-error {{deleted}} - - struct c : a { - using a::a; - c(const c &); - }; - // FIXME: As a resolution to an open DR against P0136R0, we disallow - // use of inherited constructors to construct from a single argument - // where the base class is reference-related to the argument type. - c q(static_cast<c&&>(q)); -#endif -} - -namespace dr1968 { // dr1968: yes -#if __cplusplus >= 201103L - static_assert(&typeid(int) == &typeid(int), ""); // expected-error{{not an integral constant expression}} -#endif -} - -namespace dr1991 { // dr1991: 3.9 -#if __cplusplus >= 201103L - struct A { - A(int, int) = delete; - }; - - struct B : A { - using A::A; - B(int, int, int = 0); - }; - - // FIXME: As a resolution to an open DR against P0136R1, we treat derived - // class constructors as better than base class constructors in the presence - // of ambiguity. - B b(0, 0); // ok, calls B constructor -#endif -} - -// dr1994: dup 529 diff --git a/test/CXX/drs/dr1xx.cpp b/test/CXX/drs/dr1xx.cpp deleted file mode 100644 index 26ab67d54d31..000000000000 --- a/test/CXX/drs/dr1xx.cpp +++ /dev/null @@ -1,1060 +0,0 @@ -// RUN: %clang_cc1 -std=c++98 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors - -namespace dr100 { // dr100: yes - template<const char *> struct A {}; // expected-note 0-1{{declared here}} - template<const char (&)[4]> struct B {}; // expected-note 0-1{{declared here}} - A<"foo"> a; // expected-error {{does not refer to any declaration}} - B<"bar"> b; // expected-error {{does not refer to any declaration}} -} - -namespace dr101 { // dr101: 3.5 - extern "C" void dr101_f(); - typedef unsigned size_t; - namespace X { - extern "C" void dr101_f(); - typedef unsigned size_t; - } - using X::dr101_f; - using X::size_t; - extern "C" void dr101_f(); - typedef unsigned size_t; -} - -namespace dr102 { // dr102: yes - namespace A { - template<typename T> T f(T a, T b) { return a + b; } // expected-error {{neither visible in the template definition nor found by argument-dependent lookup}} - } - namespace B { - struct S {}; - } - B::S operator+(B::S, B::S); // expected-note {{should be declared prior to the call site or in namespace 'dr102::B'}} - template B::S A::f(B::S, B::S); // expected-note {{in instantiation of}} -} - -// dr103: na -// dr104: na lib -// dr105: na - -namespace dr106 { // dr106: sup 540 - typedef int &r1; - typedef r1 &r1; - typedef const r1 r1; // expected-warning {{has no effect}} - typedef const r1 &r1; // expected-warning {{has no effect}} - - typedef const int &r2; - typedef r2 &r2; - typedef const r2 r2; // expected-warning {{has no effect}} - typedef const r2 &r2; // expected-warning {{has no effect}} -} - -namespace dr107 { // dr107: yes - struct S {}; - extern "C" S operator+(S, S) { return S(); } -} - -namespace dr108 { // dr108: yes - template<typename T> struct A { - struct B { typedef int X; }; - B::X x; // expected-error {{missing 'typename'}} - struct C : B { X x; }; // expected-error {{unknown type name}} - }; - template<> struct A<int>::B { int X; }; -} - -namespace dr109 { // dr109: yes - struct A { template<typename T> void f(T); }; - template<typename T> struct B : T { - using T::template f; // expected-error {{'template' keyword not permitted here}} - using T::template f<int>; // expected-error {{'template' keyword not permitted here}} expected-error {{using declaration cannot refer to a template specialization}} - // FIXME: We shouldn't suggest using the 'template' keyword in a location where it's not valid. - using T::f<int>; // expected-error {{use 'template' keyword}} expected-error {{using declaration cannot refer to a template specialization}} - void g() { this->f<int>(123); } // expected-error {{use 'template' keyword}} - }; -} - -namespace dr111 { // dr111: dup 535 - struct A { A(); A(volatile A&, int = 0); A(A&, const char * = "foo"); }; - struct B : A { B(); }; // expected-note +{{would lose const qualifier}} expected-note {{requires 0 arguments}} - const B b1; - B b2(b1); // expected-error {{no matching constructor}} -} - -namespace dr112 { // dr112: yes - struct T { int n; }; - typedef T Arr[1]; - - const T a1[1] = {}; - volatile T a2[1] = {}; - const Arr a3 = {}; - volatile Arr a4 = {}; - template<const volatile T*> struct X {}; - X<a1> x1; - X<a2> x2; - X<a3> x3; - X<a4> x4; -#if __cplusplus < 201103L - // expected-error@-5 {{internal linkage}} expected-note@-10 {{here}} - // expected-error@-4 {{internal linkage}} expected-note@-9 {{here}} -#else - // FIXME: Test this somehow. -#endif -} - -namespace dr113 { // dr113: yes - extern void (*p)(); - void f() { - no_such_function(); // expected-error {{undeclared}} - p(); - } - void g(); - void (*p)() = &g; -} - -namespace dr114 { // dr114: yes - struct A { - virtual void f(int) = 0; // expected-note {{unimplemented}} - }; - struct B : A { - template<typename T> void f(T); - void g() { f(0); } - } b; // expected-error {{abstract}} -} - -namespace dr115 { // dr115: yes - template<typename T> int f(T); // expected-note +{{}} - template<typename T> int g(T); // expected-note +{{}} - template<typename T> int g(T, int); // expected-note +{{}} - - int k1 = f(&f); // expected-error {{no match}} - int k2 = f(&f<int>); - int k3 = f(&g<int>); // expected-error {{no match}} - - void h() { - (void)&f; // expected-error {{address of overloaded function 'f' cannot be cast to type 'void'}} - (void)&f<int>; - (void)&g<int>; // expected-error {{address of overloaded function 'g' cannot be cast to type 'void'}} - - &f; // expected-error {{reference to overloaded function could not be resolved}} - &f<int>; // expected-warning {{unused}} - &g<int>; // expected-error {{reference to overloaded function could not be resolved}} - } - - struct S { - template<typename T> static int f(T); - template<typename T> static int g(T); - template<typename T> static int g(T, int); - } s; - - int k4 = f(&s.f); // expected-error {{non-constant pointer to member}} - int k5 = f(&s.f<int>); - int k6 = f(&s.g<int>); // expected-error {{non-constant pointer to member}} - - void i() { - (void)&s.f; // expected-error {{non-constant pointer to member}} - (void)&s.f<int>; - (void)&s.g<int>; // expected-error {{non-constant pointer to member}} - - &s.f; // expected-error {{non-constant pointer to member}} - &s.f<int>; // expected-warning {{unused}} - &s.g<int>; // expected-error {{non-constant pointer to member}} - } - - struct T { - template<typename T> int f(T); - template<typename T> int g(T); - template<typename T> int g(T, int); - } t; - - int k7 = f(&s.f); // expected-error {{non-constant pointer to member}} - int k8 = f(&s.f<int>); - int k9 = f(&s.g<int>); // expected-error {{non-constant pointer to member}} - - void j() { - (void)&s.f; // expected-error {{non-constant pointer to member}} - (void)&s.f<int>; - (void)&s.g<int>; // expected-error {{non-constant pointer to member}} - - &s.f; // expected-error {{non-constant pointer to member}} - &s.f<int>; // expected-warning {{unused}} - &s.g<int>; // expected-error {{non-constant pointer to member}} - } - -#if __cplusplus >= 201103L - // Special case kicks in only if a template argument list is specified. - template<typename T=int> void with_default(); // expected-note +{{}} - int k10 = f(&with_default); // expected-error {{no matching function}} - int k11 = f(&with_default<>); - void k() { - (void)&with_default; // expected-error {{overloaded function}} - (void)&with_default<>; - &with_default; // expected-error {{overloaded function}} - &with_default<>; // expected-warning {{unused}} - } -#endif -} - -namespace dr116 { // dr116: yes - template<int> struct A {}; - template<int N> void f(A<N>) {} // expected-note {{previous}} - template<int M> void f(A<M>) {} // expected-error {{redefinition}} - template<typename T> void f(A<sizeof(T)>) {} // expected-note {{previous}} - template<typename U> void f(A<sizeof(U)>) {} // expected-error {{redefinition}} -} - -// dr117: na -// dr118 is in its own file. -// dr119: na -// dr120: na - -namespace dr121 { // dr121: yes - struct X { - template<typename T> struct Y {}; - }; - template<typename T> struct Z { - X::Y<T> x; - T::Y<T> y; // expected-error +{{}} - }; - Z<X> z; -} - -namespace dr122 { // dr122: yes - template<typename T> void f(); - void g() { f<int>(); } -} - -// dr123: na -// dr124: dup 201 - -// dr125: yes -struct dr125_A { struct dr125_B {}; }; // expected-note {{here}} -dr125_A::dr125_B dr125_C(); -namespace dr125_B { dr125_A dr125_C(); } -namespace dr125 { - struct X { - friend dr125_A::dr125_B (::dr125_C)(); // ok - friend dr125_A (::dr125_B::dr125_C)(); // ok - friend dr125_A::dr125_B::dr125_C(); // expected-error {{did you mean the constructor name 'dr125_B'?}} - // expected-error@-1 {{missing exception specification}} - }; -} - -namespace dr126 { // dr126: partial - // FIXME: We do not yet generate correct code for this change: - // eg: - // catch (void*&) should catch void* but not int* - // catch (void*) and catch (void*const&) should catch both - // Likewise: - // catch (Base *&) should catch Base* but not Derived* - // catch (Base *) should catch both - // In each case, we emit the same code for both catches. - // - // The ABI does not let us represent the language rule in the unwind tables. - // So, when catching by non-const (or volatile) reference to pointer, we - // should compare the exception type to the caught type and only accept an - // exact match. -#if __cplusplus <= 201402L - struct C {}; - struct D : C {}; - struct E : private C { friend class A; friend class B; }; - struct F : protected C {}; - struct G : C {}; - struct H : D, G {}; - - struct A { - virtual void cp() throw(C*); - virtual void dp() throw(C*); - virtual void ep() throw(C*); // expected-note {{overridden}} - virtual void fp() throw(C*); // expected-note {{overridden}} - virtual void gp() throw(C*); - virtual void hp() throw(C*); // expected-note {{overridden}} - - virtual void cr() throw(C&); - virtual void dr() throw(C&); - virtual void er() throw(C&); // expected-note {{overridden}} - virtual void fr() throw(C&); // expected-note {{overridden}} - virtual void gr() throw(C&); - virtual void hr() throw(C&); // expected-note {{overridden}} - - virtual void pv() throw(void*); - -#if __cplusplus >= 201103L - virtual void np() throw(C*); - virtual void npm() throw(int C::*); - virtual void nr() throw(C*&); // expected-note {{overridden}} - virtual void ncr() throw(C*const&); -#endif - - virtual void ref1() throw(C *const&); - virtual void ref2() throw(C *); - - virtual void v() throw(int); - virtual void w() throw(const int); - virtual void x() throw(int*); // expected-note {{overridden}} - virtual void y() throw(const int*); - virtual void z() throw(int); // expected-note {{overridden}} - }; - struct B : A { - virtual void cp() throw(C*); - virtual void dp() throw(D*); - virtual void ep() throw(E*); // expected-error {{more lax}} - virtual void fp() throw(F*); // expected-error {{more lax}} - virtual void gp() throw(G*); - virtual void hp() throw(H*); // expected-error {{more lax}} - - virtual void cr() throw(C&); - virtual void dr() throw(D&); - virtual void er() throw(E&); // expected-error {{more lax}} - virtual void fr() throw(F&); // expected-error {{more lax}} - virtual void gr() throw(G&); - virtual void hr() throw(H&); // expected-error {{more lax}} - - virtual void pv() throw(C*); - -#if __cplusplus >= 201103L - using nullptr_t = decltype(nullptr); - virtual void np() throw(nullptr_t); - virtual void npm() throw(nullptr_t&); - virtual void nr() throw(nullptr_t); // expected-error {{more lax}} - virtual void ncr() throw(nullptr_t); -#endif - - virtual void ref1() throw(D *const &); - virtual void ref2() throw(D *); - - virtual void v() throw(const int); - virtual void w() throw(int); - virtual void x() throw(const int*); // expected-error {{more lax}} - virtual void y() throw(int*); // ok - virtual void z() throw(long); // expected-error {{more lax}} - }; -#else - void f() throw(int); // expected-error {{ISO C++17 does not allow}} expected-note {{use 'noexcept}} -#endif -} - -namespace dr127 { // dr127: yes - __extension__ typedef __decltype(sizeof(0)) size_t; - template<typename T> struct A { - A() { throw 0; } - void *operator new(size_t, const char * = 0); - void operator delete(void *, const char *) { T::error; } // expected-error 2{{no members}} - void operator delete(void *) { T::error; } - }; - A<void> *p = new A<void>; // expected-note {{instantiat}} - A<int> *q = new ("") A<int>; // expected-note {{instantiat}} -} - -namespace dr128 { // dr128: yes - enum E1 { e1 } x = e1; - enum E2 { e2 } y = static_cast<E2>(x), z = static_cast<E2>(e1); -} - -// dr129: dup 616 -// dr130: na - -namespace dr131 { // dr131: yes - const char *a_with_\u0e8c = "\u0e8c"; - const char *b_with_\u0e8d = "\u0e8d"; - const char *c_with_\u0e8e = "\u0e8e"; -#if __cplusplus < 201103L - // expected-error@-4 {{expected ';'}} expected-error@-2 {{expected ';'}} -#endif -} - -namespace dr132 { // dr132: no - void f() { - extern struct {} x; // ok - extern struct S {} y; // FIXME: This is invalid. - } - static enum { E } e; -} - -// dr133: dup 87 -// dr134: na - -namespace dr135 { // dr135: yes - struct A { - A f(A a) { return a; } - friend A g(A a) { return a; } - static A h(A a) { return a; } - }; -} - -namespace dr136 { // dr136: 3.4 - void f(int, int, int = 0); // expected-note {{previous declaration is here}} - void g(int, int, int); // expected-note {{previous declaration is here}} - struct A { - friend void f(int, int = 0, int); // expected-error {{friend declaration specifying a default argument must be the only declaration}} - friend void g(int, int, int = 0); // expected-error {{friend declaration specifying a default argument must be the only declaration}} - friend void h(int, int, int = 0); // expected-error {{friend declaration specifying a default argument must be a definition}} - friend void i(int, int, int = 0) {} // expected-note {{previous declaration is here}} - friend void j(int, int, int = 0) {} - operator int(); - }; - void i(int, int, int); // expected-error {{friend declaration specifying a default argument must be the only declaration}} - void q() { - j(A(), A()); // ok, has default argument - } - extern "C" void k(int, int, int, int); // expected-note {{previous declaration is here}} - namespace NSA { - struct A { - friend void dr136::k(int, int, int, int = 0); // expected-error {{friend declaration specifying a default argument must be the only declaration}} - }; - } - namespace NSB { - struct A { - friend void dr136::k(int, int, int = 0, int); // expected-error {{missing default argument on parameter}} - }; - } - struct B { - void f(int); // expected-note {{previous declaration is here}} - }; - struct C { - friend void B::f(int = 0); // expected-error {{friend declaration specifying a default argument must be the only declaration}} - }; -} - -namespace dr137 { // dr137: yes - extern void *p; - extern const void *cp; - extern volatile void *vp; - extern const volatile void *cvp; - int *q = static_cast<int*>(p); - int *qc = static_cast<int*>(cp); // expected-error {{casts away qualifiers}} - int *qv = static_cast<int*>(vp); // expected-error {{casts away qualifiers}} - int *qcv = static_cast<int*>(cvp); // expected-error {{casts away qualifiers}} - const int *cq = static_cast<const int*>(p); - const int *cqc = static_cast<const int*>(cp); - const int *cqv = static_cast<const int*>(vp); // expected-error {{casts away qualifiers}} - const int *cqcv = static_cast<const int*>(cvp); // expected-error {{casts away qualifiers}} - const volatile int *cvq = static_cast<const volatile int*>(p); - const volatile int *cvqc = static_cast<const volatile int*>(cp); - const volatile int *cvqv = static_cast<const volatile int*>(vp); - const volatile int *cvqcv = static_cast<const volatile int*>(cvp); -} - -namespace dr139 { // dr139: yes - namespace example1 { - typedef int f; // expected-note {{previous}} - struct A { - friend void f(A &); // expected-error {{different kind of symbol}} - }; - } - - namespace example2 { - typedef int f; - namespace N { - struct A { - friend void f(A &); - operator int(); - void g(A a) { int i = f(a); } // ok, f is typedef not friend function - }; - } - } -} - -namespace dr140 { // dr140: yes - void f(int *const) {} // expected-note {{previous}} - void f(int[3]) {} // expected-error {{redefinition}} - void g(const int); - void g(int n) { n = 2; } -} - -namespace dr141 { // dr141: yes - template<typename T> void f(); - template<typename T> struct S { int n; }; - struct A : S<int> { - template<typename T> void f(); - template<typename T> struct S {}; - } a; - struct B : S<int> {} b; - void g() { - a.f<int>(); - (void)a.S<int>::n; // expected-error {{no member named 'n'}} -#if __cplusplus < 201103L - // expected-error@-2 {{ambiguous}} - // expected-note@-11 {{lookup from the current scope}} - // expected-note@-9 {{lookup in the object type}} -#endif - b.f<int>(); // expected-error {{no member}} expected-error +{{}} - (void)b.S<int>::n; - } - template<typename T> struct C { - T t; - void g() { - t.f<int>(); // expected-error {{use 'template'}} - } - void h() { - (void)t.S<int>::n; // ok - } - void i() { - (void)t.S<int>(); // ok! - } - }; - void h() { C<B>().h(); } // ok - struct X { - template<typename T> void S(); - }; - void i() { C<X>().i(); } // ok!! -} - -namespace dr142 { // dr142: yes - class B { // expected-note +{{here}} - public: - int mi; // expected-note +{{here}} - static int si; // expected-note +{{here}} - }; - class D : private B { // expected-note +{{here}} - }; - class DD : public D { - void f(); - }; - void DD::f() { - mi = 3; // expected-error {{private base class}} expected-error {{private member}} - si = 3; // expected-error {{private member}} - B b_old; // expected-error {{private member}} - dr142::B b; - b.mi = 3; - b.si = 3; - B::si = 3; // expected-error {{private member}} - dr142::B::si = 3; - B *bp1_old = this; // expected-error {{private member}} expected-error {{private base class}} - dr142::B *bp1 = this; // expected-error {{private base class}} - B *bp2_old = (B*)this; // expected-error 2{{private member}} - dr142::B *bp2 = (dr142::B*)this; - bp2->mi = 3; - } -} - -namespace dr143 { // dr143: yes - namespace A { struct X; } - namespace B { void f(A::X); } - namespace A { - struct X { friend void B::f(X); }; - } - void g(A::X x) { - f(x); // expected-error {{undeclared identifier 'f'}} - } -} - -namespace dr145 { // dr145: yes - void f(bool b) { -#if __cplusplus <= 201402L - ++b; // expected-warning {{deprecated}} - b++; // expected-warning {{deprecated}} -#else - ++b; // expected-error {{increment}} - b++; // expected-error {{increment}} -#endif - } -} - -namespace dr147 { // dr147: yes - namespace example1 { - template<typename> struct A { - template<typename T> A(T); - }; - // Per core issue 1435, this is ill-formed because A<int>::A<int> does not - // name the injected-class-name. (A<int>::A does, though.) - template<> template<> A<int>::A<int>(int) {} // expected-error {{out-of-line constructor for 'A' cannot have template arguments}} - template<> template<> A<float>::A(float) {} - } - namespace example2 { - struct A { A(); }; - struct B : A { B(); }; - A::A a1; // expected-error {{is a constructor}} - B::A a2; - } - namespace example3 { - template<typename> struct A { - template<typename T> A(T); - static A a; - }; - template<> A<int>::A<int>(A<int>::a); // expected-error {{is a constructor}} - } -} - -namespace dr148 { // dr148: yes - struct A { int A::*p; }; - int check1[__is_pod(int(A::*)) ? 1 : -1]; - int check2[__is_pod(A) ? 1 : -1]; -} - -// dr149: na - -namespace dr151 { // dr151: yes - struct X {}; - typedef int X::*p; -#if __cplusplus < 201103L -#define fold(x) (__builtin_constant_p(0) ? (x) : (x)) -#else -#define fold -#endif - int check[fold(p() == 0) ? 1 : -1]; -#undef fold -} - -namespace dr152 { // dr152: yes - struct A { - A(); // expected-note 0-2{{not viable}} - explicit A(const A&); - }; - A a1 = A(); -#if __cplusplus <= 201402L - // expected-error@-2 {{no matching constructor}} -#endif - A a2((A())); - - A &f(); - A a3 = f(); // expected-error {{no matching constructor}} - A a4(f()); -} - -// dr153: na - -namespace dr154 { // dr154: yes - union { int a; }; // expected-error {{must be declared 'static'}} - namespace { - union { int b; }; - } - static union { int c; }; -} - -namespace dr155 { // dr155: dup 632 - struct S { int n; } s = { { 1 } }; // expected-warning {{braces around scalar initializer}} -} - -// dr158 is in its own file. - -namespace dr159 { // dr159: 3.5 - namespace X { void f(); } - void f(); - void dr159::f() {} // expected-warning {{extra qualification}} - void dr159::X::f() {} -} - -// dr160: na - -namespace dr161 { // dr161: yes - class A { - protected: - struct B { int n; } b; // expected-note 2{{here}} - static B bs; - void f(); // expected-note {{here}} - static void sf(); - }; - struct C : A {}; - struct D : A { - void g(C c) { - (void)b.n; - B b1; - C::B b2; // ok, accessible as a member of A - (void)&C::b; // expected-error {{protected}} - (void)&C::bs; - (void)c.b; // expected-error {{protected}} - (void)c.bs; - f(); - sf(); - c.f(); // expected-error {{protected}} - c.sf(); - A::f(); - D::f(); - A::sf(); - C::sf(); - D::sf(); - } - }; -} - -namespace dr162 { // dr162: no - struct A { - char &f(char); - static int &f(int); - - void g() { - int &a = (&A::f)(0); // FIXME: expected-error {{could not be resolved}} - char &b = (&A::f)('0'); // expected-error {{could not be resolved}} - } - }; - - int &c = (&A::f)(0); // FIXME: expected-error {{could not be resolved}} - char &d = (&A::f)('0'); // expected-error {{could not be resolved}} -} - -// dr163: na - -namespace dr164 { // dr164: yes - void f(int); - template <class T> int g(T t) { return f(t); } - - enum E { e }; - int f(E); - - int k = g(e); -} - -namespace dr165 { // dr165: no - namespace N { - struct A { friend struct B; }; - void f() { void g(); } - } - // FIXME: dr1477 says this is ok, dr165 says it's ill-formed - struct N::B {}; - // FIXME: dr165 says this is ill-formed, but the argument in dr1477 says it's ok - void N::g() {} -} - -namespace dr166 { // dr166: yes - namespace A { class X; } - - template<typename T> int f(T t) { return t.n; } - int g(A::X); - template<typename T> int h(T t) { return t.n; } // expected-error {{private}} - int i(A::X); - - namespace A { - class X { - friend int f<X>(X); - friend int dr166::g(X); - friend int h(X); - friend int i(X); - int n; // expected-note 2{{here}} - }; - - int h(X x) { return x.n; } - int i(X x) { return x.n; } - } - - template int f(A::X); - int g(A::X x) { return x.n; } - template int h(A::X); // expected-note {{instantiation}} - int i(A::X x) { return x.n; } // expected-error {{private}} -} - -// dr167: sup 1012 - -namespace dr168 { // dr168: no - extern "C" typedef int (*p)(); - extern "C++" typedef int (*q)(); - struct S { - static int f(); - }; - p a = &S::f; // FIXME: this should fail. - q b = &S::f; -} - -namespace dr169 { // dr169: yes - template<typename> struct A { int n; }; - struct B { - template<typename> struct C; - template<typename> void f(); - template<typename> static int n; // expected-error 0-1{{extension}} - }; - struct D : A<int>, B { - using A<int>::n; - using B::C<int>; // expected-error {{using declaration cannot refer to a template specialization}} - using B::f<int>; // expected-error {{using declaration cannot refer to a template specialization}} - using B::n<int>; // expected-error {{using declaration cannot refer to a template specialization}} - }; -} - -namespace { // dr171: yes - int dr171a; -} -int dr171b; // expected-note {{here}} -namespace dr171 { - extern "C" void dr171a(); - extern "C" void dr171b(); // expected-error {{conflicts}} -} - -namespace dr172 { // dr172: yes - enum { zero }; - int check1[-1 < zero ? 1 : -1]; - - enum { x = -1, y = (unsigned int)-1 }; - int check2[sizeof(x) > sizeof(int) ? 1 : -1]; - - enum { a = (unsigned int)-1 / 2 }; - int check3a[sizeof(a) == sizeof(int) ? 1 : -1]; - int check3b[-a < 0 ? 1 : -1]; - - enum { b = (unsigned int)-1 / 2 + 1 }; - int check4a[sizeof(b) == sizeof(unsigned int) ? 1 : -1]; - int check4b[-b > 0 ? 1 : -1]; - - enum { c = (unsigned long)-1 / 2 }; - int check5a[sizeof(c) == sizeof(long) ? 1 : -1]; - int check5b[-c < 0 ? 1 : -1]; - - enum { d = (unsigned long)-1 / 2 + 1 }; - int check6a[sizeof(d) == sizeof(unsigned long) ? 1 : -1]; - int check6b[-d > 0 ? 1 : -1]; - - enum { e = (unsigned long long)-1 / 2 }; // expected-error 0-1{{extension}} - int check7a[sizeof(e) == sizeof(long) ? 1 : -1]; // expected-error 0-1{{extension}} - int check7b[-e < 0 ? 1 : -1]; - - enum { f = (unsigned long long)-1 / 2 + 1 }; // expected-error 0-1{{extension}} - int check8a[sizeof(f) == sizeof(unsigned long) ? 1 : -1]; // expected-error 0-1{{extension}} - int check8b[-f > 0 ? 1 : -1]; -} - -namespace dr173 { // dr173: yes - int check[('0' + 1 == '1' && '0' + 2 == '2' && '0' + 3 == '3' && - '0' + 4 == '4' && '0' + 5 == '5' && '0' + 6 == '6' && - '0' + 7 == '7' && '0' + 8 == '8' && '0' + 9 == '9') ? 1 : -1]; -} - -// dr174: sup 1012 - -namespace dr175 { // dr175: yes - struct A {}; // expected-note {{here}} - struct B : private A {}; // expected-note {{constrained by private inheritance}} - struct C : B { - A a; // expected-error {{private}} - dr175::A b; - }; -} - -namespace dr176 { // dr176: yes - template<typename T> class Y; - template<> class Y<int> { - void f() { - typedef Y A; // expected-note {{here}} - typedef Y<char> A; // expected-error {{different types ('Y<char>' vs 'Y<int>')}} - } - }; - - template<typename T> struct Base {}; // expected-note 2{{found}} - template<typename T> struct Derived : public Base<T> { - void f() { - typedef typename Derived::template Base<T> A; - typedef typename Derived::Base A; - } - }; - template struct Derived<int>; - - template<typename T> struct Derived2 : Base<int>, Base<char> { - typename Derived2::Base b; // expected-error {{found in multiple base classes}} - typename Derived2::Base<double> d; - }; - - template<typename T> class X { // expected-note {{here}} - X *p1; - X<T> *p2; - X<int> *p3; - dr176::X *p4; // expected-error {{requires template arguments}} - }; -} - -namespace dr177 { // dr177: yes - struct B {}; - struct A { - A(A &); // expected-note 0-1{{not viable: expects an l-value}} - A(const B &); // expected-note 0-1{{not viable: no known conversion from 'dr177::A' to}} - }; - B b; - A a = b; -#if __cplusplus <= 201402L - // expected-error@-2 {{no viable constructor copying variable}} -#endif - - struct C { C(C&); }; // expected-note {{not viable: no known conversion from 'dr177::D' to 'dr177::C &'}} - struct D : C {}; - struct E { operator D(); }; - E e; - C c = e; // expected-error {{no viable constructor copying variable of type 'dr177::D'}} -} - -namespace dr178 { // dr178: yes - int check[int() == 0 ? 1 : -1]; -#if __cplusplus >= 201103L - static_assert(int{} == 0, ""); - struct S { int a, b; }; - static_assert(S{1}.b == 0, ""); - struct T { constexpr T() : n() {} int n; }; - static_assert(T().n == 0, ""); - struct U : S { constexpr U() : S() {} }; - static_assert(U().b == 0, ""); -#endif -} - -namespace dr179 { // dr179: yes - void f(); - int n = &f - &f; // expected-error {{arithmetic on pointers to the function type 'void ()'}} -} - -namespace dr180 { // dr180: yes - template<typename T> struct X : T, T::some_base { - X() : T::some_type_that_might_be_T(), T::some_base() {} - friend class T::some_class; - void f() { - enum T::some_enum e; - } - }; -} - -namespace dr181 { // dr181: yes - namespace X { - template <template X<class T> > struct A { }; // expected-error +{{}} - template <template X<class T> > void f(A<X>) { } // expected-error +{{}} - } - - namespace Y { - template <template <class T> class X> struct A { }; - template <template <class T> class X> void f(A<X>) { } - } -} - -namespace dr182 { // dr182: yes - template <class T> struct C { - void f(); - void g(); - }; - - template <class T> void C<T>::f() {} - template <class T> void C<T>::g() {} - - class A { - class B {}; // expected-note {{here}} - void f(); - }; - - template void C<A::B>::f(); - template <> void C<A::B>::g(); // expected-error {{private}} - - void A::f() { - C<B> cb; - cb.f(); - } -} - -namespace dr183 { // dr183: sup 382 - template<typename T> struct A {}; - template<typename T> struct B { - typedef int X; - }; - template<> struct A<int> { -#if __cplusplus <= 199711 - typename B<int>::X x; // expected-error {{'typename' occurs outside of a template}} -#else - typename B<int>::X x; -#endif - }; -} - -namespace dr184 { // dr184: yes - template<typename T = float> struct B {}; - - template<template<typename TT = float> class T> struct A { - void f(); - void g(); - }; - - template<template<typename TT> class T> void A<T>::f() { // expected-note {{here}} - T<> t; // expected-error {{too few template arguments}} - } - - template<template<typename TT = char> class T> void A<T>::g() { - T<> t; - typedef T<> X; - typedef T<char> X; - } - - void h() { A<B>().g(); } -} - -// dr185 FIXME: add codegen test - -namespace dr187 { // dr187: sup 481 - const int Z = 1; - template<int X = Z, int Z = X> struct A; - typedef A<> T; - typedef A<1, 1> T; -} - -namespace dr188 { // dr188: yes - char c[10]; - int check[sizeof(0, c) == 10 ? 1 : -1]; -} - -// dr190 FIXME: add codegen test for tbaa - -// dr193 FIXME: add codegen test - -namespace dr194 { // dr194: yes - struct A { - A(); - void A(); // expected-error {{constructor cannot have a return type}} - }; - struct B { - void B(); // expected-error {{constructor cannot have a return type}} - B(); - }; - struct C { - inline explicit C(int) {} - }; -} - -namespace dr195 { // dr195: yes - void f(); - int *p = (int*)&f; // expected-error 0-1{{extension}} - void (*q)() = (void(*)())&p; // expected-error 0-1{{extension}} -} - -namespace dr197 { // dr197: yes - char &f(char); - - template <class T> void g(T t) { - char &a = f(1); - char &b = f(T(1)); // expected-error {{unrelated type 'int'}} - char &c = f(t); // expected-error {{unrelated type 'int'}} - } - - void f(int); - - enum E { e }; - int &f(E); - - void h() { - g('a'); - g(2); - g(e); // expected-note {{in instantiation of}} - } -} - -namespace dr198 { // dr198: yes - struct A { - int n; - struct B { - int m[sizeof(n)]; -#if __cplusplus < 201103L - // expected-error@-2 {{invalid use of non-static data member}} -#endif - int f() { return n; } - // expected-error@-1 {{use of non-static data member 'n' of 'A' from nested type 'B'}} - }; - struct C; - struct D; - }; - struct A::C { - int m[sizeof(n)]; -#if __cplusplus < 201103L - // expected-error@-2 {{invalid use of non-static data member}} -#endif - int f() { return n; } - // expected-error@-1 {{use of non-static data member 'n' of 'A' from nested type 'C'}} - }; - struct A::D : A { - int m[sizeof(n)]; -#if __cplusplus < 201103L - // expected-error@-2 {{invalid use of non-static data member}} -#endif - int f() { return n; } - }; -} - -// dr199 FIXME: add codegen test diff --git a/test/CXX/drs/dr20xx.cpp b/test/CXX/drs/dr20xx.cpp deleted file mode 100644 index 5819c319fd54..000000000000 --- a/test/CXX/drs/dr20xx.cpp +++ /dev/null @@ -1,30 +0,0 @@ -// RUN: %clang_cc1 -std=c++98 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors \ -// RUN: -Wno-variadic-macros -Wno-c11-extensions -// RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++1z -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors - -// expected-no-diagnostics - -#if __cplusplus < 201103L -#define static_assert(...) _Static_assert(__VA_ARGS__) -#endif - -namespace dr2094 { // dr2094: 5 - struct A { int n; }; - struct B { volatile int n; }; - static_assert(__is_trivially_copyable(volatile int), ""); - static_assert(__is_trivially_copyable(const volatile int), ""); - static_assert(__is_trivially_copyable(const volatile int[]), ""); - static_assert(__is_trivially_copyable(A), ""); - static_assert(__is_trivially_copyable(volatile A), ""); - static_assert(__is_trivially_copyable(const volatile A), ""); - static_assert(__is_trivially_copyable(const volatile A[]), ""); - static_assert(__is_trivially_copyable(B), ""); - - static_assert(__is_trivially_constructible(A, A const&), ""); - static_assert(__is_trivially_constructible(B, B const&), ""); - - static_assert(__is_trivially_assignable(A, const A&), ""); - static_assert(__is_trivially_assignable(B, const B&), ""); -} diff --git a/test/CXX/drs/dr21xx.cpp b/test/CXX/drs/dr21xx.cpp deleted file mode 100644 index 2522ff7dbdef..000000000000 --- a/test/CXX/drs/dr21xx.cpp +++ /dev/null @@ -1,40 +0,0 @@ -// RUN: %clang_cc1 -std=c++98 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++1z -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors - -#if __cplusplus < 201103L -// expected-error@+1 {{variadic macro}} -#define static_assert(...) __extension__ _Static_assert(__VA_ARGS__) -#endif - -namespace dr2120 { // dr2120: 7 - struct A {}; - struct B : A {}; - struct C { A a; }; - struct D { C c[5]; }; - struct E : B { D d; }; - static_assert(__is_standard_layout(B), ""); - static_assert(__is_standard_layout(D), ""); - static_assert(!__is_standard_layout(E), ""); -} - -namespace dr2180 { // dr2180: yes - class A { - A &operator=(const A &); // expected-note 0-2{{here}} - A &operator=(A &&); // expected-note 0-2{{here}} expected-error 0-1{{extension}} - }; - - struct B : virtual A { - B &operator=(const B &); - B &operator=(B &&); // expected-error 0-1{{extension}} - virtual void foo() = 0; - }; -#if __cplusplus < 201103L - B &B::operator=(const B&) = default; // expected-error {{private member}} expected-error {{extension}} expected-note {{here}} - B &B::operator=(B&&) = default; // expected-error {{private member}} expected-error 2{{extension}} expected-note {{here}} -#else - B &B::operator=(const B&) = default; // expected-error {{would delete}} expected-note@-9{{inaccessible copy assignment}} - B &B::operator=(B&&) = default; // expected-error {{would delete}} expected-note@-10{{inaccessible move assignment}} -#endif -} diff --git a/test/CXX/drs/dr22xx.cpp b/test/CXX/drs/dr22xx.cpp deleted file mode 100644 index 70a26db757c3..000000000000 --- a/test/CXX/drs/dr22xx.cpp +++ /dev/null @@ -1,28 +0,0 @@ -// RUN: %clang_cc1 -std=c++98 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++1z -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors - -namespace dr2229 { // dr2229: 7 -struct AnonBitfieldQualifiers { - const unsigned : 1; // expected-error {{anonymous bit-field cannot have qualifiers}} - volatile unsigned : 1; // expected-error {{anonymous bit-field cannot have qualifiers}} - const volatile unsigned : 1; // expected-error {{anonymous bit-field cannot have qualifiers}} - - unsigned : 1; - const unsigned i1 : 1; - volatile unsigned i2 : 1; - const volatile unsigned i3 : 1; -}; -} - -#if __cplusplus >= 201103L -namespace dr2211 { // dr2211: 8 -void f() { - int a; - auto f = [a](int a) { (void)a; }; // expected-error {{a lambda parameter cannot shadow an explicitly captured entity}} - // expected-note@-1{{variable 'a' is explicitly captured here}} - auto g = [=](int a) { (void)a; }; -} -} -#endif diff --git a/test/CXX/drs/dr2xx.cpp b/test/CXX/drs/dr2xx.cpp deleted file mode 100644 index b69c014b587f..000000000000 --- a/test/CXX/drs/dr2xx.cpp +++ /dev/null @@ -1,1079 +0,0 @@ -// RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++17 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors - -// PR13819 -- __SIZE_TYPE__ is incompatible. -typedef __SIZE_TYPE__ size_t; // expected-error 0-1 {{extension}} - -#if __cplusplus < 201103L -#define fold(x) (__builtin_constant_p(x) ? (x) : (x)) -#else -#define fold -#endif - -namespace dr200 { // dr200: dup 214 - template <class T> T f(int); - template <class T, class U> T f(U) = delete; // expected-error 0-1{{extension}} - - void g() { - f<int>(1); - } -} - -// dr201 FIXME: write codegen test - -namespace dr202 { // dr202: yes - template<typename T> T f(); - template<int (*g)()> struct X { - int arr[fold(g == &f<int>) ? 1 : -1]; - }; - template struct X<f>; -} - -// FIXME (export) dr204: no - -namespace dr206 { // dr206: yes - struct S; // expected-note 2{{declaration}} - template<typename T> struct Q { S s; }; // expected-error {{incomplete}} - template<typename T> void f() { S s; } // expected-error {{incomplete}} -} - -namespace dr207 { // dr207: yes - class A { - protected: - static void f() {} - }; - class B : A { - public: - using A::f; - void g() { - A::f(); - f(); - } - }; -} - -// dr208 FIXME: write codegen test - -namespace dr209 { // dr209: yes - class A { - void f(); // expected-note {{here}} - }; - class B { - friend void A::f(); // expected-error {{private}} - }; -} - -// dr210 FIXME: write codegen test - -namespace dr211 { // dr211: yes - struct A { - A() try { - throw 0; - } catch (...) { - return; // expected-error {{return in the catch of a function try block of a constructor}} - } - }; -} - -namespace dr213 { // dr213: yes - template <class T> struct A : T { - void h(T t) { - char &r1 = f(t); - int &r2 = g(t); // expected-error {{undeclared}} - } - }; - struct B { - int &f(B); - int &g(B); // expected-note {{in dependent base class}} - }; - char &f(B); - - template void A<B>::h(B); // expected-note {{instantiation}} -} - -namespace dr214 { // dr214: yes - template<typename T, typename U> T checked_cast(U from) { U::error; } - template<typename T, typename U> T checked_cast(U *from); - class C {}; - void foo(int *arg) { checked_cast<const C *>(arg); } - - template<typename T> T f(int); - template<typename T, typename U> T f(U) { T::error; } - void g() { - f<int>(1); - } -} - -namespace dr215 { // dr215: yes - template<typename T> class X { - friend void T::foo(); - int n; - }; - struct Y { - void foo() { (void)+X<Y>().n; } - }; -} - -namespace dr216 { // dr216: no - // FIXME: Should reject this: 'f' has linkage but its type does not, - // and 'f' is odr-used but not defined in this TU. - typedef enum { e } *E; - void f(E); - void g(E e) { f(e); } - - struct S { - // FIXME: Should reject this: 'f' has linkage but its type does not, - // and 'f' is odr-used but not defined in this TU. - typedef enum { e } *E; - void f(E); - }; - void g(S s, S::E e) { s.f(e); } -} - -namespace dr217 { // dr217: yes - template<typename T> struct S { - void f(int); - }; - template<typename T> void S<T>::f(int = 0) {} // expected-error {{default arguments cannot be added}} -} - -namespace dr218 { // dr218: yes - namespace A { - struct S {}; - void f(S); - } - namespace B { - struct S {}; - void f(S); - } - - struct C { - int f; - void test1(A::S as) { f(as); } // expected-error {{called object type 'int'}} - void test2(A::S as) { void f(); f(as); } // expected-error {{too many arguments}} expected-note {{}} - void test3(A::S as) { using A::f; f(as); } // ok - void test4(A::S as) { using B::f; f(as); } // ok - void test5(A::S as) { int f; f(as); } // expected-error {{called object type 'int'}} - void test6(A::S as) { struct f {}; (void) f(as); } // expected-error {{no matching conversion}} expected-note +{{}} - }; - - namespace D { - struct S {}; - struct X { void operator()(S); } f; - } - void testD(D::S ds) { f(ds); } // expected-error {{undeclared identifier}} - - namespace E { - struct S {}; - struct f { f(S); }; - } - void testE(E::S es) { f(es); } // expected-error {{undeclared identifier}} - - namespace F { - struct S { - template<typename T> friend void f(S, T) {} - }; - } - void testF(F::S fs) { f(fs, 0); } - - namespace G { - namespace X { - int f; - struct A {}; - } - namespace Y { - template<typename T> void f(T); - struct B {}; - } - template<typename A, typename B> struct C {}; - } - void testG(G::C<G::X::A, G::Y::B> gc) { f(gc); } -} - -// dr219: na -// dr220: na - -namespace dr221 { // dr221: yes - struct A { // expected-note 2-4{{candidate}} - A &operator=(int&); // expected-note 2{{candidate}} - A &operator+=(int&); - static A &operator=(A&, double&); // expected-error {{cannot be a static member}} - static A &operator+=(A&, double&); // expected-error {{cannot be a static member}} - friend A &operator=(A&, char&); // expected-error {{must be a non-static member function}} - friend A &operator+=(A&, char&); - }; - A &operator=(A&, float&); // expected-error {{must be a non-static member function}} - A &operator+=(A&, float&); - - void test(A a, int n, char c, float f) { - a = n; - a += n; - a = c; // expected-error {{no viable}} - a += c; - a = f; // expected-error {{no viable}} - a += f; - } -} - -namespace dr222 { // dr222: dup 637 - void f(int a, int b, int c, int *x) { -#pragma clang diagnostic push -#pragma clang diagnostic warning "-Wunsequenced" - void((a += b) += c); - void((a += b) + (a += c)); // expected-warning {{multiple unsequenced modifications to 'a'}} - - x[a++] = a; // expected-warning {{unsequenced modification and access to 'a'}} - - a = b = 0; // ok, read and write of 'b' are sequenced - - a = (b = a++); // expected-warning {{multiple unsequenced modifications to 'a'}} - a = (b = ++a); -#pragma clang diagnostic pop - } -} - -// dr223: na - -namespace dr224 { // dr224: no - namespace example1 { - template <class T> class A { - typedef int type; - A::type a; - A<T>::type b; - A<T*>::type c; // expected-error {{missing 'typename'}} - ::dr224::example1::A<T>::type d; - - class B { - typedef int type; - - A::type a; - A<T>::type b; - A<T*>::type c; // expected-error {{missing 'typename'}} - ::dr224::example1::A<T>::type d; - - B::type e; - A<T>::B::type f; - A<T*>::B::type g; // expected-error {{missing 'typename'}} - typename A<T*>::B::type h; - }; - }; - - template <class T> class A<T*> { - typedef int type; - A<T*>::type a; - A<T>::type b; // expected-error {{missing 'typename'}} - }; - - template <class T1, class T2, int I> struct B { - typedef int type; - B<T1, T2, I>::type b1; - B<T2, T1, I>::type b2; // expected-error {{missing 'typename'}} - - typedef T1 my_T1; - static const int my_I = I; - static const int my_I2 = I+0; - static const int my_I3 = my_I; - B<my_T1, T2, my_I>::type b3; // FIXME: expected-error {{missing 'typename'}} - B<my_T1, T2, my_I2>::type b4; // expected-error {{missing 'typename'}} - B<my_T1, T2, my_I3>::type b5; // FIXME: expected-error {{missing 'typename'}} - }; - } - - namespace example2 { - template <int, typename T> struct X { typedef T type; }; - template <class T> class A { - static const int i = 5; - X<i, int>::type w; // FIXME: expected-error {{missing 'typename'}} - X<A::i, char>::type x; // FIXME: expected-error {{missing 'typename'}} - X<A<T>::i, double>::type y; // FIXME: expected-error {{missing 'typename'}} - X<A<T*>::i, long>::type z; // expected-error {{missing 'typename'}} - int f(); - }; - template <class T> int A<T>::f() { - return i; - } - } -} - -// dr225: yes -template<typename T> void dr225_f(T t) { dr225_g(t); } // expected-error {{call to function 'dr225_g' that is neither visible in the template definition nor found by argument-dependent lookup}} -void dr225_g(int); // expected-note {{should be declared prior to the call site}} -template void dr225_f(int); // expected-note {{in instantiation of}} - -namespace dr226 { // dr226: no - template<typename T = void> void f() {} -#if __cplusplus < 201103L - // expected-error@-2 {{extension}} - // FIXME: This appears to be wrong: default arguments for function templates - // are listed as a defect (in c++98) not an extension. EDG accepts them in - // strict c++98 mode. -#endif - template<typename T> struct S { - template<typename U = void> void g(); -#if __cplusplus < 201103L - // expected-error@-2 {{extension}} -#endif - template<typename U> struct X; - template<typename U> void h(); - }; - template<typename T> template<typename U> void S<T>::g() {} - template<typename T> template<typename U = void> struct S<T>::X {}; // expected-error {{cannot add a default template arg}} - template<typename T> template<typename U = void> void S<T>::h() {} // expected-error {{cannot add a default template arg}} - - template<typename> void friend_h(); - struct A { - // FIXME: This is ill-formed. - template<typename=void> struct friend_B; - // FIXME: f, h, and i are ill-formed. - // f is ill-formed because it is not a definition. - // h and i are ill-formed because they are not the only declarations of the - // function in the translation unit. - template<typename=void> void friend_f(); - template<typename=void> void friend_g() {} - template<typename=void> void friend_h() {} - template<typename=void> void friend_i() {} -#if __cplusplus < 201103L - // expected-error@-5 {{extension}} expected-error@-4 {{extension}} - // expected-error@-4 {{extension}} expected-error@-3 {{extension}} -#endif - }; - template<typename> void friend_i(); - - template<typename=void, typename X> void foo(X) {} - template<typename=void, typename X> struct Foo {}; // expected-error {{missing a default argument}} expected-note {{here}} -#if __cplusplus < 201103L - // expected-error@-3 {{extension}} -#endif - - template<typename=void, typename X, typename, typename Y> int foo(X, Y); - template<typename, typename X, typename=void, typename Y> int foo(X, Y); - int x = foo(0, 0); -#if __cplusplus < 201103L - // expected-error@-4 {{extension}} - // expected-error@-4 {{extension}} -#endif -} - -void dr227(bool b) { // dr227: yes - if (b) - int n; - else - int n; -} - -namespace dr228 { // dr228: yes - template <class T> struct X { - void f(); - }; - template <class T> struct Y { - void g(X<T> x) { x.template X<T>::f(); } - }; -} - -namespace dr229 { // dr229: yes - template<typename T> void f(); - template<typename T> void f<T*>() {} // expected-error {{function template partial specialization}} - template<> void f<int>() {} -} - -namespace dr230 { // dr230: yes - struct S { - S() { f(); } // expected-warning {{call to pure virtual member function}} - virtual void f() = 0; // expected-note {{declared here}} - }; -} - -namespace dr231 { // dr231: yes - namespace outer { - namespace inner { - int i; // expected-note {{here}} - } - void f() { using namespace inner; } - int j = i; // expected-error {{undeclared identifier 'i'; did you mean 'inner::i'?}} - } -} - -// dr234: na -// dr235: na - -namespace dr236 { // dr236: yes - void *p = int(); -#if __cplusplus < 201103L - // expected-warning@-2 {{null pointer}} -#else - // expected-error@-4 {{cannot initialize}} -#endif -} - -namespace dr237 { // dr237: dup 470 - template<typename T> struct A { void f() { T::error; } }; - template<typename T> struct B : A<T> {}; - template struct B<int>; // ok -} - -namespace dr239 { // dr239: yes - namespace NS { - class T {}; - void f(T); - float &g(T, int); - } - NS::T parm; - int &g(NS::T, float); - int main() { - f(parm); - float &r = g(parm, 1); - extern int &g(NS::T, float); - int &s = g(parm, 1); - } -} - -// dr240: dup 616 - -namespace dr241 { // dr241: yes - namespace A { - struct B {}; - template <int X> void f(); // expected-note 2{{candidate}} - template <int X> void g(B); - } - namespace C { - template <class T> void f(T t); // expected-note 2{{candidate}} - template <class T> void g(T t); // expected-note {{candidate}} - } - void h(A::B b) { - f<3>(b); // expected-error {{undeclared identifier}} - g<3>(b); // expected-error {{undeclared identifier}} - A::f<3>(b); // expected-error {{no matching}} - A::g<3>(b); - C::f<3>(b); // expected-error {{no matching}} - C::g<3>(b); // expected-error {{no matching}} - using C::f; - using C::g; - f<3>(b); // expected-error {{no matching}} - g<3>(b); - } -} - -namespace dr243 { // dr243: yes - struct B; - struct A { - A(B); // expected-note {{candidate}} - }; - struct B { - operator A() = delete; // expected-error 0-1{{extension}} expected-note {{candidate}} - } b; - A a1(b); - A a2 = b; // expected-error {{ambiguous}} -} - -namespace dr244 { // dr244: partial - struct B {}; struct D : B {}; // expected-note {{here}} - - D D_object; - typedef B B_alias; - B* B_ptr = &D_object; - - void f() { - D_object.~B(); // expected-error {{expression does not match the type}} - D_object.B::~B(); - B_ptr->~B(); - B_ptr->~B_alias(); - B_ptr->B_alias::~B(); - // This is valid under DR244. - B_ptr->B_alias::~B_alias(); - B_ptr->dr244::~B(); // expected-error {{refers to a member in namespace}} - B_ptr->dr244::~B_alias(); // expected-error {{refers to a member in namespace}} - } - - namespace N { - template<typename T> struct E {}; - typedef E<int> F; - } - void g(N::F f) { - typedef N::F G; - f.~G(); - f.G::~E(); - f.G::~F(); // expected-error {{expected the class name after '~' to name a destructor}} - f.G::~G(); - // This is technically ill-formed; E is looked up in 'N::' and names the - // class template, not the injected-class-name of the class. But that's - // probably a bug in the standard. - f.N::F::~E(); - // This is valid; we look up the second F in the same scope in which we - // found the first one, that is, 'N::'. - f.N::F::~F(); // FIXME: expected-error {{expected the class name after '~' to name a destructor}} - // This is technically ill-formed; G is looked up in 'N::' and is not found; - // as above, this is probably a bug in the standard. - f.N::F::~G(); - } -} - -namespace dr245 { // dr245: yes - struct S { - enum E {}; // expected-note {{here}} - class E *p; // expected-error {{does not match previous declaration}} - }; -} - -namespace dr246 { // dr246: yes - struct S { - S() try { // expected-note {{try block}} - throw 0; -X: ; - } catch (int) { - goto X; // expected-error {{cannot jump}} - } - }; -} - -namespace dr247 { // dr247: yes - struct A {}; - struct B : A { - void f(); - void f(int); - }; - void (A::*f)() = (void (A::*)())&B::f; - - struct C { - void f(); - void f(int); - }; - struct D : C {}; - void (C::*g)() = &D::f; - void (D::*h)() = &D::f; - - struct E { - void f(); - }; - struct F : E { - using E::f; - void f(int); - }; - void (F::*i)() = &F::f; -} - -namespace dr248 { // dr248: yes c++11 - // FIXME: Should this also apply to c++98 mode? This was a DR against C++98. - int \u040d\u040e = 0; -#if __cplusplus < 201103L - // FIXME: expected-error@-2 {{expected ';'}} -#endif -} - -namespace dr249 { // dr249: yes - template<typename T> struct X { void f(); }; - template<typename T> void X<T>::f() {} -} - -namespace dr250 { // dr250: yes - typedef void (*FPtr)(double x[]); - - template<int I> void f(double x[]); - FPtr fp = &f<3>; - - template<int I = 3> void g(double x[]); // expected-error 0-1{{extension}} - FPtr gp = &g<>; -} - -namespace dr252 { // dr252: yes - struct A { - void operator delete(void*); // expected-note {{found}} - }; - struct B { - void operator delete(void*); // expected-note {{found}} - }; - struct C : A, B { - virtual ~C(); - }; - C::~C() {} // expected-error {{'operator delete' found in multiple base classes}} - - struct D { - void operator delete(void*, int); // expected-note {{here}} - virtual ~D(); - }; - D::~D() {} // expected-error {{no suitable member 'operator delete'}} - - struct E { - void operator delete(void*, int); - void operator delete(void*) = delete; // expected-error 0-1{{extension}} expected-note 1-2 {{here}} - virtual ~E(); // expected-error 0-1 {{attempt to use a deleted function}} - }; - E::~E() {} // expected-error {{attempt to use a deleted function}} - - struct F { - // If both functions are available, the first one is a placement delete. - void operator delete(void*, size_t); - void operator delete(void*) = delete; // expected-error 0-1{{extension}} expected-note {{here}} - virtual ~F(); - }; - F::~F() {} // expected-error {{attempt to use a deleted function}} - - struct G { - void operator delete(void*, size_t); - virtual ~G(); - }; - G::~G() {} -} - -namespace dr254 { // dr254: yes - template<typename T> struct A { - typedef typename T::type type; // ok even if this is a typedef-name, because - // it's not an elaborated-type-specifier - typedef struct T::type foo; // expected-error {{typedef 'type' cannot be referenced with a struct specifier}} - }; - struct B { struct type {}; }; - struct C { typedef struct {} type; }; // expected-note {{here}} - A<B>::type n; - A<C>::type n; // expected-note {{instantiation of}} -} - -// dr256: dup 624 - -namespace dr257 { // dr257: yes - struct A { A(int); }; // expected-note {{here}} - struct B : virtual A { - B() {} - virtual void f() = 0; - }; - struct C : B { - C() {} - }; - struct D : B { - D() {} // expected-error {{must explicitly initialize the base class 'dr257::A'}} - void f(); - }; -} - -namespace dr258 { // dr258: yes - struct A { - void f(const int); - template<typename> void g(int); - float &h() const; - }; - struct B : A { - using A::f; - using A::g; - using A::h; - int &f(int); - template<int> int &g(int); // expected-note {{candidate}} - int &h(); - } b; - int &w = b.f(0); - int &x = b.g<int>(0); // expected-error {{no match}} - int &y = b.h(); - float &z = const_cast<const B&>(b).h(); - - struct C { - virtual void f(const int) = 0; - }; - struct D : C { - void f(int); - } d; - - struct E { - virtual void f() = 0; // expected-note {{unimplemented}} - }; - struct F : E { - void f() const {} - } f; // expected-error {{abstract}} -} - -namespace dr259 { // dr259: 4 - template<typename T> struct A {}; - template struct A<int>; // expected-note {{previous}} - template struct A<int>; // expected-error {{duplicate explicit instantiation}} - - template<> struct A<float>; // expected-note {{previous}} - template struct A<float>; // expected-warning {{has no effect}} - - template struct A<char>; // expected-note {{here}} - template<> struct A<char>; // expected-error {{explicit specialization of 'dr259::A<char>' after instantiation}} - - template<> struct A<double>; - template<> struct A<double>; - template<> struct A<double> {}; // expected-note {{here}} - template<> struct A<double> {}; // expected-error {{redefinition}} - - template<typename T> struct B; // expected-note {{here}} - template struct B<int>; // expected-error {{undefined}} - - template<> struct B<float>; // expected-note {{previous}} - template struct B<float>; // expected-warning {{has no effect}} -} - -// FIXME: When dr260 is resolved, also add tests for DR507. - -namespace dr261 { // dr261: no -#pragma clang diagnostic push -#pragma clang diagnostic warning "-Wused-but-marked-unused" - - // FIXME: This is ill-formed, with a diagnostic required, because operator new - // and operator delete are inline and odr-used, but not defined in this - // translation unit. - // We're also missing the -Wused-but-marked-unused diagnostic here. - struct A { - inline void *operator new(size_t) __attribute__((unused)); - inline void operator delete(void*) __attribute__((unused)); - A() {} - }; - - // FIXME: This is ill-formed, with a required diagnostic, for the same - // reason. - struct B { - inline void operator delete(void*) __attribute__((unused)); - ~B() {} - }; - struct C { - inline void operator delete(void*) __attribute__((unused)); - virtual ~C() {} // expected-warning {{'operator delete' was marked unused but was used}} - }; - - struct D { - inline void operator delete(void*) __attribute__((unused)); - }; - void h() { C::operator delete(0); } // expected-warning {{marked unused but was used}} - -#pragma clang diagnostic pop -} - -namespace dr262 { // dr262: yes - int f(int = 0, ...); - int k = f(); - int l = f(0); - int m = f(0, 0); -} - -namespace dr263 { // dr263: yes - struct X {}; - struct Y { -#if __cplusplus < 201103L - friend X::X() throw(); - friend X::~X() throw(); -#else - friend constexpr X::X() noexcept; - friend X::~X(); -#endif - Y::Y(); // expected-error {{extra qualification}} - Y::~Y(); // expected-error {{extra qualification}} - }; -} - -// dr265: dup 353 -// dr266: na -// dr269: na -// dr270: na - -namespace dr272 { // dr272: yes - struct X { - void f() { - this->~X(); - X::~X(); - ~X(); // expected-error {{unary expression}} - } - }; -} - -#include <stdarg.h> -#include <stddef.h> -namespace dr273 { // dr273: yes - struct A { - int n; - }; - void operator&(A); - void f(A a, ...) { - offsetof(A, n); - va_list val; - va_start(val, a); - va_end(val); - } -} - -// dr274: na - -namespace dr275 { // dr275: no - namespace N { - template <class T> void f(T) {} // expected-note 1-4{{here}} - template <class T> void g(T) {} // expected-note {{candidate}} - template <> void f(int); - template <> void f(char); - template <> void f(double); - template <> void g(char); - } - - using namespace N; - - namespace M { - template <> void N::f(char) {} // expected-error {{'M' does not enclose namespace 'N'}} - template <class T> void g(T) {} - template <> void g(char) {} - template void f(long); -#if __cplusplus >= 201103L - // FIXME: this should be rejected in c++98 too - // expected-error@-3 {{must occur in namespace 'N'}} -#endif - template void N::f(unsigned long); -#if __cplusplus >= 201103L - // FIXME: this should be rejected in c++98 too - // expected-error@-3 {{not in a namespace enclosing 'N'}} -#endif - template void h(long); // expected-error {{does not refer to a function template}} - template <> void f(double) {} // expected-error {{no function template matches}} - } - - template <class T> void g(T) {} // expected-note {{candidate}} - - template <> void N::f(char) {} - template <> void f(int) {} // expected-error {{no function template matches}} - - template void f(short); -#if __cplusplus >= 201103L - // FIXME: this should be rejected in c++98 too - // expected-error@-3 {{must occur in namespace 'N'}} -#endif - template void N::f(unsigned short); - - // FIXME: this should probably be valid. the wording from the issue - // doesn't clarify this, but it follows from the usual rules. - template void g(int); // expected-error {{ambiguous}} - - // FIXME: likewise, this should also be valid. - template<typename T> void f(T) {} // expected-note {{candidate}} - template void f(short); // expected-error {{ambiguous}} -} - -// dr276: na - -namespace dr277 { // dr277: yes - typedef int *intp; - int *p = intp(); - int a[fold(intp() ? -1 : 1)]; -} - -namespace dr280 { // dr280: yes - typedef void f0(); - typedef void f1(int); - typedef void f2(int, int); - typedef void f3(int, int, int); - struct A { - operator f1*(); // expected-note {{here}} expected-note {{candidate}} - operator f2*(); - }; - struct B { - operator f0*(); // expected-note {{candidate}} - private: - operator f3*(); // expected-note {{here}} expected-note {{candidate}} - }; - struct C { - operator f0*(); // expected-note {{candidate}} - operator f1*(); // expected-note {{candidate}} - operator f2*(); // expected-note {{candidate}} - operator f3*(); // expected-note {{candidate}} - }; - struct D : private A, B { // expected-note 2{{here}} - operator f2*(); // expected-note {{candidate}} - } d; - struct E : C, D {} e; - void g() { - d(); // ok, public - d(0); // expected-error {{private member of 'dr280::A'}} expected-error {{private base class 'dr280::A'}} - d(0, 0); // ok, suppressed by member in D - d(0, 0, 0); // expected-error {{private member of 'dr280::B'}} - e(); // expected-error {{ambiguous}} - e(0); // expected-error {{ambiguous}} - e(0, 0); // expected-error {{ambiguous}} - e(0, 0, 0); // expected-error {{ambiguous}} - } -} - -namespace dr281 { // dr281: no - void a(); - inline void b(); - - void d(); - inline void e(); - - struct S { - friend inline void a(); // FIXME: ill-formed - friend inline void b(); - friend inline void c(); // FIXME: ill-formed - friend inline void d() {} - friend inline void e() {} - friend inline void f() {} - }; -} - -namespace dr283 { // dr283: yes - template<typename T> // expected-note 2{{here}} - struct S { - friend class T; // expected-error {{shadows}} - class T; // expected-error {{shadows}} - }; -} - -namespace dr284 { // dr284: no - namespace A { - struct X; - enum Y {}; - class Z {}; - } - namespace B { - struct W; - using A::X; - using A::Y; - using A::Z; - } - struct B::V {}; // expected-error {{no struct named 'V'}} - struct B::W {}; - struct B::X {}; // FIXME: ill-formed - enum B::Y e; // ok per dr417 - class B::Z z; // ok per dr417 - - struct C { - struct X; - enum Y {}; - class Z {}; - }; - struct D : C { - struct W; - using C::X; - using C::Y; - using C::Z; - }; - struct D::V {}; // expected-error {{no struct named 'V'}} - struct D::W {}; - struct D::X {}; // FIXME: ill-formed - enum D::Y e2; // ok per dr417 - class D::Z z2; // ok per dr417 -} - -namespace dr285 { // dr285: yes - template<typename T> void f(T, int); // expected-note {{match}} - template<typename T> void f(int, T); // expected-note {{match}} - template<> void f<int>(int, int) {} // expected-error {{ambiguous}} -} - -namespace dr286 { // dr286: yes - template<class T> struct A { - class C { - template<class T2> struct B {}; // expected-note {{here}} - }; - }; - - template<class T> - template<class T2> - struct A<T>::C::B<T2*> { }; - - A<short>::C::B<int*> absip; // expected-error {{private}} -} - -// dr288: na - -namespace dr289 { // dr289: yes - struct A; // expected-note {{forward}} - struct B : A {}; // expected-error {{incomplete}} - - template<typename T> struct C { typename T::error error; }; // expected-error {{cannot be used prior to '::'}} - struct D : C<int> {}; // expected-note {{instantiation}} -} - -// dr290: na -// dr291: dup 391 -// dr292 FIXME: write a codegen test - -namespace dr294 { // dr294: no - void f() throw(int); -#if __cplusplus > 201402L - // expected-error@-2 {{ISO C++17 does not allow}} expected-note@-2 {{use 'noexcept}} -#endif - int main() { - (void)static_cast<void (*)() throw()>(f); // FIXME: ill-formed in C++14 and before -#if __cplusplus > 201402L - // FIXME: expected-error@-2 {{not allowed}} - // - // Irony: the above is valid in C++17 and beyond, but that's exactly when - // we reject it. In C++14 and before, this is ill-formed because an - // exception-specification is not permitted in a type-id. In C++17, this is - // valid because it's the inverse of a standard conversion sequence - // containing a function pointer conversion. (Well, it's actually not valid - // yet, as a static_cast is not permitted to reverse a function pointer - // conversion, but that is being changed by core issue). -#endif - (void)static_cast<void (*)() throw(int)>(f); // FIXME: ill-formed in C++14 and before -#if __cplusplus > 201402L - // expected-error@-2 {{ISO C++17 does not allow}} expected-note@-2 {{use 'noexcept}} -#endif - - void (*p)() throw() = f; // expected-error-re {{{{not superset|different exception specification}}}} - void (*q)() throw(int) = f; -#if __cplusplus > 201402L - // expected-error@-2 {{ISO C++17 does not allow}} expected-note@-2 {{use 'noexcept}} -#endif - } -} - -namespace dr295 { // dr295: 3.7 - typedef int f(); - const f g; // expected-warning {{'const' qualifier on function type 'dr295::f' (aka 'int ()') has no effect}} - f &r = g; - template<typename T> struct X { - const T &f; - }; - X<f> x = {g}; - - typedef int U(); - typedef const U U; // expected-warning {{'const' qualifier on function type 'dr295::U' (aka 'int ()') has no effect}} - - typedef int (*V)(); - typedef volatile U *V; // expected-warning {{'volatile' qualifier on function type 'dr295::U' (aka 'int ()') has no effect}} -} - -namespace dr296 { // dr296: yes - struct A { - static operator int() { return 0; } // expected-error {{static}} - }; -} - -namespace dr298 { // dr298: yes - struct A { - typedef int type; - A(); - ~A(); - }; - typedef A B; // expected-note {{here}} - typedef const A C; // expected-note {{here}} - - A::type i1; - B::type i2; - C::type i3; - - struct A a; - struct B b; // expected-error {{typedef 'B' cannot be referenced with a struct specifier}} - struct C c; // expected-error {{typedef 'C' cannot be referenced with a struct specifier}} - - B::B() {} // expected-error {{requires a type specifier}} - B::A() {} // ok - C::~C() {} // expected-error {{destructor cannot be declared using a typedef 'dr298::C' (aka 'const dr298::A') of the class name}} - - typedef struct D E; // expected-note {{here}} - struct E {}; // expected-error {{conflicts with typedef}} - - struct F { - ~F(); - }; - typedef const F G; - G::~F() {} // ok -} - -namespace dr299 { // dr299: yes c++11 - struct S { - operator int(); - }; - struct T { - operator int(); // expected-note {{}} - operator unsigned short(); // expected-note {{}} - }; - // FIXME: should this apply to c++98 mode? - int *p = new int[S()]; // expected-error 0-1{{extension}} - int *q = new int[T()]; // expected-error {{ambiguous}} -} diff --git a/test/CXX/drs/dr3xx.cpp b/test/CXX/drs/dr3xx.cpp deleted file mode 100644 index d723c5b78cdf..000000000000 --- a/test/CXX/drs/dr3xx.cpp +++ /dev/null @@ -1,1380 +0,0 @@ -// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++98 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++11 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++1z %s -verify -fexceptions -fcxx-exceptions -pedantic-errors - -namespace dr300 { // dr300: yes - template<typename R, typename A> void f(R (&)(A)) {} - int g(int); - void h() { f(g); } -} - -namespace dr301 { // dr301: yes - // see also dr38 - struct S; - template<typename T> void operator+(T, T); - void operator-(S, S); - - void f() { - bool a = (void(*)(S, S))operator+<S> < - (void(*)(S, S))operator+<S>; - bool b = (void(*)(S, S))operator- < - (void(*)(S, S))operator-; - bool c = (void(*)(S, S))operator+ < - (void(*)(S, S))operator-; // expected-error {{expected '>'}} - } - - template<typename T> void f() { - typename T::template operator+<int> a; // expected-error {{typename specifier refers to a non-type template}} expected-error +{{}} - // FIXME: This shouldn't say (null). - class T::template operator+<int> b; // expected-error {{identifier followed by '<' indicates a class template specialization but (null) refers to a function template}} - enum T::template operator+<int> c; // expected-error {{expected identifier}} expected-error {{does not declare anything}} - enum T::template operator+<int>::E d; // expected-error {{qualified name refers into a specialization of function template 'T::template operator +'}} expected-error {{forward reference}} - enum T::template X<int>::E e; - T::template operator+<int>::foobar(); // expected-error {{qualified name refers into a specialization of function template 'T::template operator +'}} - T::template operator+<int>(0); // ok - } - - template<typename T> class operator&<T*> {}; // expected-error +{{}} - template<typename T> class T::operator& {}; // expected-error +{{}} - template<typename T> class S::operator&<T*> {}; // expected-error +{{}} -} - -namespace dr302 { // dr302: yes - struct A { A(); ~A(); }; -#if __cplusplus < 201103L - struct B { // expected-error {{implicit default constructor for 'dr302::B' must explicitly initialize the const member 'n'}} - const int n; // expected-note {{declared here}} - A a; - } b = B(); // expected-note {{first required here}} - // Trivial default constructor C::C() is not called here. - struct C { - const int n; - } c = C(); -#else - struct B { - const int n; // expected-note {{deleted because field 'n' of const-qualified type 'const int' would not be initialized}} - A a; - } b = B(); // expected-error {{call to implicitly-deleted default constructor}} - // C::C() is called here, because even though it's trivial, it's deleted. - struct C { - const int n; // expected-note {{deleted because field 'n' of const-qualified type 'const int' would not be initialized}} - } c = C(); // expected-error {{call to implicitly-deleted default constructor}} - struct D { - const int n = 0; - } d = D(); -#endif -} - -// dr303: na - -namespace dr304 { // dr304: yes - typedef int &a; - int n = a(); // expected-error {{requires an initializer}} - - struct S { int &b; }; - int m = S().b; -#if __cplusplus < 201103L - // expected-error@-3 {{requires an initializer}} - // expected-note@-3 {{in value-initialization}} -#else - // expected-error@-5 {{deleted}} - // expected-note@-7 {{reference}} -#endif -} - -namespace dr305 { // dr305: no - struct A { - typedef A C; - }; - void f(A *a) { - struct A {}; - a->~A(); - a->~C(); - } - typedef A B; - void g(B *b) { - b->~B(); - b->~C(); - } - void h(B *b) { - struct B {}; // expected-note {{declared here}} - b->~B(); // expected-error {{does not match}} - } - - template<typename T> struct X {}; - void i(X<int>* x) { - struct X {}; - x->~X<int>(); - x->~X(); - x->~X<char>(); // expected-error {{no member named}} - } - -#if __cplusplus >= 201103L - struct Y { - template<typename T> using T1 = Y; - }; - template<typename T> using T2 = Y; - void j(Y *y) { - y->~T1<int>(); - y->~T2<int>(); - } - struct Z { - template<typename T> using T2 = T; - }; - void k(Z *z) { - z->~T1<int>(); // expected-error {{no member named 'T1' in 'dr305::Z'}} expected-error +{{}} - z->~T2<int>(); // expected-error {{no member named '~int'}} - z->~T2<Z>(); - } - - // FIXME: This is valid. - namespace Q { - template<typename A> struct R {}; - } - template<typename A> using R = Q::R<int>; - void qr(Q::R<int> x) { x.~R<char>(); } // expected-error {{no member named}} -#endif -} - -namespace dr306 { // dr306: no - // FIXME: dup 39 - // FIXME: This should be accepted. - struct A { struct B {}; }; // expected-note 2{{member}} - struct C { typedef A::B B; }; // expected-note {{member}} - struct D : A, A::B, C {}; - D::B b; // expected-error {{found in multiple base classes of different types}} -} - -// dr307: na - -namespace dr308 { // dr308: yes - // This is mostly an ABI library issue. - struct A {}; - struct B : A {}; - struct C : A {}; - struct D : B, C {}; - void f() { - try { - throw D(); - } catch (const A&) { // expected-note {{for type 'const dr308::A &'}} - // unreachable - } catch (const B&) { // expected-warning {{exception of type 'const dr308::B &' will be caught by earlier handler}} - // get here instead - } - } -} - -// dr309: dup 485 - -namespace dr311 { // dr311: yes - namespace X { namespace Y {} } - namespace X::Y {} -#if __cplusplus <= 201402L - // expected-error@-2 {{define each namespace separately}} -#endif - namespace X { - namespace X::Y {} -#if __cplusplus <= 201402L - // expected-error@-2 {{define each namespace separately}} -#endif - } - // FIXME: The diagnostics here are not very good. - namespace ::dr311::X {} // expected-error 2+{{}} // expected-warning {{extra qual}} -} - -// dr312: dup 616 - -namespace dr313 { // dr313: dup 299 c++11 - struct A { operator int() const; }; - int *p = new int[A()]; -#if __cplusplus < 201103L - // FIXME: should this be available in c++98 mode? expected-error@-2 {{extension}} -#endif -} - -namespace dr314 { // FIXME 314: dup 1710 - template<typename T> struct A { - template<typename U> struct B {}; - }; - template<typename T> struct C : public A<T>::template B<T> { - C() : A<T>::template B<T>() {} - }; -} - -// dr315: na -// dr316: sup 1004 - -namespace dr317 { // dr317: 3.5 - void f() {} // expected-note {{previous}} - inline void f(); // expected-error {{inline declaration of 'f' follows non-inline definition}} - - int g(); - int n = g(); - inline int g() { return 0; } - - int h(); - int m = h(); - int h() { return 0; } // expected-note {{previous}} - inline int h(); // expected-error {{inline declaration of 'h' follows non-inline definition}} -} - -namespace dr318 { // dr318: sup 1310 - struct A {}; - struct A::A a; -} - -namespace dr319 { // dr319: no - // FIXME: dup dr389 - // FIXME: We don't have a diagnostic for a name with linkage - // having a type without linkage. - typedef struct { - int i; - } *ps; - extern "C" void f(ps); - void g(ps); // FIXME: ill-formed, type 'ps' has no linkage - - static enum { e } a1; - enum { e2 } a2; // FIXME: ill-formed, enum type has no linkage - - enum { n1 = 1u }; - typedef int (*pa)[n1]; - pa parr; // ok, type has linkage despite using 'n1' - - template<typename> struct X {}; - - void f() { - struct A { int n; }; - extern A a; // FIXME: ill-formed - X<A> xa; - - typedef A B; - extern B b; // FIXME: ill-formed - X<B> xb; - - const int n = 1; - typedef int (*C)[n]; - extern C c; // ok - X<C> xc; - } -#if __cplusplus < 201103L - // expected-error@-12 {{uses local type 'A'}} - // expected-error@-9 {{uses local type 'A'}} -#endif -} - -namespace dr320 { // dr320: yes -#if __cplusplus >= 201103L - struct X { - constexpr X() {} - constexpr X(const X &x) : copies(x.copies + 1) {} - unsigned copies = 0; - }; - constexpr X f(X x) { return x; } - constexpr unsigned g(X x) { return x.copies; } - static_assert(f(X()).copies == g(X()) + 1, "expected one extra copy for return value"); -#endif -} - -namespace dr321 { // dr321: dup 557 - namespace N { - template<int> struct A { - template<int> struct B; - }; - template<> template<> struct A<0>::B<0>; - void f(A<0>::B<0>); - } - template<> template<> struct N::A<0>::B<0> {}; - - template<typename T> void g(T t) { f(t); } - template void g(N::A<0>::B<0>); - - namespace N { - template<typename> struct I { friend bool operator==(const I&, const I&); }; - } - N::I<int> i, j; - bool x = i == j; -} - -namespace dr322 { // dr322: yes - struct A { - template<typename T> operator T&(); - } a; - int &r = static_cast<int&>(a); - int &s = a; -} - -// dr323: no - -namespace dr324 { // dr324: yes - struct S { int n : 1; } s; // expected-note 3{{bit-field is declared here}} - int &a = s.n; // expected-error {{non-const reference cannot bind to bit-field}} - int *b = &s.n; // expected-error {{address of bit-field}} - int &c = (s.n = 0); // expected-error {{non-const reference cannot bind to bit-field}} - int *d = &(s.n = 0); // expected-error {{address of bit-field}} - int &e = true ? s.n : s.n; // expected-error {{non-const reference cannot bind to bit-field}} - int *f = &(true ? s.n : s.n); // expected-error {{address of bit-field}} - int &g = (void(), s.n); // expected-error {{non-const reference cannot bind to bit-field}} - int *h = &(void(), s.n); // expected-error {{address of bit-field}} - int *i = &++s.n; // expected-error {{address of bit-field}} -} - -namespace dr326 { // dr326: yes - struct S {}; - int test[__is_trivially_constructible(S, const S&) ? 1 : -1]; -} - -namespace dr327 { // dr327: dup 538 - struct A; - class A {}; - - class B; - struct B {}; -} - -namespace dr328 { // dr328: yes - struct A; // expected-note 3{{forward declaration}} - struct B { A a; }; // expected-error {{incomplete}} - template<typename> struct C { A a; }; // expected-error {{incomplete}} - A *p = new A[0]; // expected-error {{incomplete}} -} - -namespace dr329 { // dr329: 3.5 - struct B {}; - template<typename T> struct A : B { - friend void f(A a) { g(a); } - friend void h(A a) { g(a); } // expected-error {{undeclared}} - friend void i(B b) {} // expected-error {{redefinition}} expected-note {{previous}} - }; - A<int> a; - A<char> b; // expected-note {{instantiation}} - - void test() { - h(a); // expected-note {{instantiation}} - } -} - -namespace dr330 { // dr330: 7 - // Conversions between P and Q will be allowed by P0388. - typedef int *(*P)[3]; - typedef const int *const (*Q)[3]; - typedef const int *Qinner[3]; - typedef Qinner const *Q2; // same as Q, but 'const' written outside the array type - typedef const int *const (*R)[4]; - typedef const int *const (*S)[]; - typedef const int *(*T)[]; - void f(P p, Q q, Q2 q2, R r, S s, T t) { - q = p; // ok - q2 = p; // ok - r = p; // expected-error {{incompatible}} - s = p; // expected-error {{incompatible}} (for now) - t = p; // expected-error {{incompatible}} - s = q; // expected-error {{incompatible}} - s = q2; // expected-error {{incompatible}} - s = t; // ok, adding const - t = s; // expected-error {{incompatible}} - (void) const_cast<P>(q); - (void) const_cast<P>(q2); - (void) const_cast<Q>(p); - (void) const_cast<Q2>(p); - (void) const_cast<S>(p); // expected-error {{not allowed}} (for now) - (void) const_cast<P>(s); // expected-error {{not allowed}} (for now) - (void) const_cast<S>(q); // expected-error {{not allowed}} - (void) const_cast<S>(q2); // expected-error {{not allowed}} - (void) const_cast<Q>(s); // expected-error {{not allowed}} - (void) const_cast<Q2>(s); // expected-error {{not allowed}} - (void) const_cast<T>(s); - (void) const_cast<S>(t); - (void) const_cast<T>(q); // expected-error {{not allowed}} - (void) const_cast<Q>(t); // expected-error {{not allowed}} - - (void) reinterpret_cast<P>(q); // expected-error {{casts away qualifiers}} - (void) reinterpret_cast<P>(q2); // expected-error {{casts away qualifiers}} - (void) reinterpret_cast<Q>(p); - (void) reinterpret_cast<Q2>(p); - (void) reinterpret_cast<S>(p); - (void) reinterpret_cast<P>(s); // expected-error {{casts away qualifiers}} - (void) reinterpret_cast<S>(q); - (void) reinterpret_cast<S>(q2); - (void) reinterpret_cast<Q>(s); - (void) reinterpret_cast<Q2>(s); - (void) reinterpret_cast<T>(s); // expected-error {{casts away qualifiers}} - (void) reinterpret_cast<S>(t); - (void) reinterpret_cast<T>(q); // expected-error {{casts away qualifiers}} - (void) reinterpret_cast<Q>(t); - } - - namespace swift_17882 { - typedef const char P[72]; - typedef int *Q; - void f(P &pr, P *pp) { - (void) reinterpret_cast<const Q&>(pr); - (void) reinterpret_cast<const Q*>(pp); - } - - struct X {}; - typedef const volatile int A[1][2][3]; - typedef int *const X::*volatile *B1; - typedef int *const X::* *B2; - typedef int *X::* volatile *B3; - typedef volatile int *(*const B4)[4]; - void f(A *a) { - (void) reinterpret_cast<B1*>(a); - (void) reinterpret_cast<B2*>(a); // expected-error {{casts away qualifiers}} - (void) reinterpret_cast<B3*>(a); // expected-error {{casts away qualifiers}} - (void) reinterpret_cast<B4*>(a); - } - } -} - -namespace dr331 { // dr331: yes - struct A { - A(volatile A&); // expected-note {{candidate}} - } const a, b(a); // expected-error {{no matching constructor}} -} - -namespace dr332 { // dr332: dup 577 - void f(volatile void); // expected-error {{'void' as parameter must not have type qualifiers}} - void g(const void); // expected-error {{'void' as parameter must not have type qualifiers}} - void h(int n, volatile void); // expected-error {{'void' must be the first and only parameter}} -} - -namespace dr333 { // dr333: yes - int n = 0; - int f(int(n)); - int g((int(n))); - int h = f(g); -} - -namespace dr334 { // dr334: yes - template<typename T> void f() { - T x; - f((x, 123)); - } - struct S { - friend S operator,(S, int); - friend void f(S); - }; - template void f<S>(); -} - -// dr335: no - -namespace dr336 { // dr336: yes - namespace Pre { - template<class T1> class A { - template<class T2> class B { - template<class T3> void mf1(T3); - void mf2(); - }; - }; - template<> template<class X> class A<int>::B {}; - template<> template<> template<class T> void A<int>::B<double>::mf1(T t) {} // expected-error {{does not match}} - template<class Y> template<> void A<Y>::B<double>::mf2() {} // expected-error {{does not refer into a class}} - } - namespace Post { - template<class T1> class A { - template<class T2> class B { - template<class T3> void mf1(T3); - void mf2(); - }; - }; - template<> template<class X> class A<int>::B { - template<class T> void mf1(T); - }; - template<> template<> template<class T> void A<int>::B<double>::mf1(T t) {} - // FIXME: This diagnostic isn't very good. - template<class Y> template<> void A<Y>::B<double>::mf2() {} // expected-error {{does not refer into a class}} - } -} - -namespace dr337 { // dr337: yes - template<typename T> void f(T (*)[1]); - template<typename T> int &f(...); - - struct A { virtual ~A() = 0; }; - int &r = f<A>(0); - - // FIXME: The language rules here are completely broken. We cannot determine - // whether an incomplete type is abstract. See DR1640, which will probably - // supersede this one and remove this rule. - struct B; - int &s = f<B>(0); // expected-error {{of type 'void'}} - struct B { virtual ~B() = 0; }; -} - -namespace dr339 { // dr339: yes - template <int I> struct A { static const int value = I; }; - - char xxx(int); - char (&xxx(float))[2]; - - template<class T> A<sizeof(xxx((T)0))> f(T) {} // expected-note {{candidate}} - - void test() { - A<1> a = f(0); - A<2> b = f(0.0f); - A<3> c = f("foo"); // expected-error {{no matching function}} - } - - - char f(int); - int f(...); - - template <class T> struct conv_int { - static const bool value = sizeof(f(T())) == 1; - }; - - template <class T> bool conv_int2(A<sizeof(f(T()))> p); - - template<typename T> A<sizeof(f(T()))> make_A(); - - int a[conv_int<char>::value ? 1 : -1]; - bool b = conv_int2<char>(A<1>()); - A<1> c = make_A<char>(); -} - -namespace dr340 { // dr340: yes - struct A { A(int); }; - struct B { B(A, A, int); }; - int x, y; - B b(A(x), A(y), 3); -} - -namespace dr341 { // dr341: sup 1708 - namespace A { - int n; - extern "C" int &dr341_a = n; // expected-note {{previous}} expected-note {{declared with C language linkage here}} - } - namespace B { - extern "C" int &dr341_a = dr341_a; // expected-error {{redefinition}} - } - extern "C" void dr341_b(); // expected-note {{declared with C language linkage here}} -} -int dr341_a; // expected-error {{declaration of 'dr341_a' in global scope conflicts with declaration with C language linkage}} -int dr341_b; // expected-error {{declaration of 'dr341_b' in global scope conflicts with declaration with C language linkage}} -int dr341_c; // expected-note {{declared in global scope here}} -int dr341_d; // expected-note {{declared in global scope here}} -namespace dr341 { - extern "C" int dr341_c; // expected-error {{declaration of 'dr341_c' with C language linkage conflicts with declaration in global scope}} - extern "C" void dr341_d(); // expected-error {{declaration of 'dr341_d' with C language linkage conflicts with declaration in global scope}} - - namespace A { extern "C" int dr341_e; } // expected-note {{previous}} - namespace B { extern "C" void dr341_e(); } // expected-error {{redefinition of 'dr341_e' as different kind of symbol}} -} - -// dr342: na - -namespace dr343 { // FIXME 343: no - // FIXME: dup 1710 - template<typename T> struct A { - template<typename U> struct B {}; - }; - // FIXME: In these contexts, the 'template' keyword is optional. - template<typename T> struct C : public A<T>::B<T> { // expected-error {{use 'template'}} - C() : A<T>::B<T>() {} // expected-error {{use 'template'}} - }; -} - -namespace dr344 { // dr344: dup 1435 - struct A { inline virtual ~A(); }; - struct B { friend A::~A(); }; -} - -namespace dr345 { // dr345: yes - struct A { - struct X {}; - int X; // expected-note {{here}} - }; - struct B { - struct X {}; - }; - template <class T> void f(T t) { typename T::X x; } // expected-error {{refers to non-type member 'X'}} - void f(A a, B b) { - f(b); - f(a); // expected-note {{instantiation}} - } -} - -// dr346: na - -namespace dr347 { // dr347: yes - struct base { - struct nested; - static int n; - static void f(); - void g(); - }; - - struct derived : base {}; - - struct derived::nested {}; // expected-error {{no struct named 'nested'}} - int derived::n; // expected-error {{no member named 'n'}} - void derived::f() {} // expected-error {{does not match any}} - void derived::g() {} // expected-error {{does not match any}} -} - -// dr348: na - -namespace dr349 { // dr349: no - struct A { - template <class T> operator T ***() { - int ***p = 0; - return p; // expected-error {{cannot initialize return object of type 'const int ***' with an lvalue of type 'int ***'}} - } - }; - - // FIXME: This is valid. - A a; - const int *const *const *p1 = a; // expected-note {{in instantiation of}} - - struct B { - template <class T> operator T ***() { - const int ***p = 0; - return p; - } - }; - - // FIXME: This is invalid. - B b; - const int *const *const *p2 = b; -} - -// dr351: na - -namespace dr352 { // dr352: yes - namespace example1 { - namespace A { - enum E {}; - template<typename R, typename A> void foo(E, R (*)(A)); // expected-note 2{{couldn't infer template argument 'R'}} - } - - template<typename T> void arg(T); - template<typename T> int arg(T) = delete; // expected-note {{here}} expected-error 0-1{{extension}} - - void f(A::E e) { - foo(e, &arg); // expected-error {{no matching function}} - - using A::foo; - foo<int, int>(e, &arg); // expected-error {{deleted}} - } - - int arg(int); - - void g(A::E e) { - foo(e, &arg); // expected-error {{no matching function}} - - using A::foo; - foo<int, int>(e, &arg); // ok, uses non-template - } - } - - namespace contexts { - template<int I> void f1(int (&)[I]); - template<int I> void f2(int (&)[I+1]); // expected-note {{couldn't infer}} - template<int I> void f3(int (&)[I+1], int (&)[I]); - void f() { - int a[4]; - int b[3]; - f1(a); - f2(a); // expected-error {{no matching function}} - f3(a, b); - } - - template<int I> struct S {}; - template<int I> void g1(S<I>); - template<int I> void g2(S<I+1>); // expected-note {{couldn't infer}} - template<int I> void g3(S<I+1>, S<I>); - void g() { - S<4> a; - S<3> b; - g1(a); - g2(a); // expected-error {{no matching function}} - g3(a, b); - } - - template<typename T> void h1(T = 0); // expected-note {{couldn't infer}} - template<typename T> void h2(T, T = 0); - void h() { - h1(); // expected-error {{no matching function}} - h1(0); - h1<int>(); - h2(0); - } - - template<typename T> int tmpl(T); - template<typename R, typename A> void i1(R (*)(A)); // expected-note 3{{couldn't infer}} - template<typename R, typename A> void i2(R, A, R (*)(A)); // expected-note {{not viable}} - void i() { - extern int single(int); - i1(single); - i2(0, 0, single); - - extern int ambig(float), ambig(int); - i1(ambig); // expected-error {{no matching function}} - i2(0, 0, ambig); - - extern void no_match(float), no_match(int); - i1(no_match); // expected-error {{no matching function}} - i2(0, 0, no_match); // expected-error {{no matching function}} - - i1(tmpl); // expected-error {{no matching function}} - i2(0, 0, tmpl); - } - } - - template<typename T> struct is_int; - template<> struct is_int<int> {}; - - namespace example2 { - template<typename T> int f(T (*p)(T)) { is_int<T>(); } - int g(int); - int g(char); - int i = f(g); - } - - namespace example3 { - template<typename T> int f(T, T (*p)(T)) { is_int<T>(); } - int g(int); - char g(char); - int i = f(1, g); - } - - namespace example4 { - template <class T> int f(T, T (*p)(T)) { is_int<T>(); } - char g(char); - template <class T> T g(T); - int i = f(1, g); - } - - namespace example5 { - template<int I> class A {}; - template<int I> void g(A<I+1>); // expected-note {{couldn't infer}} - template<int I> void f(A<I>, A<I+1>); - void h(A<1> a1, A<2> a2) { - g(a1); // expected-error {{no matching function}} - g<0>(a1); - f(a1, a2); - } - } -} - -// dr353 needs an IRGen test. - -namespace dr354 { // dr354: yes c++11 - // FIXME: Should we allow this in C++98 too? - struct S {}; - - template<int*> struct ptr {}; // expected-note 0-4{{here}} - ptr<0> p0; - ptr<(int*)0> p1; - ptr<(float*)0> p2; - ptr<(int S::*)0> p3; -#if __cplusplus < 201103L - // expected-error@-5 {{does not refer to any decl}} - // expected-error@-5 {{does not refer to any decl}} - // expected-error@-5 {{does not refer to any decl}} - // expected-error@-5 {{does not refer to any decl}} -#elif __cplusplus <= 201402L - // expected-error@-10 {{must be cast}} - // ok - // expected-error@-10 {{does not match}} - // expected-error@-10 {{does not match}} -#else - // expected-error@-15 {{conversion from 'int' to 'int *' is not allowed}} - // ok - // expected-error@-15 {{'float *' is not implicitly convertible to 'int *'}} - // expected-error@-15 {{'int dr354::S::*' is not implicitly convertible to 'int *'}} -#endif - - template<int*> int both(); - template<int> int both(); - int b0 = both<0>(); - int b1 = both<(int*)0>(); -#if __cplusplus < 201103L - // expected-error@-2 {{no matching function}} - // expected-note@-6 {{candidate}} - // expected-note@-6 {{candidate}} -#endif - - template<int S::*> struct ptr_mem {}; // expected-note 0-4{{here}} - ptr_mem<0> m0; - ptr_mem<(int S::*)0> m1; - ptr_mem<(float S::*)0> m2; - ptr_mem<(int *)0> m3; -#if __cplusplus < 201103L - // expected-error@-5 {{cannot be converted}} - // expected-error@-5 {{is not a pointer to member constant}} - // expected-error@-5 {{cannot be converted}} - // expected-error@-5 {{cannot be converted}} -#elif __cplusplus <= 201402L - // expected-error@-10 {{must be cast}} - // ok - // expected-error@-10 {{does not match}} - // expected-error@-10 {{does not match}} -#else - // expected-error@-15 {{conversion from 'int' to 'int dr354::S::*' is not allowed}} - // ok - // expected-error@-15 {{'float dr354::S::*' is not implicitly convertible to 'int dr354::S::*'}} - // expected-error@-15 {{'int *' is not implicitly convertible to 'int dr354::S::*'}} -#endif -} - -struct dr355_S; // dr355: yes -struct ::dr355_S {}; // expected-warning {{extra qualification}} -namespace dr355 { struct ::dr355_S s; } - -// dr356: na - -namespace dr357 { // dr357: yes - template<typename T> struct A { - void f() const; // expected-note {{const qualified}} - }; - template<typename T> void A<T>::f() {} // expected-error {{does not match}} - - struct B { - template<typename T> void f(); - }; - template<typename T> void B::f() const {} // expected-error {{does not match}} -} - -namespace dr358 { // dr358: yes - extern "C" void dr358_f(); - namespace N { - int var; - extern "C" void dr358_f() { var = 10; } - } -} - -namespace dr359 { // dr359: yes - // Note, the example in the DR is wrong; it doesn't contain an anonymous - // union. - struct E { - union { - struct { - int x; - } s; - } v; - - union { - struct { // expected-error {{extension}} - int x; - } s; - - struct S { // expected-error {{types cannot be declared in an anonymous union}} - int x; - } t; - - union { // expected-error {{extension}} - int u; - }; - }; - }; -} - -// dr362: na -// dr363: na - -namespace dr364 { // dr364: yes - struct S { - static void f(int); - void f(char); - }; - - void g() { - S::f('a'); // expected-error {{call to non-static}} - S::f(0); - } -} - -#if "foo" // expected-error {{invalid token}} dr366: yes -#endif - -namespace dr367 { // dr367: yes - // FIXME: These diagnostics are terrible. Don't diagnose an ill-formed global - // array as being a VLA! - int a[true ? throw 0 : 4]; // expected-error 2{{variable length array}} - int b[true ? 4 : throw 0]; - int c[true ? *new int : 4]; // expected-error 2{{variable length array}} - int d[true ? 4 : *new int]; -#if __cplusplus < 201103L - // expected-error@-4 {{variable length array}} expected-error@-4 {{constant expression}} - // expected-error@-3 {{variable length array}} expected-error@-3 {{constant expression}} -#endif -} - -namespace dr368 { // dr368: yes - template<typename T, T> struct S {}; // expected-note {{here}} - template<typename T> int f(S<T, T()> *); // expected-error {{function type}} - //template<typename T> int g(S<T, (T())> *); // FIXME: crashes clang - template<typename T> int g(S<T, true ? T() : T()> *); // expected-note {{cannot have type 'dr368::X'}} - struct X {}; - int n = g<X>(0); // expected-error {{no matching}} -} - -// dr370: na - -namespace dr372 { // dr372: no - namespace example1 { - template<typename T> struct X { - protected: - typedef T Type; // expected-note 2{{protected}} - }; - template<typename T> struct Y {}; - - // FIXME: These two are valid; deriving from T1<T> gives Z1 access to - // the protected member T1<T>::Type. - template<typename T, - template<typename> class T1, - template<typename> class T2> struct Z1 : - T1<T>, - T2<typename T1<T>::Type> {}; // expected-error {{protected}} - - template<typename T, - template<typename> class T1, - template<typename> class T2> struct Z2 : - T2<typename T1<T>::Type>, // expected-error {{protected}} - T1<T> {}; - - Z1<int, X, Y> z1; // expected-note {{instantiation of}} - Z2<int, X, Y> z2; // expected-note {{instantiation of}} - } - - namespace example2 { - struct X { - private: - typedef int Type; // expected-note {{private}} - }; - template<typename T> struct A { - typename T::Type t; // expected-error {{private}} - }; - A<X> ax; // expected-note {{instantiation of}} - } - - namespace example3 { - struct A { - protected: - typedef int N; // expected-note 2{{protected}} - }; - - template<typename T> struct B {}; - template<typename U> struct C : U, B<typename U::N> {}; // expected-error {{protected}} - template<typename U> struct D : B<typename U::N>, U {}; // expected-error {{protected}} - - C<A> x; // expected-note {{instantiation of}} - D<A> y; // expected-note {{instantiation of}} - } - - namespace example4 { - class A { - class B {}; - friend class X; - }; - - struct X : A::B { - A::B mx; - class Y { - A::B my; - }; - }; - } - - // FIXME: This is valid: deriving from A gives D access to A::B - namespace std_example { - class A { - protected: - struct B {}; // expected-note {{here}} - }; - struct D : A::B, A {}; // expected-error {{protected}} - } - - // FIXME: This is valid: deriving from A::B gives access to A::B! - namespace badwolf { - class A { - protected: - struct B; // expected-note {{here}} - }; - struct A::B : A {}; - struct C : A::B {}; // expected-error {{protected}} - } -} - -namespace dr373 { // dr373: 5 - namespace X { int dr373; } - struct dr373 { // expected-note {{here}} - void f() { - using namespace dr373::X; - int k = dr373; // expected-error {{does not refer to a value}} - - namespace Y = dr373::X; - k = Y::dr373; - } - }; - - struct A { struct B {}; }; // expected-note 2{{here}} - namespace X = A::B; // expected-error {{expected namespace name}} - using namespace A::B; // expected-error {{expected namespace name}} -} - -namespace dr374 { // dr374: yes - namespace N { - template<typename T> void f(); - template<typename T> struct A { void f(); }; - } - template<> void N::f<char>() {} - template<> void N::A<char>::f() {} - template<> struct N::A<int> {}; -} - -// dr375: dup 345 -// dr376: na - -namespace dr377 { // dr377: yes - enum E { // expected-error {{enumeration values exceed range of largest integer}} - a = -__LONG_LONG_MAX__ - 1, // expected-error 0-1{{extension}} - b = 2 * (unsigned long long)__LONG_LONG_MAX__ // expected-error 0-2{{extension}} - }; -} - -// dr378: dup 276 -// dr379: na - -namespace dr381 { // dr381: yes - struct A { - int a; - }; - struct B : virtual A {}; - struct C : B {}; - struct D : B {}; - struct E : public C, public D {}; - struct F : public A {}; - void f() { - E e; - e.B::a = 0; // expected-error {{ambiguous conversion}} - F f; - f.A::a = 1; - } -} - -namespace dr382 { // dr382: yes c++11 - // FIXME: Should we allow this in C++98 mode? - struct A { typedef int T; }; - typename A::T t; - typename dr382::A a; -#if __cplusplus < 201103L - // expected-error@-3 {{occurs outside of a template}} - // expected-error@-3 {{occurs outside of a template}} -#endif - typename A b; // expected-error {{expected a qualified name}} -} - -namespace dr383 { // dr383: yes - struct A { A &operator=(const A&); }; - struct B { ~B(); }; - union C { C &operator=(const C&); }; - union D { ~D(); }; - int check[(__is_pod(A) || __is_pod(B) || __is_pod(C) || __is_pod(D)) ? -1 : 1]; -} - -namespace dr384 { // dr384: yes - namespace N1 { - template<typename T> struct Base {}; - template<typename T> struct X { - struct Y : public Base<T> { - Y operator+(int) const; - }; - Y f(unsigned i) { return Y() + i; } - }; - } - - namespace N2 { - struct Z {}; - template<typename T> int *operator+(T, unsigned); - } - - int main() { - N1::X<N2::Z> v; - v.f(0); - } -} - -namespace dr385 { // dr385: yes - struct A { protected: void f(); }; - struct B : A { using A::f; }; - struct C : A { void g(B b) { b.f(); } }; - void h(B b) { b.f(); } - - struct D { int n; }; // expected-note {{member}} - struct E : protected D {}; // expected-note 2{{protected}} - struct F : E { friend int i(E); }; - int i(E e) { return e.n; } // expected-error {{protected base}} expected-error {{protected member}} -} - -namespace dr387 { // dr387: yes - namespace old { - template<typename T> class number { - number(int); // expected-note 2{{here}} - friend number gcd(number &x, number &y) {} - }; - - void g() { - number<double> a(3), b(4); // expected-error 2{{private}} - a = gcd(a, b); - b = gcd(3, 4); // expected-error {{undeclared}} - } - } - - namespace newer { - template <typename T> class number { - public: - number(int); - friend number gcd(number x, number y) { return 0; } - }; - - void g() { - number<double> a(3), b(4); - a = gcd(a, b); - b = gcd(3, 4); // expected-error {{undeclared}} - } - } -} - -// FIXME: dr388 needs codegen test - -namespace dr389 { // dr389: no - struct S { - typedef struct {} A; - typedef enum {} B; - typedef struct {} const C; // expected-note 0-2{{here}} - typedef enum {} const D; // expected-note 0-1{{here}} - }; - template<typename> struct T {}; - - struct WithLinkage1 {}; - enum WithLinkage2 {}; - typedef struct {} *WithLinkage3a, WithLinkage3b; - typedef enum {} WithLinkage4a, *WithLinkage4b; - typedef S::A WithLinkage5; - typedef const S::B WithLinkage6; - typedef int WithLinkage7; - typedef void (*WithLinkage8)(WithLinkage2 WithLinkage1::*, WithLinkage5 *); - typedef T<WithLinkage5> WithLinkage9; - - typedef struct {} *WithoutLinkage1; // expected-note 0-1{{here}} - typedef enum {} const WithoutLinkage2; // expected-note 0-1{{here}} - // These two types don't have linkage even though they are externally visible - // and the ODR requires them to be merged across TUs. - typedef S::C WithoutLinkage3; - typedef S::D WithoutLinkage4; - typedef void (*WithoutLinkage5)(int (WithoutLinkage3::*)(char)); - -#if __cplusplus >= 201103L - // This has linkage even though its template argument does not. - // FIXME: This is probably a defect. - typedef T<WithoutLinkage1> WithLinkage10; -#else - typedef int WithLinkage10; // dummy - - typedef T<WithLinkage1> GoodArg1; - typedef T<WithLinkage2> GoodArg2; - typedef T<WithLinkage3a> GoodArg3a; - typedef T<WithLinkage3b> GoodArg3b; - typedef T<WithLinkage4a> GoodArg4a; - typedef T<WithLinkage4b> GoodArg4b; - typedef T<WithLinkage5> GoodArg5; - typedef T<WithLinkage6> GoodArg6; - typedef T<WithLinkage7> GoodArg7; - typedef T<WithLinkage8> GoodArg8; - typedef T<WithLinkage9> GoodArg9; - - typedef T<WithoutLinkage1> BadArg1; // expected-error{{template argument uses}} - typedef T<WithoutLinkage2> BadArg2; // expected-error{{template argument uses}} - typedef T<WithoutLinkage3> BadArg3; // expected-error{{template argument uses}} - typedef T<WithoutLinkage4> BadArg4; // expected-error{{template argument uses}} - typedef T<WithoutLinkage5> BadArg5; // expected-error{{template argument uses}} -#endif - - extern WithLinkage1 withLinkage1; - extern WithLinkage2 withLinkage2; - extern WithLinkage3a withLinkage3a; - extern WithLinkage3b withLinkage3b; - extern WithLinkage4a withLinkage4a; - extern WithLinkage4b withLinkage4b; - extern WithLinkage5 withLinkage5; - extern WithLinkage6 withLinkage6; - extern WithLinkage7 withLinkage7; - extern WithLinkage8 withLinkage8; - extern WithLinkage9 withLinkage9; - extern WithLinkage10 withLinkage10; - - // FIXME: These are all ill-formed. - extern WithoutLinkage1 withoutLinkage1; - extern WithoutLinkage2 withoutLinkage2; - extern WithoutLinkage3 withoutLinkage3; - extern WithoutLinkage4 withoutLinkage4; - extern WithoutLinkage5 withoutLinkage5; - - // OK, extern "C". - extern "C" { - extern WithoutLinkage1 dr389_withoutLinkage1; - extern WithoutLinkage2 dr389_withoutLinkage2; - extern WithoutLinkage3 dr389_withoutLinkage3; - extern WithoutLinkage4 dr389_withoutLinkage4; - extern WithoutLinkage5 dr389_withoutLinkage5; - } - - // OK, defined. - WithoutLinkage1 withoutLinkageDef1; - WithoutLinkage2 withoutLinkageDef2 = WithoutLinkage2(); - WithoutLinkage3 withoutLinkageDef3 = {}; - WithoutLinkage4 withoutLinkageDef4 = WithoutLinkage4(); - WithoutLinkage5 withoutLinkageDef5; - - void use(const void *); - void use_all() { - use(&withLinkage1); use(&withLinkage2); use(&withLinkage3a); use(&withLinkage3b); - use(&withLinkage4a); use(&withLinkage4b); use(&withLinkage5); use(&withLinkage6); - use(&withLinkage7); use(&withLinkage8); use(&withLinkage9); use(&withLinkage10); - - use(&withoutLinkage1); use(&withoutLinkage2); use(&withoutLinkage3); - use(&withoutLinkage4); use(&withoutLinkage5); - - use(&dr389_withoutLinkage1); use(&dr389_withoutLinkage2); - use(&dr389_withoutLinkage3); use(&dr389_withoutLinkage4); - use(&dr389_withoutLinkage5); - - use(&withoutLinkageDef1); use(&withoutLinkageDef2); use(&withoutLinkageDef3); - use(&withoutLinkageDef4); use(&withoutLinkageDef5); - } - - void local() { - // FIXME: This is ill-formed. - extern WithoutLinkage1 withoutLinkageLocal; - } -} - -namespace dr390 { // dr390: yes - template<typename T> - struct A { - A() { f(); } // expected-warning {{call to pure virt}} - virtual void f() = 0; // expected-note {{here}} - virtual ~A() = 0; - }; - template<typename T> A<T>::~A() { T::error; } // expected-error {{cannot be used prior to}} - template<typename T> void A<T>::f() { T::error; } // ok, not odr-used - struct B : A<int> { // expected-note 2{{in instantiation of}} - void f() {} - } b; -} - -namespace dr391 { // dr391: yes c++11 - // FIXME: Should this apply to C++98 too? - class A { A(const A&); }; // expected-note 0-1{{here}} - A fa(); - const A &a = fa(); -#if __cplusplus < 201103L - // expected-error@-2 {{C++98 requires an accessible copy constructor}} -#endif - - struct B { B(const B&) = delete; }; // expected-error 0-1{{extension}} expected-note 0-1{{here}} - B fb(); - const B &b = fb(); -#if __cplusplus < 201103L - // expected-error@-2 {{deleted}} -#endif - - template<typename T> - struct C { - C(const C&) { T::error; } - }; - C<int> fc(); - const C<int> &c = fc(); -} - -// dr392 FIXME write codegen test -// dr394: na - -namespace dr395 { // dr395: yes - struct S { - template <typename T, int N>(&operator T())[N]; // expected-error {{cannot specify any part of a return type}} - template <typename T, int N> operator(T (&)[N])(); // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error +{{}} - template <typename T> operator T *() const { return 0; } - template <typename T, typename U> operator T U::*() const { return 0; } - template <typename T, typename U> operator T (U::*)()() const { return 0; } // expected-error +{{}} - }; - - struct null1_t { - template <class T, class U> struct ptr_mem_fun_t { - typedef T (U::*type)(); - }; - - template <class T, class U> - operator typename ptr_mem_fun_t<T, U>::type() const { // expected-note {{couldn't infer}} - return 0; - } - } null1; - int (S::*p)() = null1; // expected-error {{no viable conversion}} - - template <typename T> using id = T; // expected-error 0-1{{extension}} - - struct T { - template <typename T, int N> operator id<T[N]> &(); - template <typename T, typename U> operator id<T (U::*)()>() const; - }; - - struct null2_t { - template<class T, class U> using ptr_mem_fun_t = T (U::*)(); // expected-error 0-1{{extension}} - template<class T, class U> operator ptr_mem_fun_t<T, U>() const { return 0; }; - } null2; - int (S::*q)() = null2; -} - -namespace dr396 { // dr396: yes - void f() { - auto int a(); // expected-error {{storage class on function}} - int (i); // expected-note {{previous}} - auto int (i); // expected-error {{redefinition}} -#if __cplusplus >= 201103L - // expected-error@-4 {{'auto' storage class}} expected-error@-2 {{'auto' storage class}} -#endif - } -} - -// dr397: sup 1823 - -namespace dr398 { // dr398: yes - namespace example1 { - struct S { - static int const I = 42; - }; - template <int N> struct X {}; - template <typename T> void f(X<T::I> *) {} - template <typename T> void f(X<T::J> *) {} - void foo() { f<S>(0); } - } - - namespace example2 { - template <int I> struct X {}; - template <template <class T> class> struct Z {}; - template <class T> void f(typename T::Y *) {} // expected-note 2{{substitution failure}} - template <class T> void g(X<T::N> *) {} // expected-note {{substitution failure}} - template <class T> void h(Z<T::template TT> *) {} // expected-note {{substitution failure}} - struct A {}; - struct B { - int Y; - }; - struct C { - typedef int N; - }; - struct D { - typedef int TT; - }; - - void test() { - f<A>(0); // expected-error {{no matching function}} - f<B>(0); // expected-error {{no matching function}} - g<C>(0); // expected-error {{no matching function}} - h<D>(0); // expected-error {{no matching function}} - } - } -} diff --git a/test/CXX/drs/dr412.cpp b/test/CXX/drs/dr412.cpp deleted file mode 100644 index 27bc7e5cf94e..000000000000 --- a/test/CXX/drs/dr412.cpp +++ /dev/null @@ -1,21 +0,0 @@ -// RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -DNOEXCEPT="throw()" -DBAD_ALLOC="throw(std::bad_alloc)" -// RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -DNOEXCEPT=noexcept -DBAD_ALLOC= -// RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -DNOEXCEPT=noexcept -DBAD_ALLOC= -// RUN: %clang_cc1 -std=c++1z %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -DNOEXCEPT=noexcept -DBAD_ALLOC= - -// dr412: yes -// lwg404: yes -// lwg2340: yes - -// FIXME: __SIZE_TYPE__ expands to 'long long' on some targets. -__extension__ typedef __SIZE_TYPE__ size_t; -namespace std { struct bad_alloc {}; } - -inline void* operator new(size_t) BAD_ALLOC; // expected-error {{cannot be declared 'inline'}} -inline void* operator new[](size_t) BAD_ALLOC; // expected-error {{cannot be declared 'inline'}} -inline void operator delete(void*) NOEXCEPT; // expected-error {{cannot be declared 'inline'}} -inline void operator delete[](void*) NOEXCEPT; // expected-error {{cannot be declared 'inline'}} -#ifdef __cpp_sized_deallocation -inline void operator delete(void*, size_t) NOEXCEPT; // expected-error {{cannot be declared 'inline'}} -inline void operator delete[](void*, size_t) NOEXCEPT; // expected-error {{cannot be declared 'inline'}} -#endif diff --git a/test/CXX/drs/dr4xx.cpp b/test/CXX/drs/dr4xx.cpp deleted file mode 100644 index 00393cc2e4c0..000000000000 --- a/test/CXX/drs/dr4xx.cpp +++ /dev/null @@ -1,1229 +0,0 @@ -// RUN: env ASAN_OPTIONS=detect_stack_use_after_return=0 %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: env ASAN_OPTIONS=detect_stack_use_after_return=0 %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: env ASAN_OPTIONS=detect_stack_use_after_return=0 %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: env ASAN_OPTIONS=detect_stack_use_after_return=0 %clang_cc1 -std=c++17 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors - -// FIXME: __SIZE_TYPE__ expands to 'long long' on some targets. -__extension__ typedef __SIZE_TYPE__ size_t; - -namespace std { struct type_info; } - -namespace dr400 { // dr400: yes - struct A { int a; struct a {}; }; // expected-note 2{{conflicting}} expected-note {{ambiguous}} - struct B { int a; struct a {}; }; // expected-note 2{{target}} expected-note {{ambiguous}} - struct C : A, B { using A::a; struct a b; }; - struct D : A, B { using A::a; using B::a; struct a b; }; // expected-error 2{{conflicts}} - struct E : A, B { struct a b; }; // expected-error {{found in multiple base classes}} -} - -namespace dr401 { // dr401: yes - template<class T, class U = typename T::type> class A : public T {}; // expected-error {{protected}} expected-error 2{{private}} - - class B { - protected: - typedef int type; // expected-note {{protected}} -#if __cplusplus == 199711L - // expected-note@-2 {{protected}} -#endif - }; - - class C { - typedef int type; // expected-note {{private}} - friend class A<C>; // expected-note {{default argument}} - }; - - class D { - typedef int type; // expected-note {{private}} - friend class A<D, int>; - }; - - A<B> *b; // expected-note {{default argument}} - A<D> *d; // expected-note {{in instantiation of default argument}} - - struct E { - template<class T, class U = typename T::type> class A : public T {}; - }; - class F { - typedef int type; - friend class E; - }; - E::A<F> eaf; // ok, default argument is in befriended context - - // FIXME: Why do we get different diagnostics in C++11 onwards here? We seem - // to not treat the default template argument as a SFINAE context in C++98. - template<class T, class U = typename T::type> void f(T) {} - void g(B b) { f(b); } -#if __cplusplus < 201103L - // expected-error@-3 0-1{{extension}} expected-error@-3 {{protected}} expected-note@-3 {{instantiation}} - // expected-note@-3 {{substituting}} -#else - // expected-error@-5 {{no matching}} expected-note@-6 {{protected}} -#endif -} - -namespace dr403 { // dr403: yes - namespace A { - struct S {}; - int f(void*); - } - template<typename T> struct X {}; - typedef struct X<A::S>::X XS; - XS *p; - int k = f(p); // ok, finds A::f, even though type XS is a typedef-name - // referring to an elaborated-type-specifier naming a - // injected-class-name, which is about as far from a - // template-id as we can make it. -} - -// dr404: na -// (NB: also sup 594) - -namespace dr406 { // dr406: yes - typedef struct { - static int n; // expected-error {{static data member 'n' not allowed in anonymous struct}} - } A; -} - -namespace dr407 { // dr407: 3.8 - struct S; - typedef struct S S; - void f() { - struct S *p; - { - typedef struct S S; // expected-note {{here}} - struct S *p; // expected-error {{typedef 'S' cannot be referenced with a struct specifier}} - } - } - struct S {}; - - namespace UsingDir { - namespace A { - struct S {}; // expected-note {{found}} - } - namespace B { - typedef int S; // expected-note {{found}} - } - namespace C { - using namespace A; - using namespace B; - struct S s; // expected-error {{ambiguous}} - } - namespace D { - using A::S; - typedef struct S S; - struct S s; - } - namespace E { - // The standard doesn't say whether this is valid. We interpret - // DR407 as meaning "if lookup finds both a tag and a typedef with the - // same type, then it's OK in an elaborated-type-specifier". - typedef A::S S; - using A::S; - struct S s; - } - namespace F { - typedef A::S S; - } - // The standard doesn't say what to do in these cases either. - namespace G { - using namespace A; - using namespace F; - struct S s; - } - namespace H { - using namespace F; - using namespace A; - struct S s; - } - } -} - -namespace dr408 { // dr408: 3.4 - template<int N> void g() { int arr[N != 1 ? 1 : -1]; } - template<> void g<2>() { } - - template<typename T> struct S { - static int i[]; - void f(); - }; - template<typename T> int S<T>::i[] = { 1 }; - - template<typename T> void S<T>::f() { - g<sizeof (i) / sizeof (int)>(); - } - template<> int S<int>::i[] = { 1, 2 }; - template void S<int>::f(); // uses g<2>(), not g<1>(). - - - template<typename T> struct R { - static int arr[]; - void f(); - }; - template<typename T> int R<T>::arr[1]; - template<typename T> void R<T>::f() { - int arr[sizeof(arr) != sizeof(int) ? 1 : -1]; - } - template<> int R<int>::arr[2]; - template void R<int>::f(); -} - -namespace dr409 { // dr409: yes - template<typename T> struct A { - typedef int B; - B b1; - A::B b2; - A<T>::B b3; - A<T*>::B b4; // expected-error {{missing 'typename'}} - }; -} - -namespace dr410 { // dr410: no - template<class T> void f(T); - void g(int); - namespace M { - template<class T> void h(T); - template<class T> void i(T); - struct A { - friend void f<>(int); - friend void h<>(int); - friend void g(int); - template<class T> void i(T); - friend void i<>(int); - private: - static void z(); // expected-note {{private}} - }; - - template<> void h(int) { A::z(); } - // FIXME: This should be ill-formed. The member A::i<> is befriended, - // not this function. - template<> void i(int) { A::z(); } - } - template<> void f(int) { M::A::z(); } - void g(int) { M::A::z(); } // expected-error {{private}} -} - -// dr412 is in its own file. - -namespace dr413 { // dr413: yes - struct S { - int a; - int : 17; - int b; - }; - S s = { 1, 2, 3 }; // expected-error {{excess elements}} - - struct E {}; - struct T { // expected-note {{here}} - int a; - E e; - int b; - }; - T t1 = { 1, {}, 2 }; - T t2 = { 1, 2 }; // expected-error {{aggregate with no elements requires explicit braces}} -} - -namespace dr414 { // dr414: dup 305 - struct X {}; - void f() { - X x; - struct X {}; - x.~X(); - } -} - -namespace dr415 { // dr415: yes - template<typename T> void f(T, ...) { T::error; } - void f(int, int); - void g() { f(0, 0); } // ok -} - -namespace dr416 { // dr416: yes - extern struct A a; - int &operator+(const A&, const A&); - int &k = a + a; - struct A { float &operator+(A&); }; - float &f = a + a; -} - -namespace dr417 { // dr417: no - struct A; - struct dr417::A {}; // expected-warning {{extra qualification}} - struct B { struct X; }; - struct C : B {}; - struct C::X {}; // expected-error {{no struct named 'X' in 'dr417::C'}} - struct B::X { struct Y; }; - struct C::X::Y {}; // ok! - namespace N { - struct D; - struct E; - struct F; - struct H; - } - // FIXME: This is ill-formed. - using N::D; - struct dr417::D {}; // expected-warning {{extra qualification}} - using namespace N; - struct dr417::E {}; // expected-warning {{extra qualification}} expected-error {{no struct named 'E'}} - struct N::F {}; - struct G; - using N::H; - namespace M { - struct dr417::G {}; // expected-error {{namespace 'M' does not enclose}} - struct dr417::H {}; // expected-error {{namespace 'M' does not enclose}} - } -} - -namespace dr420 { // dr420: yes - template<typename T> struct ptr { - T *operator->() const; - T &operator*() const; - }; - template<typename T, typename P> void test(P p) { - p->~T(); - p->T::~T(); - (*p).~T(); - (*p).T::~T(); - } - struct X {}; - template void test<int>(int*); - template void test<int>(ptr<int>); - template void test<X>(X*); - template void test<X>(ptr<X>); - - template<typename T> - void test2(T p) { - p->template Y<int>::~Y<int>(); - p->~Y<int>(); - // FIXME: This is ill-formed, but this diagnostic is terrible. We should - // reject this in the parser. - p->template ~Y<int>(); // expected-error 2{{no member named '~typename Y<int>'}} - } - template<typename T> struct Y {}; - template void test2(Y<int>*); // expected-note {{instantiation}} - template void test2(ptr<Y<int> >); // expected-note {{instantiation}} - - void test3(int *p, ptr<int> q) { - typedef int Int; - p->~Int(); - q->~Int(); - p->Int::~Int(); - q->Int::~Int(); - } - -#if __cplusplus >= 201103L - template<typename T> using id = T; - struct A { template<typename T> using id = T; }; - void test4(int *p, ptr<int> q) { - p->~id<int>(); - q->~id<int>(); - p->id<int>::~id<int>(); - q->id<int>::~id<int>(); - p->template id<int>::~id<int>(); // expected-error {{'template' keyword not permitted here}} expected-error {{base type 'int' is not a struct}} - q->template id<int>::~id<int>(); // expected-error {{'template' keyword not permitted here}} expected-error {{base type 'int' is not a struct}} - p->A::template id<int>::~id<int>(); - q->A::template id<int>::~id<int>(); - } -#endif -} - -namespace dr421 { // dr421: yes - struct X { X(); int n; int &r; }; - int *p = &X().n; // expected-error-re {{{{taking the address of a temporary|cannot take the address of an rvalue}}}} - int *q = &X().r; -} - -namespace dr422 { // dr422: yes - template<typename T, typename U> void f() { - typedef T type; // expected-note {{prev}} - typedef U type; // expected-error {{redef}} - } - template void f<int, int>(); - template void f<int, char>(); // expected-note {{instantiation}} -} - -namespace dr423 { // dr423: yes - template<typename T> struct X { operator T&(); }; - void f(X<int> x) { x += 1; } -} - -namespace dr424 { // dr424: yes - struct A { - typedef int N; // expected-note {{previous}} - typedef int N; // expected-error {{redefinition}} - - struct X; - typedef X X; // expected-note {{previous}} - struct X {}; - - struct X *p; - struct A::X *q; - X *r; - - typedef X X; // expected-error {{redefinition}} - }; - struct B { - typedef int N; - }; - struct C : B { - typedef int N; // expected-note {{previous}} - typedef int N; // expected-error {{redefinition}} - }; -} - -namespace dr425 { // dr425: yes - struct A { template<typename T> operator T() const; } a; - float f = 1.0f * a; // expected-error {{ambiguous}} expected-note 5+{{built-in candidate}} - - template<typename T> struct is_float; - template<> struct is_float<float> { typedef void type; }; - - struct B { - template<typename T, typename U = typename is_float<T>::type> operator T() const; // expected-error 0-1{{extension}} - } b; - float g = 1.0f * b; // ok -} - -namespace dr427 { // dr427: yes - struct B {}; - struct D : public B { - D(B &) = delete; // expected-error 0-1{{extension}} expected-note {{deleted}} - }; - - extern D d1; - B &b = d1; - const D &d2 = static_cast<const D&>(b); - const D &d3 = (const D&)b; - const D &d4(b); // expected-error {{deleted}} -} - -namespace dr428 { // dr428: yes - template<typename T> T make(); - extern struct X x; // expected-note 5{{forward declaration}} - void f() { - throw void(); // expected-error {{cannot throw}} - throw make<void*>(); - throw make<const volatile void*>(); - throw x; // expected-error {{cannot throw}} - throw make<X&>(); // expected-error {{cannot throw}} - throw make<X*>(); // expected-error {{cannot throw}} - throw make<const volatile X&>(); // expected-error {{cannot throw}} - throw make<const volatile X*>(); // expected-error {{cannot throw}} - } -} - -namespace dr429 { // dr429: yes c++11 - // FIXME: This rule is obviously intended to apply to C++98 as well. - struct A { - static void *operator new(size_t, size_t); - static void operator delete(void*, size_t); - } *a = new (0) A; -#if __cplusplus >= 201103L - // expected-error@-2 {{'new' expression with placement arguments refers to non-placement 'operator delete'}} - // expected-note@-4 {{here}} -#endif - struct B { - static void *operator new(size_t, size_t); - static void operator delete(void*); - static void operator delete(void*, size_t); - } *b = new (0) B; // ok, second delete is not a non-placement deallocation function -} - -namespace dr430 { // dr430: yes c++11 - // resolved by n2239 - // FIXME: This should apply in C++98 too. - void f(int n) { - int a[] = { n++, n++, n++ }; -#if __cplusplus < 201103L - // expected-warning@-2 {{multiple unsequenced modifications to 'n'}} -#endif - } -} - -namespace dr431 { // dr431: yes - struct A { - template<typename T> T *get(); - template<typename T> struct B { - template<typename U> U *get(); - }; - }; - - template<typename T> void f(A a) { - a.get<A>()->get<T>(); - a.get<T>() - ->get<T>(); // expected-error {{use 'template'}} - a.get<T>()->template get<T>(); - a.A::get<T>(); - A::B<int> *b = a.get<A::B<int> >(); - b->get<int>(); - b->A::B<int>::get<int>(); - b->A::B<int>::get<T>(); - b->A::B<T>::get<int>(); // expected-error {{use 'template'}} - b->A::B<T>::template get<int>(); - b->A::B<T>::get<T>(); // expected-error {{use 'template'}} - b->A::B<T>::template get<T>(); - A::B<T> *c = a.get<A::B<T> >(); - c->get<int>(); // expected-error {{use 'template'}} - c->template get<int>(); - } -} - -namespace dr432 { // dr432: yes - template<typename T> struct A {}; - template<typename T> struct B : A<B> {}; // expected-error {{requires template arguments}} expected-note {{declared}} - template<typename T> struct C : A<C<T> > {}; -#if __cplusplus >= 201103L - template<typename T> struct D : decltype(A<D>()) {}; // expected-error {{requires template arguments}} expected-note {{declared}} -#endif -} - -namespace dr433 { // dr433: yes - template<class T> struct S { - void f(union U*); - }; - U *p; - template<class T> void S<T>::f(union U*) {} - - S<int> s; -} - -namespace dr434 { // dr434: yes - void f() { - const int ci = 0; - int *pi = 0; - const int *&rpci = pi; // expected-error {{cannot bind}} - rpci = &ci; - *pi = 1; - } -} - -// dr435: na - -namespace dr436 { // dr436: yes - enum E { f }; // expected-note {{previous}} - void f(); // expected-error {{redefinition}} -} - -namespace dr437 { // dr437: sup 1308 - // This is superseded by 1308, which is in turn superseded by 1330, - // which restores this rule. - template<typename U> struct T : U {}; - struct S { - void f() throw(S); -#if __cplusplus > 201402L - // expected-error@-2 {{ISO C++17 does not allow}} expected-note@-2 {{use 'noexcept}} -#endif - void g() throw(T<S>); -#if __cplusplus > 201402L - // expected-error@-2 {{ISO C++17 does not allow}} expected-note@-2 {{use 'noexcept}} -#endif - struct U; - void h() throw(U); -#if __cplusplus > 201402L - // expected-error@-2 {{ISO C++17 does not allow}} expected-note@-2 {{use 'noexcept}} -#endif - struct U {}; - }; -} - -// dr438 FIXME write a codegen test -// dr439 FIXME write a codegen test -// dr441 FIXME write a codegen test -// dr442: sup 348 -// dr443: na - -namespace dr444 { // dr444: yes - struct D; - struct B { // expected-note {{candidate function (the implicit copy}} expected-note 0-1 {{implicit move}} - D &operator=(D &) = delete; // expected-error 0-1{{extension}} expected-note {{deleted}} - }; - struct D : B { // expected-note {{candidate function (the implicit copy}} expected-note 0-1 {{implicit move}} - using B::operator=; - } extern d; - void f() { - d = d; // expected-error {{deleted}} - } -} - -namespace dr445 { // dr445: yes - class A { void f(); }; // expected-note {{private}} - struct B { - friend void A::f(); // expected-error {{private}} - }; -} - -namespace dr446 { // dr446: yes - struct C; - struct A { - A(); - A(const A&) = delete; // expected-error 0-1{{extension}} expected-note +{{deleted}} - A(const C&); - }; - struct C : A {}; - void f(A a, bool b, C c) { - void(b ? a : a); - b ? A() : a; // expected-error {{deleted}} - b ? a : A(); // expected-error {{deleted}} - b ? A() : A(); -#if __cplusplus <= 201402L - // expected-error@-2 {{deleted}} -#endif - - void(b ? a : c); - b ? a : C(); // expected-error {{deleted}} - b ? c : A(); -#if __cplusplus <= 201402L - // expected-error@-2 {{deleted}} -#endif - b ? A() : C(); -#if __cplusplus <= 201402L - // expected-error@-2 {{deleted}} -#endif - } -} - -namespace dr447 { // dr447: yes - struct A { int n; int a[4]; }; - template<int> struct U { - typedef int type; - template<typename V> static void h(); - }; - template<typename T> U<sizeof(T)> g(T); - template<typename T, int N> void f(int n) { - // ok, not type dependent - g(__builtin_offsetof(A, n)).h<int>(); - g(__builtin_offsetof(T, n)).h<int>(); - // value dependent if first argument is a dependent type - U<__builtin_offsetof(A, n)>::type a; - U<__builtin_offsetof(T, n)>::type b; // expected-error +{{}} expected-warning 0+{{}} - // as an extension, we allow the member-designator to include array indices - g(__builtin_offsetof(A, a[0])).h<int>(); - g(__builtin_offsetof(A, a[N])).h<int>(); - U<__builtin_offsetof(A, a[0])>::type c; - U<__builtin_offsetof(A, a[N])>::type d; // expected-error +{{}} expected-warning 0+{{}} - } -} - -namespace dr448 { // dr448: yes - template<typename T = int> void f(int); // expected-error 0-1{{extension}} expected-note {{no known conversion}} - template<typename T> void g(T t) { - f<T>(t); // expected-error {{neither visible in the template definition nor found by argument-dependent lookup}} - dr448::f(t); // expected-error {{no matching function}} - } - template<typename T> void f(T); // expected-note {{should be declared prior to the call site}} - namespace HideFromADL { struct X {}; } - template void g(int); // ok - template void g(HideFromADL::X); // expected-note {{instantiation of}} -} - -// dr449: na - -namespace dr450 { // dr450: yes - typedef int A[3]; - void f1(const A &); - void f2(A &); // expected-note +{{not viable}} - struct S { A n; }; - void g() { - f1(S().n); - f2(S().n); // expected-error {{no match}}} - } -#if __cplusplus >= 201103L - void h() { - f1(A{}); - f2(A{}); // expected-error {{no match}} - } -#endif -} - -namespace dr451 { // dr451: yes - const int a = 1 / 0; // expected-warning {{undefined}} - const int b = 1 / 0; // expected-warning {{undefined}} - int arr[b]; // expected-error +{{variable length arr}} -} - -namespace dr452 { // dr452: yes - struct A { - int a, b, c; - A *p; - int f(); - A() : a(f()), b(this->f() + a), c(this->a), p(this) {} - }; -} - -// dr454 FIXME write a codegen test - -namespace dr456 { // dr456: yes - // sup 903 c++11 - const int null = 0; - void *p = null; -#if __cplusplus >= 201103L - // expected-error@-2 {{cannot initialize}} -#else - // expected-warning@-4 {{null}} -#endif - - const bool f = false; - void *q = f; -#if __cplusplus >= 201103L - // expected-error@-2 {{cannot initialize}} -#else - // expected-warning@-4 {{null}} -#endif -} - -namespace dr457 { // dr457: yes - const int a = 1; - const volatile int b = 1; - int ax[a]; - int bx[b]; // expected-error +{{variable length array}} - - enum E { - ea = a, - eb = b // expected-error {{constant}} expected-note {{read of volatile-qualified}} - }; -} - -namespace dr458 { // dr458: no - struct A { - int T; - int f(); - template<typename> int g(); - }; - - template<typename> struct B : A { - int f(); - template<typename> int g(); - template<typename> int h(); - }; - - int A::f() { - return T; - } - template<typename T> - int A::g() { - return T; // FIXME: this is invalid, it finds the template parameter - } - - template<typename T> - int B<T>::f() { - return T; - } - template<typename T> template<typename U> - int B<T>::g() { - return T; - } - template<typename U> template<typename T> - int B<U>::h() { - return T; // FIXME: this is invalid, it finds the template parameter - } -} - -namespace dr460 { // dr460: yes - namespace X { namespace Q { int n; } } - namespace Y { - using X; // expected-error {{requires a qualified name}} - using dr460::X; // expected-error {{cannot refer to a namespace}} - using X::Q; // expected-error {{cannot refer to a namespace}} - } -} - -// dr461: na -// dr462 FIXME write a codegen test -// dr463: na -// dr464: na -// dr465: na - -namespace dr466 { // dr466: no - typedef int I; - typedef const int CI; - typedef volatile int VI; - void f(int *a, CI *b, VI *c) { - a->~I(); - a->~CI(); - a->~VI(); - a->I::~I(); - a->CI::~CI(); - a->VI::~VI(); - - a->CI::~VI(); // FIXME: This is invalid; CI and VI are not the same scalar type. - - b->~I(); - b->~CI(); - b->~VI(); - b->I::~I(); - b->CI::~CI(); - b->VI::~VI(); - - c->~I(); - c->~CI(); - c->~VI(); - c->I::~I(); - c->CI::~CI(); - c->VI::~VI(); - } -} - -namespace dr467 { // dr467: yes - int stuff(); - - int f() { - static bool done; - if (done) - goto later; - static int k = stuff(); - done = true; - later: - return k; - } - int g() { - goto later; // expected-error {{cannot jump}} - int k = stuff(); // expected-note {{bypasses variable initialization}} - later: - return k; - } -} - -namespace dr468 { // dr468: yes c++11 - // FIXME: Should we allow this in C++98 too? - template<typename> struct A { - template<typename> struct B { - static int C; - }; - }; - int k = dr468::template A<int>::template B<char>::C; -#if __cplusplus < 201103L - // expected-error@-2 2{{'template' keyword outside of a template}} -#endif -} - -namespace dr469 { // dr469: no - template<typename T> struct X; // expected-note {{here}} - template<typename T> struct X<const T> {}; - X<int&> x; // expected-error {{undefined}} -} - -namespace dr470 { // dr470: yes - template<typename T> struct A { - struct B {}; - }; - template<typename T> struct C { - }; - - template struct A<int>; // expected-note {{previous}} - template struct A<int>::B; // expected-error {{duplicate explicit instantiation}} - - // ok, instantiating C<char> doesn't instantiate base class members. - template struct A<char>; - template struct C<char>; -} - -namespace dr471 { // dr471: yes - struct A { int n; }; - struct B : private virtual A {}; - struct C : protected virtual A {}; - struct D : B, C { int f() { return n; } }; - struct E : private virtual A { - using A::n; - }; - struct F : E, B { int f() { return n; } }; - struct G : virtual A { - private: - using A::n; // expected-note {{here}} - }; - struct H : B, G { int f() { return n; } }; // expected-error {{private}} -} - -namespace dr474 { // dr474: yes - namespace N { - struct S { - void f(); - }; - } - void N::S::f() { - void g(); // expected-note {{previous}} - } - int g(); - namespace N { - int g(); // expected-error {{cannot be overloaded}} - } -} - -// dr475 FIXME write a codegen test - -namespace dr477 { // dr477: 3.5 - struct A { - explicit A(); - virtual void f(); - }; - struct B { - friend explicit A::A(); // expected-error {{'explicit' is invalid in friend declarations}} - friend virtual void A::f(); // expected-error {{'virtual' is invalid in friend declarations}} - }; - explicit A::A() {} // expected-error {{can only be specified inside the class definition}} - virtual void A::f() {} // expected-error {{can only be specified inside the class definition}} -} - -namespace dr478 { // dr478: yes - struct A { virtual void f() = 0; }; // expected-note {{unimplemented}} - void f(A *a); - void f(A a[10]); // expected-error {{array of abstract class type}} -} - -namespace dr479 { // dr479: yes - struct S { - S(); - private: - S(const S&); // expected-note +{{here}} - ~S(); // expected-note +{{here}} - }; - void f() { - throw S(); - // expected-error@-1 {{temporary of type 'dr479::S' has private destructor}} - // expected-error@-2 {{exception object of type 'dr479::S' has private destructor}} -#if __cplusplus < 201103L - // expected-error@-4 {{C++98 requires an accessible copy constructor}} -#endif -#if __cplusplus <= 201402L - // expected-error@-7 {{calling a private constructor}} (copy ctor) -#endif - } - void g() { - S s; // expected-error {{private destructor}}} - throw s; - // expected-error@-1 {{calling a private constructor}} - // expected-error@-2 {{exception object of type 'dr479::S' has private destructor}} - } - void h() { - try { - f(); - g(); - } catch (S s) { - // expected-error@-1 {{calling a private constructor}} - // expected-error@-2 {{variable of type 'dr479::S' has private destructor}} - } - } -} - -namespace dr480 { // dr480: yes - struct A { int n; }; - struct B : A {}; - struct C : virtual B {}; - struct D : C {}; - - int A::*a = &A::n; - int D::*b = a; // expected-error {{virtual base}} - - extern int D::*c; - int A::*d = static_cast<int A::*>(c); // expected-error {{virtual base}} - - D *e; - A *f = e; - D *g = static_cast<D*>(f); // expected-error {{virtual base}} - - extern D &i; - A &j = i; - D &k = static_cast<D&>(j); // expected-error {{virtual base}} -} - -namespace dr481 { // dr481: yes - template<class T, T U> class A { T *x; }; - T *x; // expected-error {{unknown type}} - - template<class T *U> class B { T *x; }; - T *y; // ok - - struct C { - template<class T> void f(class D *p); - }; - D *z; // ok - - template<typename A = C, typename C = A> struct E { - void f() { - typedef ::dr481::C c; // expected-note {{previous}} - typedef C c; // expected-error {{different type}} - } - }; - template struct E<>; // ok - template struct E<int>; // expected-note {{instantiation of}} - - template<template<typename U_no_typo_correction> class A, - A<int> *B, - U_no_typo_correction *C> // expected-error {{unknown type}} - struct F { - U_no_typo_correction *x; // expected-error {{unknown type}} - }; - - template<template<class H *> class> struct G { - H *x; - }; - H *q; - - typedef int N; - template<N X, typename N, template<N Y> class T> struct I; - template<char*> struct J; - I<123, char*, J> *j; -} - -namespace dr482 { // dr482: 3.5 - extern int a; - void f(); - - int dr482::a = 0; // expected-warning {{extra qualification}} - void dr482::f() {} // expected-warning {{extra qualification}} - - inline namespace X { // expected-error 0-1{{C++11 feature}} - extern int b; - void g(); - struct S; - } - int dr482::b = 0; // expected-warning {{extra qualification}} - void dr482::g() {} // expected-warning {{extra qualification}} - struct dr482::S {}; // expected-warning {{extra qualification}} - - void dr482::f(); // expected-warning {{extra qualification}} - void dr482::g(); // expected-warning {{extra qualification}} - - // FIXME: The following are valid in DR482's wording, but these are bugs in - // the wording which we deliberately don't implement. - namespace N { typedef int type; } - typedef int N::type; // expected-error {{typedef declarator cannot be qualified}} - struct A { - struct B; - struct A::B {}; // expected-error {{extra qualification}} - -#if __cplusplus >= 201103L - enum class C; - enum class A::C {}; // expected-error {{extra qualification}} -#endif - }; -} - -namespace dr483 { // dr483: yes - namespace climits { - int check1[__SCHAR_MAX__ >= 127 ? 1 : -1]; - int check2[__SHRT_MAX__ >= 32767 ? 1 : -1]; - int check3[__INT_MAX__ >= 32767 ? 1 : -1]; - int check4[__LONG_MAX__ >= 2147483647 ? 1 : -1]; - int check5[__LONG_LONG_MAX__ >= 9223372036854775807 ? 1 : -1]; -#if __cplusplus < 201103L - // expected-error@-2 {{extension}} -#endif - } - namespace cstdint { - int check1[__PTRDIFF_WIDTH__ >= 16 ? 1 : -1]; - int check2[__SIG_ATOMIC_WIDTH__ >= 8 ? 1 : -1]; - int check3[__SIZE_WIDTH__ >= 16 ? 1 : -1]; - int check4[__WCHAR_WIDTH__ >= 8 ? 1 : -1]; - int check5[__WINT_WIDTH__ >= 16 ? 1 : -1]; - } -} - -namespace dr484 { // dr484: yes - struct A { - A(); - void f(); - }; - typedef const A CA; - void CA::f() { - this->~CA(); - this->CA::~A(); - this->CA::A::~A(); - } - CA::A() {} - - struct B : CA { - B() : CA() {} - void f() { return CA::f(); } - }; - - struct C; - typedef C CT; // expected-note {{here}} - struct CT {}; // expected-error {{conflicts with typedef}} - - namespace N { - struct D; - typedef D DT; // expected-note {{here}} - } - struct N::DT {}; // expected-error {{conflicts with typedef}} - - typedef struct { - S(); // expected-error {{requires a type}} - } S; -} - -namespace dr485 { // dr485: yes - namespace N { - struct S {}; - int operator+(S, S); - template<typename T> int f(S); - } - template<typename T> int f(); - - N::S s; - int a = operator+(s, s); - int b = f<int>(s); -} - -namespace dr486 { // dr486: yes - template<typename T> T f(T *); // expected-note 2{{substitution failure}} - int &f(...); - - void g(); - int n[10]; - - void h() { - int &a = f(&g); - int &b = f(&n); - f<void()>(&g); // expected-error {{no match}} - f<int[10]>(&n); // expected-error {{no match}} - } -} - -namespace dr487 { // dr487: yes - enum E { e }; - int operator+(int, E); - int i[4 + e]; // expected-error 2{{variable length array}} -} - -namespace dr488 { // dr488: yes c++11 - template <typename T> void f(T); - void f(int); - void g() { - // FIXME: It seems CWG thought this should be a SFINAE failure prior to - // allowing local types as template arguments. In C++98, we should either - // allow local types as template arguments or treat this as a SFINAE - // failure. - enum E { e }; - f(e); -#if __cplusplus < 201103L - // expected-error@-2 {{local type}} -#endif - } -} - -// dr489: na - -namespace dr490 { // dr490: yes - template<typename T> struct X {}; - - struct A { - typedef int T; - struct K {}; // expected-note {{declared}} - - int f(T); - int g(T); - int h(X<T>); - int X<T>::*i(); // expected-note {{previous}} - int K::*j(); - - template<typename T> T k(); - - operator X<T>(); - }; - - struct B { - typedef char T; - typedef int U; - friend int A::f(T); - friend int A::g(U); - friend int A::h(X<T>); - - // FIXME: Per this DR, these two are valid! That is another defect - // (no number yet...) which will eventually supersede this one. - friend int X<T>::*A::i(); // expected-error {{return type}} - friend int K::*A::j(); // expected-error {{undeclared identifier 'K'; did you mean 'A::K'?}} - - // ok, lookup finds B::T, not A::T, so return type matches - friend char A::k<T>(); - friend int A::k<U>(); - - // A conversion-type-id in a conversion-function-id is always looked up in - // the class of the conversion function first. - friend A::operator X<T>(); - }; -} - -namespace dr491 { // dr491: dup 413 - struct A {} a, b[3] = { a, {} }; - A c[2] = { a, {}, b[1] }; // expected-error {{excess elements}} -} - -// dr492 FIXME write a codegen test - -namespace dr493 { // dr493: dup 976 - struct X { - template <class T> operator const T &() const; - }; - void f() { - if (X()) { - } - } -} - -namespace dr494 { // dr494: dup 372 - class A { - class B {}; - friend class C; - }; - class C : A::B { - A::B x; - class D : A::B { - A::B y; - }; - }; -} - -namespace dr495 { // dr495: 3.5 - template<typename T> - struct S { - operator int() { return T::error; } - template<typename U> operator U(); - }; - S<int> s; - long n = s; - - template<typename T> - struct S2 { - template<typename U> operator U(); - operator int() { return T::error; } - }; - S2<int> s2; - long n2 = s2; -} - -namespace dr496 { // dr496: sup 2094 - struct A { int n; }; - struct B { volatile int n; }; - int check1[ __is_trivially_copyable(const int) ? 1 : -1]; - // This checks the dr2094 behavior, not dr496 - int check2[ __is_trivially_copyable(volatile int) ? 1 : -1]; - int check3[ __is_trivially_constructible(A, const A&) ? 1 : -1]; - int check4[ __is_trivially_constructible(B, const B&) ? 1 : -1]; - int check5[ __is_trivially_assignable(A, const A&) ? 1 : -1]; - int check6[ __is_trivially_assignable(B, const B&) ? 1 : -1]; -} - -namespace dr497 { // dr497: sup 253 - void before() { - struct S { - mutable int i; - }; - const S cs; - int S::*pm = &S::i; - cs.*pm = 88; // expected-error {{not assignable}} - } - - void after() { - struct S { - S() : i(0) {} - mutable int i; - }; - const S cs; - int S::*pm = &S::i; - cs.*pm = 88; // expected-error {{not assignable}} - } -} - -namespace dr499 { // dr499: yes - extern char str[]; - void f() { throw str; } -} diff --git a/test/CXX/drs/dr5xx.cpp b/test/CXX/drs/dr5xx.cpp deleted file mode 100644 index 2099612e23f3..000000000000 --- a/test/CXX/drs/dr5xx.cpp +++ /dev/null @@ -1,1016 +0,0 @@ -// RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++17 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors - -// FIXME: This is included to avoid a diagnostic with no source location -// pointing at the implicit operator new. We can't match such a diagnostic -// with -verify. -__extension__ typedef __SIZE_TYPE__ size_t; -void *operator new(size_t); // expected-error 0-1{{missing exception spec}} expected-note{{candidate}} -#if __cplusplus > 201402L -namespace std { - enum class align_val_t : size_t {}; -} -void *operator new(size_t, std::align_val_t); // expected-note{{candidate}} -#endif - -namespace dr500 { // dr500: dup 372 - class D; - class A { - class B; - class C; - friend class D; - }; - class A::B {}; - class A::C : public A::B {}; - class D : public A::B {}; -} - -namespace dr501 { // dr501: yes - struct A { - friend void f() {} - void g() { - void (*p)() = &f; // expected-error {{undeclared identifier}} - } - }; -} - -namespace dr502 { // dr502: yes - struct Q {}; - template<typename T> struct A { - enum E { e = 1 }; - void q1() { f(e); } - void q2() { Q arr[sizeof(E)]; f(arr); } - void q3() { Q arr[e]; f(arr); } - void sanity() { Q arr[1]; f(arr); } // expected-error {{undeclared identifier 'f'}} - }; - int f(A<int>::E); - template<int N> int f(Q (&)[N]); - template struct A<int>; -} - -namespace dr505 { // dr505: yes - const char *exts = "\e\(\{\[\%"; // expected-error 5{{use of non-standard escape}} - const char *unknown = "\Q"; // expected-error {{unknown escape sequence}} -} - -namespace dr506 { // dr506: yes - struct NonPod { ~NonPod(); }; - void f(...); - void g(NonPod np) { f(np); } // expected-error {{cannot pass}} -} - -// FIXME: Add tests here once DR260 is resolved. -// dr507: dup 260 - -// dr508: na -// dr509: na -// dr510: na - -namespace dr512 { // dr512: yes - struct A { - A(int); - }; - union U { A a; }; -#if __cplusplus < 201103L - // expected-error@-2 {{has a non-trivial default constructor}} - // expected-note@-6 {{no default constructor}} - // expected-note@-6 {{suppressed by user-declared constructor}} -#endif -} - -// dr513: na - -namespace dr514 { // dr514: yes - namespace A { extern int x, y; } - int A::x = y; -} - -namespace dr515 { // dr515: sup 1017 - // FIXME: dr1017 reverses the wording of dr515, but the current draft has - // dr515's wording, with a different fix for dr1017. - - struct X { int n; }; - template<typename T> struct Y : T { - int f() { return X::n; } - }; - int k = Y<X>().f(); - - struct A { int a; }; - struct B { void f() { int k = sizeof(A::a); } }; -#if __cplusplus < 201103L - // expected-error@-2 {{invalid use of non-static data member}} -#endif -} - -// dr516: na - -namespace dr517 { // dr517: no - // This is NDR, but we should diagnose it anyway. - template<typename T> struct S {}; - template<typename T> int v = 0; // expected-error 0-1{{extension}} - - template struct S<int*>; - template int v<int*>; - - S<char&> s; - int k = v<char&>; - - // FIXME: These are both ill-formed. - template<typename T> struct S<T*> {}; - template<typename T> int v<T*> = 0; // expected-error 0-1{{extension}} - - // FIXME: These are both ill-formed. - template<typename T> struct S<T&> {}; - template<typename T> int v<T&> = 0; // expected-error 0-1{{extension}} -} - -namespace dr518 { // dr518: yes c++11 - enum E { e, }; -#if __cplusplus < 201103L - // expected-error@-2 {{C++11 extension}} -#endif -} - -namespace dr519 { // dr519: yes -// FIXME: Add a codegen test. -#if __cplusplus >= 201103L -#define fold(x) (__builtin_constant_p(x) ? (x) : (x)) - int test[fold((int*)(void*)0) ? -1 : 1]; -#undef fold -#endif -} - -// dr520: na - -// dr521: no -// FIXME: The wording here is broken. It's not reasonable to expect a -// diagnostic here. Once the relevant DR gets a number, mark this as a dup. - -namespace dr522 { // dr522: yes - struct S {}; - template<typename T> void b1(volatile T &); - template<typename T> void b2(volatile T * const *); - template<typename T> void b2(volatile T * const S::*); - template<typename T> void b2(volatile T * const S::* const *); - template<typename T> void b2a(volatile T *S::* const *); // expected-note {{candidate template ignored: deduced type 'volatile int *dr522::S::*const *' of 1st parameter does not match adjusted type 'int *dr522::S::**' of argument}} - - template<typename T> struct Base {}; - struct Derived : Base<int> {}; - template<typename T> void b3(Base<T>); - template<typename T> void b3(Base<T> *); - - void test(int n, const int cn, int **p, int *S::*pm) { - int *a[3], *S::*am[3]; - const Derived cd = Derived(); - Derived d[3]; - - b1(n); - b1(cn); - b2(p); - b2(pm); - b2(a); - b2(am); - b2a(am); // expected-error {{no matching function}} - b3(d); - b3(cd); - } -} - -namespace dr524 { // dr524: yes - template<typename T> void f(T a, T b) { operator+(a, b); } // expected-error {{call}} - - struct S {}; - void operator+(S, S); - template void f(S, S); - - namespace N { struct S {}; } - void operator+(N::S, N::S); // expected-note {{should be declared}} - template void f(N::S, N::S); // expected-note {{instantiation}} -} - -namespace dr525 { // dr525: yes - namespace before { - // Note, the example was correct prior to the change; instantiation is - // required for cases like this: - template <class T> struct D { operator T*(); }; - void g(D<double> ppp) { - delete ppp; - } - } - namespace after { - template <class T> struct D { typename T::error e; }; // expected-error {{prior to '::'}} - void g(D<double> *ppp) { - delete ppp; // expected-note {{instantiation of}} - } - } -} - -namespace dr526 { // dr526: yes - template<int> struct S {}; - template<int N> void f1(S<N> s); - template<int N> void f2(S<(N)> s); // expected-note {{couldn't infer}} - template<int N> void f3(S<+N> s); // expected-note {{couldn't infer}} - template<int N> void g1(int (&)[N]); - template<int N> void g2(int (&)[(N)]); // expected-note {{couldn't infer}} - template<int N> void g3(int (&)[+N]); // expected-note {{couldn't infer}} - - void test(int (&a)[3], S<3> s) { - f1(s); - f2(s); // expected-error {{no matching}} - f3(s); // expected-error {{no matching}} - g1(a); - g2(a); // expected-error {{no matching}} - g3(a); // expected-error {{no matching}} - } - - template<int N> struct X { - typedef int type; - X<N>::type v1; - X<(N)>::type v2; // expected-error {{missing 'typename'}} - X<+N>::type v3; // expected-error {{missing 'typename'}} - }; -} - -namespace dr527 { // dr527: na - // This DR is meaningless. It removes a required diagnostic from the case - // where a not-externally-visible object is odr-used but not defined, which - // requires a diagnostic for a different reason. - extern struct { int x; } a; // FIXME: We should reject this, per dr389. - static struct { int x; } b; - extern "C" struct { int x; } c; - namespace { extern struct { int x; } d; } - typedef struct { int x; } *P; - struct E { static P e; }; // FIXME: We should reject this, per dr389. - namespace { struct F { static P f; }; } - - int ax = a.x, bx = b.x, cx = c.x, dx = d.x, ex = E::e->x, fx = F::f->x; -} - -namespace dr530 { // dr530: yes - template<int*> struct S { enum { N = 1 }; }; - template<void(*)()> struct T { enum { N = 1 }; }; - int n; - void f(); - int a[S<&n>::N]; - int b[T<&f>::N]; -} - -namespace dr531 { // dr531: partial - namespace good { - template<typename T> struct A { - void f(T) { T::error; } - template<typename U> void g(T, U) { T::error; } - struct B { typename T::error error; }; - template<typename U> struct C { typename T::error error; }; - static T n; - }; - template<typename T> T A<T>::n = T::error; - - template<> void A<int>::f(int) {} - template<> template<typename U> void A<int>::g(int, U) {} - template<> struct A<int>::B {}; - template<> template<typename U> struct A<int>::C {}; - template<> int A<int>::n = 0; - - void use(A<int> a) { - a.f(a.n); - a.g(0, 0); - A<int>::B b; - A<int>::C<int> c; - } - - template<> struct A<char> { - void f(char); - template<typename U> void g(char, U); - struct B; - template<typename U> struct C; - static char n; - }; - - void A<char>::f(char) {} - template<typename U> void A<char>::g(char, U) {} - struct A<char>::B {}; - template<typename U> struct A<char>::C {}; - char A<char>::n = 0; - } - - namespace bad { - template<typename T> struct A { - void f(T) { T::error; } - template<typename U> void g(T, U) { T::error; } - struct B { typename T::error error; }; - template<typename U> struct C { typename T::error error; }; // expected-note {{here}} - static T n; - }; - template<typename T> T A<T>::n = T::error; - - void A<int>::f(int) {} // expected-error {{requires 'template<>'}} - template<typename U> void A<int>::g(int, U) {} // expected-error {{should be empty}} - struct A<int>::B {}; // expected-error {{requires 'template<>'}} - template<typename U> struct A<int>::C {}; // expected-error {{should be empty}} expected-error {{different kind of symbol}} - int A<int>::n = 0; // expected-error {{requires 'template<>'}} - - template<> struct A<char> { // expected-note 2{{here}} - void f(char); - template<typename U> void g(char, U); - struct B; // expected-note {{here}} - template<typename U> struct C; - static char n; - }; - - template<> void A<char>::f(char) {} // expected-error {{no function template matches}} - // FIXME: This is ill-formed; -pedantic-errors should reject. - template<> template<typename U> void A<char>::g(char, U) {} // expected-warning {{extraneous template parameter list}} - template<> struct A<char>::B {}; // expected-error {{extraneous 'template<>'}} expected-error {{does not specialize}} - // FIXME: This is ill-formed; -pedantic-errors should reject. - template<> template<typename U> struct A<char>::C {}; // expected-warning {{extraneous template parameter list}} - template<> char A<char>::n = 0; // expected-error {{extraneous 'template<>'}} - } - - namespace nested { - template<typename T> struct A { - template<typename U> struct B; - }; - template<> template<typename U> struct A<int>::B { - void f(); - void g(); - template<typename V> void h(); - template<typename V> void i(); - }; - template<> template<typename U> void A<int>::B<U>::f() {} - template<typename U> void A<int>::B<U>::g() {} // expected-error {{should be empty}} - - template<> template<typename U> template<typename V> void A<int>::B<U>::h() {} - template<typename U> template<typename V> void A<int>::B<U>::i() {} // expected-error {{should be empty}} - - template<> template<> void A<int>::B<int>::f() {} - template<> template<> template<typename V> void A<int>::B<int>::h() {} - template<> template<> template<> void A<int>::B<int>::h<int>() {} - - template<> void A<int>::B<char>::f() {} // expected-error {{requires 'template<>'}} - template<> template<typename V> void A<int>::B<char>::h() {} // expected-error {{should be empty}} - } -} - -// PR8130 -namespace dr532 { // dr532: 3.5 - struct A { }; - - template<class T> struct B { - template<class R> int &operator*(R&); - }; - - template<class T, class R> float &operator*(T&, R&); - void test() { - A a; - B<A> b; - int &ir = b * a; - } -} - -// dr533: na - -namespace dr534 { // dr534: yes - struct S {}; - template<typename T> void operator+(S, T); - template<typename T> void operator+<T*>(S, T*) {} // expected-error {{function template partial spec}} -} - -namespace dr535 { // dr535: yes - class X { private: X(const X&); }; - struct A { - X x; - template<typename T> A(T&); - }; - struct B : A { - X y; - B(volatile A&); - }; - - extern A a1; - A a2(a1); // ok, uses constructor template - - extern volatile B b1; - B b2(b1); // ok, uses converting constructor - - void f() { throw a1; } - -#if __cplusplus >= 201103L - struct C { - constexpr C() : n(0) {} - template<typename T> constexpr C(T&t) : n(t.n == 0 ? throw 0 : 0) {} - int n; - }; - constexpr C c() { return C(); } - // ok, copy is elided - constexpr C x = c(); -#endif -} - -// dr537: na -// dr538: na - -// dr539: yes -const dr539( // expected-error {{requires a type specifier}} - const a) { // expected-error {{unknown type name 'a'}} - const b; // expected-error {{requires a type specifier}} - new const; // expected-error {{expected a type}} - try {} catch (const n) {} // expected-error {{unknown type name 'n'}} - try {} catch (const) {} // expected-error {{expected a type}} - if (const n = 0) {} // expected-error {{requires a type specifier}} - switch (const n = 0) {} // expected-error {{requires a type specifier}} - while (const n = 0) {} // expected-error {{requires a type specifier}} - for (const n = 0; // expected-error {{requires a type specifier}} - const m = 0; ) {} // expected-error {{requires a type specifier}} - sizeof(const); // expected-error {{requires a type specifier}} - struct S { - const n; // expected-error {{requires a type specifier}} - operator const(); // expected-error {{expected a type}} - }; -#if __cplusplus >= 201103L - int arr[3]; - // FIXME: The extra braces here are to avoid the parser getting too - // badly confused when recovering here. We should fix this recovery. - { for (const n // expected-error {{unknown type name 'n'}} expected-note {{}} - : arr) ; {} } // expected-error +{{}} - (void) [](const) {}; // expected-error {{requires a type specifier}} - (void) [](const n) {}; // expected-error {{unknown type name 'n'}} - enum E : const {}; // expected-error {{expected a type}} - using T = const; // expected-error {{expected a type}} - auto f() -> const; // expected-error {{expected a type}} -#endif -} - -namespace dr540 { // dr540: yes - typedef int &a; - typedef const a &a; // expected-warning {{has no effect}} - typedef const int &b; - typedef b &b; - typedef const a &c; // expected-note {{previous}} expected-warning {{has no effect}} - typedef const b &c; // expected-error {{different}} expected-warning {{has no effect}} -} - -namespace dr541 { // dr541: yes - template<int> struct X { typedef int type; }; - template<typename T> struct S { - int f(T); - - int g(int); - T g(bool); - - int h(); - int h(T); - - void x() { - // These are type-dependent expressions, even though we could - // determine that all calls have type 'int'. - X<sizeof(f(0))>::type a; // expected-error +{{}} - X<sizeof(g(0))>::type b; // expected-error +{{}} - X<sizeof(h(0))>::type b; // expected-error +{{}} - - typename X<sizeof(f(0))>::type a; - typename X<sizeof(h(0))>::type b; - } - }; -} - -namespace dr542 { // dr542: yes -#if __cplusplus >= 201103L - struct A { A() = delete; int n; }; - A a[32] = {}; // ok, constructor not called - - struct B { - int n; - private: - B() = default; - }; - B b[32] = {}; // ok, constructor not called -#endif -} - -namespace dr543 { // dr543: yes - // In C++98+DR543, this is valid because value-initialization doesn't call a - // trivial default constructor, so we never notice that defining the - // constructor would be ill-formed. - // - // In C++11+DR543, this is ill-formed, because the default constructor is - // deleted, and value-initialization *does* call a deleted default - // constructor, even if it is trivial. - struct A { - const int n; - }; - A a = A(); -#if __cplusplus >= 201103L - // expected-error@-2 {{deleted}} - // expected-note@-5 {{would not be initialized}} -#endif -} - -namespace dr544 { // dr544: yes - int *n; - - template<class T> struct A { int n; }; - template<class T> struct B : A<T> { int get(); }; - template<> int B<int>::get() { return n; } - int k = B<int>().get(); -} - -namespace dr546 { // dr546: yes - template<typename T> struct A { void f(); }; - template struct A<int>; - template<typename T> void A<T>::f() { T::error; } -} - -namespace dr547 { // dr547: yes - template<typename T> struct X; - template<typename T> struct X<T() const> {}; - template<typename T, typename C> X<T> f(T C::*) { return X<T>(); } - - struct S { void f() const; }; - X<void() const> x = f(&S::f); -} - -namespace dr548 { // dr548: dup 482 - template<typename T> struct S {}; - template<typename T> void f() {} - template struct dr548::S<int>; - template void dr548::f<int>(); -} - -namespace dr551 { // dr551: yes c++11 - // FIXME: This obviously should apply in C++98 mode too. - template<typename T> void f() {} - template inline void f<int>(); -#if __cplusplus >= 201103L - // expected-error@-2 {{cannot be 'inline'}} -#endif - - template<typename T> inline void g() {} - template inline void g<int>(); -#if __cplusplus >= 201103L - // expected-error@-2 {{cannot be 'inline'}} -#endif - - template<typename T> struct X { - void f() {} - }; - template inline void X<int>::f(); -#if __cplusplus >= 201103L - // expected-error@-2 {{cannot be 'inline'}} -#endif -} - -namespace dr552 { // dr552: yes - template<typename T, typename T::U> struct X {}; - struct Y { typedef int U; }; - X<Y, 0> x; -} - -struct dr553_class { - friend void *operator new(size_t, dr553_class); -}; -namespace dr553 { - dr553_class c; - // Contrary to the apparent intention of the DR, operator new is not actually - // looked up with a lookup mechanism that performs ADL; the standard says it - // "is looked up in global scope", where it is not visible. - void *p = new (c) int; // expected-error {{no matching function}} - - struct namespace_scope { - friend void *operator new(size_t, namespace_scope); // expected-error {{cannot be declared inside a namespace}} - }; -} - -// dr556: na - -namespace dr557 { // dr557: yes - template<typename T> struct S { - friend void f(S<T> *); - friend void g(S<S<T> > *); - }; - void x(S<int> *p, S<S<int> > *q) { - f(p); - g(q); - } -} - -namespace dr558 { // dr558: yes - wchar_t a = L'\uD7FF'; - wchar_t b = L'\xD7FF'; - wchar_t c = L'\uD800'; // expected-error {{invalid universal character}} - wchar_t d = L'\xD800'; - wchar_t e = L'\uDFFF'; // expected-error {{invalid universal character}} - wchar_t f = L'\xDFFF'; - wchar_t g = L'\uE000'; - wchar_t h = L'\xE000'; -} - -template<typename> struct dr559 { typedef int T; dr559::T u; }; // dr559: yes - -namespace dr561 { // dr561: yes - template<typename T> void f(int); - template<typename T> void g(T t) { - f<T>(t); - } - namespace { - struct S {}; - template<typename T> static void f(S); - } - void h(S s) { - g(s); - } -} - -namespace dr564 { // dr564: yes - extern "C++" void f(int); - void f(int); // ok - extern "C++" { extern int n; } - int n; // ok -} - -namespace dr565 { // dr565: yes - namespace N { - template<typename T> int f(T); // expected-note {{target}} - } - using N::f; // expected-note {{using}} - template<typename T> int f(T*); - template<typename T> void f(T); - template<typename T, int = 0> int f(T); // expected-error 0-1{{extension}} - template<typename T> int f(T, int = 0); - template<typename T> int f(T); // expected-error {{conflicts with}} -} - -namespace dr566 { // dr566: yes -#if __cplusplus >= 201103L - int check[int(-3.99) == -3 ? 1 : -1]; -#endif -} - -// dr567: na - -namespace dr568 { // dr568: yes c++11 - // FIXME: This is a DR issue against C++98, so should probably apply there - // too. - struct x { int y; }; - class trivial : x { - x y; - public: - int n; - }; - int check_trivial[__is_trivial(trivial) ? 1 : -1]; - - struct std_layout { - std_layout(); - std_layout(const std_layout &); - ~std_layout(); - private: - int n; - }; - int check_std_layout[__is_standard_layout(std_layout) ? 1 : -1]; - - struct aggregate { - int x; - int y; - trivial t; - std_layout sl; - }; - aggregate aggr = {}; - - void f(...); - void g(trivial t) { f(t); } -#if __cplusplus < 201103L - // expected-error@-2 {{non-POD}} -#endif - - void jump() { - goto x; -#if __cplusplus < 201103L - // expected-error@-2 {{cannot jump}} - // expected-note@+2 {{non-POD}} -#endif - trivial t; - x: ; - } -} - -namespace dr569 { // dr569: yes c++11 - // FIXME: This is a DR issue against C++98, so should probably apply there - // too. - ;;;;; -#if __cplusplus < 201103L - // expected-error@-2 {{C++11 extension}} -#endif -} - -namespace dr570 { // dr570: dup 633 - int n; - int &r = n; // expected-note {{previous}} - int &r = n; // expected-error {{redefinition}} -} - -namespace dr571 { // dr571 unknown - // FIXME: Add a codegen test. - typedef int &ir; - int n; - const ir r = n; // expected-warning {{has no effect}} FIXME: Test if this has internal linkage. -} - -namespace dr572 { // dr572: yes - enum E { a = 1, b = 2 }; - int check[a + b == 3 ? 1 : -1]; -} - -namespace dr573 { // dr573: no - void *a; - int *b = reinterpret_cast<int*>(a); - void (*c)() = reinterpret_cast<void(*)()>(a); - void *d = reinterpret_cast<void*>(c); -#if __cplusplus < 201103L - // expected-error@-3 {{extension}} - // expected-error@-3 {{extension}} -#endif - void f() { delete a; } // expected-error {{cannot delete}} - int n = d - a; // expected-error {{arithmetic on pointers to void}} - // FIXME: This is ill-formed. - template<void*> struct S; - template<int*> struct T; -} - -namespace dr574 { // dr574: yes - struct A { - A &operator=(const A&) const; // expected-note {{different qualifiers}} - }; - struct B { - B &operator=(const B&) volatile; // expected-note {{different qualifiers}} - }; -#if __cplusplus >= 201103L - struct C { - C &operator=(const C&) &; // expected-note {{not viable}} expected-note {{candidate}} expected-note {{here}} - }; - struct D { - D &operator=(const D&) &&; // expected-note {{not viable}} expected-note {{candidate}} expected-note {{here}} - }; - void test(C c, D d) { - c = c; - C() = c; // expected-error {{no viable}} - d = d; // expected-error {{no viable}} - D() = d; - } -#endif - struct Test { - friend A &A::operator=(const A&); // expected-error {{does not match}} - friend B &B::operator=(const B&); // expected-error {{does not match}} -#if __cplusplus >= 201103L - // FIXME: We shouldn't produce the 'cannot overload' diagnostics here. - friend C &C::operator=(const C&); // expected-error {{does not match}} expected-error {{cannot overload}} - friend D &D::operator=(const D&); // expected-error {{does not match}} expected-error {{cannot overload}} -#endif - }; -} - -namespace dr575 { // dr575: yes - template<typename T, typename U = typename T::type> void a(T); void a(...); // expected-error 0-1{{extension}} - template<typename T, typename T::type U = 0> void b(T); void b(...); // expected-error 0-1{{extension}} - template<typename T, int U = T::value> void c(T); void c(...); // expected-error 0-1{{extension}} - template<typename T> void d(T, int = T::value); void d(...); // expected-error {{cannot be used prior to '::'}} - void x() { - a(0); - b(0); - c(0); - d(0); // expected-note {{in instantiation of default function argument}} - } - - template<typename T = int&> void f(T* = 0); // expected-error 0-1{{extension}} - template<typename T = int> void f(T = 0); // expected-error 0-1{{extension}} - void g() { f<>(); } - - template<typename T> T &h(T *); - template<typename T> T *h(T *); - void *p = h((void*)0); -} - -namespace dr576 { // dr576: yes - typedef void f() {} // expected-error {{function definition declared 'typedef'}} - void f(typedef int n); // expected-error {{invalid storage class}} - void f(char c) { typedef int n; } -} - -namespace dr577 { // dr577: yes - typedef void V; - typedef const void CV; - void a(void); - void b(const void); // expected-error {{qualifiers}} - void c(V); - void d(CV); // expected-error {{qualifiers}} - void (*e)(void) = c; - void (*f)(const void); // expected-error {{qualifiers}} - void (*g)(V) = a; - void (*h)(CV); // expected-error {{qualifiers}} - template<typename T> void i(T); // expected-note 2{{requires 1 arg}} - template<typename T> void j(void (*)(T)); // expected-note 2{{argument may not have 'void' type}} - void k() { - a(); - c(); - i<void>(); // expected-error {{no match}} - i<const void>(); // expected-error {{no match}} - j<void>(0); // expected-error {{no match}} - j<const void>(0); // expected-error {{no match}} - } -} - -namespace dr580 { // dr580: partial - class C; - struct A { static C c; }; - struct B { static C c; }; - class C { - C(); // expected-note {{here}} - ~C(); // expected-note {{here}} - - typedef int I; // expected-note 2{{here}} - template<int> struct X; - template<int> friend struct Y; - template<int> void f(); - template<int> friend void g(); - friend struct A; - }; - - template<C::I> struct C::X {}; - template<C::I> struct Y {}; - template<C::I> struct Z {}; // expected-error {{private}} - - struct C2 { - class X { - struct A; - typedef int I; - friend struct A; - }; - class Y { - template<X::I> struct A {}; // FIXME: We incorrectly accept this - // because we think C2::Y::A<...> might - // instantiate to C2::X::A - }; - }; - - template<C::I> void C::f() {} - template<C::I> void g() {} - template<C::I> void h() {} // expected-error {{private}} - - C A::c; - C B::c; // expected-error 2{{private}} -} - -// dr582: na - -namespace dr583 { // dr583: 4 - // see n3624 - int *p; - bool b1 = p < 0; // expected-error {{ordered comparison between pointer and zero}} - bool b2 = p > 0; // expected-error {{ordered comparison between pointer and zero}} - bool b3 = p <= 0; // expected-error {{ordered comparison between pointer and zero}} - bool b4 = p >= 0; // expected-error {{ordered comparison between pointer and zero}} -} - -// dr584: na - -namespace dr585 { // dr585: yes - template<typename> struct T; - struct A { - friend T; -#if __cplusplus <= 201402L - // expected-error@-2 {{requires a type specifier}} expected-error@-2 {{can only be classes or functions}} -#else - // expected-error@-4 {{use of class template 'T' requires template arguments; argument deduction not allowed in friend declaration}} - // expected-note@-7 {{here}} -#endif - // FIXME: It's not clear whether the standard allows this or what it means, - // but the DR585 writeup suggests it as an alternative. - template<typename U> friend T<U>; // expected-error {{must use an elaborated type}} - }; - template<template<typename> class T> struct B { - friend T; -#if __cplusplus <= 201402L - // expected-error@-2 {{requires a type specifier}} expected-error@-2 {{can only be classes or functions}} -#else - // expected-error@-4 {{use of template template parameter 'T' requires template arguments; argument deduction not allowed in friend declaration}} - // expected-note@-6 {{here}} -#endif - template<typename U> friend T<U>; // expected-error {{must use an elaborated type}} - }; -} - -// dr586: na - -namespace dr587 { // dr587: yes - template<typename T> void f(bool b, const T x, T y) { - const T *p = &(b ? x : y); - } - struct S {}; - template void f(bool, const int, int); - template void f(bool, const S, S); -} - -namespace dr588 { // dr588: yes - struct A { int n; }; // expected-note {{ambiguous}} - template<typename T> int f() { - struct S : A, T { int f() { return n; } } s; - int a = s.f(); - int b = s.n; // expected-error {{found in multiple}} - } - struct B { int n; }; // expected-note {{ambiguous}} - int k = f<B>(); // expected-note {{here}} -} - -namespace dr589 { // dr589: yes - struct B { }; - struct D : B { }; - D f(); - extern const B &b; - bool a; - const B *p = &(a ? f() : b); // expected-error {{temporary}} - const B *q = &(a ? D() : b); // expected-error {{temporary}} -} - -namespace dr590 { // dr590: yes - template<typename T> struct A { - struct B { - struct C { - A<T>::B::C f(A<T>::B::C); // ok, no 'typename' required. - }; - }; - }; - template<typename T> typename A<T>::B::C A<T>::B::C::f(A<T>::B::C) {} -} - -namespace dr591 { // dr591: no - template<typename T> struct A { - typedef int M; - struct B { - typedef void M; - struct C; - }; - }; - - template<typename T> struct A<T>::B::C : A<T> { - // FIXME: Should find member of non-dependent base class A<T>. - M m; // expected-error {{incomplete type 'dr591::A::B::M' (aka 'void'}} - }; -} - -// dr592: na -// dr593 needs an IRGen test. -// dr594: na - -namespace dr595 { // dr595: dup 1330 - template<class T> struct X { - void f() throw(T) {} -#if __cplusplus > 201402L - // expected-error@-2 {{ISO C++17 does not allow}} expected-note@-2 {{use 'noexcept}} -#endif - }; - struct S { - X<S> xs; - }; -} - -// dr597: na - -namespace dr598 { // dr598: yes - namespace N { - void f(int); - void f(char); - // Not found by ADL. - void g(void (*)(int)); - void h(void (*)(int)); - - namespace M { - struct S {}; - int &h(void (*)(S)); - } - void i(M::S); - void i(); - } - int &g(void(*)(char)); - int &r = g(N::f); - int &s = h(N::f); // expected-error {{undeclared}} - int &t = h(N::i); -} - -namespace dr599 { // dr599: partial - typedef int Fn(); - struct S { operator void*(); }; - struct T { operator Fn*(); }; - struct U { operator int*(); operator void*(); }; // expected-note 2{{conversion}} - struct V { operator int*(); operator Fn*(); }; - void f(void *p, void (*q)(), S s, T t, U u, V v) { - delete p; // expected-error {{cannot delete}} - delete q; // expected-error {{cannot delete}} - delete s; // expected-error {{cannot delete}} - delete t; // expected-error {{cannot delete}} - // FIXME: This is valid, but is rejected due to a non-conforming GNU - // extension allowing deletion of pointers to void. - delete u; // expected-error {{ambiguous}} - delete v; - } -} diff --git a/test/CXX/drs/dr6xx.cpp b/test/CXX/drs/dr6xx.cpp deleted file mode 100644 index b4247b22607d..000000000000 --- a/test/CXX/drs/dr6xx.cpp +++ /dev/null @@ -1,1122 +0,0 @@ -// RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -fno-spell-checking -// RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -fno-spell-checking -// RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -fno-spell-checking -// RUN: %clang_cc1 -std=c++17 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -fno-spell-checking -// RUN: %clang_cc1 -std=c++2a %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -fno-spell-checking - -namespace std { - struct type_info {}; - __extension__ typedef __SIZE_TYPE__ size_t; -} // namespace std - -namespace dr601 { // dr601: yes -#if __cplusplus >= 201103L -#define MAX __LLONG_MAX__ -#else -#define MAX __LONG_MAX__ -#endif - -#if 0x8000 < -1 -#error 0x8000 should be signed -#endif - -#if MAX > 0xFFFFFFFF && 0x80000000 < -1 -#error 0x80000000 should be signed -#endif - -#if __INT_MAX__ == 0x7FFFFFFF -_Static_assert(0x80000000 < -1, "0x80000000 should be unsigned"); // expected-error {{C11}} -#endif - -#if MAX > 0xFFFFFFFFFFFFFFFF && 0x8000000000000000 < -1 -#error 0x8000000000000000 should be signed -#endif - -#if __cplusplus >= 201103L && __LLONG_MAX__ == 0x7FFFFFFFFFFFFFFF -static_assert(0x8000000000000000 < -1, "0x8000000000000000 should be unsigned"); // expected-error {{C11}} -#endif - -#undef MAX -} - -namespace dr602 { // dr602: yes - template<class T> struct A { - template<class U> friend struct A; - }; - - template<class T> struct B { - class C { - template<class U> friend struct B; - typedef int type; - }; - typename C::type ct; // ok, befriended - }; - B<int> b; -} - -namespace dr603 { // dr603: yes - template<unsigned char> struct S {}; - typedef S<'\001'> S1; - typedef S<(1ul << __CHAR_BIT__) + 1> S1; -#if __cplusplus >= 201103L - // expected-error@-2 {{cannot be narrowed}} -#endif -} - -// dr604: na -// dr605 needs IRGen test - -namespace dr606 { // dr606: yes -#if __cplusplus >= 201103L - template<typename T> struct S {}; - template<typename T> void f(S<T> &&); // expected-note {{no known conversion from 'S<int>' to 'S<int> &&'}} - template<typename T> void g(T &&); - template<typename T> void h(const T &&); // expected-note {{no known conversion from 'S<int>' to 'const dr606::S<int> &&'}} - - void test(S<int> s) { - f(s); // expected-error {{no match}} - g(s); - h(s); // expected-error {{no match}} - - g(test); - h(test); // ok, an rvalue reference can bind to a function lvalue - } -#endif -} - -namespace dr608 { // dr608: yes - struct A { virtual void f(); }; - struct B : A {}; - struct C : A { void f(); }; - struct D : B, C {}; -} - -int dr610[-0u == 0u ? 1 : -1]; // dr610: yes - -namespace dr611 { // dr611: yes - int k; - struct S { int &r; } s = { k ? k : k }; -} - -// dr612: na - -namespace dr613 { // dr613: yes c++11 - // see also n2253 - struct A { int n; static void f(); }; - int f(int); - struct B { virtual void f(); }; - B &g(int); - - int an1 = sizeof(A::n); - int an2 = sizeof(A::n + 1); // valid per dr850 - int an3 = sizeof A::n; - int an4 = sizeof(f(A::n)); - int an5 = sizeof(g(A::n)); - const std::type_info &an6 = typeid(A::n); - const std::type_info &an7 = typeid(A::n + 1); - const std::type_info &an8 = typeid(f(A::n)); - const std::type_info &an9 = typeid(g(A::n)); // expected-error {{non-static}} -#if __cplusplus < 201103L - // expected-error@-10 {{non-static}} - // expected-error@-10 {{non-static}} - // expected-error@-10 {{non-static}} - // expected-error@-10 {{non-static}} - // expected-error@-10 {{non-static}} - // expected-error@-10 {{non-static}} - // expected-error@-10 {{non-static}} - // expected-error@-10 {{non-static}} -#endif - - void A::f() { - int an1 = sizeof n; - const std::type_info &an2 = typeid(n + 1); -#if __cplusplus < 201103L - // expected-error@-3 {{static}} - // expected-error@-3 {{static}} -#endif - const std::type_info &an3 = typeid(g(n)); // expected-error {{static}} - } -} - -int dr614_a[(-1) / 2 == 0 ? 1 : -1]; // dr614: yes -int dr614_b[(-1) % 2 == -1 ? 1 : -1]; - -namespace dr615 { // dr615: yes - int f(); - static int n = f(); -} - -namespace dr616 { // dr616: 4 -#if __cplusplus >= 201103L - struct S { int n; } s; - S f(); - using T = decltype((S().n)); - using T = decltype((static_cast<S&&>(s).n)); - using T = decltype((f().n)); - using T = decltype(S().*&S::n); - using T = decltype(static_cast<S&&>(s).*&S::n); - using T = decltype(f().*&S::n); - using T = int&&; - - using U = decltype(S().n); - using U = decltype(static_cast<S&&>(s).n); - using U = int; -#endif -} - -namespace dr618 { // dr618: yes -#if (unsigned)-1 > 0 -#error wrong -#endif -} - -namespace dr619 { // dr619: yes - extern int x[10]; - struct S { static int x[10]; }; - - int x[]; - _Static_assert(sizeof(x) == sizeof(int) * 10, ""); // expected-error {{C11}} - extern int x[]; - _Static_assert(sizeof(x) == sizeof(int) * 10, ""); // expected-error {{C11}} - - int S::x[]; - _Static_assert(sizeof(S::x) == sizeof(int) * 10, ""); // expected-error {{C11}} - - void f() { - extern int x[]; - sizeof(x); // expected-error {{incomplete}} - } -} - -// dr620: dup 568 - -namespace dr621 { - template<typename T> T f(); - template<> int f() {} // expected-note {{previous}} - template<> int f<int>() {} // expected-error {{redefinition}} -} - -// dr623: na -// FIXME: Add documentation saying we allow invalid pointer values. - -// dr624 needs an IRGen check. - -namespace dr625 { // dr625: yes - template<typename T> struct A {}; - A<auto> x = A<int>(); // expected-error {{'auto' not allowed in template argument}} expected-error 0-1{{extension}} - void f(int); - void (*p)(auto) = f; // expected-error {{'auto' not allowed in function prototype}} expected-error 0-1{{extension}} -} - -namespace dr626 { // dr626: yes -#define STR(x) #x - char c[2] = STR(c); // ok, type matches - wchar_t w[2] = STR(w); // expected-error {{initializing wide char array with non-wide string literal}} -} - -namespace dr627 { // dr627: yes - void f() { - true a = 0; // expected-error +{{}} expected-warning {{unused}} - } -} - -// dr628: na - -namespace dr629 { // dr629: yes - typedef int T; - int n = 1; - void f() { - auto T = 2; -#if __cplusplus < 201103L - // expected-error@-2 {{expected unqualified-id}} -#else - // expected-note@-4 {{previous}} -#endif - - auto T(n); -#if __cplusplus >= 201103L - // expected-error@-2 {{redefinition of 'T'}} -#endif - } -} - -namespace dr630 { // dr630: yes -const bool MB_EQ_WC = - ' ' == L' ' && '\t' == L'\t' && '\v' == L'\v' && '\r' == L'\r' && - '\n' == L'\n' && // - 'a' == L'a' && 'b' == L'b' && 'c' == L'c' && 'd' == L'd' && 'e' == L'e' && - 'f' == L'f' && 'g' == L'g' && 'h' == L'h' && 'i' == L'i' && 'j' == L'j' && - 'k' == L'k' && 'l' == L'l' && 'm' == L'm' && 'n' == L'n' && 'o' == L'o' && - 'p' == L'p' && 'q' == L'q' && 'r' == L'r' && 's' == L's' && 't' == L't' && - 'u' == L'u' && 'v' == L'v' && 'w' == L'w' && 'x' == L'x' && 'y' == L'y' && - 'z' == L'z' && // - 'A' == L'A' && 'B' == L'B' && 'C' == L'C' && 'D' == L'D' && 'E' == L'E' && - 'F' == L'F' && 'G' == L'G' && 'H' == L'H' && 'I' == L'I' && 'J' == L'J' && - 'K' == L'K' && 'L' == L'L' && 'M' == L'M' && 'N' == L'N' && 'O' == L'O' && - 'P' == L'P' && 'Q' == L'Q' && 'R' == L'R' && 'S' == L'S' && 'T' == L'T' && - 'U' == L'U' && 'V' == L'V' && 'W' == L'W' && 'X' == L'X' && 'Y' == L'Y' && - 'Z' == L'Z' && // - '0' == L'0' && '1' == L'1' && '2' == L'2' && '3' == L'3' && '4' == L'4' && - '5' == L'5' && '6' == L'6' && '7' == L'7' && '8' == L'8' && - '9' == L'9' && // - '_' == L'_' && '{' == L'{' && '}' == L'}' && '[' == L'[' && ']' == L']' && - '#' == L'#' && '(' == L'(' && ')' == L')' && '<' == L'<' && '>' == L'>' && - '%' == L'%' && ':' == L':' && ';' == L';' && '.' == L'.' && '?' == L'?' && - '*' == L'*' && '+' == L'+' && '-' == L'-' && '/' == L'/' && '^' == L'^' && - '&' == L'&' && '|' == L'|' && '~' == L'~' && '!' == L'!' && '=' == L'=' && - ',' == L',' && '\\' == L'\\' && '"' == L'"' && '\'' == L'\''; -#if __STDC_MB_MIGHT_NEQ_WC__ -#ifndef __FreeBSD__ // PR22208, FreeBSD expects us to give a bad (but conforming) answer here. -_Static_assert(!MB_EQ_WC, "__STDC_MB_MIGHT_NEQ_WC__ but all basic source characters have same representation"); // expected-error {{C11}} -#endif -#else -_Static_assert(MB_EQ_WC, "!__STDC_MB_MIGHT_NEQ_WC__ but some character differs"); // expected-error {{C11}} -#endif -} - -// dr631: na - -namespace dr632 { // dr632: yes - struct S { int n; } s = {{5}}; // expected-warning {{braces}} -} - -// dr633: na -// see also n2993 - -namespace dr634 { // dr634: yes - struct S { S(); S(const S&); virtual void f(); ~S(); }; - int f(...); - char f(int); - template<typename T> int (&g(T))[sizeof f(T())]; - int (&a)[sizeof(int)] = g(S()); - int (&b)[1] = g(0); - int k = f(S()); // expected-error {{cannot pass}} -} - -namespace dr635 { // dr635: yes - template<typename T> struct A { A(); ~A(); }; - template<typename T> A<T>::A<T>() {} // expected-error {{cannot have template arguments}} - template<typename T> A<T>::~A<T>() {} - - template<typename T> struct B { B(); ~B(); }; - template<typename T> B<T>::B() {} - template<typename T> B<T>::~B() {} - - struct C { template<typename T> C(); C(); }; - template<typename T> C::C() {} - C::C() {} - template<> C::C<int>() {} // expected-error {{constructor name}} expected-error {{unqualified-id}} - /*FIXME: needed for error recovery:*/; - - template<typename T> struct D { template<typename U> D(); D(); }; - template<typename T> D<T>::D() {} // expected-note {{previous}} - template<typename T> template<typename U> D<T>::D() {} - template<typename T> D<T>::D<T>() {} // expected-error {{redefinition}} expected-error {{cannot have template arg}} -} - -namespace dr637 { // dr637: yes - void f(int i) { - i = ++i + 1; - i = i++ + 1; // expected-warning {{unsequenced}} - } -} - -namespace dr638 { // dr638: no - template<typename T> struct A { - struct B; - void f(); - void g(); - struct C { - void h(); - }; - }; - - class X { - typedef int type; - template<class T> friend struct A<T>::B; // expected-warning {{not supported}} - template<class T> friend void A<T>::f(); // expected-warning {{not supported}} - template<class T> friend void A<T>::g(); // expected-warning {{not supported}} - template<class T> friend void A<T>::C::h(); // expected-warning {{not supported}} - }; - - template<> struct A<int> { - X::type a; // FIXME: private - struct B { - X::type b; // ok - }; - int f() { X::type c; } // FIXME: private - void g() { X::type d; } // ok - struct D { - void h() { X::type e; } // FIXME: private - }; - }; -} - -namespace dr639 { // dr639: yes - void f(int i) { - void((i = 0) + (i = 0)); // expected-warning {{unsequenced}} - } -} - -namespace dr641 { // dr641: yes - namespace std_example { - struct abc; - - struct xyz { - xyz(); // expected-note 0-1{{candidate}} - xyz(xyz &); // expected-note 0-1{{candidate}} - - operator xyz &() = delete; // expected-error 0-1{{extension}} expected-warning {{will never be used}} - operator abc &() = delete; // expected-error 0-1{{extension}} - }; - - struct abc : xyz {}; - - template<typename T> - void use(T &); // expected-note {{expects an l-value}} - void test() { - use<xyz>(xyz()); // expected-error {{no match}} - use<const xyz>(xyz()); -#if __cplusplus < 201103L - // expected-error-re@-2 {{no viable constructor copying parameter of type '{{.*}}xyz'}} -#endif - } - } - - template<typename T> struct error { typedef typename T::error type; }; - - struct A { - template<typename T, typename error<T>::type = 0> operator T() const; // expected-error 0-1{{extension}} - }; - A a; - void f(A&); // expected-note 2{{candidate}} - void g(const A ca) { - f(A()); // expected-error {{no match}} - f(ca); // expected-error {{no match}} - (void)A(); - (void)ca; - } -} - -namespace dr642 { // dr642: yes - void f() { - const int i = 2; - { - char i[i]; - _Static_assert(sizeof(i) == 2, ""); // expected-error {{C11}} - } - } - - struct s { int a; }; - void g(int s) { - struct s *p = new struct s; - p->a = s; - } -} - -#if __cplusplus >= 201103L -namespace dr643 { // dr643: yes - struct A { - int x; - auto f() -> decltype(this->x); - auto f(A &a) -> decltype(a.x); - auto g() -> decltype(x); - auto h() -> decltype(this->y); // expected-error {{no member named 'y'}} - auto h(A &a) -> decltype(a.y); // expected-error {{no member named 'y'}} - auto i() -> decltype(y); // expected-error {{undeclared identifier 'y'}} - int y; - }; -} -#endif - -#if __cplusplus >= 201103L -namespace dr644 { // dr644: partial - struct A { - A() = default; - int x, y; - }; - static_assert(__is_literal_type(A), ""); - - struct B : A {}; - static_assert(__is_literal_type(B), ""); - - struct C : virtual A {}; - static_assert(!__is_literal_type(C), ""); - - struct D { C c; }; - static_assert(!__is_literal_type(D), ""); - - // FIXME: According to DR644, E<C> is a literal type despite having virtual - // base classes. This appears to be a wording defect. - template<typename T> - struct E : T { - constexpr E() = default; - }; - static_assert(!__is_literal_type(E<C>), ""); -} -#endif - -// dr645 increases permission to optimize; it's not clear that it's possible to -// test for this. -// dr645: na - -#if __cplusplus >= 201103L -namespace dr646 { // dr646: sup 981 - struct A { - constexpr A(const A&) = default; // ok - }; - - struct B { - constexpr B() {} - B(B&); - }; - constexpr B b = {}; // ok -} -#endif - -#if __cplusplus >= 201103L -namespace dr647 { // dr647: yes - // This is partially superseded by dr1358. - struct A { - constexpr virtual void f() const; - constexpr virtual void g() const {} // expected-error {{virtual function cannot be constexpr}} - }; - - struct X { virtual void f() const; }; // expected-note {{overridden}} - struct B : X { - constexpr void f() const {} // expected-error {{virtual function cannot be constexpr}} - }; - - struct NonLiteral { NonLiteral() {} }; // expected-note {{not an aggregate and has no constexpr constructors}} - - struct C { - constexpr C(NonLiteral); - constexpr C(NonLiteral, int) {} // expected-error {{not a literal type}} - constexpr C() try {} catch (...) {} -#if __cplusplus <= 201703L - // expected-error@-2 {{function try block in constexpr constructor is a C++2a extension}} -#endif -#if __cplusplus < 201402L - // expected-error@-5 {{use of this statement in a constexpr constructor is a C++14 extension}} -#endif - }; - - struct D { - operator int() const; - constexpr D(int) {} - D(float); // expected-note 2{{declared here}} - }; - constexpr int get(); - struct E { - int n; - D d; - - // FIXME: We should diagnose this, as the conversion function is not - // constexpr. However, that part of this issue is supreseded by dr1364 and - // others; no diagnostic is required for this any more. - constexpr E() - : n(D(0)), - d(0) {} - - constexpr E(int) // expected-error {{never produces a constant expression}} - : n(0), - d(0.0f) {} // expected-note {{non-constexpr constructor}} - constexpr E(float f) // expected-error {{never produces a constant expression}} - : n(get()), - d(D(0) + f) {} // expected-note {{non-constexpr constructor}} - }; -} -#endif - -#if __cplusplus >= 201103L -namespace dr648 { // dr648: yes - int f(); - constexpr int a = (true ? 1 : f()); - constexpr int b = false && f(); - constexpr int c = true || f(); -} -#endif - -#if __cplusplus >= 201103L -namespace dr649 { // dr649: yes - alignas(0x20000000) int n; // expected-error {{requested alignment}} - struct alignas(0x20000000) X {}; // expected-error {{requested alignment}} - struct Y { int n alignas(0x20000000); }; // expected-error {{requested alignment}} - struct alignas(256) Z {}; - // This part is superseded by dr2130 and eventually by aligned allocation support. - auto *p = new Z; -} -#endif - -// dr650 FIXME: add codegen test - -#if __cplusplus >= 201103L -namespace dr651 { // dr651: yes - struct X { - virtual X &f(); - }; - struct Y : X { - Y &f(); - }; - using T = decltype(((X&&)Y()).f()); - using T = X &; -} -#endif - -#if __cplusplus >= 201103L -namespace dr652 { // dr652: yes - constexpr int n = 1.2 * 3.4; - static_assert(n == 4, ""); -} -#endif - -// dr653 FIXME: add codegen test - -#if __cplusplus >= 201103L -namespace dr654 { // dr654: yes - void f() { - if (nullptr) {} // expected-warning {{implicit conversion of nullptr constant to 'bool'}} - bool b = nullptr; // expected-warning {{implicit conversion of nullptr constant to 'bool'}} - if (nullptr == 0) {} - if (nullptr != 0) {} - if (nullptr <= 0) {} // expected-error {{invalid operands}} - if (nullptr == 1) {} // expected-error {{invalid operands}} - if (!nullptr) {} // expected-warning {{implicit conversion of nullptr constant to 'bool'}} - decltype(nullptr) n = 0; - static_cast<int>(nullptr); // expected-error {{not allowed}} - (void)static_cast<decltype(nullptr)>(0); - static_cast<decltype(nullptr)>(1); // expected-error {{not allowed}} - void(true ? nullptr : 0); - void(true ? 0 : nullptr); - } -} -#endif - -namespace dr655 { // dr655: yes - struct A { A(int); }; // expected-note 2-3{{not viable}} - struct B : A { - A a; - B(); - B(int) : B() {} // expected-error 0-1 {{C++11}} - B(int*) : A() {} // expected-error {{no matching constructor}} - }; -} - -namespace dr656 { // dr656: yes - struct A { A(const A&) = delete; }; // expected-error 0-1 {{C++11}} - struct B : A {}; - struct X { operator B(); } x; - const A &r = x; - struct Y : private A { // expected-note 2{{here}} expected-note 2{{candidate}} - operator B() volatile; - }; - extern Y y; - extern volatile Y vy; - // Conversion not considered due to reference-related types. - const A &s = y; // expected-error {{private base class}} - const A &t = vy; // expected-error {{drops 'volatile'}} - - struct C { operator struct D(); } c; - struct D : C {}; - const D &d = c; // ok, D not reference-related to C - - template<typename T> void accept(T); // expected-note {{candidate}} - template<typename T> void accept(...) = delete; // expected-error 0-1 {{C++11}} expected-note {{candidate}} - void f() { - accept<const A&>(x); - accept<const A&>(y); // expected-error {{private base class}} - accept<const A&>(vy); // expected-error {{call to deleted}} expected-error {{no matching constructor}} - accept<const D&>(c); - } -} - -namespace dr657 { // dr657: partial - struct Abs { virtual void x() = 0; }; - struct Der : public Abs { virtual void x(); }; - - struct Cnvt { template<typename F> Cnvt(F); }; - - void foo(Cnvt a); - void foo(Abs &a); - void f(Abs *a) { foo(*a); } - - void bar(Abs &a); - template<typename T> void bar(T); - void g(Abs *a) { bar(*a); } - - // FIXME: The following examples demonstrate that we might be accepting the - // above cases for the wrong reason. - - // FIXME: We should reject this. - struct C { C(Abs) {} }; - // FIXME: We should reject this. - struct Q { operator Abs() { __builtin_unreachable(); } } q; -#if __cplusplus >= 201703L - // FIXME: We should *definitely* reject this. - C c = Q().operator Abs(); -#endif - - template<typename F> struct Cnvt2 { Cnvt2(F); typedef int type; }; - - // FIXME: We should reject this. - void baz(Abs &a); - template<typename T> typename Cnvt2<T>::type baz(T); - void h(Abs *a) { baz(*a); } - - // FIXME: We should reject this too. - Cnvt2<Abs>::type err; -} - -// dr658 FIXME: add codegen test - -#if __cplusplus >= 201103L -namespace dr659 { // dr659: yes - static_assert(alignof(char) == alignof(char&), ""); - static_assert(alignof(int) == alignof(int&), ""); - int n = alignof(int(&)()); // expected-error {{application of 'alignof' to a function type}} - struct A; // expected-note {{forward}} - int m = alignof(A&); // expected-error {{application of 'alignof' to an incomplete type}} -} -#endif - -#if __cplusplus >= 201103L -namespace dr660 { // dr660: yes - enum : int { a }; - enum class { b }; // expected-error {{requires a name}} - auto x = a; - - struct X { - enum : int { a }; - enum class { b }; // expected-error {{requires a name}} - }; - auto y = X::a; -} -#endif - -// dr661 FIXME: add codegen test - -namespace dr662 { // dr662: yes - template <typename T> void f(T t) { - T &tr = t; - T *tp = &t; // expected-error {{pointer to a reference}} -#if __cplusplus >= 201103L - auto *ap = &t; -#endif - } - void g(int n) { f<int&>(n); } // expected-note {{instantiation of}} -} - -namespace dr663 { // dr663: yes c++11 - int ЍЎ = 123; -#if __cplusplus < 201103L - // expected-error@-2 {{non-ASCII}} -#endif -} - -#if __cplusplus >= 201103L -namespace dr664 { // dr664: yes - struct A { A(const A&) = delete; }; - A &&f(A &&a, int n) { - if (n) - return f(static_cast<A&&>(a), n - 1); - return static_cast<A&&>(a); - } -} -#endif - -namespace dr665 { // dr665: yes - struct A { virtual ~A(); }; - struct B : A {} *b; - struct C : private A {} *c; // expected-note {{here}} - struct D : B, C {} *d; - - struct VB : virtual A {} *vb; - struct VC : private virtual A {} *vc; // expected-note {{here}} - struct VD : VB, VC {} *vd; - - void f() { - (void)dynamic_cast<A*>(b); - (void)dynamic_cast<A*>(c); // expected-error {{private}} - (void)dynamic_cast<A*>(d); // expected-error {{ambiguous}} - (void)dynamic_cast<A*>(vb); - (void)dynamic_cast<A*>(vc); // expected-error {{private}}, even though it could be valid at runtime - (void)dynamic_cast<A*>(vd); - } -} - -namespace dr666 { // dr666: yes - struct P { friend P operator*(P, P); P(int); } p(0); - - template<int> int f(); - template<typename T> int f() { - T::type *p = 0; // expected-error {{missing 'typename'}} - int a(T::type); // expected-error {{missing 'typename'}} - return f<T::type>(); // expected-error {{missing 'typename'}} - } - struct X { static const int type = 0; }; - struct Y { typedef int type; }; - int a = f<X>(); - int b = f<Y>(); // expected-note {{instantiation of}} -} - -// Triviality is entirely different in C++98. -#if __cplusplus >= 201103L -namespace dr667 { // dr667: yes - struct A { - A() = default; // expected-warning {{explicitly defaulted default constructor is implicitly deleted}} - int &r; // expected-note {{because field 'r' of reference type 'int &' would not be initialized}} - }; - static_assert(!__is_trivially_constructible(A), ""); - - struct B { ~B() = delete; }; - union C { B b; }; - static_assert(!__is_trivially_destructible(C), ""); - - struct D { D(const D&) = delete; }; - struct E : D {}; - static_assert(!__is_trivially_constructible(E, const E&), ""); - - struct F { F &operator=(F&&) = delete; }; - struct G : F {}; - static_assert(!__is_trivially_assignable(G, G&&), ""); -} -#endif - -// dr668 FIXME: add codegen test - -#if __cplusplus >= 201103L -namespace dr669 { // dr669: yes - void f() { - int n; - using T = decltype(n); - using T = int; - using U = decltype((n)); - using U = int &; - - [=] { - using V = decltype(n); - using V = int; - using W = decltype((n)); - using W = const int&; - } (); - - struct X { - int n; - void f() const { - using X = decltype(n); - using X = int; - using Y = decltype((n)); - using Y = const int&; - } - }; - } -} -#endif - -namespace dr671 { // dr671: yes - enum class E { e }; // expected-error 0-1 {{C++11}} - E e = static_cast<E>(0); - int n = static_cast<int>(E::e); // expected-error 0-1 {{C++11}} - int m = static_cast<int>(e); // expected-error 0-1 {{C++11}} -} - -// dr672 FIXME: add codegen test - -namespace dr673 { // dr673: yes - template<typename> struct X { static const int n = 0; }; - - class A { - friend class B *f(); - class C *f(); - void f(class D *); - enum { e = X<struct E>::n }; - void g() { extern struct F *p; } - }; - B *b; - C *c; - D *d; - E *e; - F *f; // expected-error {{unknown type name}} -} - -namespace dr674 { // dr674: 8 - template<typename T> int f(T); - - int g(int); - template<typename T> int g(T); - - int h(int); - template<typename T> int h(T); - - class X { - friend int dr674::f(int); - friend int dr674::g(int); - friend int dr674::h<>(int); - int n; // expected-note 2{{private}} - }; - - template<typename T> int f(T) { return X().n; } - int g(int) { return X().n; } - template<typename T> int g(T) { return X().n; } // expected-error {{private}} - int h(int) { return X().n; } // expected-error {{private}} - template<typename T> int h(T) { return X().n; } - - template int f(int); - template int g(int); // expected-note {{in instantiation of}} - template int h(int); - - - struct Y { - template<typename T> int f(T); - - int g(int); - template<typename T> int g(T); - - int h(int); - template<typename T> int h(T); - }; - - class Z { - friend int Y::f(int); - friend int Y::g(int); - friend int Y::h<>(int); - int n; // expected-note 2{{private}} - }; - - template<typename T> int Y::f(T) { return Z().n; } - int Y::g(int) { return Z().n; } - template<typename T> int Y::g(T) { return Z().n; } // expected-error {{private}} - int Y::h(int) { return Z().n; } // expected-error {{private}} - template<typename T> int Y::h(T) { return Z().n; } - - // FIXME: Should the <> be required here? - template int Y::f<>(int); - template int Y::g<>(int); // expected-note {{in instantiation of}} - template int Y::h<>(int); -} - -namespace dr675 { // dr675: dup 739 - template<typename T> struct A { T n : 1; }; -#if __cplusplus >= 201103L - static_assert(A<char>{1}.n < 0, ""); - static_assert(A<int>{1}.n < 0, ""); - static_assert(A<long long>{1}.n < 0, ""); -#endif -} - -// dr676: na - -namespace dr677 { // dr677: no - struct A { - void *operator new(std::size_t); - void operator delete(void*) = delete; // expected-error 0-1{{C++11}} expected-note {{deleted}} - }; - struct B { - void *operator new(std::size_t); - void operator delete(void*) = delete; // expected-error 0-1{{C++11}} expected-note 2{{deleted}} - virtual ~B(); - }; - void f(A *p) { delete p; } // expected-error {{deleted}} - // FIXME: This appears to be valid; we shouldn't even be looking up the 'operator delete' here. - void f(B *p) { delete p; } // expected-error {{deleted}} - B::~B() {} // expected-error {{deleted}} -} - -// dr678 FIXME: check that the modules ODR check catches this - -namespace dr679 { // dr679: yes - struct X {}; - template<int> void operator+(X, X); - template<> void operator+<0>(X, X) {} // expected-note {{previous}} - template<> void operator+<0>(X, X) {} // expected-error {{redefinition}} -} - -// dr680: na - -#if __cplusplus >= 201103L -namespace dr681 { // dr681: partial - auto *a() -> int; // expected-error {{must specify return type 'auto', not 'auto *'}} - auto (*b)() -> int; - // FIXME: The errors here aren't great. - auto (*c()) -> int; // expected-error {{expected function body}} - auto ((*d)()) -> int; // expected-error {{expected ';'}} expected-error {{requires an initializer}} - - // FIXME: This is definitely wrong. This should be - // "function of () returning pointer to function of () returning int" - // not a function with a deduced return type. - auto (*e())() -> int; // expected-error 0-1{{C++14}} - - auto f() -> int (*)(); - auto g() -> auto (*)() -> int; -} -#endif - -#if __cplusplus >= 201103L -namespace dr683 { // dr683: yes - struct A { - A() = default; - A(const A&) = default; - A(A&); - }; - static_assert(__is_trivially_constructible(A, const A&), ""); - static_assert(!__is_trivially_constructible(A, A&), ""); - static_assert(!__is_trivial(A), ""); - - struct B : A {}; - static_assert(__is_trivially_constructible(B, const B&), ""); - static_assert(__is_trivially_constructible(B, B&), ""); - static_assert(__is_trivial(B), ""); -} -#endif - -#if __cplusplus >= 201103L -namespace dr684 { // dr684: sup 1454 - void f() { - int a; // expected-note {{here}} - constexpr int *p = &a; // expected-error {{constant expression}} expected-note {{pointer to 'a'}} - } -} -#endif - -#if __cplusplus >= 201103L -namespace dr685 { // dr685: yes - enum E : long { e }; - void f(int); - int f(long); - int a = f(e); - - enum G : short { g }; - int h(short); - void h(long); - int b = h(g); - - int i(int); - void i(long); - int c = i(g); - - int j(unsigned int); // expected-note {{candidate}} - void j(long); // expected-note {{candidate}} - int d = j(g); // expected-error {{ambiguous}} - - int k(short); // expected-note {{candidate}} - void k(int); // expected-note {{candidate}} - int x = k(g); // expected-error {{ambiguous}} -} -#endif - -namespace dr686 { // dr686: yes - void f() { - (void)dynamic_cast<struct A*>(0); // expected-error {{incomplete}} expected-note {{forward}} - (void)dynamic_cast<struct A{}*>(0); // expected-error {{cannot be defined in a type specifier}} - (void)typeid(struct B*); - (void)typeid(struct B{}*); // expected-error {{cannot be defined in a type specifier}} - (void)static_cast<struct C*>(0); - (void)static_cast<struct C{}*>(0); // expected-error {{cannot be defined in a type specifier}} - (void)reinterpret_cast<struct D*>(0); - (void)reinterpret_cast<struct D{}*>(0); // expected-error {{cannot be defined in a type specifier}} - (void)const_cast<struct E*>(0); // expected-error {{not allowed}} - (void)const_cast<struct E{}*>(0); // expected-error {{cannot be defined in a type specifier}} - (void)sizeof(struct F*); - (void)sizeof(struct F{}*); // expected-error {{cannot be defined in a type specifier}} - (void)new struct G*; - (void)new struct G{}*; // expected-error {{cannot be defined in a type specifier}} -#if __cplusplus >= 201103L - (void)alignof(struct H*); - (void)alignof(struct H{}*); // expected-error {{cannot be defined in a type specifier}} -#endif - (void)(struct I*)0; - (void)(struct I{}*)0; // expected-error {{cannot be defined in a type specifier}} - if (struct J *p = 0) {} - if (struct J {} *p = 0) {} // expected-error {{cannot be defined in a condition}} - for (struct K *p = 0; struct L *q = 0; ) {} - for (struct K {} *p = 0; struct L {} *q = 0; ) {} // expected-error {{'L' cannot be defined in a condition}} -#if __cplusplus >= 201103L - using M = struct {}; -#endif - struct N { - operator struct O{}(){}; // expected-error {{cannot be defined in a type specifier}} - }; - try {} - catch (struct P *) {} // expected-error {{incomplete}} expected-note {{forward}} - catch (struct P {} *) {} // expected-error {{cannot be defined in a type specifier}} -#if __cplusplus < 201703L - void g() throw(struct Q); // expected-error {{incomplete}} expected-note {{forward}} - void h() throw(struct Q {}); // expected-error {{cannot be defined in a type specifier}} -#endif - } - template<struct R *> struct X; - template<struct R {} *> struct Y; // expected-error {{cannot be defined in a type specifier}} -} - -namespace dr687 { // dr687 still open - template<typename T> void f(T a) { - // FIXME: This is valid in C++20. - g<int>(a); // expected-error {{undeclared}} expected-error {{'('}} - - // This is not. - template g<int>(a); // expected-error {{expected expression}} - } -} - -namespace dr692 { // dr692: no - namespace temp_func_order_example2 { - template <typename T, typename U> struct A {}; - template <typename T, typename U> void f(U, A<U, T> *p = 0); // expected-note {{candidate}} - template <typename U> int &f(U, A<U, U> *p = 0); // expected-note {{candidate}} - template <typename T> void g(T, T = T()); - template <typename T, typename... U> void g(T, U...); // expected-error 0-1{{C++11}} - void h() { - int &r = f<int>(42, (A<int, int> *)0); - f<int>(42); // expected-error {{ambiguous}} - // FIXME: We should reject this due to ambiguity between the pack and the - // default argument. Only parameters with arguments are considered during - // partial ordering of function templates. - g(42); - } - } - - namespace temp_func_order_example3 { - template <typename T, typename... U> void f(T, U...); // expected-error 0-1{{C++11}} - template <typename T> void f(T); - template <typename T, typename... U> int &g(T *, U...); // expected-error 0-1{{C++11}} - template <typename T> void g(T); - void h(int i) { - // This is made ambiguous by dr692, but made valid again by dr1395. - f(&i); - int &r = g(&i); - } - } - - namespace temp_deduct_partial_example { - template <typename... Args> char &f(Args... args); // expected-error 0-1{{C++11}} - template <typename T1, typename... Args> short &f(T1 a1, Args... args); // expected-error 0-1{{C++11}} - template <typename T1, typename T2> int &f(T1 a1, T2 a2); - void g() { - char &a = f(); - short &b = f(1, 2, 3); - int &c = f(1, 2); - } - } - - namespace temp_deduct_type_example1 { - template <class T1, class ...Z> class S; // expected-error 0-1{{C++11}} - template <class T1, class ...Z> class S<T1, const Z&...>; // expected-error 0-1{{C++11}} - template <class T1, class T2> class S<T1, const T2&> {}; - S<int, const int&> s; - - // FIXME: This should select the first partial specialization. Deduction of - // the second from the first should succeed, because we should ignore the - // trailing pack in A with no corresponding P. - template<class T, class... U> struct A; // expected-error 0-1{{C++11}} - template<class T1, class T2, class... U> struct A<T1,T2*,U...>; // expected-note {{matches}} expected-error 0-1{{C++11}} - template<class T1, class T2> struct A<T1,T2> {}; // expected-note {{matches}} - template struct A<int, int*>; // expected-error {{ambiguous}} - } - - namespace temp_deduct_type_example3 { - // FIXME: This should select the first template, as in the case above. - template<class T, class... U> void f(T*, U...){} // expected-note {{candidate}} expected-error 0-1{{C++11}} - template<class T> void f(T){} // expected-note {{candidate}} - template void f(int*); // expected-error {{ambiguous}} - } -} diff --git a/test/CXX/drs/dr7xx.cpp b/test/CXX/drs/dr7xx.cpp deleted file mode 100644 index d02582b5b40c..000000000000 --- a/test/CXX/drs/dr7xx.cpp +++ /dev/null @@ -1,92 +0,0 @@ -// RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++1z %s -verify -fexceptions -fcxx-exceptions -pedantic-errors - -namespace dr727 { // dr727: partial - struct A { - template<typename T> struct C; // expected-note 6{{here}} - template<typename T> void f(); // expected-note {{here}} - template<typename T> static int N; // expected-error 0-1{{C++14}} expected-note 6{{here}} - - template<> struct C<int>; - template<> void f<int>(); - template<> static int N<int>; - - template<typename T> struct C<T*>; - template<typename T> static int N<T*>; - - struct B { - template<> struct C<float>; // expected-error {{not in class 'A' or an enclosing namespace}} - template<> void f<float>(); // expected-error {{no function template matches}} - template<> static int N<float>; // expected-error {{not in class 'A' or an enclosing namespace}} - - template<typename T> struct C<T**>; // expected-error {{not in class 'A' or an enclosing namespace}} - template<typename T> static int N<T**>; // expected-error {{not in class 'A' or an enclosing namespace}} - - template<> struct A::C<double>; // expected-error {{not in class 'A' or an enclosing namespace}} - template<> void A::f<double>(); // expected-error {{no function template matches}} expected-error {{cannot have a qualified name}} - template<> static int A::N<double>; // expected-error {{not in class 'A' or an enclosing namespace}} expected-error {{cannot have a qualified name}} - - template<typename T> struct A::C<T***>; // expected-error {{not in class 'A' or an enclosing namespace}} - template<typename T> static int A::N<T***>; // expected-error {{not in class 'A' or an enclosing namespace}} expected-error {{cannot have a qualified name}} - }; - }; - - template<> struct A::C<char>; - template<> void A::f<char>(); - template<> int A::N<char>; - - template<typename T> struct A::C<T****>; - template<typename T> int A::N<T****>; - - namespace C { - template<> struct A::C<long>; // expected-error {{not in class 'A' or an enclosing namespace}} - template<> void A::f<long>(); // expected-error {{not in class 'A' or an enclosing namespace}} - template<> int A::N<long>; // expected-error {{not in class 'A' or an enclosing namespace}} - - template<typename T> struct A::C<T*****>; // expected-error {{not in class 'A' or an enclosing namespace}} - template<typename T> int A::N<T*****>; // expected-error {{not in class 'A' or an enclosing namespace}} - } - - template<typename> - struct D { - template<typename T> struct C { typename T::error e; }; // expected-error {{no members}} - template<typename T> void f() { T::error; } // expected-error {{no members}} - template<typename T> static const int N = T::error; // expected-error 2{{no members}} expected-error 0-1{{C++14}} - - template<> struct C<int> {}; - template<> void f<int>() {} - template<> static const int N<int>; - - template<typename T> struct C<T*> {}; - template<typename T> static const int N<T*>; - }; - - void d(D<int> di) { - D<int>::C<int>(); - di.f<int>(); - int a = D<int>::N<int>; // FIXME: expected-note {{instantiation of}} - - D<int>::C<int*>(); - int b = D<int>::N<int*>; - - D<int>::C<float>(); // expected-note {{instantiation of}} - di.f<float>(); // expected-note {{instantiation of}} - int c = D<int>::N<float>; // expected-note {{instantiation of}} - } -} - -namespace dr777 { // dr777: 3.7 -#if __cplusplus >= 201103L -template <typename... T> -void f(int i = 0, T ...args) {} -void ff() { f(); } - -template <typename... T> -void g(int i = 0, T ...args, T ...args2) {} - -template <typename... T> -void h(int i = 0, T ...args, int j = 1) {} -#endif -} diff --git a/test/CXX/drs/dr9xx.cpp b/test/CXX/drs/dr9xx.cpp deleted file mode 100644 index b37e17d6b098..000000000000 --- a/test/CXX/drs/dr9xx.cpp +++ /dev/null @@ -1,75 +0,0 @@ -// RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++1z %s -verify -fexceptions -fcxx-exceptions -pedantic-errors - -#if __cplusplus < 201103L -// expected-no-diagnostics -#endif - -namespace std { - __extension__ typedef __SIZE_TYPE__ size_t; - - template<typename T> struct initializer_list { - const T *p; size_t n; - initializer_list(const T *p, size_t n); - }; -} - -namespace dr990 { // dr990: 3.5 -#if __cplusplus >= 201103L - struct A { // expected-note 2{{candidate}} - A(std::initializer_list<int>); // expected-note {{candidate}} - }; - struct B { - A a; - }; - B b1 { }; - B b2 { 1 }; // expected-error {{no viable conversion from 'int' to 'dr990::A'}} - B b3 { { 1 } }; - - struct C { - C(); - C(int); - C(std::initializer_list<int>) = delete; // expected-note {{here}} - }; - C c1[3] { 1 }; // ok - C c2[3] { 1, {2} }; // expected-error {{call to deleted}} - - struct D { - D(); - D(std::initializer_list<int>); - D(std::initializer_list<double>); - }; - D d{}; -#endif -} - -namespace dr948 { // dr948: 3.7 -#if __cplusplus >= 201103L - class A { - public: - constexpr A(int v) : v(v) { } - constexpr operator int() const { return v; } - private: - int v; - }; - - constexpr int id(int x) - { - return x; - } - - void f() { - if (constexpr int i = id(101)) { } - switch (constexpr int i = id(2)) { default: break; case 2: break; } - for (; constexpr int i = id(0); ) { } - while (constexpr int i = id(0)) { } - - if (constexpr A i = 101) { } - switch (constexpr A i = 2) { default: break; case 2: break; } - for (; constexpr A i = 0; ) { } - while (constexpr A i = 0) { } - } -#endif -} diff --git a/test/CXX/except/except.handle/p16.cpp b/test/CXX/except/except.handle/p16.cpp deleted file mode 100644 index 0810be108e41..000000000000 --- a/test/CXX/except/except.handle/p16.cpp +++ /dev/null @@ -1,40 +0,0 @@ -// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -fsyntax-only -verify %s - -// The object declared in an exception-declaration or, if the -// exception-declaration does not specify a name, a temporary (12.2) -// is copy-initialized (8.5) from the exception object. -// -template<typename T> -class X { - T* ptr; - -public: - X(const X<T> &) { - int *ip = 0; - ptr = ip; // expected-error{{assigning to 'float *' from incompatible type 'int *'}} - } - - ~X() { - float *fp = 0; - ptr = fp; // expected-error{{assigning to 'int *' from incompatible type 'float *'}} - } -}; - -void f() { - try { - } catch (X<float>) { // expected-note{{instantiation}} - // copy constructor - } catch (X<int> xi) { // expected-note{{instantiation}} - // destructor - } -} - -struct Abstract { - virtual void f() = 0; // expected-note{{pure virtual}} -}; - -void g() { - try { - } catch (Abstract) { // expected-error{{variable type 'Abstract' is an abstract class}} - } -} diff --git a/test/CXX/except/except.spec/canonical.cpp b/test/CXX/except/except.spec/canonical.cpp deleted file mode 100644 index d6dc25889205..000000000000 --- a/test/CXX/except/except.spec/canonical.cpp +++ /dev/null @@ -1,54 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s -// expected-no-diagnostics - -// 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/p1.cpp b/test/CXX/except/except.spec/p1.cpp deleted file mode 100644 index 03d75326a643..000000000000 --- a/test/CXX/except/except.spec/p1.cpp +++ /dev/null @@ -1,97 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -fexceptions -fcxx-exceptions -fsyntax-only -verify %s - -// Simple parser tests, dynamic specification. - -namespace dyn { - - struct X { }; - - struct Y { }; - - void f() throw() { } - - void g(int) throw(X) { } - - void h() throw(X, Y) { } - - class Class { - void foo() throw (X, Y) { } - }; - - void (*fptr)() throw(); - -} - -// Simple parser tests, noexcept specification. - -namespace noex { - - void f1() noexcept { } - void f2() noexcept (true) { } - void f3() noexcept (false) { } - void f4() noexcept (1 < 2) { } - - class CA1 { - void foo() noexcept { } - void bar() noexcept (true) { } - }; - - void (*fptr1)() noexcept; - void (*fptr2)() noexcept (true); - -} - -namespace mix { - - void f() throw(int) noexcept { } // expected-error {{cannot have both}} - void g() noexcept throw(int) { } // expected-error {{cannot have both}} - -} - -// Sema tests, noexcept specification - -namespace noex { - - struct A {}; - - void g1() noexcept(A()); // expected-error {{not contextually convertible}} - void g2(bool b) noexcept(b); // expected-error {{argument to noexcept specifier must be a constant expression}} expected-note {{read of non-const variable 'b'}} expected-note {{here}} - -} - -namespace noexcept_unevaluated { - template<typename T> bool f(T) { - T* x = 1; - } - - template<typename T> - void g(T x) noexcept((sizeof(T) == sizeof(int)) || noexcept(f(x))) { } - - void h() { - g(1); - } -} - -namespace PR11084 { - template<int X> struct A { - static int f() noexcept(1/X) { return 10; } // expected-error{{argument to noexcept specifier must be a constant expression}} expected-note{{division by zero}} - }; - - template<int X> void f() { - int (*p)() noexcept(1/X); // expected-error{{argument to noexcept specifier must be a constant expression}} expected-note{{division by zero}} - }; - - void g() { - A<0>::f(); // expected-note{{in instantiation of exception specification for 'f'}} - f<0>(); // expected-note{{in instantiation of function template specialization}} - } -} - -namespace FuncTmplNoexceptError { - int a = 0; - // expected-error@+1{{argument to noexcept specifier must be a constant expression}} - template <class T> T f() noexcept(a++){ return {};} - void g(){ - f<int>(); - } -}; diff --git a/test/CXX/except/except.spec/p11.cpp b/test/CXX/except/except.spec/p11.cpp deleted file mode 100644 index b7b9fcb23144..000000000000 --- a/test/CXX/except/except.spec/p11.cpp +++ /dev/null @@ -1,12 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -fexceptions -fcxx-exceptions -fsyntax-only -verify %s - -// This is the "let the user shoot themselves in the foot" clause. -void f() noexcept { // expected-note {{function declared non-throwing here}} - throw 0; // expected-warning {{has a non-throwing exception specification but}} -} -void g() throw() { // expected-note {{function declared non-throwing here}} - throw 0; // expected-warning {{has a non-throwing exception specification but}} -} -void h() throw(int) { - throw 0.0; // no-error -} diff --git a/test/CXX/except/except.spec/p14-ir.cpp b/test/CXX/except/except.spec/p14-ir.cpp deleted file mode 100644 index af1d9a442505..000000000000 --- a/test/CXX/except/except.spec/p14-ir.cpp +++ /dev/null @@ -1,81 +0,0 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -fexceptions -o - %s | FileCheck %s - -// Copy constructor -struct X0 { - X0(); - X0(const X0 &) throw(); - X0(X0 &); -}; - -struct X1 { - X1(); - X1(const X1 &) throw(); -}; - -struct X2 : X1 { - X2(); -}; -struct X3 : X0, X1 { - X3(); -}; - -struct X4 { - X4(X4 &) throw(); -}; - -struct X5 : X0, X4 { }; - -void test(X2 x2, X3 x3, X5 x5) { - // CHECK: define linkonce_odr void @_ZN2X2C1ERKS_(%struct.X2* %this, %struct.X2* dereferenceable({{[0-9]+}})) unnamed_addr - // CHECK: call void @_ZN2X2C2ERKS_({{.*}}) [[NUW:#[0-9]+]] - // CHECK-NEXT: ret void - // CHECK-NEXT: } - X2 x2a(x2); - // CHECK: define linkonce_odr void @_ZN2X3C1ERKS_(%struct.X3* %this, %struct.X3* dereferenceable({{[0-9]+}})) unnamed_addr - // CHECK: call void @_ZN2X3C2ERKS_({{.*}}) [[NUW]] - // CHECK-NEXT: ret void - // CHECK-NEXT: } - X3 x3a(x3); - // CHECK: define linkonce_odr void @_ZN2X5C1ERS_({{.*}}) unnamed_addr - // CHECK-NOT: call void @__cxa_call_unexpected - // CHECK: ret void - X5 x5a(x5); -} - -// Default constructor -struct X6 { - X6() throw(); -}; - -struct X7 { - X7(); -}; - -struct X8 : X6 { }; -struct X9 : X6, X7 { }; - -void test() { - // CHECK: define linkonce_odr void @_ZN2X8C1Ev(%struct.X8* %this) unnamed_addr - // CHECK: call void @_ZN2X8C2Ev({{.*}}) [[NUW]] - // CHECK-NEXT: ret void - X8(); - - // 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 @_ZN2X8C2Ev(%struct.X8* %this) unnamed_addr - // CHECK: call void @_ZN2X6C2Ev({{.*}}) [[NUW]] - // CHECK-NEXT: ret void - - // CHECK: define linkonce_odr void @_ZN2X9C2Ev(%struct.X9* %this) unnamed_addr - // CHECK: call void @_ZN2X6C2Ev({{.*}}) [[NUW]] - // FIXME: and here: - // CHECK-NEXT: bitcast - // CHECK-NEXT: call void @_ZN2X7C2Ev({{.*}}) - // CHECK: ret void -} - -// CHECK: attributes [[NUW]] = { nounwind{{.*}} } diff --git a/test/CXX/except/except.spec/p14.cpp b/test/CXX/except/except.spec/p14.cpp deleted file mode 100644 index c717d9779791..000000000000 --- a/test/CXX/except/except.spec/p14.cpp +++ /dev/null @@ -1,143 +0,0 @@ -// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -verify -std=c++11 %s -struct A { }; -struct B { }; -struct C { }; - -// Destructor -struct X0 { - virtual ~X0() throw(A); // expected-note{{overridden virtual function is here}} -}; -struct X1 { - virtual ~X1() throw(B); // expected-note{{overridden virtual function is here}} -}; -struct X2 : public X0, public X1 { }; // expected-error 2{{exception specification of overriding function is more lax than base version}} - -// Copy-assignment operator. -struct CA0 { - CA0 &operator=(const CA0&) throw(A); -}; -struct CA1 { - CA1 &operator=(const CA1&) throw(B); -}; -struct CA2 : CA0, CA1 { }; - -void test_CA() { - CA2 &(CA2::*captr1)(const CA2&) throw(A, B) = &CA2::operator=; - CA2 &(CA2::*captr2)(const CA2&) throw(A, B, C) = &CA2::operator=; - CA2 &(CA2::*captr3)(const CA2&) throw(A) = &CA2::operator=; // expected-error{{target exception specification is not superset of source}} - CA2 &(CA2::*captr4)(const CA2&) throw(B) = &CA2::operator=; // expected-error{{target exception specification is not superset of source}} -} - -// In-class member initializers. -struct IC0 { - int inClassInit = 0; -}; -struct IC1 { - int inClassInit = (throw B(), 0); -}; -// FIXME: the exception specification on the default constructor is wrong: -// we cannot currently compute the set of thrown types. -static_assert(noexcept(IC0()), "IC0() does not throw"); -static_assert(!noexcept(IC1()), "IC1() throws"); - -namespace PR13381 { - struct NoThrowMove { - NoThrowMove(const NoThrowMove &); - NoThrowMove(NoThrowMove &&) noexcept; - NoThrowMove &operator=(const NoThrowMove &) const; - NoThrowMove &operator=(NoThrowMove &&) const noexcept; - }; - struct NoThrowMoveOnly { - NoThrowMoveOnly(NoThrowMoveOnly &&) noexcept; - NoThrowMoveOnly &operator=(NoThrowMoveOnly &&) noexcept; - }; - struct X { - const NoThrowMove a; - NoThrowMoveOnly b; - - static X val(); - static X &ref(); - }; - // These both perform a move, but that copy might throw, because it calls - // NoThrowMove's copy constructor (because PR13381::a is const). - static_assert(!noexcept(X(X::val())), ""); - static_assert(!noexcept(X::ref() = X::val()), ""); -} - -namespace PR14141 { - // Part of DR1351: the implicit exception-specification is noexcept(false) if - // the set of potential exceptions of the special member function contains - // "any". Hence it is compatible with noexcept(false). - struct ThrowingBase { - ThrowingBase() noexcept(false); - ThrowingBase(const ThrowingBase&) noexcept(false); - ThrowingBase(ThrowingBase&&) noexcept(false); - ThrowingBase &operator=(const ThrowingBase&) noexcept(false); - ThrowingBase &operator=(ThrowingBase&&) noexcept(false); - ~ThrowingBase() noexcept(false); - }; - struct Derived : ThrowingBase { - Derived() noexcept(false) = default; - Derived(const Derived&) noexcept(false) = default; - Derived(Derived&&) noexcept(false) = default; - Derived &operator=(const Derived&) noexcept(false) = default; - Derived &operator=(Derived&&) noexcept(false) = default; - ~Derived() noexcept(false) = default; - }; - struct Derived2 : ThrowingBase { - Derived2() = default; - Derived2(const Derived2&) = default; - Derived2(Derived2&&) = default; - Derived2 &operator=(const Derived2&) = default; - Derived2 &operator=(Derived2&&) = default; - ~Derived2() = default; - }; - struct Derived3 : ThrowingBase { - Derived3() noexcept(true) = default; // expected-error {{does not match the calculated}} - Derived3(const Derived3&) noexcept(true) = default; // expected-error {{does not match the calculated}} - Derived3(Derived3&&) noexcept(true) = default; // expected-error {{does not match the calculated}} - Derived3 &operator=(const Derived3&) noexcept(true) = default; // expected-error {{does not match the calculated}} - Derived3 &operator=(Derived3&&) noexcept(true) = default; // expected-error {{does not match the calculated}} - ~Derived3() noexcept(true) = default; // expected-error {{does not match the calculated}} - }; -} - -namespace rdar13017229 { - struct Base { - virtual ~Base() {} - }; - - struct Derived : Base { - virtual ~Derived(); - Typo foo(); // expected-error{{unknown type name 'Typo'}} - }; -} - -namespace InhCtor { - template<int> struct X {}; - struct Base { - Base(X<0>) noexcept(true); - Base(X<1>) noexcept(false); - Base(X<2>) throw(X<2>); - template<typename T> Base(T) throw(T); - }; - template<typename T> struct Throw { - Throw() throw(T); - }; - struct Derived1 : Base, X<5> { - using Base::Base; - int n; - }; - struct Derived2 : Base, Throw<X<3>> { - using Base::Base; - }; - struct Derived3 : Base { - using Base::Base; - Throw<X<4>> x; - }; - static_assert(noexcept(Derived1(X<0>())), ""); - static_assert(!noexcept(Derived1(X<1>())), ""); - static_assert(!noexcept(Derived1(X<2>())), ""); - static_assert(!noexcept(Derived2(X<0>())), ""); - static_assert(!noexcept(Derived3(X<0>())), ""); -} diff --git a/test/CXX/except/except.spec/p15.cpp b/test/CXX/except/except.spec/p15.cpp deleted file mode 100644 index acf4426a8eb5..000000000000 --- a/test/CXX/except/except.spec/p15.cpp +++ /dev/null @@ -1,32 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -fexceptions -fcxx-exceptions -fsyntax-only -verify %s -// RUN: %clang_cc1 -DUSE -std=c++11 -fexceptions -fcxx-exceptions -fsyntax-only -verify %s - -// Maybe force the implicit declaration of 'operator delete' and 'operator -// delete[]'. This should make no difference to anything! -#ifdef USE -void f(int *p) { - delete p; - delete [] p; -} -#endif - -// Deallocation functions are implicitly noexcept. -// Thus, explicit specs aren't allowed to conflict. - -void operator delete(void*); // expected-warning {{function previously declared with an explicit exception specification redeclared with an implicit exception specification}} -void operator delete[](void*); // expected-warning {{function previously declared with an explicit exception specification redeclared with an implicit exception specification}} - -static_assert(noexcept(operator delete(0)), ""); -static_assert(noexcept(operator delete[](0)), ""); - -// Same goes for explicit declarations. -void operator delete(void*, float); -void operator delete[](void*, float); - -static_assert(noexcept(operator delete(0, 0.f)), ""); -static_assert(noexcept(operator delete[](0, 0.f)), ""); - -// But explicit specs stay. -void operator delete(void*, double) throw(int); // expected-note {{previous}} -static_assert(!noexcept(operator delete(0, 0.)), ""); -void operator delete(void*, double) noexcept; // expected-error {{does not match}} diff --git a/test/CXX/except/except.spec/p2-dynamic-types.cpp b/test/CXX/except/except.spec/p2-dynamic-types.cpp deleted file mode 100644 index 57f8c3251a1c..000000000000 --- a/test/CXX/except/except.spec/p2-dynamic-types.cpp +++ /dev/null @@ -1,34 +0,0 @@ -// RUN: %clang_cc1 -fexceptions -fcxx-exceptions -fsyntax-only -verify %s - -// Dynamic specifications: valid types. - -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}} - -// 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/CXX/except/except.spec/p2-places-1z.cpp b/test/CXX/except/except.spec/p2-places-1z.cpp deleted file mode 100644 index 619ea33b5349..000000000000 --- a/test/CXX/except/except.spec/p2-places-1z.cpp +++ /dev/null @@ -1,17 +0,0 @@ -// RUN: %clang_cc1 -std=c++1z -fexceptions -fcxx-exceptions -fsyntax-only -verify %s - -// In C++1z, we can put an exception-specification on any function declarator; the -// corresponding paragraph from C++14 and before was deleted. -// expected-no-diagnostics - -void f() noexcept; -void (*fp)() noexcept; -void (**fpp)() noexcept; -void g(void (**pfa)() noexcept); -void (**h())() noexcept; - -template<typename T> struct A {}; -template<void() noexcept> struct B {}; -A<void() noexcept> a; -B<f> b; -auto *p = new decltype(f)**; diff --git a/test/CXX/except/except.spec/p2-places.cpp b/test/CXX/except/except.spec/p2-places.cpp deleted file mode 100644 index ea842af89845..000000000000 --- a/test/CXX/except/except.spec/p2-places.cpp +++ /dev/null @@ -1,65 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -fexceptions -fcxx-exceptions -fsyntax-only -verify %s - -// Tests where specs are allowed and where they aren't. - -namespace dyn { - - // 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}} - - // FIXME: Missing a lot of negative tests, primarily type-ids in various places - // We fail to diagnose all of those. -} - -namespace noex { - - // These parallel those from above. - - void f() noexcept(false); - - void (*fp)() noexcept(false); - - void g(void pfa() noexcept(false)); - - typedef int (*pf)() noexcept(false); // expected-error {{specifications are not allowed in typedefs}} - - void (*h())() noexcept(false); - - void (*i() noexcept(false))(void (*)() noexcept(true)) noexcept(false); - - void (**k)(void pfa() noexcept(false)); // no-error - - void (**j)() noexcept(false); // expected-error {{not allowed beyond a single}} - - void (**(*h())())() noexcept(false); // expected-error {{not allowed beyond a single}} -} diff --git a/test/CXX/except/except.spec/p3.cpp b/test/CXX/except/except.spec/p3.cpp deleted file mode 100644 index d5af4651047f..000000000000 --- a/test/CXX/except/except.spec/p3.cpp +++ /dev/null @@ -1,116 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -fexceptions -fcxx-exceptions -fsyntax-only -verify %s - -// Exception specification compatibility. -// We test function pointers, because functions have an extra rule in p4. - -// Same type is compatible -extern void (*r1)() throw(int); -extern void (*r1)() throw(int); - -// Typedefs don't matter. -typedef int INT; -extern void (*r2)() throw(int); -extern void (*r2)() throw(INT); - -// Order doesn't matter. -extern void (*r3)() throw(int, float); -extern void (*r3)() throw(float, int); - -// MS throw-any spec and no spec at all are compatible -extern void (*r4)(); -extern void (*r4)() throw(...); - -// throw(X) and no spec are not compatible -extern void (*r5)() throw(int); // expected-note {{previous declaration}} -extern void (*r5)(); // expected-error {{exception specification in declaration does not match}} - -// throw(int) and no spec are not compatible -extern void f5() throw(int); // expected-note {{previous declaration}} -extern void f5(); // expected-error {{missing exception specification}} - -// Different types are not compatible. -extern void (*r7)() throw(int); // expected-note {{previous declaration}} -extern void (*r7)() throw(float); // expected-error {{exception specification in declaration does not match}} - -// Top-level const doesn't matter. -extern void (*r8)() throw(int); -extern void (*r8)() throw(const int); - -// Multiple appearances don't matter. -extern void (*r9)() throw(int, int); -extern void (*r9)() throw(int, int); - - -// noexcept is compatible with itself -extern void (*r10)() noexcept; -extern void (*r10)() noexcept; - -// noexcept(true) is compatible with noexcept -extern void (*r11)() noexcept; -extern void (*r11)() noexcept(true); - -// noexcept(false) isn't -extern void (*r12)() noexcept; // expected-note {{previous declaration}} -extern void (*r12)() noexcept(false); // expected-error {{does not match}} - -// The form of the boolean expression doesn't matter. -extern void (*r13)() noexcept(1 < 2); -extern void (*r13)() noexcept(2 > 1); - -// noexcept(false) is incompatible with noexcept(true) -extern void (*r14)() noexcept(true); // expected-note {{previous declaration}} -extern void (*r14)() noexcept(false); // expected-error {{does not match}} - -// noexcept(false) is compatible with itself -extern void (*r15)() noexcept(false); -extern void (*r15)() noexcept(false); - -// noexcept(false) is compatible with MS throw(...) -extern void (*r16)() noexcept(false); -extern void (*r16)() throw(...); - -// noexcept(false) is *not* compatible with no spec -extern void (*r17)(); // expected-note {{previous declaration}} -extern void (*r17)() noexcept(false); // expected-error {{does not match}} - -// except for functions -void f17(); -void f17() noexcept(false); - -// noexcept(false) is compatible with dynamic specs that throw unless -// CWG 1073 resolution is accepted. Clang implements it. -//extern void (*r18)() throw(int); -//extern void (*r18)() noexcept(false); - -// noexcept(true) is compatible with dynamic specs that don't throw -extern void (*r19)() throw(); -extern void (*r19)() noexcept(true); - -// The other way round doesn't work. -extern void (*r20)() throw(); // expected-note {{previous declaration}} -extern void (*r20)() noexcept(false); // expected-error {{does not match}} - -extern void (*r21)() throw(int); // expected-note {{previous declaration}} -extern void (*r21)() noexcept(true); // expected-error {{does not match}} - - -// As a very special workaround, we allow operator new to match no spec -// with a throw(bad_alloc) spec, because C++0x makes an incompatible change -// here. -extern "C++" { namespace std { class bad_alloc {}; } } -typedef decltype(sizeof(int)) mysize_t; -void* operator new(mysize_t) throw(std::bad_alloc); -void* operator new(mysize_t); -void* operator new[](mysize_t); -void* operator new[](mysize_t) throw(std::bad_alloc); - -template<bool X> void equivalent() noexcept (X); -template<bool X> void equivalent() noexcept (X); - -template<bool X, bool Y> void not_equivalent() noexcept (X); // expected-note {{previous}} -template<bool X, bool Y> void not_equivalent() noexcept (Y); // expected-error {{does not match}} - -template<bool X> void missing() noexcept (X); // expected-note {{previous}} -// FIXME: The missing exception specification that we report here doesn't make -// sense in the context of this declaration. -template<bool P> void missing(); // expected-error {{missing exception specification 'noexcept(X)'}} diff --git a/test/CXX/except/except.spec/p4.cpp b/test/CXX/except/except.spec/p4.cpp deleted file mode 100644 index 04b2bd9bf28b..000000000000 --- a/test/CXX/except/except.spec/p4.cpp +++ /dev/null @@ -1,41 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 %s -verify -fcxx-exceptions - -// We permit overriding an implicit exception specification with an explicit one -// as an extension, for compatibility with existing code. - -struct S { - void a(); // expected-note {{here}} - ~S(); // expected-note {{here}} - void operator delete(void*); // expected-note {{here}} -}; - -void S::a() noexcept {} // expected-error {{does not match previous}} -S::~S() noexcept {} // expected-warning {{function previously declared with an implicit exception specification redeclared with an explicit exception specification}} -void S::operator delete(void*) noexcept {} // expected-warning {{function previously declared with an implicit exception specification redeclared with an explicit exception specification}} - -struct T { - void a() noexcept; // expected-note {{here}} - ~T() noexcept; // expected-note {{here}} - void operator delete(void*) noexcept; // expected-note {{here}} -}; - -void T::a() {} // expected-error {{missing exception specification 'noexcept'}} -T::~T() {} // expected-warning {{function previously declared with an explicit exception specification redeclared with an implicit exception specification}} -void T::operator delete(void*) {} // expected-warning {{function previously declared with an explicit exception specification redeclared with an implicit exception specification}} - - -// The extension does not extend to function templates. - -template<typename T> struct U { - T t; - ~U(); // expected-note {{here}} - void operator delete(void*); // expected-note {{here}} -}; - -template<typename T> U<T>::~U() noexcept(true) {} // expected-error {{exception specification in declaration does not match previous declaration}} -template<typename T> void U<T>::operator delete(void*) noexcept(false) {} // expected-error {{exception specification in declaration does not match previous declaration}} - - -// Make sure this restriction interacts properly with __attribute__((noreturn)) -void __attribute__ ((__noreturn__)) PR17110(int status) throw(); -void PR17110(int status) throw(); diff --git a/test/CXX/except/except.spec/p5-delayed.cpp b/test/CXX/except/except.spec/p5-delayed.cpp deleted file mode 100644 index 99c0e2de31a9..000000000000 --- a/test/CXX/except/except.spec/p5-delayed.cpp +++ /dev/null @@ -1,15 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -verify %s -fexceptions -fcxx-exceptions - -struct A { struct X { virtual ~X() throw(Y); }; struct Y : X {}; }; -struct B { struct X { virtual void f() throw(Y); }; struct Y : X { void f() throw(Y); }; }; -struct C { struct X { virtual void f() throw(Y); }; struct Y : X { void f() throw(); }; }; -struct D { struct X { virtual void f() throw(Y); }; struct Y : X { void f() noexcept; }; }; -struct E { struct Y; struct X { virtual Y &operator=(const Y&) throw(Y); }; struct Y : X {}; }; -struct F { - struct X { - virtual void f() throw(Y); // expected-note {{here}} - }; - struct Y : X { - void f() throw(int); // expected-error {{more lax}} - }; -}; diff --git a/test/CXX/except/except.spec/p5-pointers.cpp b/test/CXX/except/except.spec/p5-pointers.cpp deleted file mode 100644 index dedc5bd376f9..000000000000 --- a/test/CXX/except/except.spec/p5-pointers.cpp +++ /dev/null @@ -1,85 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -fexceptions -fcxx-exceptions -fsyntax-only -verify %s - -// Assignment of function pointers. - -struct A -{ -}; - -struct B1 : A -{ -}; - -struct B2 : A -{ -}; - -struct D : B1, B2 -{ -}; - -struct P : private A -{ -}; - -// 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 s10() noexcept; -void s11() noexcept(true); -void s12() noexcept(false); - -void fnptrs() -{ - // Assignment and initialization of function pointers. - void (*t1)() throw() = &s1; // valid - t1 = &s2; // expected-error {{not superset}} - t1 = &s3; // expected-error {{not superset}} - 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}} - void (*t5)() = &s1; // valid - t5 = &s2; // valid - t5 = &s6; // valid - t5 = &s7; // valid - t1 = t3; // expected-error {{not superset}} - t3 = t1; // valid - void (*t6)() throw(B1); - t6 = t4; // expected-error {{not superset}} - t4 = t6; // valid - t5 = t1; // valid - t1 = t5; // expected-error {{not superset}} - - // 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 - void (*t11)(void (*)() throw(A)) = &s9; // expected-error {{argument types differ}} - void (*t12)(void (*)() throw(D)) = &s9; // expected-error {{argument types differ}} -} - -// Member function stuff - -struct Str1 { void f() throw(int); }; // expected-note {{previous declaration}} -void Str1::f() // expected-error {{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}} -} diff --git a/test/CXX/except/except.spec/p5-virtual.cpp b/test/CXX/except/except.spec/p5-virtual.cpp deleted file mode 100644 index 69daec6ee533..000000000000 --- a/test/CXX/except/except.spec/p5-virtual.cpp +++ /dev/null @@ -1,96 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -fexceptions -fcxx-exceptions -fsyntax-only -verify %s - -// Compatibility of virtual functions. - -struct A -{ -}; - -struct B1 : A -{ -}; - -struct B2 : A -{ -}; - -struct D : B1, B2 -{ -}; - -struct P : private A -{ -}; - -struct Base -{ - virtual void f1() throw(); - virtual void f2() throw(int, float); - - virtual void f3() throw(int, float); - virtual void f4() throw(A); - virtual void f5() throw(A, int, float); - virtual void f6(); - - virtual void f7() noexcept; - virtual void f8() noexcept; - virtual void f9() noexcept(false); - virtual void f10() noexcept(false); - - virtual void f11() throw(); - virtual void f12() noexcept; - virtual void f13() noexcept(false); - virtual void f14() throw(int); - - virtual void f15(); - virtual void f16(); - - 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}} - - virtual void g6() noexcept; // expected-note {{overridden virtual function is here}} - virtual void g7() noexcept; // expected-note {{overridden virtual function is here}} - - virtual void g8() noexcept; // expected-note {{overridden virtual function is here}} - virtual void g9() throw(); // expected-note {{overridden virtual function is here}} - virtual void g10() throw(int); // expected-note {{overridden virtual function is here}} -}; -struct Derived : Base -{ - virtual void f1() throw(); - virtual void f2() throw(float, int); - - virtual void f3() throw(float); - virtual void f4() throw(B1); - virtual void f5() throw(B1, B2, int); - virtual void f6() throw(B2, B2, int, float, char, double, bool); - - virtual void f7() noexcept; - virtual void f8() noexcept(true); - virtual void f9() noexcept(true); - virtual void f10() noexcept(false); - - virtual void f11() noexcept; - virtual void f12() throw(); - virtual void f13() throw(int); - virtual void f14() noexcept(true); - - virtual void f15() noexcept; - virtual void f16() throw(); - - 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}} - - virtual void g6() noexcept(false); // expected-error {{exception specification of overriding function is more lax}} - virtual void g7(); // expected-error {{exception specification of overriding function is more lax}} - - virtual void g8() throw(int); // expected-error {{exception specification of overriding function is more lax}} - virtual void g9() noexcept(false); // expected-error {{exception specification of overriding function is more lax}} - virtual void g10() noexcept(false); // expected-error {{exception specification of overriding function is more lax}} -}; diff --git a/test/CXX/except/except.spec/p9-dynamic.cpp b/test/CXX/except/except.spec/p9-dynamic.cpp deleted file mode 100644 index 1e7b29479fbd..000000000000 --- a/test/CXX/except/except.spec/p9-dynamic.cpp +++ /dev/null @@ -1,12 +0,0 @@ -// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - -fcxx-exceptions -fexceptions | FileCheck %s - -void external(); - -void target() throw(int) -{ - // CHECK: invoke void @_Z8externalv() - external(); -} -// CHECK: landingpad { i8*, i32 } -// CHECK-NEXT: filter [1 x i8*] [i8* bitcast (i8** @_ZTIi to i8*)] -// CHECK: call void @__cxa_call_unexpected diff --git a/test/CXX/except/except.spec/p9-noexcept.cpp b/test/CXX/except/except.spec/p9-noexcept.cpp deleted file mode 100644 index d8cda2f62285..000000000000 --- a/test/CXX/except/except.spec/p9-noexcept.cpp +++ /dev/null @@ -1,22 +0,0 @@ -// RUN: %clang_cc1 %s -std=c++11 -triple=x86_64-apple-darwin10 -emit-llvm -o - -fcxx-exceptions -fexceptions | FileCheck %s - -void external(); - -void target() noexcept -{ - // CHECK: invoke void @_Z8externalv() - external(); -} -// CHECK: [[T0:%.*]] = landingpad { i8*, i32 } -// CHECK-NEXT: catch i8* null -// CHECK-NEXT: [[T1:%.*]] = extractvalue { i8*, i32 } [[T0]], 0 -// CHECK-NEXT: call void @__clang_call_terminate(i8* [[T1]]) [[NR_NUW:#[0-9]+]] -// CHECK-NEXT: unreachable - -void reverse() noexcept(false) -{ - // CHECK: call void @_Z8externalv() - external(); -} - -// CHECK: attributes [[NR_NUW]] = { noreturn nounwind } diff --git a/test/CXX/except/except.spec/template.cpp b/test/CXX/except/except.spec/template.cpp deleted file mode 100644 index 805a604db588..000000000000 --- a/test/CXX/except/except.spec/template.cpp +++ /dev/null @@ -1,12 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -fexceptions -fcxx-exceptions -fsyntax-only -verify %s - -// We use pointer assignment compatibility to test instantiation. - -template <int N> void f1() throw(int); -template <int N> void f2() noexcept(N > 1); - -void (*t1)() throw(int) = &f1<0>; -void (*t2)() throw() = &f1<0>; // expected-error {{not superset}} - -void (*t3)() noexcept = &f2<2>; // no-error -void (*t4)() noexcept = &f2<0>; // expected-error {{not superset}} diff --git a/test/CXX/expr/expr.ass/p9-cxx11.cpp b/test/CXX/expr/expr.ass/p9-cxx11.cpp deleted file mode 100644 index ecc6d2c3d5bf..000000000000 --- a/test/CXX/expr/expr.ass/p9-cxx11.cpp +++ /dev/null @@ -1,34 +0,0 @@ -// RUN: %clang_cc1 -verify -std=c++11 %s - -template<typename T> struct complex { - complex(T = T(), T = T()); - void operator+=(complex); - T a, b; -}; - -void std_example() { - complex<double> z; - z = { 1, 2 }; - z += { 1, 2 }; - - int a, b; - a = b = { 1 }; - a = { 1 } = b; // expected-error {{initializer list cannot be used on the left hand side of operator '='}} - a = a + { 4 }; // expected-error {{initializer list cannot be used on the right hand side of operator '+'}} - a = { 3 } * { 4 }; // expected-error {{initializer list cannot be used on the left hand side of operator '*'}} \ - expected-error {{initializer list cannot be used on the right hand side of operator '*'}} -} - -struct S { - constexpr S(int a, int b) : a(a), b(b) {} - int a, b; -}; -struct T { - constexpr int operator=(S s) const { return s.a; } - constexpr int operator+=(S s) const { return s.b; } -}; -static_assert((T() = {4, 9}) == 4, ""); -static_assert((T() += {4, 9}) == 9, ""); - -int k1 = T() = { 1, 2 } = { 3, 4 }; // expected-error {{initializer list cannot be used on the left hand side of operator '='}} -int k2 = T() = { 1, 2 } + 1; // expected-error {{initializer list cannot be used on the left hand side of operator '+'}} diff --git a/test/CXX/expr/expr.cast/p4-0x.cpp b/test/CXX/expr/expr.cast/p4-0x.cpp deleted file mode 100644 index 76ac31801730..000000000000 --- a/test/CXX/expr/expr.cast/p4-0x.cpp +++ /dev/null @@ -1,12 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s -// expected-no-diagnostics - -struct X { }; -struct Y : X { }; - -void test_lvalue_to_rvalue_drop_cvquals(const X &x, const Y &y, const int &i) { - (void)(X&&)x; - (void)(int&&)i; - (void)(X&&)y; - (void)(Y&&)x; -} diff --git a/test/CXX/expr/expr.cast/p4.cpp b/test/CXX/expr/expr.cast/p4.cpp deleted file mode 100644 index 907e00872442..000000000000 --- a/test/CXX/expr/expr.cast/p4.cpp +++ /dev/null @@ -1,23 +0,0 @@ -// RUN: %clang_cc1 -ast-dump %s | FileCheck %s - -struct A { int x; }; -struct B { int y; }; -struct C : A, B { }; - -// CHECK: casting_away_constness -void casting_away_constness(const B &b, const C &c, const B *bp, const C *cp) { - // CHECK: DerivedToBase (B) - // CHECK: DeclRefExpr {{.*}} ParmVar {{.*}} 'c' - (void)(B&)c; - // CHECK: BaseToDerived (B) - // CHECK: DeclRefExpr {{.*}} ParmVar {{.*}} 'b' - (void)(C&)b; - // CHECK: DerivedToBase (B) - // CHECK: DeclRefExpr {{.*}} ParmVar {{.*}} 'cp' - (void)(B*)cp; - // CHECK: BaseToDerived (B) - // CHECK: DeclRefExpr {{.*}} ParmVar {{.*}} 'bp' - (void)(C*)bp; - // CHECK: ReturnStmt - return; -} diff --git a/test/CXX/expr/expr.cond/p4.cpp b/test/CXX/expr/expr.cond/p4.cpp deleted file mode 100644 index 4d0cf3538cf0..000000000000 --- a/test/CXX/expr/expr.cond/p4.cpp +++ /dev/null @@ -1,10 +0,0 @@ -// RUN: %clang_cc1 -std=c++98 -verify %s -// RUN: %clang_cc1 -std=c++1z -verify %s - -// expected-no-diagnostics - -struct A { A(); A(int); }; -void f() { - const A a; - true ? a : 0; -} diff --git a/test/CXX/expr/expr.const/p2-0x.cpp b/test/CXX/expr/expr.const/p2-0x.cpp deleted file mode 100644 index 4daed23bf9c6..000000000000 --- a/test/CXX/expr/expr.const/p2-0x.cpp +++ /dev/null @@ -1,611 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -std=c++11 -pedantic -verify -fcxx-exceptions %s -fconstexpr-depth 128 -triple i686-pc-linux-gnu - -// A conditional-expression is a core constant expression unless it involves one -// of the following as a potentially evaluated subexpression [...]: - -// - this (5.1.1 [expr.prim.general]) [Note: when evaluating a constant -// expression, function invocation substitution (7.1.5 [dcl.constexpr]) -// replaces each occurrence of this in a constexpr member function with a -// pointer to the class object. -end note]; -struct This { - int this1 : this1; // expected-error {{undeclared}} - int this2 : this->this1; // expected-error {{invalid}} - void this3() { - int n1[this->this1]; // expected-warning {{variable length array}} - int n2[this1]; // expected-warning {{variable length array}} - (void)n1, (void)n2; - } -}; - -// - an invocation of a function other than a constexpr constructor for a -// literal class or a constexpr function [ Note: Overload resolution (13.3) -// is applied as usual - end note ]; -struct NonConstexpr1 { - static int f() { return 1; } // expected-note {{here}} - int n : f(); // expected-error {{constant expression}} expected-note {{non-constexpr function 'f' cannot be used in a constant expression}} -}; -struct NonConstexpr2 { - constexpr NonConstexpr2(); // expected-note {{here}} - int n; -}; -struct NonConstexpr3 { - NonConstexpr3(); - int m : NonConstexpr2().n; // expected-error {{constant expression}} expected-note {{undefined constructor 'NonConstexpr2'}} -}; -struct NonConstexpr4 { - NonConstexpr4(); - int n; -}; -struct NonConstexpr5 { - int n : NonConstexpr4().n; // expected-error {{constant expression}} expected-note {{non-literal type 'NonConstexpr4' cannot be used in a constant expression}} -}; - -// - an invocation of an undefined constexpr function or an undefined -// constexpr constructor; -struct UndefinedConstexpr { - constexpr UndefinedConstexpr(); - static constexpr int undefinedConstexpr1(); // expected-note {{here}} - int undefinedConstexpr2 : undefinedConstexpr1(); // expected-error {{constant expression}} expected-note {{undefined function 'undefinedConstexpr1' cannot be used in a constant expression}} -}; - -// - an invocation of a constexpr function with arguments that, when substituted -// by function invocation substitution (7.1.5), do not produce a core constant -// expression; -namespace NonConstExprReturn { - static constexpr const int &id_ref(const int &n) { - return n; - } - struct NonConstExprFunction { - int n : id_ref(16); // ok - }; - constexpr const int *address_of(const int &a) { - return &a; - } - constexpr const int *return_param(int n) { // expected-note {{declared here}} - return address_of(n); - } - struct S { - int n : *return_param(0); // expected-error {{constant expression}} expected-note {{read of variable whose lifetime has ended}} - }; -} - -// - an invocation of a constexpr constructor with arguments that, when -// substituted by function invocation substitution (7.1.5), do not produce all -// constant expressions for the constructor calls and full-expressions in the -// mem-initializers (including conversions); -namespace NonConstExprCtor { - struct T { - constexpr T(const int &r) : - r(r) { - } - const int &r; - }; - constexpr int n = 0; - constexpr T t1(n); // ok - constexpr T t2(0); // expected-error {{must be initialized by a constant expression}} expected-note {{temporary created here}} expected-note {{reference to temporary is not a constant expression}} - - struct S { - int n : T(4).r; // ok - }; -} - -// - an invocation of a constexpr function or a constexpr constructor that would -// exceed the implementation-defined recursion limits (see Annex B); -namespace RecursionLimits { - constexpr int RecurseForever(int n) { - return n + RecurseForever(n+1); // expected-note {{constexpr evaluation exceeded maximum depth of 128 calls}} expected-note 9{{in call to 'RecurseForever(}} expected-note {{skipping 118 calls}} - } - struct AlsoRecurseForever { - constexpr AlsoRecurseForever(int n) : - n(AlsoRecurseForever(n+1).n) // expected-note {{constexpr evaluation exceeded maximum depth of 128 calls}} expected-note 9{{in call to 'AlsoRecurseForever(}} expected-note {{skipping 118 calls}} - {} - int n; - }; - struct S { - int k : RecurseForever(0); // expected-error {{constant expression}} expected-note {{in call to}} - int l : AlsoRecurseForever(0).n; // expected-error {{constant expression}} expected-note {{in call to}} - }; -} - -// DR1458: taking the address of an object of incomplete class type -namespace IncompleteClassTypeAddr { - struct S; - extern S s; - constexpr S *p = &s; // ok - static_assert(p, ""); - - extern S sArr[]; - constexpr S (*p2)[] = &sArr; // ok - - struct S { - constexpr S *operator&() const { return nullptr; } - }; - constexpr S *q = &s; // ok - static_assert(!q, ""); -} - -// - an operation that would have undefined behavior [Note: including, for -// example, signed integer overflow (Clause 5 [expr]), certain pointer -// arithmetic (5.7 [expr.add]), division by zero (5.6 [expr.mul]), or certain -// shift operations (5.8 [expr.shift]) -end note]; -namespace UndefinedBehavior { - void f(int n) { - switch (n) { - case (int)4.4e9: // expected-error {{constant expression}} expected-note {{value 4.4E+9 is outside the range of representable values of type 'int'}} - case (int)0x80000000u: // ok - case (int)10000000000ll: // expected-note {{here}} - case (unsigned int)10000000000ll: // expected-error {{duplicate case value}} - case (int)(unsigned)(long long)4.4e9: // ok - case (int)(float)1e300: // expected-error {{constant expression}} expected-note {{value 1.0E+300 is outside the range of representable values of type 'float'}} - case (int)((float)1e37 / 1e30): // ok - case (int)(__fp16)65536: // expected-error {{constant expression}} expected-note {{value 65536 is outside the range of representable values of type '__fp16'}} - break; - } - } - - constexpr int int_min = ~0x7fffffff; - constexpr int minus_int_min = -int_min; // expected-error {{constant expression}} expected-note {{value 2147483648 is outside the range}} - constexpr int div0 = 3 / 0; // expected-error {{constant expression}} expected-note {{division by zero}} - constexpr int mod0 = 3 % 0; // expected-error {{constant expression}} expected-note {{division by zero}} - constexpr int int_min_div_minus_1 = int_min / -1; // expected-error {{constant expression}} expected-note {{value 2147483648 is outside the range}} - constexpr int int_min_mod_minus_1 = int_min % -1; // expected-error {{constant expression}} expected-note {{value 2147483648 is outside the range}} - - constexpr int shl_m1 = 0 << -1; // expected-error {{constant expression}} expected-note {{negative shift count -1}} - constexpr int shl_0 = 0 << 0; // ok - constexpr int shl_31 = 0 << 31; // ok - constexpr int shl_32 = 0 << 32; // expected-error {{constant expression}} expected-note {{shift count 32 >= width of type 'int' (32}} - constexpr int shl_unsigned_negative = unsigned(-3) << 1; // ok - constexpr int shl_unsigned_into_sign = 1u << 31; // ok - constexpr int shl_unsigned_overflow = 1024u << 31; // ok - constexpr int shl_signed_negative = (-3) << 1; // expected-error {{constant expression}} expected-note {{left shift of negative value -3}} - constexpr int shl_signed_ok = 1 << 30; // ok - constexpr int shl_signed_into_sign = 1 << 31; // ok (DR1457) - constexpr int shl_signed_into_sign_2 = 0x7fffffff << 1; // ok (DR1457) - constexpr int shl_signed_off_end = 2 << 31; // expected-error {{constant expression}} expected-note {{signed left shift discards bits}} expected-warning {{signed shift result (0x100000000) requires 34 bits to represent, but 'int' only has 32 bits}} - constexpr int shl_signed_off_end_2 = 0x7fffffff << 2; // expected-error {{constant expression}} expected-note {{signed left shift discards bits}} expected-warning {{signed shift result (0x1FFFFFFFC) requires 34 bits to represent, but 'int' only has 32 bits}} - constexpr int shl_signed_overflow = 1024 << 31; // expected-error {{constant expression}} expected-note {{signed left shift discards bits}} expected-warning {{requires 43 bits to represent}} - constexpr int shl_signed_ok2 = 1024 << 20; // ok - - constexpr int shr_m1 = 0 >> -1; // expected-error {{constant expression}} expected-note {{negative shift count -1}} - constexpr int shr_0 = 0 >> 0; // ok - constexpr int shr_31 = 0 >> 31; // ok - constexpr int shr_32 = 0 >> 32; // expected-error {{constant expression}} expected-note {{shift count 32 >= width of type}} - - struct S { - int m; - }; - constexpr S s = { 5 }; - constexpr const int *p = &s.m + 1; - constexpr const int &f(const int *q) { - return q[0]; - } - constexpr int n = (f(p), 0); // ok - struct T { - int n : f(p); // expected-error {{not an integral constant expression}} expected-note {{read of dereferenced one-past-the-end pointer}} - }; - - namespace Ptr { - struct A {}; - struct B : A { int n; }; - B a[3][3]; - constexpr B *p = a[0] + 4; // expected-error {{constant expression}} expected-note {{element 4 of array of 3 elements}} - B b = {}; - constexpr A *pa = &b + 1; // expected-error {{constant expression}} expected-note {{base class of pointer past the end}} - constexpr B *pb = (B*)((A*)&b + 1); // expected-error {{constant expression}} expected-note {{derived class of pointer past the end}} - constexpr const int *pn = &(&b + 1)->n; // expected-error {{constant expression}} expected-note {{field of pointer past the end}} - constexpr B *parr = &a[3][0]; // expected-error {{constant expression}} expected-note {{array element of pointer past the end}} - - constexpr A *na = nullptr; - constexpr B *nb = nullptr; - constexpr A &ra = *nb; // expected-error {{constant expression}} expected-note {{cannot access base class of null pointer}} - constexpr B &rb = (B&)*na; // expected-error {{constant expression}} expected-note {{cannot access derived class of null pointer}} - static_assert((A*)nb == 0, ""); - static_assert((B*)na == 0, ""); - constexpr const int &nf = nb->n; // expected-error {{constant expression}} expected-note {{cannot access field of null pointer}} - constexpr const int *np1 = (int*)nullptr + 0; // ok - constexpr const int *np2 = &(*(int(*)[4])nullptr)[0]; // ok - constexpr const int *np3 = &(*(int(*)[4])nullptr)[2]; // expected-error {{constant expression}} expected-note {{cannot perform pointer arithmetic on null pointer}} - - struct C { - constexpr int f() const { return 0; } - } constexpr c = C(); - constexpr int k1 = c.f(); // ok - constexpr int k2 = ((C*)nullptr)->f(); // expected-error {{constant expression}} expected-note {{cannot call member function on null pointer}} - constexpr int k3 = (&c)[1].f(); // expected-error {{constant expression}} expected-note {{cannot call member function on pointer past the end of object}} - C c2; - constexpr int k4 = c2.f(); // ok! - - constexpr int diff1 = &a[2] - &a[0]; - constexpr int diff2 = &a[1][3] - &a[1][0]; - constexpr int diff3 = &a[2][0] - &a[1][0]; // expected-error {{constant expression}} expected-note {{subtracted pointers are not elements of the same array}} - static_assert(&a[2][0] == &a[1][3], ""); - constexpr int diff4 = (&b + 1) - &b; - constexpr int diff5 = &a[1][2].n - &a[1][0].n; // expected-error {{constant expression}} expected-note {{subtracted pointers are not elements of the same array}} - constexpr int diff6 = &a[1][2].n - &a[1][2].n; - constexpr int diff7 = (A*)&a[0][1] - (A*)&a[0][0]; // expected-error {{constant expression}} expected-note {{subtracted pointers are not elements of the same array}} - } - - namespace Overflow { - // Signed int overflow. - constexpr int n1 = 2 * 3 * 3 * 7 * 11 * 31 * 151 * 331; // ok - constexpr int n2 = 65536 * 32768; // expected-error {{constant expression}} expected-note {{value 2147483648 is outside the range of }} - constexpr int n3 = n1 + 1; // ok - constexpr int n4 = n3 + 1; // expected-error {{constant expression}} expected-note {{value 2147483648 is outside the range of }} - constexpr int n5 = -65536 * 32768; // ok - constexpr int n6 = 3 * -715827883; // expected-error {{constant expression}} expected-note {{value -2147483649 is outside the range of }} - constexpr int n7 = -n3 + -1; // ok - constexpr int n8 = -1 + n7; // expected-error {{constant expression}} expected-note {{value -2147483649 is outside the range of }} - constexpr int n9 = n3 - 0; // ok - constexpr int n10 = n3 - -1; // expected-error {{constant expression}} expected-note {{value 2147483648 is outside the range of }} - constexpr int n11 = -1 - n3; // ok - constexpr int n12 = -2 - n3; // expected-error {{constant expression}} expected-note {{value -2147483649 is outside the range of }} - constexpr int n13 = n5 + n5; // expected-error {{constant expression}} expected-note {{value -4294967296 is outside the range of }} - constexpr int n14 = n3 - n5; // expected-error {{constant expression}} expected-note {{value 4294967295 is outside the range of }} - constexpr int n15 = n5 * n5; // expected-error {{constant expression}} expected-note {{value 4611686018427387904 is outside the range of }} - constexpr signed char c1 = 100 * 2; // ok expected-warning{{changes value}} - constexpr signed char c2 = '\x64' * '\2'; // also ok expected-warning{{changes value}} - constexpr long long ll1 = 0x7fffffffffffffff; // ok - constexpr long long ll2 = ll1 + 1; // expected-error {{constant}} expected-note {{ 9223372036854775808 }} - constexpr long long ll3 = -ll1 - 1; // ok - constexpr long long ll4 = ll3 - 1; // expected-error {{constant}} expected-note {{ -9223372036854775809 }} - constexpr long long ll5 = ll3 * ll3; // expected-error {{constant}} expected-note {{ 85070591730234615865843651857942052864 }} - - // Yikes. - char melchizedek[2200000000]; - typedef decltype(melchizedek[1] - melchizedek[0]) ptrdiff_t; - constexpr ptrdiff_t d1 = &melchizedek[0x7fffffff] - &melchizedek[0]; // ok - constexpr ptrdiff_t d2 = &melchizedek[0x80000000u] - &melchizedek[0]; // expected-error {{constant expression}} expected-note {{ 2147483648 }} - constexpr ptrdiff_t d3 = &melchizedek[0] - &melchizedek[0x80000000u]; // ok - constexpr ptrdiff_t d4 = &melchizedek[0] - &melchizedek[0x80000001u]; // expected-error {{constant expression}} expected-note {{ -2147483649 }} - - // Unsigned int overflow. - static_assert(65536u * 65536u == 0u, ""); // ok - static_assert(4294967295u + 1u == 0u, ""); // ok - static_assert(0u - 1u == 4294967295u, ""); // ok - static_assert(~0u * ~0u == 1u, ""); // ok - - // Floating-point overflow and NaN. - constexpr float f1 = 1e38f * 3.4028f; // ok - constexpr float f2 = 1e38f * 3.4029f; // expected-error {{constant expression}} expected-note {{floating point arithmetic produces an infinity}} - constexpr float f3 = 1e38f / -.2939f; // ok - constexpr float f4 = 1e38f / -.2938f; // expected-error {{constant expression}} expected-note {{floating point arithmetic produces an infinity}} - constexpr float f5 = 2e38f + 2e38f; // expected-error {{constant expression}} expected-note {{floating point arithmetic produces an infinity}} - constexpr float f6 = -2e38f - 2e38f; // expected-error {{constant expression}} expected-note {{floating point arithmetic produces an infinity}} - constexpr float f7 = 0.f / 0.f; // expected-error {{constant expression}} expected-note {{floating point arithmetic produces a NaN}} - } -} - -// - a lambda-expression (5.1.2); -struct Lambda { - int n : []{ return 1; }(); // expected-error {{constant expression}} expected-error {{integral constant expression}} expected-note {{non-literal type}} -}; - -// - an lvalue-to-rvalue conversion (4.1) unless it is applied to -namespace LValueToRValue { - // - a non-volatile glvalue of integral or enumeration type that refers to a - // non-volatile const object with a preceding initialization, initialized - // with a constant expression [Note: a string literal (2.14.5 [lex.string]) - // corresponds to an array of such objects. -end note], or - volatile const int vi = 1; // expected-note 2{{here}} - const int ci = 1; - volatile const int &vrci = ci; - static_assert(vi, ""); // expected-error {{constant expression}} expected-note {{read of volatile-qualified type}} - static_assert(const_cast<int&>(vi), ""); // expected-error {{constant expression}} expected-note {{read of volatile object 'vi'}} - static_assert(vrci, ""); // expected-error {{constant expression}} expected-note {{read of volatile-qualified type}} - - // - a non-volatile glvalue of literal type that refers to a non-volatile - // object defined with constexpr, or that refers to a sub-object of such an - // object, or - struct V { - constexpr V() : v(1) {} - volatile int v; // expected-note {{not literal because}} - }; - constexpr V v; // expected-error {{non-literal type}} - struct S { - constexpr S(int=0) : i(1), v(const_cast<volatile int&>(vi)) {} - constexpr S(const S &s) : i(2), v(const_cast<volatile int&>(vi)) {} - int i; - volatile int &v; - }; - constexpr S s; // ok - constexpr volatile S vs; // expected-note {{here}} - constexpr const volatile S &vrs = s; // ok - static_assert(s.i, ""); - static_assert(s.v, ""); // expected-error {{constant expression}} expected-note {{read of volatile-qualified type}} - static_assert(const_cast<int&>(s.v), ""); // expected-error {{constant expression}} expected-note {{read of volatile object 'vi'}} - static_assert(vs.i, ""); // expected-error {{constant expression}} expected-note {{read of volatile-qualified type}} - static_assert(const_cast<int&>(vs.i), ""); // expected-error {{constant expression}} expected-note {{read of volatile object 'vs'}} - static_assert(vrs.i, ""); // expected-error {{constant expression}} expected-note {{read of volatile-qualified type}} - - // - a non-volatile glvalue of literal type that refers to a non-volatile - // temporary object whose lifetime has not ended, initialized with a - // constant expression; - constexpr volatile S f() { return S(); } - static_assert(f().i, ""); // expected-error {{constant expression}} expected-note {{read of volatile-qualified type}} - static_assert(((volatile const S&&)(S)0).i, ""); // expected-error {{constant expression}} expected-note {{read of volatile-qualified type}} -} - -// DR1312: The proposed wording for this defect has issues, so we ignore this -// bullet and instead prohibit casts from pointers to cv void (see core-20842 -// and core-20845). -// -// - an lvalue-to-rvalue conversion (4.1 [conv.lval]) that is applied to a -// glvalue of type cv1 T that refers to an object of type cv2 U, where T and U -// are neither the same type nor similar types (4.4 [conv.qual]); - -// - an lvalue-to-rvalue conversion (4.1) that is applied to a glvalue that -// refers to a non-active member of a union or a subobject thereof; -namespace LValueToRValueUnion { - // test/SemaCXX/constant-expression-cxx11.cpp contains more thorough testing - // of this. - union U { int a, b; } constexpr u = U(); - static_assert(u.a == 0, ""); - constexpr const int *bp = &u.b; - constexpr int b = *bp; // expected-error {{constant expression}} expected-note {{read of member 'b' of union with active member 'a'}} - - extern const U pu; - constexpr const int *pua = &pu.a; - constexpr const int *pub = &pu.b; - constexpr U pu = { .b = 1 }; // expected-warning {{C99 feature}} - constexpr const int a2 = *pua; // expected-error {{constant expression}} expected-note {{read of member 'a' of union with active member 'b'}} - constexpr const int b2 = *pub; // ok -} - -// - an id-expression that refers to a variable or data member of reference type -// unless the reference has a preceding initialization, initialized with a -// constant expression; -namespace References { - const int a = 2; - int &b = *const_cast<int*>(&a); - int c = 10; // expected-note 2 {{here}} - int &d = c; - constexpr int e = 42; - int &f = const_cast<int&>(e); - extern int &g; - constexpr int &h(); // expected-note {{here}} - int &i = h(); // expected-note {{here}} - constexpr int &j() { return b; } - int &k = j(); - - struct S { - int A : a; - int B : b; - int C : c; // expected-error {{constant expression}} expected-note {{read of non-const variable 'c'}} - int D : d; // expected-error {{constant expression}} expected-note {{read of non-const variable 'c'}} - int D2 : &d - &c + 1; - int E : e / 2; - int F : f - 11; - int G : g; // expected-error {{constant expression}} - int H : h(); // expected-error {{constant expression}} expected-note {{undefined function 'h'}} - int I : i; // expected-error {{constant expression}} expected-note {{initializer of 'i' is not a constant expression}} - int J : j(); - int K : k; - }; -} - -// - a dynamic_cast (5.2.7); -namespace DynamicCast { - struct S { int n; }; - constexpr S s { 16 }; - struct T { - int n : dynamic_cast<const S*>(&s)->n; // expected-warning {{constant expression}} expected-note {{dynamic_cast}} - }; -} - -// - a reinterpret_cast (5.2.10); -namespace ReinterpretCast { - struct S { int n; }; - constexpr S s { 16 }; - struct T { - int n : reinterpret_cast<const S*>(&s)->n; // expected-warning {{constant expression}} expected-note {{reinterpret_cast}} - }; - struct U { - int m : (long)(S*)6; // expected-warning {{constant expression}} expected-note {{reinterpret_cast}} - }; -} - -// - a pseudo-destructor call (5.2.4); -namespace PseudoDtor { - int k; - typedef int I; - struct T { - int n : (k.~I(), 0); // expected-error {{constant expression}} - }; -} - -// - increment or decrement operations (5.2.6, 5.3.2); -namespace IncDec { - int k = 2; - struct T { - int n : ++k; // expected-error {{constant expression}} - int m : --k; // expected-error {{constant expression}} - }; -} - -// - a typeid expression (5.2.8) whose operand is of a polymorphic class type; -namespace std { - struct type_info { - virtual ~type_info(); - const char *name; - }; -} -namespace TypeId { - struct S { virtual void f(); }; - constexpr S *p = 0; - constexpr const std::type_info &ti1 = typeid(*p); // expected-error {{must be initialized by a constant expression}} expected-note {{typeid applied to expression of polymorphic type 'TypeId::S'}} - - struct T {} t; - constexpr const std::type_info &ti2 = typeid(t); -} - -// - a new-expression (5.3.4); -// - a delete-expression (5.3.5); -namespace NewDelete { - int *p = 0; - struct T { - int n : *new int(4); // expected-error {{constant expression}} - int m : (delete p, 2); // expected-error {{constant expression}} - }; -} - -// - a relational (5.9) or equality (5.10) operator where the result is -// unspecified; -namespace UnspecifiedRelations { - int a, b; - constexpr int *p = &a, *q = &b; - // C++11 [expr.rel]p2: If two pointers p and q of the same type point to - // different objects that are not members of the same array or to different - // functions, or if only one of them is null, the results of p<q, p>q, p<=q, - // and p>=q are unspecified. - constexpr bool u1 = p < q; // expected-error {{constant expression}} - constexpr bool u2 = p > q; // expected-error {{constant expression}} - constexpr bool u3 = p <= q; // expected-error {{constant expression}} - constexpr bool u4 = p >= q; // expected-error {{constant expression}} - constexpr bool u5 = p < (int*)0; // expected-error {{constant expression}} - constexpr bool u6 = p <= (int*)0; // expected-error {{constant expression}} - constexpr bool u7 = p > (int*)0; // expected-error {{constant expression}} - constexpr bool u8 = p >= (int*)0; // expected-error {{constant expression}} - constexpr bool u9 = (int*)0 < q; // expected-error {{constant expression}} - constexpr bool u10 = (int*)0 <= q; // expected-error {{constant expression}} - constexpr bool u11 = (int*)0 > q; // expected-error {{constant expression}} - constexpr bool u12 = (int*)0 >= q; // expected-error {{constant expression}} - void f(), g(); - - constexpr void (*pf)() = &f, (*pg)() = &g; - constexpr bool u13 = pf < pg; // expected-error {{constant expression}} - constexpr bool u14 = pf == pg; - - // If two pointers point to non-static data members of the same object with - // different access control, the result is unspecified. - struct A { - public: - constexpr A() : a(0), b(0) {} - int a; - constexpr bool cmp() const { return &a < &b; } // expected-note {{comparison of address of fields 'a' and 'b' of 'A' with differing access specifiers (public vs private) has unspecified value}} - private: - int b; - }; - static_assert(A().cmp(), ""); // expected-error {{constant expression}} expected-note {{in call}} - class B { - public: - A a; - constexpr bool cmp() const { return &a.a < &b.a; } // expected-note {{comparison of address of fields 'a' and 'b' of 'B' with differing access specifiers (public vs protected) has unspecified value}} - protected: - A b; - }; - static_assert(B().cmp(), ""); // expected-error {{constant expression}} expected-note {{in call}} - - // If two pointers point to different base sub-objects of the same object, or - // one points to a base subobject and the other points to a member, the result - // of the comparison is unspecified. This is not explicitly called out by - // [expr.rel]p2, but is covered by 'Other pointer comparisons are - // unspecified'. - struct C { - int c[2]; - }; - struct D { - int d; - }; - struct E : C, D { - struct Inner { - int f; - } e; - } e; - constexpr bool base1 = &e.c[0] < &e.d; // expected-error {{constant expression}} expected-note {{comparison of addresses of subobjects of different base classes has unspecified value}} - constexpr bool base2 = &e.c[1] < &e.e.f; // expected-error {{constant expression}} expected-note {{comparison of address of base class subobject 'C' of class 'E' to field 'e' has unspecified value}} - constexpr bool base3 = &e.e.f < &e.d; // expected-error {{constant expression}} expected-note {{comparison of address of base class subobject 'D' of class 'E' to field 'e' has unspecified value}} - - // [expr.rel]p3: Pointers to void can be compared [...] if both pointers - // represent the same address or are both the null pointer [...]; otherwise - // the result is unspecified. - struct S { int a, b; } s; - constexpr void *null = 0; - constexpr void *pv = (void*)&s.a; - constexpr void *qv = (void*)&s.b; - constexpr bool v1 = null < (int*)0; - constexpr bool v2 = null < pv; // expected-error {{constant expression}} - constexpr bool v3 = null == pv; // ok - constexpr bool v4 = qv == pv; // ok - constexpr bool v5 = qv >= pv; // expected-error {{constant expression}} expected-note {{unequal pointers to void}} - constexpr bool v6 = qv > null; // expected-error {{constant expression}} - constexpr bool v7 = qv <= (void*)&s.b; // ok - constexpr bool v8 = qv > (void*)&s.a; // expected-error {{constant expression}} expected-note {{unequal pointers to void}} -} - -// - an assignment or a compound assignment (5.17); or -namespace Assignment { - int k; - struct T { - int n : (k = 9); // expected-error {{constant expression}} - int m : (k *= 2); // expected-error {{constant expression}} - }; - - struct Literal { - constexpr Literal(const char *name) : name(name) {} - const char *name; - }; - struct Expr { - constexpr Expr(Literal l) : IsLiteral(true), l(l) {} - bool IsLiteral; - union { - Literal l; - // ... - }; - }; - struct MulEq { - constexpr MulEq(Expr a, Expr b) : LHS(a), RHS(b) {} - Expr LHS; - Expr RHS; - }; - constexpr MulEq operator*=(Expr a, Expr b) { return MulEq(a, b); } - Literal a("a"); - Literal b("b"); - MulEq c = a *= b; // ok -} - -// - a throw-expression (15.1) -namespace Throw { - struct S { - int n : (throw "hello", 10); // expected-error {{constant expression}} - }; -} - -// PR9999 -template<unsigned int v> -class bitWidthHolding { -public: - static const - unsigned int width = (v == 0 ? 0 : bitWidthHolding<(v >> 1)>::width + 1); -}; - -static const int width=bitWidthHolding<255>::width; - -template<bool b> -struct always_false { - static const bool value = false; -}; - -template<bool b> -struct and_or { - static const bool and_value = b && and_or<always_false<b>::value>::and_value; - static const bool or_value = !b || and_or<always_false<b>::value>::or_value; -}; - -static const bool and_value = and_or<true>::and_value; -static const bool or_value = and_or<true>::or_value; - -static_assert(and_value == false, ""); -static_assert(or_value == true, ""); - -namespace rdar13090123 { - typedef __INTPTR_TYPE__ intptr_t; - - constexpr intptr_t f(intptr_t x) { - return (((x) >> 21) * 8); - } - - extern "C" int foo; - - constexpr intptr_t i = f((intptr_t)&foo - 10); // expected-error{{constexpr variable 'i' must be initialized by a constant expression}} \ - // expected-note{{reinterpret_cast}} -} diff --git a/test/CXX/expr/expr.const/p3-0x-nowarn.cpp b/test/CXX/expr/expr.const/p3-0x-nowarn.cpp deleted file mode 100644 index 7d12cedeacf0..000000000000 --- a/test/CXX/expr/expr.const/p3-0x-nowarn.cpp +++ /dev/null @@ -1,9 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -std=c++11 -Wno-c++11-narrowing -verify %s -// expected-no-diagnostics - -// <rdar://problem/11121178> -void f(int x) { - switch (x) { - case 0x80000001: break; - } -} diff --git a/test/CXX/expr/expr.const/p3-0x.cpp b/test/CXX/expr/expr.const/p3-0x.cpp deleted file mode 100644 index 731e0c312fa1..000000000000 --- a/test/CXX/expr/expr.const/p3-0x.cpp +++ /dev/null @@ -1,121 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s -// RUN: %clang_cc1 -fsyntax-only -std=c++1z -verify %s - -// A converted constant expression of type T is a core constant expression, -int nonconst = 8; // expected-note 3 {{here}} -enum NonConstE : unsigned char { NCE = nonconst }; // expected-error {{enumerator value is not a constant expression}} expected-note {{read of non-const}} -template<int = nonconst> struct NonConstT {}; // expected-error {{non-type template argument is not a constant expression}} expected-note {{read of non-const}} -void NonConstF() { - switch (nonconst) { - case nonconst: // expected-error {{case value is not a constant expression}} expected-note {{read of non-const}} - break; - } - return; -} - -// implicitly converted to a prvalue of type T, where the converted expression -// is a literal constant expression - -bool a(int n) { - constexpr char vowels[] = "aeiou"; - switch (n) { - case vowels[0]: - case vowels[1]: - case vowels[2]: - case vowels[3]: - case vowels[4]: - static_assert(!vowels[5], "unexpected number of vowels"); - return true; - } - return false; -} - -// and the implicit conversion sequence contains only -// -// user-defined conversions, -struct S { constexpr operator int() const { return 5; } }; -enum E : unsigned char { E5 = S(), E6, E10 = S() * 2, E1 = E5 / 5 }; - -// lvalue-to-rvalue conversions, -const E e10 = E10; -template<E> struct T {}; -T<e10> s10; - -// integral promotions, -enum class EE { EE32 = ' ', EE65 = 'A', EE1 = (short)1, EE5 = E5 }; - -// integral conversions other than narrowing conversions, -int b(unsigned n) { - switch (n) { - case E6: - case EE::EE32: // expected-error {{not implicitly convertible}} - case (int)EE::EE32: - case 1000: - case (long long)1e10: // expected-error {{case value evaluates to 10000000000, which cannot be narrowed to type 'unsigned int'}} - case -3: // expected-error {{case value evaluates to -3, which cannot be narrowed to type 'unsigned int'}} - return n; - } - return 0; -} -enum class EEE : unsigned short { - a = E6, - b = EE::EE32, // expected-error {{not implicitly convertible}} - c = (int)EE::EE32, - d = 1000, - e = 123456, // expected-error {{enumerator value evaluates to 123456, which cannot be narrowed to type 'unsigned short'}} - f = -3 // expected-error {{enumerator value evaluates to -3, which cannot be narrowed to type 'unsigned short'}} -}; -template<unsigned char> using A = int; -using Int = A<E6>; -using Int = A<EE::EE32>; // expected-error {{not implicitly convertible}} -using Int = A<(int)EE::EE32>; -using Int = A<200>; -using Int = A<1000>; // expected-error {{template argument evaluates to 1000, which cannot be narrowed to type 'unsigned char'}} -using Int = A<-3>; // expected-error {{template argument evaluates to -3, which cannot be narrowed to type 'unsigned char'}} - -// Note, conversions from integral or unscoped enumeration types to bool are -// integral conversions as well as boolean conversions. -// FIXME: Per core issue 1407, this is not correct. -template<typename T, T v> struct Val { static constexpr T value = v; }; -static_assert(Val<bool, E1>::value == 1, ""); // ok -static_assert(Val<bool, '\0'>::value == 0, ""); // ok -static_assert(Val<bool, U'\1'>::value == 1, ""); // ok -static_assert(Val<bool, E5>::value == 1, ""); // expected-error {{5, which cannot be narrowed to type 'bool'}} - -// function pointer conversions [C++17] -void noexcept_false() noexcept(false); -void noexcept_true() noexcept(true); -Val<decltype(&noexcept_false), &noexcept_true> remove_noexcept; -Val<decltype(&noexcept_true), &noexcept_false> add_noexcept; -#if __cplusplus > 201402L -// expected-error@-2 {{value of type 'void (*)() noexcept(false)' is not implicitly convertible to 'void (*)() noexcept'}} -#endif - -// (no other conversions are permitted) -using Int = A<1.0>; // expected-error {{conversion from 'double' to 'unsigned char' is not allowed in a converted constant expression}} -enum B : bool { - True = &a, // expected-error {{conversion from 'bool (*)(int)' to 'bool' is not allowed in a converted constant expression}} - False = nullptr // expected-error {{conversion from 'nullptr_t' to 'bool' is not allowed in a converted constant expression}} -}; -void c() { - // Note, promoted type of switch is 'int'. - switch (bool b = a(5)) { // expected-warning {{boolean value}} - case 0.0f: // expected-error {{conversion from 'float' to 'int' is not allowed in a converted constant expression}} - break; - } -} -template <bool B> int f() { return B; } // expected-note {{candidate template ignored: invalid explicitly-specified argument for template parameter 'B'}} -template int f<&S::operator int>(); // expected-error {{does not refer to a function template}} -template int f<(bool)&S::operator int>(); - -int n = Val<bool, &S::operator int>::value; // expected-error-re {{conversion from 'int (S::*)(){{( __attribute__\(\(thiscall\)\))?}} const' to 'bool' is not allowed in a converted constant expression}} - -namespace NonConstLValue { - struct S { - constexpr operator int() const { return 10; } - }; - S s; // not constexpr - // Under the FDIS, this is not a converted constant expression. - // Under the new proposed wording, it is. - enum E : char { e = s }; -} diff --git a/test/CXX/expr/expr.const/p5-0x.cpp b/test/CXX/expr/expr.const/p5-0x.cpp deleted file mode 100644 index 079870947db0..000000000000 --- a/test/CXX/expr/expr.const/p5-0x.cpp +++ /dev/null @@ -1,85 +0,0 @@ -// RUN: %clang_cc1 -triple %itanium_abi_triple -fsyntax-only -std=c++11 -verify %s - -// If an expression of literal class type is used in a context where an integral -// constant expression is required, then that class type shall have a single -// non-explicit conversion function to an integral or unscoped enumeration type -namespace std_example { - -struct A { - constexpr A(int i) : val(i) { } - constexpr operator int() const { return val; } - constexpr operator long() const { return 43; } -private: - int val; -}; -template<int> struct X { }; -constexpr A a = 42; -X<a> x; // ok, unique conversion to int -int ary[a]; // expected-error {{size of array has non-integer type 'const std_example::A'}} - -} - -struct OK { - constexpr OK() {} - constexpr operator int() const { return 8; } -} constexpr ok; -extern struct Incomplete incomplete; // expected-note 4{{forward decl}} -struct Explicit { - constexpr Explicit() {} - constexpr explicit operator int() const { return 4; } // expected-note 4{{here}} -} constexpr expl; -struct Ambiguous { - constexpr Ambiguous() {} - constexpr operator int() const { return 2; } // expected-note 4{{here}} - constexpr operator long() const { return 1; } // expected-note 4{{here}} -} constexpr ambig; - -constexpr int test_ok = ok; // ok -constexpr int test_explicit(expl); // ok -constexpr int test_ambiguous = ambig; // ok - -static_assert(test_ok == 8, ""); -static_assert(test_explicit == 4, ""); -static_assert(test_ambiguous == 2, ""); - -// [expr.new]p6: Every constant-expression in a noptr-new-declarator shall be -// an integral constant expression -auto new1 = new int[1][ok]; -auto new2 = new int[1][incomplete]; // expected-error {{incomplete}} -auto new3 = new int[1][expl]; // expected-error {{explicit conversion}} -auto new4 = new int[1][ambig]; // expected-error {{ambiguous conversion}} - -// [dcl.enum]p5: If the underlying type is not fixed [...] the initializing -// value [...] shall be an integral constant expression. -enum NotFixed { - enum1 = ok, - enum2 = incomplete, // expected-error {{incomplete}} - enum3 = expl, // expected-error {{explicit conversion}} - enum4 = ambig // expected-error {{ambiguous conversion}} -}; - -// [dcl.align]p2: When the alignment-specifier is of the form -// alignas(assignment-expression), the assignment-expression shall be an -// integral constant expression -alignas(ok) int alignas1; -alignas(incomplete) int alignas2; // expected-error {{incomplete}} -alignas(expl) int alignas3; // expected-error {{explicit conversion}} -alignas(ambig) int alignas4; // expected-error {{ambiguous conversion}} - -// [dcl.array]p1: If the constant-expression is present, it shall be an integral -// constant expression -// FIXME: The VLA recovery results in us giving diagnostics which aren't great -// here. -int array1[ok]; -int array2[incomplete]; // expected-error {{non-integer type}} -int array3[expl]; // expected-error {{non-integer type}} -int array4[ambig]; // expected-error {{non-integer type}} - -// [class.bit]p1: The constasnt-expression shall be an integral constant -// expression -struct Bitfields { - int bitfield1 : ok; - int bitfield2 : incomplete; // expected-error {{incomplete}} - int bitfield3 : expl; // expected-error {{explicit conversion}} - int bitfield4 : ambig; // expected-error {{ambiguous conversion}} -}; diff --git a/test/CXX/expr/expr.const/p6.cpp b/test/CXX/expr/expr.const/p6.cpp deleted file mode 100644 index a8fc7754e7db..000000000000 --- a/test/CXX/expr/expr.const/p6.cpp +++ /dev/null @@ -1,39 +0,0 @@ -// RUN: %clang_cc1 -std=c++17 -verify %s - -template<typename T> int not_constexpr() { return T::error; } -template<typename T> constexpr int is_constexpr() { return T::error; } // expected-error {{'::'}} - -template<typename T> int not_constexpr_var = T::error; -template<typename T> constexpr int is_constexpr_var = T::error; // expected-error {{'::'}} -template<typename T> const int is_const_var = T::error; // expected-error {{'::'}} -template<typename T> const volatile int is_const_volatile_var = T::error; -template<typename T> T is_dependent_var = T::error; // expected-error {{'::'}} -template<typename T> int &is_reference_var = T::error; // expected-error {{'::'}} -template<typename T> float is_float_var = T::error; - -void test() { - // Do not instantiate functions referenced in unevaluated operands... - (void)sizeof(not_constexpr<long>()); - (void)sizeof(is_constexpr<long>()); - (void)sizeof(not_constexpr_var<long>); - (void)sizeof(is_constexpr_var<long>); - (void)sizeof(is_const_var<long>); - (void)sizeof(is_const_volatile_var<long>); - (void)sizeof(is_dependent_var<long>); - (void)sizeof(is_dependent_var<const long>); - (void)sizeof(is_reference_var<long>); - (void)sizeof(is_float_var<long>); - - // ... but do if they are potentially constant evaluated, and refer to - // constexpr functions or to variables usable in constant expressions. - (void)sizeof(int{not_constexpr<int>()}); - (void)sizeof(int{is_constexpr<int>()}); // expected-note {{instantiation of}} - (void)sizeof(int{not_constexpr_var<int>}); - (void)sizeof(int{is_constexpr_var<int>}); // expected-note {{instantiation of}} - (void)sizeof(int{is_const_var<int>}); // expected-note {{instantiation of}} - (void)sizeof(int{is_const_volatile_var<int>}); - (void)sizeof(int{is_dependent_var<int>}); - (void)sizeof(int{is_dependent_var<const int>}); // expected-note {{instantiation of}} - (void)sizeof(int{is_reference_var<int>}); // expected-note {{instantiation of}} - (void)sizeof(int{is_float_var<int>}); // expected-error {{cannot be narrowed}} expected-note {{cast}} -} diff --git a/test/CXX/expr/expr.mptr.oper/p5.cpp b/test/CXX/expr/expr.mptr.oper/p5.cpp deleted file mode 100644 index c26b30d43da1..000000000000 --- a/test/CXX/expr/expr.mptr.oper/p5.cpp +++ /dev/null @@ -1,61 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s - -struct X0 { - void f0(); - void f1() const; - void f2() volatile; - void f3() const volatile; -}; - -void test_object_cvquals(void (X0::*pm)(), - void (X0::*pmc)() const, - void (X0::*pmv)() volatile, - void (X0::*pmcv)() const volatile, - X0 *p, - const X0 *pc, - volatile X0 *pv, - const volatile X0 *pcv, - X0 &o, - const X0 &oc, - volatile X0 &ov, - const volatile X0 &ocv) { - (p->*pm)(); - (p->*pmc)(); - (p->*pmv)(); - (p->*pmcv)(); - - (pc->*pm)(); // expected-error-re{{call to pointer to member function of type 'void (){{( __attribute__\(\(thiscall\)\))?}}' drops 'const' qualifier}} - (pc->*pmc)(); - (pc->*pmv)(); // expected-error-re{{call to pointer to member function of type 'void (){{( __attribute__\(\(thiscall\)\))?}} volatile' drops 'const' qualifier}} - (pc->*pmcv)(); - - (pv->*pm)(); // expected-error-re{{call to pointer to member function of type 'void (){{( __attribute__\(\(thiscall\)\))?}}' drops 'volatile' qualifier}} - (pv->*pmc)(); // expected-error-re{{call to pointer to member function of type 'void (){{( __attribute__\(\(thiscall\)\))?}} const' drops 'volatile' qualifier}} - (pv->*pmv)(); - (pv->*pmcv)(); - - (pcv->*pm)(); // expected-error-re{{call to pointer to member function of type 'void (){{( __attribute__\(\(thiscall\)\))?}}' drops 'const volatile' qualifiers}} - (pcv->*pmc)(); // expected-error-re{{call to pointer to member function of type 'void (){{( __attribute__\(\(thiscall\)\))?}} const' drops 'volatile' qualifier}} - (pcv->*pmv)(); // expected-error-re{{call to pointer to member function of type 'void (){{( __attribute__\(\(thiscall\)\))?}} volatile' drops 'const' qualifier}} - (pcv->*pmcv)(); - - (o.*pm)(); - (o.*pmc)(); - (o.*pmv)(); - (o.*pmcv)(); - - (oc.*pm)(); // expected-error-re{{call to pointer to member function of type 'void (){{( __attribute__\(\(thiscall\)\))?}}' drops 'const' qualifier}} - (oc.*pmc)(); - (oc.*pmv)(); // expected-error-re{{call to pointer to member function of type 'void (){{( __attribute__\(\(thiscall\)\))?}} volatile' drops 'const' qualifier}} - (oc.*pmcv)(); - - (ov.*pm)(); // expected-error-re{{call to pointer to member function of type 'void (){{( __attribute__\(\(thiscall\)\))?}}' drops 'volatile' qualifier}} - (ov.*pmc)(); // expected-error-re{{call to pointer to member function of type 'void (){{( __attribute__\(\(thiscall\)\))?}} const' drops 'volatile' qualifier}} - (ov.*pmv)(); - (ov.*pmcv)(); - - (ocv.*pm)(); // expected-error-re{{call to pointer to member function of type 'void (){{( __attribute__\(\(thiscall\)\))?}}' drops 'const volatile' qualifiers}} - (ocv.*pmc)(); // expected-error-re{{call to pointer to member function of type 'void (){{( __attribute__\(\(thiscall\)\))?}} const' drops 'volatile' qualifier}} - (ocv.*pmv)(); // expected-error-re{{call to pointer to member function of type 'void (){{( __attribute__\(\(thiscall\)\))?}} volatile' drops 'const' qualifier}} - (ocv.*pmcv)(); -} diff --git a/test/CXX/expr/expr.mptr.oper/p6-0x.cpp b/test/CXX/expr/expr.mptr.oper/p6-0x.cpp deleted file mode 100644 index b1823e59fff2..000000000000 --- a/test/CXX/expr/expr.mptr.oper/p6-0x.cpp +++ /dev/null @@ -1,34 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s - -struct X { }; - -template<typename T> T& lvalue(); -template<typename T> T&& xvalue(); -template<typename T> T prvalue(); - -// In a .* expression whose object expression is an rvalue, the -// program is ill-formed if the second operand is a pointer to member -// function with ref-qualifier &. In a ->* expression or in a .* -// expression whose object expression is an lvalue, the program is -// ill-formed if the second operand is a pointer to member function -// with ref-qualifier &&. -void test(X *xp, int (X::*pmf)(int), int (X::*l_pmf)(int) &, - int (X::*r_pmf)(int) &&) { - // No ref-qualifier. - (lvalue<X>().*pmf)(17); - (xvalue<X>().*pmf)(17); - (prvalue<X>().*pmf)(17); - (xp->*pmf)(17); - - // Lvalue ref-qualifier. - (lvalue<X>().*l_pmf)(17); - (xvalue<X>().*l_pmf)(17); // expected-error-re{{pointer-to-member function type 'int (X::*)(int){{( __attribute__\(\(thiscall\)\))?}} &' can only be called on an lvalue}} - (prvalue<X>().*l_pmf)(17); // expected-error-re{{pointer-to-member function type 'int (X::*)(int){{( __attribute__\(\(thiscall\)\))?}} &' can only be called on an lvalue}} - (xp->*l_pmf)(17); - - // Rvalue ref-qualifier. - (lvalue<X>().*r_pmf)(17); // expected-error-re{{pointer-to-member function type 'int (X::*)(int){{( __attribute__\(\(thiscall\)\))?}} &&' can only be called on an rvalue}} - (xvalue<X>().*r_pmf)(17); - (prvalue<X>().*r_pmf)(17); - (xp->*r_pmf)(17); // expected-error-re{{pointer-to-member function type 'int (X::*)(int){{( __attribute__\(\(thiscall\)\))?}} &&' can only be called on an rvalue}} -} diff --git a/test/CXX/expr/expr.post/expr.call/p7-0x.cpp b/test/CXX/expr/expr.post/expr.call/p7-0x.cpp deleted file mode 100644 index fbb685c5a448..000000000000 --- a/test/CXX/expr/expr.post/expr.call/p7-0x.cpp +++ /dev/null @@ -1,46 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s - -struct X1 { - X1(); -}; - -struct X2 { - X2(); - ~X2(); -}; - -struct X3 { - X3(const X3&) = default; -}; - -struct X4 { - X4(const X4&) = default; - X4(X4&); -}; - -void vararg(...); - -void g(); - -void f(X1 x1, X2 x2, X3 x3, X4 x4) { - vararg(x1); // OK - vararg(x2); // expected-error{{cannot pass object of non-trivial type 'X2' through variadic function; call will abort at runtime}} - vararg(x3); // OK - vararg(x4); // expected-error{{cannot pass object of non-trivial type 'X4' through variadic function; call will abort at runtime}} - - vararg(g()); // expected-error{{cannot pass expression of type 'void' to variadic function}} - vararg({1, 2, 3}); // expected-error{{cannot pass initializer list to variadic function}} -} - - -namespace PR11131 { - struct S; - - S &getS(); - - int f(...); - - void g() { - (void)sizeof(f(getS())); - } -} diff --git a/test/CXX/expr/expr.post/expr.const.cast/p1-0x.cpp b/test/CXX/expr/expr.post/expr.const.cast/p1-0x.cpp deleted file mode 100644 index f4c0f1ae1229..000000000000 --- a/test/CXX/expr/expr.post/expr.const.cast/p1-0x.cpp +++ /dev/null @@ -1,45 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s - -// The result of the expression const_cast<T>(v) is of type T. If T is -// an lvalue reference to object type, the result is an lvalue; if T -// is an rvalue reference to object type, the result is an xvalue;. - -unsigned int f(int); - -struct X {}; - -template<typename T> T& lvalue(); -template<typename T> T&& xvalue(); -template<typename T> T prvalue(); - -void test_classification(const int *ptr, X x) { - int *&&ptr0 = const_cast<int *&&>(ptr); - int *&&ptr1 = const_cast<int *&&>(xvalue<const int*>()); - int *&&ptr2 = const_cast<int *&&>(prvalue<const int*>()); // expected-error {{const_cast from rvalue to reference type 'int *&&'}} - X &&ptr3 = const_cast<X&&>(x); - X &&ptr4 = const_cast<X&&>(xvalue<X>()); - X &&ptr5 = const_cast<X&&>(prvalue<X>()); - - int *&ptr6 = const_cast<int *&>(ptr); - int *&ptr7 = const_cast<int *&>(xvalue<const int*>()); // expected-error {{const_cast from rvalue to reference type 'int *&'}} - int *&ptr8 = const_cast<int *&>(prvalue<const int*>()); // expected-error {{const_cast from rvalue to reference type 'int *&'}} - X &ptr9 = const_cast<X&>(x); - X &ptrA = const_cast<X&>(xvalue<X>()); // expected-error {{const_cast from rvalue to reference type 'X &'}} - X &ptrB = const_cast<X&>(prvalue<X>()); // expected-error {{const_cast from rvalue to reference type 'X &'}} -} - -struct A { - volatile unsigned ubf : 4; - volatile unsigned uv; - volatile int sv; - void foo(); - bool pred(); -}; - -void test(A &a) { - unsigned &t0 = const_cast<unsigned&>(a.ubf); // expected-error {{const_cast from bit-field lvalue to reference type}} - unsigned &t1 = const_cast<unsigned&>(a.foo(), a.ubf); // expected-error {{const_cast from bit-field lvalue to reference type}} - unsigned &t2 = const_cast<unsigned&>(a.pred() ? a.ubf : a.ubf); // expected-error {{const_cast from bit-field lvalue to reference type}} - unsigned &t3 = const_cast<unsigned&>(a.pred() ? a.ubf : a.uv); // expected-error {{const_cast from bit-field lvalue to reference type}} - unsigned &t4 = const_cast<unsigned&>(a.pred() ? a.ubf : a.sv); // expected-error {{const_cast from rvalue to reference type}} -} diff --git a/test/CXX/expr/expr.post/expr.dynamic.cast/p3-0x.cpp b/test/CXX/expr/expr.post/expr.dynamic.cast/p3-0x.cpp deleted file mode 100644 index cddd5cf25e3b..000000000000 --- a/test/CXX/expr/expr.post/expr.dynamic.cast/p3-0x.cpp +++ /dev/null @@ -1,14 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s - -struct X { virtual ~X(); }; -struct Y : public X { }; -struct Z; // expected-note{{forward declaration of 'Z'}} - -void test(X &x, Y &y, Z &z) { - // If T is an rvalue reference type, v shall be an expression having - // a complete class type, and the result is an xvalue of the type - // referred to by T. - Y &&yr0 = dynamic_cast<Y&&>(x); - Y &&yr1 = dynamic_cast<Y&&>(static_cast<X&&>(x)); - Y &&yr2 = dynamic_cast<Y&&>(z); // expected-error{{'Z' is an incomplete type}} -} diff --git a/test/CXX/expr/expr.post/expr.ref/p3.cpp b/test/CXX/expr/expr.post/expr.ref/p3.cpp deleted file mode 100644 index db33c014eeb7..000000000000 --- a/test/CXX/expr/expr.post/expr.ref/p3.cpp +++ /dev/null @@ -1,16 +0,0 @@ -// RUN: %clang_cc1 -verify -fsyntax-only %s -// expected-no-diagnostics - -template<typename T> struct Node { - int lhs; - void splay( ) - { - Node<T> n[1]; - (void)n->lhs; - } -}; - -void f() { - Node<int> n; - return n.splay(); -} diff --git a/test/CXX/expr/expr.post/expr.reinterpret.cast/p1-0x.cpp b/test/CXX/expr/expr.post/expr.reinterpret.cast/p1-0x.cpp deleted file mode 100644 index 212adc8c2bd4..000000000000 --- a/test/CXX/expr/expr.post/expr.reinterpret.cast/p1-0x.cpp +++ /dev/null @@ -1,19 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s - -// If T is an lvalue reference type or an rvalue reference to function -// type, the result is an lvalue; if T is an rvalue reference to -// object type, the result is an xvalue; - -unsigned int f(int); - -template<typename T> T&& xvalue(); -void test_classification(char *ptr) { - int (&fr0)(int) = reinterpret_cast<int (&&)(int)>(f); - int &&ir0 = reinterpret_cast<int &&>(*ptr); - int &&ir1 = reinterpret_cast<int &&>(0); // expected-error {{rvalue to reference type}} - int &&ir2 = reinterpret_cast<int &&>('a'); // expected-error {{rvalue to reference type}} - int &&ir3 = reinterpret_cast<int &&>(xvalue<char>()); - // Per DR1268, reinterpret_cast can convert between lvalues and xvalues. - int &ir4 = reinterpret_cast<int &>(xvalue<char>()); - int &&ir5 = reinterpret_cast<int &&>(*ptr); -} diff --git a/test/CXX/expr/expr.post/expr.reinterpret.cast/p2.cpp b/test/CXX/expr/expr.post/expr.reinterpret.cast/p2.cpp deleted file mode 100644 index b03db27ee1d0..000000000000 --- a/test/CXX/expr/expr.post/expr.reinterpret.cast/p2.cpp +++ /dev/null @@ -1,26 +0,0 @@ -// RUN: %clang_cc1 %s -verify - -// The reinterpret_cast operator shall not cast away constness. -struct X {}; -struct Y {}; -void f(const int * X::* Y::* *p) { - // This applies for similar types... - (void)reinterpret_cast<int * X::* Y::* *>(p); // expected-error {{casts away qualifiers}} - // ... and for cases where the base type is different ... - (void)reinterpret_cast<float * X::* Y::* *>(p); // expected-error {{casts away qualifiers}} - // ... and for cases where pointers to members point to members of different classes ... - (void)reinterpret_cast<int * Y::* X::* *>(p); // expected-error {{casts away qualifiers}} - // ... and even for cases where the path is wholly different! - // (Though we accept such cases as an extension.) - (void)reinterpret_cast<double Y::* X::* * *>(p); // expected-warning {{casts away qualifiers}} - - // If qualifiers are added, we need a 'const' at every level above. - (void)reinterpret_cast<const volatile double Y::* X::* * *>(p); // expected-warning {{casts away qualifiers}} - (void)reinterpret_cast<const volatile double Y::*const X::*const **>(p); // expected-warning {{casts away qualifiers}} - (void)reinterpret_cast<const volatile double Y::*const X::**const *>(p); // expected-warning {{casts away qualifiers}} - (void)reinterpret_cast<const volatile double Y::*X::*const *const *>(p); // expected-warning {{casts away qualifiers}} - (void)reinterpret_cast<const volatile double Y::*const X::*const *const *>(p); // ok - - (void)reinterpret_cast<const double Y::*volatile X::**const *>(p); // expected-warning {{casts away qualifiers}} - (void)reinterpret_cast<const double Y::*volatile X::*const *const *>(p); // ok -} diff --git a/test/CXX/expr/expr.post/expr.static.cast/p3-0x.cpp b/test/CXX/expr/expr.post/expr.static.cast/p3-0x.cpp deleted file mode 100644 index 830ccda245ba..000000000000 --- a/test/CXX/expr/expr.post/expr.static.cast/p3-0x.cpp +++ /dev/null @@ -1,25 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s -// expected-no-diagnostics - -// A glvalue of type "cv1 T1" can be cast to type "rvalue reference to -// cv2 T2" if "cv2 T2" is reference-compatible with "cv1 T1" (8.5.3). -struct A { }; -struct B : A { }; - -template<typename T> T& lvalue(); -template<typename T> T&& xvalue(); - -void test(A &a, B &b) { - A &&ar0 = static_cast<A&&>(a); - A &&ar1 = static_cast<A&&>(b); - A &&ar2 = static_cast<A&&>(lvalue<A>()); - A &&ar3 = static_cast<A&&>(lvalue<B>()); - A &&ar4 = static_cast<A&&>(xvalue<A>()); - A &&ar5 = static_cast<A&&>(xvalue<B>()); - const A &&ar6 = static_cast<const A&&>(a); - const A &&ar7 = static_cast<const A&&>(b); - const A &&ar8 = static_cast<const A&&>(lvalue<A>()); - const A &&ar9 = static_cast<const A&&>(lvalue<B>()); - const A &&ar10 = static_cast<const A&&>(xvalue<A>()); - const A &&ar11 = static_cast<const A&&>(xvalue<B>()); -} diff --git a/test/CXX/expr/expr.post/expr.static.cast/p3-p4-0x.cpp b/test/CXX/expr/expr.post/expr.static.cast/p3-p4-0x.cpp deleted file mode 100644 index 8701a00d5cf0..000000000000 --- a/test/CXX/expr/expr.post/expr.static.cast/p3-p4-0x.cpp +++ /dev/null @@ -1,43 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s - - -// p3 -// A glvalue of type "cv1 T1" can be cast to type "rvalue reference to -// cv2 T2" if "cv2 T2" is reference-compatible with "cv1 T1" (8.5.3). -// p4 -// Otherwise, an expression e can be explicitly converted to a type T using a -// static_cast of the form static_cast<T>(e) if the declaration T t(e); is -// well-formed, for some invented temporary variable t (8.5). [...] -struct A { }; -struct B : A { }; - -struct C { explicit operator A&&(); }; -struct D { operator B(); }; - -template<typename T> T& lvalue(); -template<typename T> T&& xvalue(); -template <typename T> T prvalue(); - -void test(A &a, B &b) { - A &&ar0 = static_cast<A&&>(prvalue<A>()); - A &&ar1 = static_cast<A&&>(prvalue<B>()); - A &&ar2 = static_cast<A&&>(lvalue<C>()); - A &&ar3 = static_cast<A&&>(xvalue<C>()); - A &&ar4 = static_cast<A&&>(prvalue<C>()); - A &&ar5 = static_cast<A&&>(lvalue<D>()); - A &&ar6 = static_cast<A&&>(xvalue<D>()); - A &&ar7 = static_cast<A&&>(prvalue<D>()); - - A &&ar8 = static_cast<A&&>(prvalue<const A>()); // expected-error {{binding value of type 'const A' to reference to type 'A' drops 'const' qualifier}} - A &&ar9 = static_cast<A&&>(lvalue<const A>()); // expected-error {{cannot cast from lvalue of type 'const A'}} - A &&ar10 = static_cast<A&&>(xvalue<const A>()); // expected-error {{cannot cast from rvalue of type 'const A'}} - - const A &&ar11 = static_cast<const A&&>(prvalue<A>()); - const A &&ar12 = static_cast<const A&&>(prvalue<B>()); - const A &&ar13 = static_cast<const A&&>(lvalue<C>()); - const A &&ar14 = static_cast<const A&&>(xvalue<C>()); - const A &&ar15 = static_cast<const A&&>(prvalue<C>()); - const A &&ar16 = static_cast<const A&&>(lvalue<D>()); - - const A &&ar17 = static_cast<const A&&>(prvalue<A const volatile>()); // expected-error {{binding value of type 'const volatile A' to reference to type 'const A' drops 'volatile' qualifier}} -} diff --git a/test/CXX/expr/expr.post/expr.static.cast/p7.cpp b/test/CXX/expr/expr.post/expr.static.cast/p7.cpp deleted file mode 100644 index fd8e478b5193..000000000000 --- a/test/CXX/expr/expr.post/expr.static.cast/p7.cpp +++ /dev/null @@ -1,10 +0,0 @@ -// RUN: %clang_cc1 -std=c++1z -verify %s -fcxx-exceptions - -void (*p)() noexcept; -void (*q)(); - -void f() { - // FIXME: This seems like a bad rule. - p = static_cast<decltype(p)>(q); // expected-error {{not allowed}} - q = static_cast<decltype(q)>(p); -} diff --git a/test/CXX/expr/expr.post/expr.static.cast/p9-0x.cpp b/test/CXX/expr/expr.post/expr.static.cast/p9-0x.cpp deleted file mode 100644 index c624c7e3f2f9..000000000000 --- a/test/CXX/expr/expr.post/expr.static.cast/p9-0x.cpp +++ /dev/null @@ -1,30 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s -// expected-no-diagnostics - -enum class EC { ec1 }; - -void test0(EC ec) { - (void)static_cast<bool>(ec); - (void)static_cast<bool>(EC::ec1); - (void)static_cast<char>(ec); - (void)static_cast<char>(EC::ec1); - (void)static_cast<int>(ec); - (void)static_cast<int>(EC::ec1); - (void)static_cast<unsigned long>(ec); - (void)static_cast<unsigned long>(EC::ec1); - (void)static_cast<float>(ec); - (void)static_cast<float>(EC::ec1); - (void)static_cast<double>(ec); - (void)static_cast<double>(EC::ec1); -} - -namespace PR9107 { - enum E {}; - template <class _Tp> inline _Tp* addressof(_Tp& __x) { - return (_Tp*)&(char&)__x; - } - void test() { - E a; - addressof(a); - } -} diff --git a/test/CXX/expr/expr.post/expr.type.conv/p1-0x.cpp b/test/CXX/expr/expr.post/expr.type.conv/p1-0x.cpp deleted file mode 100644 index 568c61b95fb9..000000000000 --- a/test/CXX/expr/expr.post/expr.type.conv/p1-0x.cpp +++ /dev/null @@ -1,13 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s -// expected-no-diagnostics - -struct foo { - foo(); - foo(int); -}; - -int func(foo& f) { - decltype(foo())(); - f = (decltype(foo()))5; - return decltype(3)(5); -} diff --git a/test/CXX/expr/expr.post/expr.type.conv/p1.cpp b/test/CXX/expr/expr.post/expr.type.conv/p1.cpp deleted file mode 100644 index f3608bc378bc..000000000000 --- a/test/CXX/expr/expr.post/expr.type.conv/p1.cpp +++ /dev/null @@ -1,10 +0,0 @@ -// RUN: %clang_cc1 -std=c++1z -verify %s - -template<typename T> struct A { // expected-note 2{{candidate}} - T t, u; -}; -template<typename T> A(T, T) -> A<T>; // expected-note {{deduced conflicting types for parameter 'T'}} -template<typename T> A(A<T>) -> A<T>; // expected-note {{requires 1 argument, but 2 were provided}} - -A a = A{1, 2}; -A b = A{3, 4.0}; // expected-error {{no viable constructor or deduction guide}} diff --git a/test/CXX/expr/expr.prim/expr.prim.general/p12-0x.cpp b/test/CXX/expr/expr.prim/expr.prim.general/p12-0x.cpp deleted file mode 100644 index 249c97646089..000000000000 --- a/test/CXX/expr/expr.prim/expr.prim.general/p12-0x.cpp +++ /dev/null @@ -1,38 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s - -struct S { - int *j = &nonexistent; // expected-error {{use of undeclared identifier 'nonexistent'}} - int *m = &n; // ok - - int n = f(); // ok - int f(); -}; - -int i = sizeof(S::m); // ok -int j = sizeof(S::m + 42); // ok - - -struct T { - int n; - static void f() { - int a[n]; // expected-error {{invalid use of member 'n' in static member function}} - int b[sizeof n]; // ok - } -}; - -// Make sure the rule for unevaluated operands works correctly with typeid. -namespace std { - class type_info; -} -class Poly { virtual ~Poly(); }; -const std::type_info& k = typeid(S::m); -const std::type_info& m = typeid(*(Poly*)S::m); // expected-error {{invalid use of non-static data member}} -const std::type_info& n = typeid(*(Poly*)(0*sizeof S::m)); - -namespace PR11956 { - struct X { char a; }; - struct Y { int f() { return sizeof(X::a); } }; // ok - - struct A { enum E {} E; }; - struct B { int f() { return sizeof(A::E); } }; // ok -} diff --git a/test/CXX/expr/expr.prim/expr.prim.general/p3-0x.cpp b/test/CXX/expr/expr.prim/expr.prim.general/p3-0x.cpp deleted file mode 100644 index 0e948ce00031..000000000000 --- a/test/CXX/expr/expr.prim/expr.prim.general/p3-0x.cpp +++ /dev/null @@ -1,165 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -verify - -struct A { - int &f(int*); - float &f(int*) const noexcept; - - int *ptr; - auto g1() noexcept(noexcept(f(ptr))) -> decltype(f(this->ptr)); - auto g2() const noexcept(noexcept(f((*this).ptr))) -> decltype(f(ptr)); -}; - -void testA(A &a) { - int &ir = a.g1(); - float &fr = a.g2(); - static_assert(!noexcept(a.g1()), "exception-specification failure"); - static_assert(noexcept(a.g2()), "exception-specification failure"); -} - -struct B { - char g(); - template<class T> auto f(T t) -> decltype(t + g()) - { return t + g(); } -}; - -template auto B::f(int t) -> decltype(t + g()); - -template<typename T> -struct C { - int &f(T*); - float &f(T*) const noexcept; - - T* ptr; - auto g1() noexcept(noexcept(f(ptr))) -> decltype(f(ptr)); - auto g2() const noexcept(noexcept(f(((this))->ptr))) -> decltype(f(ptr)); - auto g3() noexcept(noexcept(f(this->ptr))) -> decltype(f((*this).ptr)); - auto g4() const noexcept(noexcept(f(((this))->ptr))) -> decltype(f(this->ptr)); - auto g5() noexcept(noexcept(this->f(ptr))) -> decltype(this->f(ptr)); - auto g6() const noexcept(noexcept(this->f(((this))->ptr))) -> decltype(this->f(ptr)); - auto g7() noexcept(noexcept(this->f(this->ptr))) -> decltype(this->f((*this).ptr)); - auto g8() const noexcept(noexcept(this->f(((this))->ptr))) -> decltype(this->f(this->ptr)); -}; - -void test_C(C<int> ci) { - int &ir = ci.g1(); - float &fr = ci.g2(); - int &ir2 = ci.g3(); - float &fr2 = ci.g4(); - int &ir3 = ci.g5(); - float &fr3 = ci.g6(); - int &ir4 = ci.g7(); - float &fr4 = ci.g8(); - static_assert(!noexcept(ci.g1()), "exception-specification failure"); - static_assert(noexcept(ci.g2()), "exception-specification failure"); - static_assert(!noexcept(ci.g3()), "exception-specification failure"); - static_assert(noexcept(ci.g4()), "exception-specification failure"); - static_assert(!noexcept(ci.g5()), "exception-specification failure"); - static_assert(noexcept(ci.g6()), "exception-specification failure"); - static_assert(!noexcept(ci.g7()), "exception-specification failure"); - static_assert(noexcept(ci.g8()), "exception-specification failure"); -} - -namespace PR14263 { - template<typename T> struct X { - void f(); - T f() const; - - auto g() -> decltype(this->f()) { return f(); } - auto g() const -> decltype(this->f()) { return f(); } - }; - template struct X<int>; -} - -namespace PR10036 { - template <class I> - void - iter_swap(I x, I y) noexcept; - - template <class T> - class A - { - T t_; - public: - void swap(A& a) noexcept(noexcept(iter_swap(&t_, &a.t_))); - }; - - void test() { - A<int> i, j; - i.swap(j); - } -} - -namespace PR15290 { - template<typename T> - class A { - T v_; - friend int add_to_v(A &t) noexcept(noexcept(v_ + 42)) - { - return t.v_ + 42; - } - }; - void f() - { - A<int> t; - add_to_v(t); - } -} - -namespace Static { - struct X1 { - int m; - // FIXME: This should be accepted. - static auto f() -> decltype(m); // expected-error{{'this' cannot be implicitly used in a static member function declaration}} - static auto g() -> decltype(this->m); // expected-error{{'this' cannot be used in a static member function declaration}} - - static int h(); - - static int i() noexcept(noexcept(m + 2)); // expected-error{{'this' cannot be implicitly used in a static member function declaration}} - }; - - auto X1::h() -> decltype(m) { return 0; } // expected-error{{'this' cannot be implicitly used in a static member function declaration}} - - template<typename T> - struct X2 { - int m; - - T f(T*); - static T f(int); - - auto g(T x) -> decltype(f(x)) { return 0; } - }; - - void test_X2() { - X2<int>().g(0); - } -} - -namespace PR12564 { - struct Base { - void bar(Base&) {} - }; - - struct Derived : Base { - void foo(Derived& d) noexcept(noexcept(d.bar(d))) {} - }; -} - -namespace rdar13473493 { - template <typename F> - class wrap - { - public: - template <typename... Args> - auto operator()(Args&&... args) const -> decltype(wrapped(args...)) // expected-note{{candidate template ignored: substitution failure [with Args = <int>]: use of undeclared identifier 'wrapped'}} - { - return wrapped(args...); - } - - private: - F wrapped; - }; - - void test(wrap<int (*)(int)> w) { - w(5); // expected-error{{no matching function for call to object of type 'wrap<int (*)(int)>'}} - } -} diff --git a/test/CXX/expr/expr.prim/expr.prim.general/p4-0x.cpp b/test/CXX/expr/expr.prim/expr.prim.general/p4-0x.cpp deleted file mode 100644 index 54b2ff52895a..000000000000 --- a/test/CXX/expr/expr.prim/expr.prim.general/p4-0x.cpp +++ /dev/null @@ -1,22 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s - -struct S { - S *p = this; // ok - decltype(this) q; // expected-error {{invalid use of 'this' outside of a non-static member function}} - - int arr[sizeof(this)]; // expected-error {{invalid use of 'this' outside of a non-static member function}} - int sz = sizeof(this); // ok - - typedef auto f() -> decltype(this); // expected-error {{invalid use of 'this' outside of a non-static member function}} -}; - -namespace CaptureThis { - struct X { - int n = 10; - int m = [&]{return n + 1; }(); - int o = [&]{return this->m + 1; }(); - int p = [&]{return [&](int x) { return this->m + x;}(o); }(); - }; - - X x; -} diff --git a/test/CXX/expr/expr.prim/expr.prim.general/p8-0x.cpp b/test/CXX/expr/expr.prim/expr.prim.general/p8-0x.cpp deleted file mode 100644 index b5cd98828cc9..000000000000 --- a/test/CXX/expr/expr.prim/expr.prim.general/p8-0x.cpp +++ /dev/null @@ -1,78 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s - -struct global { -}; - -namespace PR10127 { - struct outer { - struct middle { - struct inner { - int func(); - int i; - }; - struct inner2 { - }; - struct inner3 { - }; - int mfunc(); - }; - typedef int td_int; - }; - - struct str { - operator decltype(outer::middle::inner()) (); - operator decltype(outer::middle())::inner2 (); - operator decltype(outer())::middle::inner3 (); - str(int (decltype(outer::middle::inner())::*n)(), - int (decltype(outer::middle())::inner::*o)(), - int (decltype(outer())::middle::inner::*p)()); - }; - - decltype(outer::middle::inner()) a; - void scope() { - a.decltype(outer::middle())::mfunc(); // expected-error{{'PR10127::outer::middle::mfunc' is not a member of class 'decltype(outer::middle::inner())'}} - a.decltype(outer::middle::inner())::func(); - a.decltype(outer::middle())::inner::func(); - a.decltype(outer())::middle::inner::func(); - - a.decltype(outer())::middle::inner::~inner(); - - decltype(outer())::middle::inner().func(); - } - decltype(outer::middle())::inner b; - decltype(outer())::middle::inner c; - decltype(outer())::fail d; // expected-error{{no type named 'fail' in 'PR10127::outer'}} - decltype(outer())::fail::inner e; // expected-error{{no member named 'fail' in 'PR10127::outer'}} - decltype()::fail f; // expected-error{{expected expression}} - decltype()::middle::fail g; // expected-error{{expected expression}} - - decltype(int()) h; - decltype(int())::PR10127::outer i; // expected-error{{'decltype(int())' (aka 'int') is not a class, namespace, or enumeration}} - decltype(int())::global j; // expected-error{{'decltype(int())' (aka 'int') is not a class, namespace, or enumeration}} - - outer::middle k = decltype(outer())::middle(); - outer::middle::inner l = decltype(outer())::middle::inner(); - - template<typename T> - struct templ { - typename decltype(T())::middle::inner x; // expected-error{{type 'decltype(int())' (aka 'int') cannot be used prior to '::' because it has no members}} - }; - - template class templ<int>; // expected-note{{in instantiation of template class 'PR10127::templ<int>' requested here}} - template class templ<outer>; - - enum class foo { - bar, - baz - }; - - foo m = decltype(foo::bar)::baz; - - enum E { - }; - struct bar { - enum E : decltype(outer())::td_int(4); - enum F : decltype(outer())::td_int; - enum G : decltype; // expected-error{{expected '(' after 'decltype'}} - }; -} diff --git a/test/CXX/expr/expr.prim/expr.prim.lambda/blocks-irgen.mm b/test/CXX/expr/expr.prim/expr.prim.lambda/blocks-irgen.mm deleted file mode 100644 index 24ce2cd6c198..000000000000 --- a/test/CXX/expr/expr.prim/expr.prim.lambda/blocks-irgen.mm +++ /dev/null @@ -1,29 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -fblocks -emit-llvm -o - -triple x86_64-apple-darwin11.3 %s | FileCheck %s - -namespace PR12746 { - // CHECK: define zeroext i1 @_ZN7PR127462f1EPi - bool f1(int *x) { - // CHECK: store i8* bitcast (i1 (i8*)* @___ZN7PR127462f1EPi_block_invoke to i8*) - bool (^outer)() = ^ { - auto inner = [&]() -> bool { - return x == 0; - }; - return inner(); - }; - return outer(); - } - - // CHECK: define internal zeroext i1 @___ZN7PR127462f1EPi_block_invoke - // CHECK: call zeroext i1 @"_ZZZN7PR127462f1EPiEUb_ENK3$_0clEv" - - bool f2(int *x) { - auto outer = [&]() -> bool { - bool (^inner)() = ^ { - return x == 0; - }; - return inner(); - }; - return outer(); - } -} - diff --git a/test/CXX/expr/expr.prim/expr.prim.lambda/blocks.mm b/test/CXX/expr/expr.prim/expr.prim.lambda/blocks.mm deleted file mode 100644 index 96e8fcd8d371..000000000000 --- a/test/CXX/expr/expr.prim/expr.prim.lambda/blocks.mm +++ /dev/null @@ -1,144 +0,0 @@ -// RUN: %clang_cc1 -triple i686-pc-linux -std=c++11 -fblocks %s -verify - -void block_capture_errors() { - __block int var; // expected-note 2{{'var' declared here}} - (void)[var] { }; // expected-error{{__block variable 'var' cannot be captured in a lambda}} - - (void)[=] { var = 17; }; // expected-error{{__block variable 'var' cannot be captured in a lambda}} -} - -void conversion_to_block(int captured) { - int (^b1)(int) = [=](int x) { return x + captured; }; - - const auto lambda = [=](int x) { return x + captured; }; - int (^b2)(int) = lambda; -} - -template<typename T> -class ConstCopyConstructorBoom { -public: - ConstCopyConstructorBoom(ConstCopyConstructorBoom&); - - ConstCopyConstructorBoom(const ConstCopyConstructorBoom&) { - T *ptr = 1; // expected-error{{cannot initialize a variable of type 'float *' with an rvalue of type 'int'}} - } - - void foo() const; -}; - -void conversion_to_block_init(ConstCopyConstructorBoom<int> boom, - ConstCopyConstructorBoom<float> boom2) { - const auto& lambda1([=] { boom.foo(); }); // okay - - const auto& lambda2([=] { boom2.foo(); }); // expected-note{{in instantiation of member function}} - void (^block)(void) = lambda2; -} - - -void nesting() { - int array[7]; // expected-note 2{{'array' declared here}} - [=] () mutable { - [&] { - ^ { - int i = array[2]; - i += array[3]; - }(); - }(); - }(); - - [&] { - [=] () mutable { - ^ { - int i = array[2]; // expected-error{{cannot refer to declaration with an array type inside block}} - i += array[3]; // expected-error{{cannot refer to declaration with an array type inside block}} - }(); - }(); - }(); -} - -namespace overloading { - void bool_conversion() { - if ([](){}) { - } - - bool b = []{}; - b = (bool)[]{}; - } - - void conversions() { - int (*fp)(int) = [](int x) { return x + 1; }; - fp = [](int x) { return x + 1; }; - - typedef int (*func_ptr)(int); - fp = (func_ptr)[](int x) { return x + 1; }; - - int (^bp)(int) = [](int x) { return x + 1; }; - bp = [](int x) { return x + 1; }; - - typedef int (^block_ptr)(int); - bp = (block_ptr)[](int x) { return x + 1; }; - } - - int &accept_lambda_conv(int (*fp)(int)); - float &accept_lambda_conv(int (^bp)(int)); - - void call_with_lambda() { - int &ir = accept_lambda_conv([](int x) { return x + 1; }); - } - - template<typename T> using id = T; - - auto a = [](){}; - struct C : decltype(a) { - using decltype(a)::operator id<void(*)()>; - private: - using decltype(a)::operator id<void(^)()>; - } extern c; - - struct D : decltype(a) { - using decltype(a)::operator id<void(^)()>; - private: - using decltype(a)::operator id<void(*)()>; // expected-note {{here}} - } extern d; - - bool r1 = c; - bool r2 = d; // expected-error {{private}} -} - -namespace PR13117 { - struct A { - template<typename ... Args> static void f(Args...); - - template<typename ... Args> static void f1() - { - (void)^(Args args) { // expected-error{{block contains unexpanded parameter pack 'Args'}} - }; - } - - template<typename ... Args> static void f2() - { - // FIXME: Allow this. - f( - ^(Args args) // expected-error{{block contains unexpanded parameter pack 'Args'}} - { } - ... // expected-error{{pack expansion does not contain any unexpanded parameter packs}} - ); - } - - template<typename ... Args> static void f3() - { - (void)[](Args args) { // expected-error{{expression contains unexpanded parameter pack 'Args'}} - }; - } - - template<typename ... Args> static void f4() - { - f([](Args args) { } ...); - } - }; - - void g() { - A::f1<int, int>(); - A::f2<int, int>(); - } -} diff --git a/test/CXX/expr/expr.prim/expr.prim.lambda/default-arguments.cpp b/test/CXX/expr/expr.prim/expr.prim.lambda/default-arguments.cpp deleted file mode 100644 index 9b0a9ad8c257..000000000000 --- a/test/CXX/expr/expr.prim/expr.prim.lambda/default-arguments.cpp +++ /dev/null @@ -1,53 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -verify - -void defargs() { - auto l1 = [](int i, int j = 17, int k = 18) { return i + j + k; }; - int i1 = l1(1); - int i2 = l1(1, 2); - int i3 = l1(1, 2, 3); -} - - -void defargs_errors() { - auto l1 = [](int i, - int j = 17, - int k) { }; // expected-error{{missing default argument on parameter 'k'}} - - auto l2 = [](int i, int j = i) {}; // expected-error{{default argument references parameter 'i'}} - - int foo; - auto l3 = [](int i = foo) {}; // expected-error{{default argument references local variable 'foo' of enclosing function}} -} - -struct NonPOD { - NonPOD(); - NonPOD(const NonPOD&); - ~NonPOD(); -}; - -struct NoDefaultCtor { - NoDefaultCtor(const NoDefaultCtor&); // expected-note{{candidate constructor}} \ - // expected-note{{candidate constructor not viable: requires 1 argument, but 0 were provided}} - ~NoDefaultCtor(); -}; - -template<typename T> -void defargs_in_template_unused(T t) { - auto l1 = [](const T& value = T()) { }; // expected-error{{no matching constructor for initialization of 'NoDefaultCtor'}} - l1(t); -} - -template void defargs_in_template_unused(NonPOD); -template void defargs_in_template_unused(NoDefaultCtor); // expected-note{{in instantiation of function template specialization 'defargs_in_template_unused<NoDefaultCtor>' requested here}} - -template<typename T> -void defargs_in_template_used() { - auto l1 = [](const T& value = T()) { }; // expected-error{{no matching constructor for initialization of 'NoDefaultCtor'}} \ - // expected-note{{candidate function not viable: requires single argument 'value', but no arguments were provided}} \ - // expected-note{{conversion candidate of type 'void (*)(const NoDefaultCtor &)'}} - l1(); // expected-error{{no matching function for call to object of type '(lambda at }} -} - -template void defargs_in_template_used<NonPOD>(); -template void defargs_in_template_used<NoDefaultCtor>(); // expected-note{{in instantiation of function template specialization}} - diff --git a/test/CXX/expr/expr.prim/expr.prim.lambda/p10.cpp b/test/CXX/expr/expr.prim/expr.prim.lambda/p10.cpp deleted file mode 100644 index 245e27042be3..000000000000 --- a/test/CXX/expr/expr.prim/expr.prim.lambda/p10.cpp +++ /dev/null @@ -1,40 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 %s -verify - -int GlobalVar; // expected-note {{declared here}} - -namespace N { - int AmbiguousVar; // expected-note {{candidate}} -} -int AmbiguousVar; // expected-note {{candidate}} -using namespace N; - -class X0 { - int Member; - - static void Overload(int); - void Overload(); - virtual X0& Overload(float); - - void explicit_capture() { - int variable; // expected-note {{declared here}} - (void)[&Overload] () {}; // expected-error {{does not name a variable}} - (void)[&GlobalVar] () {}; // expected-error {{does not have automatic storage duration}} - (void)[&AmbiguousVar] () {}; // expected-error {{reference to 'AmbiguousVar' is ambiguous}} - (void)[&Variable] () {}; // expected-error {{use of undeclared identifier 'Variable'; did you mean 'variable'}} - } -}; - -void test_reaching_scope() { - int local; // expected-note{{declared here}} - static int local_static; // expected-note{{'local_static' declared here}} - (void)[=]() { - struct InnerLocal { - void member() { - (void)[local, // expected-error{{reference to local variable 'local' declared in enclosing function 'test_reaching_scope'}} - local_static]() { // expected-error{{'local_static' cannot be captured because it does not have automatic storage duration}} - return 0; - }; - } - }; - }; -} diff --git a/test/CXX/expr/expr.prim/expr.prim.lambda/p11-1y.cpp b/test/CXX/expr/expr.prim/expr.prim.lambda/p11-1y.cpp deleted file mode 100644 index 63e51a761449..000000000000 --- a/test/CXX/expr/expr.prim/expr.prim.lambda/p11-1y.cpp +++ /dev/null @@ -1,78 +0,0 @@ -// RUN: %clang_cc1 -std=c++1y %s -verify - -const char *has_no_member = [x("hello")] {}.x; // expected-error {{no member named 'x'}} - -double f; -auto with_float = [f(1.0f)] { - using T = decltype(f); - using T = float; -}; -auto with_float_2 = [&f(f)] { // ok, refers to outer f - using T = decltype(f); - using T = double&; -}; - -// Within the lambda-expression's compound-statement, -// the identifier in the init-capture hides any declaration -// of the same name in scopes enclosing the lambda-expression. -void hiding() { - char c; - (void) [c("foo")] { - static_assert(sizeof(c) == sizeof(const char*), ""); - }; - (void) [c("bar")] () -> decltype(c) { // outer c, not init-capture - return "baz"; // expected-error {{cannot initialize}} - }; -} - -struct ExplicitCopy { - ExplicitCopy(); // expected-note 2{{not viable}} - explicit ExplicitCopy(const ExplicitCopy&); -}; -auto init_kind_1 = [ec(ExplicitCopy())] {}; -auto init_kind_2 = [ec = ExplicitCopy()] {}; // expected-error {{no matching constructor}} - -template<typename T> void init_kind_template() { - auto init_kind_1 = [ec(T())] {}; - auto init_kind_2 = [ec = T()] {}; // expected-error {{no matching constructor}} -} -template void init_kind_template<int>(); -template void init_kind_template<ExplicitCopy>(); // expected-note {{instantiation of}} - -void void_fn(); -int overload_fn(); -int overload_fn(int); - -auto bad_init_1 = [a()] {}; // expected-error {{expected expression}} -auto bad_init_2 = [a(1, 2)] {}; // expected-error {{initializer for lambda capture 'a' contains multiple expressions}} -auto bad_init_3 = [&a(void_fn())] {}; // expected-error {{cannot form a reference to 'void'}} -auto bad_init_4 = [a(void_fn())] {}; // expected-error {{has incomplete type 'void'}} -auto bad_init_5 = [a(overload_fn)] {}; // expected-error {{cannot deduce type for lambda capture 'a' from initializer of type '<overloaded function}} -auto bad_init_6 = [a{overload_fn}] {}; // expected-error {{cannot deduce type for lambda capture 'a' from initializer list}} -auto bad_init_7 = [a{{1}}] {}; // expected-error {{cannot deduce type for lambda capture 'a' from nested initializer list}} - -template<typename...T> void pack_1(T...t) { (void)[a(t...)] {}; } // expected-error {{initializer missing for lambda capture 'a'}} -template void pack_1<>(); // expected-note {{instantiation of}} - -// FIXME: Might need lifetime extension for the temporary here. -// See DR1695. -auto a = [a(4), b = 5, &c = static_cast<const int&&>(0)] { - static_assert(sizeof(a) == sizeof(int), ""); - static_assert(sizeof(b) == sizeof(int), ""); - using T = decltype(c); - using T = const int &; -}; -auto b = [a{0}] {}; // OK, per N3922 - -struct S { S(); S(S&&); }; -template<typename T> struct remove_reference { typedef T type; }; -template<typename T> struct remove_reference<T&> { typedef T type; }; -template<typename T> decltype(auto) move(T &&t) { return static_cast<typename remove_reference<T>::type&&>(t); } -auto s = [s(move(S()))] {}; - -template<typename T> T instantiate_test(T t) { - [x(&t)]() { *x = 1; } (); // expected-error {{assigning to 'const char *'}} - return t; -} -int instantiate_test_1 = instantiate_test(0); -const char *instantiate_test_2 = instantiate_test("foo"); // expected-note {{here}} diff --git a/test/CXX/expr/expr.prim/expr.prim.lambda/p11.cpp b/test/CXX/expr/expr.prim/expr.prim.lambda/p11.cpp deleted file mode 100644 index d265dd757398..000000000000 --- a/test/CXX/expr/expr.prim/expr.prim.lambda/p11.cpp +++ /dev/null @@ -1,16 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 %s -verify - -void test_reaching_scope() { - int local; // expected-note{{declared here}} - static int local_static; - (void)[=]() { - struct InnerLocal { - void member() { - (void)[=]() { - return local + // expected-error{{reference to local variable 'local' declared in enclosing function 'test_reaching_scope'}} - local_static; - }; - } - }; - }; -} diff --git a/test/CXX/expr/expr.prim/expr.prim.lambda/p12.cpp b/test/CXX/expr/expr.prim/expr.prim.lambda/p12.cpp deleted file mode 100644 index e7fce11abc5e..000000000000 --- a/test/CXX/expr/expr.prim/expr.prim.lambda/p12.cpp +++ /dev/null @@ -1,77 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 %s -Wunused -Wno-unused-lambda-capture -verify - -void odr_used() { - int i = 17; - [i]{}(); -} - -struct ReachingThis { - static void static_foo() { - (void)[this](){}; // expected-error{{'this' cannot be captured in this context}} - - struct Local { - int i; - - void bar() { - (void)[this](){}; - (void)[&](){i = 7; }; - } - }; - } - - void foo() { - (void)[this](){}; - - struct Local { - int i; - - static void static_bar() { - (void)[this](){}; // expected-error{{'this' cannot be captured in this context}} - (void)[&](){i = 7; }; // expected-error{{invalid use of member 'i' in static member function}} - } - }; - } -}; - -void immediately_enclosing(int i) { // expected-note{{'i' declared here}} - [i]() { - [i] {}(); - }(); - - [=]() { - [i] {}(); - }(); - - []() { // expected-note{{lambda expression begins here}} - [i] {}(); // expected-error{{variable 'i' cannot be implicitly captured in a lambda with no capture-default specified}} - }(); -} - -void f1(int i) { // expected-note{{declared here}} - int const N = 20; - auto m1 = [=]{ - int const M = 30; - auto m2 = [i]{ - int x[N][M]; - x[0][0] = i; - }; - (void)N; - (void)M; - (void)m2; - }; - struct s1 { - int f; - void work(int n) { // expected-note{{declared here}} - int m = n*n; - int j = 40; // expected-note{{declared here}} - auto m3 = [this,m] { // expected-note 3{{lambda expression begins here}} - auto m4 = [&,j] { // expected-error{{variable 'j' cannot be implicitly captured in a lambda with no capture-default specified}} - int x = n; // expected-error{{variable 'n' cannot be implicitly captured in a lambda with no capture-default specified}} - x += m; - x += i; // expected-error{{variable 'i' cannot be implicitly captured in a lambda with no capture-default specified}} - x += f; - }; - }; - } - }; -} diff --git a/test/CXX/expr/expr.prim/expr.prim.lambda/p13.cpp b/test/CXX/expr/expr.prim/expr.prim.lambda/p13.cpp deleted file mode 100644 index b55beb7d4ed7..000000000000 --- a/test/CXX/expr/expr.prim/expr.prim.lambda/p13.cpp +++ /dev/null @@ -1,16 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 %s -Wunused -Wno-unused-lambda-capture -verify - -void f2() { - int i = 1; - void g1(int = ([i]{ return i; })()); // expected-error{{lambda expression in default argument cannot capture any entity}} - void g2(int = ([i]{ return 0; })()); // expected-error{{lambda expression in default argument cannot capture any entity}} - void g3(int = ([=]{ return i; })()); // expected-error{{lambda expression in default argument cannot capture any entity}} - void g4(int = ([=]{ return 0; })()); - void g5(int = ([]{ return sizeof i; })()); -} - -namespace lambda_in_default_args { - int f(int = [] () -> int { int n; return ++n; } ()); - template<typename T> T g(T = [] () -> T { T n; return ++n; } ()); - int k = f() + g<int>(); -} diff --git a/test/CXX/expr/expr.prim/expr.prim.lambda/p14.cpp b/test/CXX/expr/expr.prim/expr.prim.lambda/p14.cpp deleted file mode 100644 index 7fc86e810927..000000000000 --- a/test/CXX/expr/expr.prim/expr.prim.lambda/p14.cpp +++ /dev/null @@ -1,111 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -verify - -template<typename T> void capture(const T&); - -class NonCopyable { - NonCopyable(const NonCopyable&); // expected-note 2 {{implicitly declared private here}} -public: - void foo() const; -}; - -class NonConstCopy { -public: - NonConstCopy(NonConstCopy&); // expected-note{{would lose const}} -}; - -void capture_by_copy(NonCopyable nc, NonCopyable &ncr, const NonConstCopy nco) { - (void)[nc] { }; // expected-error{{capture of variable 'nc' as type 'NonCopyable' calls private copy constructor}} - (void)[=] { // expected-error{{capture of variable 'ncr' as type 'NonCopyable' calls private copy constructor}} - ncr.foo(); - }(); - - [nco] {}(); // expected-error{{no matching constructor for initialization of 'const NonConstCopy'}} -} - -struct NonTrivial { - NonTrivial(); - NonTrivial(const NonTrivial &); - ~NonTrivial(); -}; - -struct CopyCtorDefault { - CopyCtorDefault(); - CopyCtorDefault(const CopyCtorDefault&, NonTrivial nt = NonTrivial()); - - void foo() const; -}; - -void capture_with_default_args(CopyCtorDefault cct) { - (void)[=] () -> void { cct.foo(); }; -} - -struct ExpectedArrayLayout { - CopyCtorDefault array[3]; -}; - -void capture_array() { - CopyCtorDefault array[3]; - auto x = [=]() -> void { - capture(array[0]); - }; - static_assert(sizeof(x) == sizeof(ExpectedArrayLayout), "layout mismatch"); -} - -// Check for the expected non-static data members. - -struct ExpectedLayout { - char a; - short b; -}; - -void test_layout(char a, short b) { - auto x = [=] () -> void { - capture(a); - capture(b); - }; - static_assert(sizeof(x) == sizeof(ExpectedLayout), "Layout mismatch!"); -} - -struct ExpectedThisLayout { - ExpectedThisLayout* a; - void f() { - auto x = [this]() -> void {}; - static_assert(sizeof(x) == sizeof(ExpectedThisLayout), "Layout mismatch!"); - } -}; - -struct CaptureArrayAndThis { - int value; - - void f() { - int array[3]; - [=]() -> int { - int result = value; - for (unsigned i = 0; i < 3; ++i) - result += array[i]; - return result; - }(); - } -}; - -namespace rdar14468891 { - class X { - public: - virtual ~X() = 0; // expected-note{{unimplemented pure virtual method '~X' in 'X'}} - }; - - class Y : public X { }; - - void capture(X &x) { - [x]() {}(); // expected-error{{by-copy capture of value of abstract type 'rdar14468891::X'}} - } -} - -namespace rdar15560464 { - struct X; // expected-note{{forward declaration of 'rdar15560464::X'}} - void foo(const X& param) { - auto x = ([=]() { - auto& y = param; // expected-error{{by-copy capture of variable 'param' with incomplete type 'const rdar15560464::X'}} - }); - } -} diff --git a/test/CXX/expr/expr.prim/expr.prim.lambda/p15-star-this-capture.cpp b/test/CXX/expr/expr.prim/expr.prim.lambda/p15-star-this-capture.cpp deleted file mode 100644 index bae1e25add35..000000000000 --- a/test/CXX/expr/expr.prim/expr.prim.lambda/p15-star-this-capture.cpp +++ /dev/null @@ -1,22 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -std=c++1z %s -verify
-
-class NonCopyable {
- NonCopyable(const NonCopyable&) = delete; //expected-note3{{explicitly marked deleted here}}
- int x = 10;
- void foo() {
- auto L = [this] { return x; };
- const auto &M = [*this] { return x; };//expected-error{{call to deleted}}
- const auto &M2 = [this] () -> auto&& {
- ++x;
- return [*this] { //expected-error{{call to deleted}} expected-warning{{reference to local}}
- return ++x; //expected-error{{read-only}}
- };
- };
- const auto &M3 = [*this] () mutable -> auto&& { //expected-error{{call to deleted}}
- ++x;
- return [this] { // expected-warning{{reference to local}}
- return x;
- };
- };
- }
-};
diff --git a/test/CXX/expr/expr.prim/expr.prim.lambda/p15.cpp b/test/CXX/expr/expr.prim/expr.prim.lambda/p15.cpp deleted file mode 100644 index b4b1605ab002..000000000000 --- a/test/CXX/expr/expr.prim/expr.prim.lambda/p15.cpp +++ /dev/null @@ -1,13 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -verify -// expected-no-diagnostics - -class NonCopyable { - NonCopyable(const NonCopyable&); -}; - -void capture_by_ref(NonCopyable nc, NonCopyable &ncr) { - int array[3]; - (void)[&nc] () -> void {}; - (void)[&ncr] () -> void {}; - (void)[&array] () -> void {}; -} diff --git a/test/CXX/expr/expr.prim/expr.prim.lambda/p16.cpp b/test/CXX/expr/expr.prim/expr.prim.lambda/p16.cpp deleted file mode 100644 index 905192ff830b..000000000000 --- a/test/CXX/expr/expr.prim/expr.prim.lambda/p16.cpp +++ /dev/null @@ -1,40 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 %s -Wunused -Wno-unused-lambda-capture -verify - - -struct X { - X(const X&) = delete; // expected-note 2{{explicitly marked deleted}} - X(X&); -}; - -void test_capture(X x) { - [x] { }(); // okay: non-const copy ctor - - [x] { - [x] { // expected-error{{call to deleted constructor of 'X'}} - }(); - }(); - - [x] { - [&x] { - [x] { // expected-error{{call to deleted constructor of 'const X'}} - }(); - }(); - }(); - - int a; - [=]{ - [&] { - int &x = a; // expected-error{{binding value of type 'const int' to reference to type 'int' drops 'const' qualifier}} - int &x2 = a; // expected-error{{binding value of type 'const int' to reference to type 'int' drops 'const' qualifier}} - }(); - }(); - - [=]{ - [&a] { - [&] { - int &x = a; // expected-error{{binding value of type 'const int' to reference to type 'int' drops 'const' qualifier}} - int &x2 = a; // expected-error{{binding value of type 'const int' to reference to type 'int' drops 'const' qualifier}} - }(); - }(); - }(); -} diff --git a/test/CXX/expr/expr.prim/expr.prim.lambda/p18.cpp b/test/CXX/expr/expr.prim/expr.prim.lambda/p18.cpp deleted file mode 100644 index 72cf93be5190..000000000000 --- a/test/CXX/expr/expr.prim/expr.prim.lambda/p18.cpp +++ /dev/null @@ -1,46 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 %s -Wunused -Wno-unused-lambda-capture -verify -// expected-no-diagnostics - -template<typename T, typename U> -struct is_same { - static const bool value = false; -}; - -template<typename T> -struct is_same<T, T> { - static const bool value = true; -}; - -void f3() { - float x, &r = x; - int i; - int &ir = i; - const int &irc = i; - - [=,&irc,&ir] { - static_assert(is_same<decltype(((r))), float const&>::value, - "should be const float&"); - static_assert(is_same<decltype(x), float>::value, "should be float"); - static_assert(is_same<decltype((x)), const float&>::value, - "should be const float&"); - static_assert(is_same<decltype(r), float&>::value, "should be float&"); - static_assert(is_same<decltype(ir), int&>::value, "should be int&"); - static_assert(is_same<decltype((ir)), int&>::value, "should be int&"); - static_assert(is_same<decltype(irc), const int&>::value, - "should be const int&"); - static_assert(is_same<decltype((irc)), const int&>::value, - "should be const int&"); - }(); - - [=] { - [=] () mutable { - static_assert(is_same<decltype(x), float>::value, "should be float"); - static_assert(is_same<decltype((x)), float&>::value, - "should be float&"); - }(); - }(); - - [&i] { - static_assert(is_same<decltype((i)), int&>::value, "should be int&"); - }(); -} diff --git a/test/CXX/expr/expr.prim/expr.prim.lambda/p19.cpp b/test/CXX/expr/expr.prim/expr.prim.lambda/p19.cpp deleted file mode 100644 index a8b40249f0f0..000000000000 --- a/test/CXX/expr/expr.prim/expr.prim.lambda/p19.cpp +++ /dev/null @@ -1,28 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 %s -Wunused -Wno-unused-lambda-capture -verify - -struct MoveOnly { - MoveOnly(MoveOnly&&); - MoveOnly(const MoveOnly&); -}; - -template<typename T> T &&move(T&); -void test_special_member_functions(MoveOnly mo, int i) { - auto lambda1 = [i]() { }; // expected-note 2{{lambda expression begins here}} expected-note 2{{candidate}} - - // Default constructor - decltype(lambda1) lambda2; // expected-error{{no matching constructor}} - - // Copy assignment operator - lambda1 = lambda1; // expected-error{{copy assignment operator is implicitly deleted}} - - // Move assignment operator - lambda1 = move(lambda1); // expected-error{{copy assignment operator is implicitly deleted}} - - // Copy constructor - decltype(lambda1) lambda3 = lambda1; - decltype(lambda1) lambda4(lambda1); - - // Move constructor - decltype(lambda1) lambda5 = move(lambda1); - decltype(lambda1) lambda6(move(lambda1)); -} diff --git a/test/CXX/expr/expr.prim/expr.prim.lambda/p2-generic-lambda-1y.cpp b/test/CXX/expr/expr.prim/expr.prim.lambda/p2-generic-lambda-1y.cpp deleted file mode 100644 index d791ed60cfca..000000000000 --- a/test/CXX/expr/expr.prim/expr.prim.lambda/p2-generic-lambda-1y.cpp +++ /dev/null @@ -1,25 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++1y -DCXX1Y - -// prvalue -void prvalue() { - auto&& x = [](auto a)->void { }; - auto& y = [](auto *a)->void { }; // expected-error{{cannot bind to a temporary of type}} -} - -namespace std { - class type_info; -} - -struct P { - virtual ~P(); -}; - -void unevaluated_operand(P &p, int i) { //expected-note{{declared here}} - // FIXME: this should only emit one error. - int i2 = sizeof([](auto a, auto b)->void{}(3, '4')); // expected-error{{lambda expression in an unevaluated operand}} \ - // expected-error{{invalid application of 'sizeof'}} - const std::type_info &ti1 = typeid([](auto &a) -> P& { static P p; return p; }(i)); // expected-warning {{expression with side effects will be evaluated despite being used as an operand to 'typeid'}} - const std::type_info &ti2 = typeid([](auto) -> int { return i; }(i)); // expected-error{{lambda expression in an unevaluated operand}}\ - // expected-error{{cannot be implicitly captured}}\ - // expected-note{{begins here}} -} diff --git a/test/CXX/expr/expr.prim/expr.prim.lambda/p2-template-parameter.cpp b/test/CXX/expr/expr.prim/expr.prim.lambda/p2-template-parameter.cpp deleted file mode 100644 index f120a63badcb..000000000000 --- a/test/CXX/expr/expr.prim/expr.prim.lambda/p2-template-parameter.cpp +++ /dev/null @@ -1,7 +0,0 @@ -// RUN: %clang_cc1 -std=c++17 %s -verify - -template<auto> struct Nothing {}; - -void pr33696() { - Nothing<[]() { return 0; }()> nothing; // expected-error{{a lambda expression cannot appear in this context}} -} diff --git a/test/CXX/expr/expr.prim/expr.prim.lambda/p2.cpp b/test/CXX/expr/expr.prim/expr.prim.lambda/p2.cpp deleted file mode 100644 index 872248e77e6a..000000000000 --- a/test/CXX/expr/expr.prim/expr.prim.lambda/p2.cpp +++ /dev/null @@ -1,43 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -std=c++11 -Wno-unused-value %s -verify - -// prvalue -void prvalue() { - auto&& x = []()->void { }; - auto& y = []()->void { }; // expected-error{{cannot bind to a temporary of type}} -} - -namespace std { - class type_info; -} - -struct P { - virtual ~P(); -}; - -void unevaluated_operand(P &p, int i) { - int i2 = sizeof([] ()->int { return 0; }()); // expected-error{{lambda expression in an unevaluated operand}} - const std::type_info &ti1 = typeid([&]() -> P& { return p; }()); - const std::type_info &ti2 = typeid([&]() -> int { return i; }()); // expected-error{{lambda expression in an unevaluated operand}} -} - -template<typename T> -struct Boom { - Boom(const Boom&) { - T* x = 1; // expected-error{{cannot initialize a variable of type 'int *' with an rvalue of type 'int'}} \ - // expected-error{{cannot initialize a variable of type 'double *' with an rvalue of type 'int'}} - } - void tickle() const; -}; - -void odr_used(P &p, Boom<int> boom_int, Boom<float> boom_float, - Boom<double> boom_double) { - const std::type_info &ti1 - = typeid([=,&p]() -> P& { boom_int.tickle(); return p; }()); // expected-note{{in instantiation of member function 'Boom<int>::Boom' requested here}} - // This does not cause the instantiation of the Boom copy constructor, - // because the copy-initialization of the capture of boom_float occurs in an - // unevaluated operand. - const std::type_info &ti2 - = typeid([=]() -> int { boom_float.tickle(); return 0; }()); // expected-error{{lambda expression in an unevaluated operand}} - - auto foo = [=]() -> int { boom_double.tickle(); return 0; }; // expected-note{{in instantiation of member function 'Boom<double>::Boom' requested here}} -} diff --git a/test/CXX/expr/expr.prim/expr.prim.lambda/p20.cpp b/test/CXX/expr/expr.prim/expr.prim.lambda/p20.cpp deleted file mode 100644 index 17eb841fc3fc..000000000000 --- a/test/CXX/expr/expr.prim/expr.prim.lambda/p20.cpp +++ /dev/null @@ -1,13 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 %s -Wunused -verify -// expected-no-diagnostics - -template<typename T> -void destroy(T* ptr) { - ptr->~T(); - (*ptr).~T(); -} - -void destructor() { - auto lambda = []{}; - destroy(&lambda); -} diff --git a/test/CXX/expr/expr.prim/expr.prim.lambda/p21.cpp b/test/CXX/expr/expr.prim/expr.prim.lambda/p21.cpp deleted file mode 100644 index bc2c9997379a..000000000000 --- a/test/CXX/expr/expr.prim/expr.prim.lambda/p21.cpp +++ /dev/null @@ -1,10 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -verify -// expected-no-diagnostics - -struct DirectInitOnly { - explicit DirectInitOnly(DirectInitOnly&); -}; - -void direct_init_capture(DirectInitOnly &dio) { - [dio] {}(); -} diff --git a/test/CXX/expr/expr.prim/expr.prim.lambda/p23.cpp b/test/CXX/expr/expr.prim/expr.prim.lambda/p23.cpp deleted file mode 100644 index 4ae34dec3e34..000000000000 --- a/test/CXX/expr/expr.prim/expr.prim.lambda/p23.cpp +++ /dev/null @@ -1,81 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -verify -Wno-c++1y-extensions -// RUN: %clang_cc1 -fsyntax-only -std=c++1y %s -verify - -void print(); - -template<typename T, typename... Ts> -void print(T first, Ts... rest) { - (void)first; - print(rest...); -} - -template<typename... Ts> -void unexpanded_capture(Ts ...values) { - auto unexp = [values] {}; // expected-error{{initializer contains unexpanded parameter pack 'values'}} -} - -template<typename... Ts> -void implicit_capture(Ts ...values) { - auto implicit = [&] { print(values...); }; - implicit(); -} - -template<typename... Ts> -void do_print(Ts... values) { - auto bycopy = [values...]() { print(values...); }; - bycopy(); - auto byref = [&values...]() { print(values...); }; - byref(); - - auto bycopy2 = [=]() { print(values...); }; - bycopy2(); - auto byref2 = [&]() { print(values...); }; - byref2(); -} - -template void do_print(int, float, double); - -template<typename T, int... Values> -void bogus_expansions(T x) { - auto l1 = [x...] {}; // expected-error{{pack expansion does not contain any unexpanded parameter packs}} - auto l2 = [Values...] {}; // expected-error{{'Values' in capture list does not name a variable}} -} - -void g(int*, float*, double*); - -template<class... Args> -void std_example(Args... args) { - auto lm = [&, args...] { return g(args...); }; -}; - -template void std_example(int*, float*, double*); - -template<typename ...Args> -void variadic_lambda(Args... args) { - auto lambda = [](Args... inner_args) { return g(inner_args...); }; - lambda(args...); -} - -template void variadic_lambda(int*, float*, double*); - -template<typename ...Args> -void init_capture_pack_err(Args ...args) { - [as(args)...] {} (); // expected-error {{expected ','}} - [as...(args)]{} (); // expected-error {{expected ','}} -} - -template<typename ...Args> -void init_capture_pack_multi(Args ...args) { - [as(args...)] {} (); // expected-error {{initializer missing for lambda capture 'as'}} expected-error {{multiple}} -} -template void init_capture_pack_multi(); // expected-note {{instantiation}} -template void init_capture_pack_multi(int); -template void init_capture_pack_multi(int, int); // expected-note {{instantiation}} - -template<typename ...Args> -void init_capture_pack_outer(Args ...args) { - print([as(args)] { return sizeof(as); } () ...); -} -template void init_capture_pack_outer(); -template void init_capture_pack_outer(int); -template void init_capture_pack_outer(int, int); diff --git a/test/CXX/expr/expr.prim/expr.prim.lambda/p3.cpp b/test/CXX/expr/expr.prim/expr.prim.lambda/p3.cpp deleted file mode 100644 index db40bd5d1420..000000000000 --- a/test/CXX/expr/expr.prim/expr.prim.lambda/p3.cpp +++ /dev/null @@ -1,19 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -verify -// RUN: %clang_cc1 -fsyntax-only -std=c++14 %s -verify -// RUN: %clang_cc1 -fsyntax-only -std=c++17 %s -verify - -void test_nonaggregate(int i) { - auto lambda = [i]() -> void {}; // expected-note 2{{candidate constructor}} - decltype(lambda) foo = { 1 }; // expected-error{{no matching constructor}} - static_assert(__is_literal(decltype(lambda)) == (__cplusplus >= 201703L), ""); - - auto lambda2 = []{}; // expected-note 2{{candidate constructor}} - decltype(lambda2) bar = {}; // expected-error{{no matching constructor}} - static_assert(__is_literal(decltype(lambda2)) == (__cplusplus >= 201703L), ""); -} - -constexpr auto literal = []{}; -#if __cplusplus < 201703L -// expected-error@-2 {{constexpr variable cannot have non-literal type}} -// expected-note@-3 {{lambda closure types are non-literal types before C++17}} -#endif diff --git a/test/CXX/expr/expr.prim/expr.prim.lambda/p4-1y.cpp b/test/CXX/expr/expr.prim/expr.prim.lambda/p4-1y.cpp deleted file mode 100644 index f8461335b768..000000000000 --- a/test/CXX/expr/expr.prim/expr.prim.lambda/p4-1y.cpp +++ /dev/null @@ -1,66 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -std=c++1y %s -verify - -int a; -int &b = [] (int &r) -> decltype(auto) { return r; } (a); -int &c = [] (int &r) -> decltype(auto) { return (r); } (a); -int &d = [] (int &r) -> auto & { return r; } (a); -int &e = [] (int &r) -> auto { return r; } (a); // expected-error {{cannot bind to a temporary}} -int &f = [] (int r) -> decltype(auto) { return r; } (a); // expected-error {{cannot bind to a temporary}} -int &g = [] (int r) -> decltype(auto) { return (r); } (a); // expected-warning {{reference to stack}} - - -int test_explicit_auto_return() -{ - struct X {}; - auto L = [](auto F, auto a) { return F(a); }; - auto M = [](auto a) -> auto { return a; }; // OK - auto MRef = [](auto b) -> auto& { return b; }; //expected-warning{{reference to stack}} - auto MPtr = [](auto c) -> auto* { return &c; }; //expected-warning{{address of stack}} - auto MDeclType = [](auto&& d) -> decltype(auto) { return static_cast<decltype(d)>(d); }; //OK - M(3); - - auto &&x = MDeclType(X{}); - auto &&x1 = M(X{}); - auto &&x2 = MRef(X{});//expected-note{{in instantiation of}} - auto &&x3 = MPtr(X{}); //expected-note{{in instantiation of}} - return 0; -} - -int test_implicit_auto_return() -{ - { - auto M = [](auto a) { return a; }; - struct X {}; - X x = M(X{}); - - } -} - -int test_multiple_returns() { - auto M = [](auto a) { - bool k; - if (k) - return a; - else - return 5; //expected-error{{deduced as 'int' here}} - }; - M(3); // OK - M('a'); //expected-note{{in instantiation of}} - return 0; -} -int test_no_parameter_list() -{ - static int si = 0; - auto M = [] { return 5; }; // OK - auto M2 = [] -> auto&& { return si; }; // expected-error{{lambda requires '()'}} - M(); -} - -int test_conditional_in_return() { - auto Fac = [](auto f, auto n) { - return n <= 0 ? n : f(f, n - 1) * n; - }; - // FIXME: this test causes a recursive limit - need to error more gracefully. - //Fac(Fac, 3); - -}
\ No newline at end of file diff --git a/test/CXX/expr/expr.prim/expr.prim.lambda/p4.cpp b/test/CXX/expr/expr.prim/expr.prim.lambda/p4.cpp deleted file mode 100644 index a36175af6fec..000000000000 --- a/test/CXX/expr/expr.prim/expr.prim.lambda/p4.cpp +++ /dev/null @@ -1,52 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -verify -// RUN: %clang_cc1 -fsyntax-only -std=c++1y %s -verify -DCPP1Y - -void missing_lambda_declarator() { - [](){}(); -} - -template<typename T> T get(); - -void infer_void_return_type(int i) { - if (i > 17) - return []() { }(); - - if (i > 11) - return []() { return; }(); - - return [](int x) { - switch (x) { - case 0: return get<void>(); - case 1: return; - case 2: return { 1, 2.0 }; //expected-error{{cannot deduce}} - } - }(7); -} - -struct X { }; - -X infer_X_return_type(X x) { - return [&x](int y) { - if (y > 0) - return X(); - else - return x; - }(5); -} - -X infer_X_return_type_2(X x) { - return [x](int y) { - if (y > 0) - return X(); - else - return x; // ok even in c++11, per dr1048. - }(5); -} - -struct Incomplete; // expected-note{{forward declaration of 'Incomplete'}} -void test_result_type(int N) { - auto l1 = [] () -> Incomplete { }; // expected-error{{incomplete result type 'Incomplete' in lambda expression}} - - typedef int vla[N]; - auto l2 = [] () -> vla { }; // expected-error{{function cannot return array type 'vla' (aka 'int [N]')}} -} diff --git a/test/CXX/expr/expr.prim/expr.prim.lambda/p4.mm b/test/CXX/expr/expr.prim/expr.prim.lambda/p4.mm deleted file mode 100644 index 92c62904d57b..000000000000 --- a/test/CXX/expr/expr.prim/expr.prim.lambda/p4.mm +++ /dev/null @@ -1,8 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -verify - -@interface A -@end - -void test_result_type() { - auto l1 = [] () -> A { }; // expected-error{{interface type 'A' cannot be returned by value; did you forget * in 'A'?}} -} diff --git a/test/CXX/expr/expr.prim/expr.prim.lambda/p5-generic-lambda-1y.cpp b/test/CXX/expr/expr.prim/expr.prim.lambda/p5-generic-lambda-1y.cpp deleted file mode 100644 index 415c3d84560e..000000000000 --- a/test/CXX/expr/expr.prim/expr.prim.lambda/p5-generic-lambda-1y.cpp +++ /dev/null @@ -1,131 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++1y -DCXX1Y - -namespace test_factorial { - -auto Fact = [](auto Self, unsigned n) -> unsigned { - return !n ? 1 : Self(Self, n - 1) * n; -}; - -auto six = Fact(Fact, 3); - -} - -namespace overload_generic_lambda { - template <class F1, class F2> struct overload : F1, F2 { - using F1::operator(); - using F2::operator(); - overload(F1 f1, F2 f2) : F1(f1), F2(f2) { } - }; - - auto NumParams = [](auto Self, auto h, auto ... rest) -> unsigned { - return 1 + Self(Self, rest...); - }; - auto Base = [](auto Self, auto h) -> unsigned { - return 1; - }; - overload<decltype(Base), decltype(NumParams)> O(Base, NumParams); - int num_params = O(O, 5, 3, "abc", 3.14, 'a'); -} - - -namespace overload_generic_lambda_return_type_deduction { - template <class F1, class F2> struct overload : F1, F2 { - using F1::operator(); - using F2::operator(); - overload(F1 f1, F2 f2) : F1(f1), F2(f2) { } - }; - - auto NumParams = [](auto Self, auto h, auto ... rest) { - return 1 + Self(Self, rest...); - }; - auto Base = [](auto Self, auto h) { - return 1; - }; - overload<decltype(Base), decltype(NumParams)> O(Base, NumParams); - int num_params = O(O, 5, 3, "abc", 3.14, 'a'); -} - -namespace test_standard_p5 { -// FIXME: This test should eventually compile without an explicit trailing return type -auto glambda = [](auto a, auto&& b) ->bool { return a < b; }; -bool b = glambda(3, 3.14); // OK - -} -namespace test_deduction_failure { - int test() { - auto g = [](auto *a) { //expected-note{{candidate template ignored}} - return a; - }; - struct X { }; - X *x; - g(x); - g(3); //expected-error{{no matching function}} - return 0; - } - -} - -namespace test_instantiation_or_sfinae_failure { -int test2() { - { - auto L = [](auto *a) { - return (*a)(a); }; //expected-error{{called object type 'double' is not a function}} - double d; - L(&d); //expected-note{{in instantiation of}} - auto M = [](auto b) { return b; }; - L(&M); // ok - } - { - auto L = [](auto *a) ->decltype (a->foo()) { //expected-note2{{candidate template ignored:}} - return (*a)(a); }; - double d; - L(&d); //expected-error{{no matching function for call}} - auto M = [](auto b) { return b; }; - L(&M); //expected-error{{no matching function for call}} - - } - return 0; -} - - -} - -namespace test_misc { -auto GL = [](auto a, decltype(a) b) //expected-note{{candidate function}} - -> int { return a + b; }; - -void test() { - struct X { }; - GL(3, X{}); //expected-error{{no matching function}} -} - -void test2() { - auto l = [](auto *a) -> int { - (*a)(a); return 0; }; //expected-error{{called object type 'double' is not a function}} - l(&l); - double d; - l(&d); //expected-note{{in instantiation of}} -} - -} - -namespace nested_lambdas { - int test() { - auto L = [](auto a) { - return [=](auto b) { - return a + b; - }; - }; - } - auto get_lambda() { - return [](auto a) { - return a; - }; - }; - - int test2() { - auto L = get_lambda(); - L(3); - } -} - diff --git a/test/CXX/expr/expr.prim/expr.prim.lambda/p5.cpp b/test/CXX/expr/expr.prim/expr.prim.lambda/p5.cpp deleted file mode 100644 index b8504d490650..000000000000 --- a/test/CXX/expr/expr.prim/expr.prim.lambda/p5.cpp +++ /dev/null @@ -1,63 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 %s -Winvalid-noreturn -verify - -// An attribute-specifier-seq in a lambda-declarator appertains to the -// type of the corresponding function call operator. -void test_attributes() { - auto nrl = [](int x) -> int { if (x > 0) return x; }; // expected-warning{{control may reach end of non-void lambda}} - - // FIXME: GCC accepts the [[gnu::noreturn]] attribute here. - auto nrl2 = []() [[gnu::noreturn]] { return; }; // expected-warning{{attribute 'noreturn' ignored}} -} - -template<typename T> -struct bogus_override_if_virtual : public T { - bogus_override_if_virtual() : T(*(T*)0) { } // expected-warning {{binding dereferenced null pointer to reference has undefined behavior}} - int operator()() const; -}; - -void test_quals() { - // This function call operator is declared const (9.3.1) if and only - // if the lambda- expression's parameter-declaration-clause is not - // followed by mutable. - auto l = [=](){}; // expected-note{{method is not marked volatile}} - const decltype(l) lc = l; - l(); - lc(); - - auto ml = [=]() mutable{}; // expected-note{{method is not marked const}} \ - // expected-note{{method is not marked volatile}} - const decltype(ml) mlc = ml; - ml(); - mlc(); // expected-error{{no matching function for call to object of type}} - - // It is neither virtual nor declared volatile. - volatile decltype(l) lv = l; - volatile decltype(ml) mlv = ml; - lv(); // expected-error{{no matching function for call to object of type}} - mlv(); // expected-error{{no matching function for call to object of type}} - - bogus_override_if_virtual<decltype(l)> bogus; // expected-note{{in instantiation of member function 'bogus_override_if_virtual<(lambda}} -} - -// Core issue 974: default arguments (8.3.6) may be specified in the -// parameter-declaration-clause of a lambda-declarator. -int test_default_args() { - return [](int i = 5, int j = 17) { return i+j;}(5, 6); -} - -// Any exception-specification specified on a lambda-expression -// applies to the corresponding function call operator. -void test_exception_spec() { - auto tl1 = []() throw(int) {}; - auto tl2 = []() {}; - static_assert(!noexcept(tl1()), "lambda can throw"); - static_assert(!noexcept(tl2()), "lambda can throw"); - - auto ntl1 = []() throw() {}; - auto ntl2 = []() noexcept(true) {}; - auto ntl3 = []() noexcept {}; - static_assert(noexcept(ntl1()), "lambda cannot throw"); - static_assert(noexcept(ntl2()), "lambda cannot throw"); - static_assert(noexcept(ntl3()), "lambda cannot throw"); -} - diff --git a/test/CXX/expr/expr.prim/expr.prim.lambda/p6.cpp b/test/CXX/expr/expr.prim/expr.prim.lambda/p6.cpp deleted file mode 100644 index 90a3aec50cb3..000000000000 --- a/test/CXX/expr/expr.prim/expr.prim.lambda/p6.cpp +++ /dev/null @@ -1,32 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -verify -// RUN: %clang_cc1 -fsyntax-only -std=c++1z %s -verify - -void test_conversion() { - int (*fp1)(int) = [](int x) { return x + 1; }; - void (*fp2)(int) = [](int x) { }; - - const auto lambda = [](int x) { }; - void (*fp3)(int) = lambda; - - volatile const auto lambda2 = [](int x) { }; // expected-note{{but method is not marked volatile}} - void (*fp4)(int) = lambda2; // expected-error{{no viable conversion}} - - void (*fp5)(int) noexcept = [](int x) { }; -#if __cplusplus > 201402L - // expected-error@-2 {{no viable}} expected-note@-2 {{candidate}} - void (*fp5a)(int) noexcept = [](auto x) { }; - // expected-error@-1 {{no viable}} expected-note@-1 {{candidate}} - void (*fp5b)(int) noexcept = [](auto x) noexcept { }; -#endif - void (*fp6)(int) noexcept = [](int x) noexcept { }; -} - -void test_no_conversion() { - int (*fp1)(int) = [=](int x) { return x + 1; }; // expected-error{{no viable conversion}} - void (*fp2)(int) = [&](int x) { }; // expected-error{{no viable conversion}} -} - -void test_wonky() { - const auto l = [](int x) mutable -> int { return + 1; }; - l(17); // okay: uses conversion function -} diff --git a/test/CXX/expr/expr.prim/expr.prim.lambda/p7.cpp b/test/CXX/expr/expr.prim/expr.prim.lambda/p7.cpp deleted file mode 100644 index 9dbe2e189f4a..000000000000 --- a/test/CXX/expr/expr.prim/expr.prim.lambda/p7.cpp +++ /dev/null @@ -1,56 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -verify - -// Check that analysis-based warnings work in lambda bodies. -void analysis_based_warnings() { - (void)[]() -> int { }; // expected-warning{{control reaches end of non-void lambda}} -} - -// Check that we get the right types of captured variables (the -// semantic-analysis part of p7). -int &check_const_int(int&); -float &check_const_int(const int&); - -void test_capture_constness(int i, const int ic) { - (void)[i,ic] ()->void { - float &fr1 = check_const_int(i); - float &fr2 = check_const_int(ic); - }; - - (void)[=] ()->void { - float &fr1 = check_const_int(i); - float &fr2 = check_const_int(ic); - }; - - (void)[i,ic] () mutable ->void { - int &ir = check_const_int(i); - float &fr = check_const_int(ic); - }; - - (void)[=] () mutable ->void { - int &ir = check_const_int(i); - float &fr = check_const_int(ic); - }; - - (void)[&i,&ic] ()->void { - int &ir = check_const_int(i); - float &fr = check_const_int(ic); - }; - - (void)[&] ()->void { - int &ir = check_const_int(i); - float &fr = check_const_int(ic); - }; -} - - -struct S1 { - int x, y; - S1 &operator=(int*); - int operator()(int); - void f() { - [&]()->int { - S1 &s1 = operator=(&this->x); - return operator()(this->x + y); - }(); - } -}; diff --git a/test/CXX/expr/expr.prim/expr.prim.lambda/p8.cpp b/test/CXX/expr/expr.prim/expr.prim.lambda/p8.cpp deleted file mode 100644 index 1cc1fd974ca5..000000000000 --- a/test/CXX/expr/expr.prim/expr.prim.lambda/p8.cpp +++ /dev/null @@ -1,32 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 %s -verify -Wno-c++1y-extensions - -class X0 { - void explicit_capture() { - int foo; - - (void)[foo, foo] () {}; // expected-error {{'foo' can appear only once}} - (void)[this, this] () {}; // expected-error {{'this' can appear only once}} - (void)[=, foo] () {}; // expected-error {{'&' must precede a capture when}} - (void)[=, &foo] () {}; - (void)[=, this] () {}; // expected-warning {{C++2a extension}} - (void)[&, foo] () {}; - (void)[&, &foo] () {}; // expected-error {{'&' cannot precede a capture when}} - (void)[&, this] () {}; - } -}; - -struct S2 { - void f(int i); - void g(int i); -}; - -void S2::f(int i) { - (void)[&, i]{ }; - (void)[&, &i]{ }; // expected-error{{'&' cannot precede a capture when the capture default is '&'}} - (void)[=, this]{ }; // expected-warning{{C++2a extension}} - (void)[=]{ this->g(i); }; - (void)[i, i]{ }; // expected-error{{'i' can appear only once in a capture list}} - (void)[i(0), i(1)]{ }; // expected-error{{'i' can appear only once in a capture list}} - (void)[i, i(1)]{ }; // expected-error{{'i' can appear only once in a capture list}} - (void)[i(0), i]{ }; // expected-error{{'i' can appear only once in a capture list}} -} diff --git a/test/CXX/expr/expr.prim/expr.prim.lambda/templates.cpp b/test/CXX/expr/expr.prim/expr.prim.lambda/templates.cpp deleted file mode 100644 index 2bb75df7ac6a..000000000000 --- a/test/CXX/expr/expr.prim/expr.prim.lambda/templates.cpp +++ /dev/null @@ -1,149 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -std=c++11 -Winvalid-noreturn %s -verify - -template<typename T> -void test_attributes() { - // FIXME: GCC accepts [[gnu::noreturn]] here. - auto nrl = []() [[gnu::noreturn]] {}; // expected-warning{{attribute 'noreturn' ignored}} -} - -template void test_attributes<int>(); - -template<typename T> -void call_with_zero() { - [](T *ptr) -> T& { return *ptr; }(0); -} - -template void call_with_zero<int>(); - -template<typename T> -T captures(T x, T y) { - auto lambda = [=, &y] () -> T { - T i = x; - return i + y; - }; - - return lambda(); -} - -struct X { - X(const X&); -}; - -X operator+(X, X); -X operator-(X, X); - -template int captures(int, int); -template X captures(X, X); - -template<typename T> -int infer_result(T x, T y) { - auto lambda = [=](bool b) { return x + y; }; - return lambda(true); // expected-error{{no viable conversion from returned value of type 'X' to function return type 'int'}} -} - -template int infer_result(int, int); -template int infer_result(X, X); // expected-note{{in instantiation of function template specialization 'infer_result<X>' requested here}} - -// Make sure that lambda's operator() can be used from templates. -template<typename F> -void accept_lambda(F f) { - f(1); -} - -template<typename T> -void pass_lambda(T x) { - accept_lambda([&x](T y) { return x + y; }); -} - -template void pass_lambda(int); - -namespace std { - class type_info; -} - -namespace p2 { - struct P { - virtual ~P(); - }; - - template<typename T> - struct Boom { - Boom(const Boom&) { - T* x = 1; // expected-error{{cannot initialize a variable of type 'float *' with an rvalue of type 'int'}} - } - void tickle() const; - }; - - template<typename R, typename T> - void odr_used(R &r, Boom<T> boom) { - const std::type_info &ti - = typeid([=,&r] () -> R& { // expected-error{{lambda expression in an unevaluated operand}} - boom.tickle(); - return r; - }()); - } - - template void odr_used(int&, Boom<int>); // expected-note{{in instantiation of function template specialization}} - - template<typename R, typename T> - void odr_used2(R &r, Boom<T> boom) { - const std::type_info &ti - = typeid([=,&r] () -> R& { // expected-note{{in instantiation of member function 'p2::Boom<float>::Boom' requested here}} - boom.tickle(); - return r; - }()); - } - - template void odr_used2(P&, Boom<float>); -} - -namespace p5 { - struct NonConstCopy { - NonConstCopy(const NonConstCopy&) = delete; - NonConstCopy(NonConstCopy&); - }; - - template<typename T> - void double_capture(T &nc) { - [=] () mutable { - [=] () mutable { - T nc2(nc); - }(); - }(); - } - - template void double_capture(NonConstCopy&); -} - -namespace NonLocalLambdaInstantation { - template<typename T> - struct X { - static int value; - }; - - template<typename T> - int X<T>::value = []{ return T(); }(); // expected-error{{cannot initialize a variable of type 'int' with an rvalue of type 'int *'}} - - template int X<int>::value; - template int X<float>::value; - template int X<int*>::value; // expected-note{{in instantiation of static data member }} - - template<typename T> - void defaults(int x = []{ return T(); }()) { }; // expected-error{{cannot initialize a parameter of type 'int' with an rvalue of type 'int *'}} \ - // expected-note{{passing argument to parameter 'x' here}} - - void call_defaults() { - defaults<int>(); - defaults<float>(); - defaults<int*>(); // expected-note{{in instantiation of default function argument expression for 'defaults<int *>' required here}} - } - - template<typename T> - struct X2 { // expected-note{{in instantiation of default member initializer 'NonLocalLambdaInstantation::X2<int *>::x'}} - int x = []{ return T(); }(); // expected-error{{cannot initialize a member subobject of type 'int' with an rvalue of type 'int *'}} - }; - - X2<int> x2i; - X2<float> x2f; - X2<int*> x2ip; // expected-note {{in evaluation of exception spec}} -} diff --git a/test/CXX/expr/expr.unary/expr.delete/p10.cpp b/test/CXX/expr/expr.unary/expr.delete/p10.cpp deleted file mode 100644 index aad2747dd32f..000000000000 --- a/test/CXX/expr/expr.unary/expr.delete/p10.cpp +++ /dev/null @@ -1,25 +0,0 @@ -// RUN: %clang_cc1 -std=c++1z -verify %s - -using size_t = decltype(sizeof(0)); -namespace std { enum class align_val_t : size_t {}; } - -// Aligned version is preferred over unaligned version, -// unsized version is preferred over sized version. -template<unsigned Align> -struct alignas(Align) A { - void operator delete(void*); - void operator delete(void*, std::align_val_t) = delete; // expected-note {{here}} - - void operator delete(void*, size_t) = delete; - void operator delete(void*, size_t, std::align_val_t) = delete; -}; -void f(A<__STDCPP_DEFAULT_NEW_ALIGNMENT__> *p) { delete p; } -void f(A<__STDCPP_DEFAULT_NEW_ALIGNMENT__ * 2> *p) { delete p; } // expected-error {{deleted}} - -template<unsigned Align> -struct alignas(Align) B { - void operator delete(void*, size_t); - void operator delete(void*, size_t, std::align_val_t) = delete; // expected-note {{here}} -}; -void f(B<__STDCPP_DEFAULT_NEW_ALIGNMENT__> *p) { delete p; } -void f(B<__STDCPP_DEFAULT_NEW_ALIGNMENT__ * 2> *p) { delete p; } // expected-error {{deleted}} diff --git a/test/CXX/expr/expr.unary/expr.delete/p5.cpp b/test/CXX/expr/expr.unary/expr.delete/p5.cpp deleted file mode 100644 index ecb29189af60..000000000000 --- a/test/CXX/expr/expr.unary/expr.delete/p5.cpp +++ /dev/null @@ -1,46 +0,0 @@ -// RUN: %clang_cc1 -verify %s - -// If the object being deleted has incomplete class type at the point of -// deletion and the complete class has a non-trivial destructor or a -// deallocation function, the behavior is undefined. - -// The trivial case. -class T0; // expected-note {{forward declaration}} -void f0(T0 *a) { delete a; } // expected-warning {{deleting pointer to incomplete type}} -class T0 { ~T0(); }; - -// The trivial case, inside a template instantiation. -template<typename T> -struct T1_A { T *x; ~T1_A() { delete x; } }; // expected-warning {{deleting pointer to incomplete type}} -class T1_B; // expected-note {{forward declaration}} -void f0() { T1_A<T1_B> x; } // expected-note {{in instantiation of member function}} - -// This case depends on when we check T2_C::f0. -class T2_A; -template<typename T> -struct T2_B { void f0(T *a) { delete a; } }; -struct T2_C { T2_B<T2_A> x; void f0(T2_A *a) { x.f0(a); } }; -void f0(T2_A *a) { T2_C x; x.f0(a); } -class T2_A { }; - -// An alternate version of the same. -class T3_A; -template<typename T> -struct T3_B { - void f0(T *a) { - delete a; // expected-error{{calling a private destructor of class 'T3_A'}} - } -}; - -struct T3_C { - T3_B<T3_A> x; - void f0(T3_A *a) { - x.f0(a); // expected-note{{in instantiation of member function 'T3_B<T3_A>::f0' requested here}} - } -}; - -void f0(T3_A *a) { T3_C x; x.f0(a); } -class T3_A { -private: - ~T3_A(); // expected-note{{declared private here}} -}; diff --git a/test/CXX/expr/expr.unary/expr.new/p14.cpp b/test/CXX/expr/expr.unary/expr.new/p14.cpp deleted file mode 100644 index 6537cdcfeafa..000000000000 --- a/test/CXX/expr/expr.unary/expr.new/p14.cpp +++ /dev/null @@ -1,69 +0,0 @@ -// RUN: %clang_cc1 -std=c++1z -fsized-deallocation -fexceptions %s -verify - -using size_t = decltype(sizeof(0)); -namespace std { enum class align_val_t : size_t {}; } - -struct Arg {} arg; - -// If the type is aligned, first try with an alignment argument and then -// without. If not, never consider supplying an alignment. - -template<unsigned Align, typename ...Ts> -struct alignas(Align) Unaligned { - void *operator new(size_t, Ts...) = delete; // expected-note 4{{deleted}} -}; -auto *ua = new Unaligned<__STDCPP_DEFAULT_NEW_ALIGNMENT__>; // expected-error {{deleted}} -auto *ub = new Unaligned<__STDCPP_DEFAULT_NEW_ALIGNMENT__ * 2>; // expected-error {{deleted}} -auto *uap = new (arg) Unaligned<__STDCPP_DEFAULT_NEW_ALIGNMENT__, Arg>; // expected-error {{deleted}} -auto *ubp = new (arg) Unaligned<__STDCPP_DEFAULT_NEW_ALIGNMENT__ * 2, Arg>; // expected-error {{deleted}} - -template<unsigned Align, typename ...Ts> -struct alignas(Align) Aligned { - void *operator new(size_t, std::align_val_t, Ts...) = delete; // expected-note 2{{deleted}} expected-note 2{{not viable}} -}; -auto *aa = new Aligned<__STDCPP_DEFAULT_NEW_ALIGNMENT__>; // expected-error {{no matching}} -auto *ab = new Aligned<__STDCPP_DEFAULT_NEW_ALIGNMENT__ * 2>; // expected-error {{deleted}} -auto *aap = new (arg) Aligned<__STDCPP_DEFAULT_NEW_ALIGNMENT__, Arg>; // expected-error {{no matching}} -auto *abp = new (arg) Aligned<__STDCPP_DEFAULT_NEW_ALIGNMENT__ * 2, Arg>; // expected-error {{deleted}} - -// If both are available, we prefer the aligned version for an overaligned -// type, and only use the unaligned version for a non-overaligned type. - -template<unsigned Align, typename ...Ts> -struct alignas(Align) Both1 { - void *operator new(size_t, Ts...); // expected-note 2{{not viable}} - void *operator new(size_t, std::align_val_t, Ts...) = delete; // expected-note 2{{deleted}} -}; -template<unsigned Align, typename ...Ts> -struct alignas(Align) Both2 { - void *operator new(size_t, Ts...) = delete; // expected-note 2{{deleted}} - void *operator new(size_t, std::align_val_t, Ts...); // expected-note 2{{not viable}} -}; -auto *b1a = new Both1<__STDCPP_DEFAULT_NEW_ALIGNMENT__>; -auto *b1b = new Both1<__STDCPP_DEFAULT_NEW_ALIGNMENT__ * 2>; // expected-error {{deleted}} -auto *b2a = new Both2<__STDCPP_DEFAULT_NEW_ALIGNMENT__>; // expected-error {{deleted}} -auto *b2b = new Both2<__STDCPP_DEFAULT_NEW_ALIGNMENT__ * 2>; -auto *b1ap = new (arg) Both1<__STDCPP_DEFAULT_NEW_ALIGNMENT__, Arg>; -auto *b1bp = new (arg) Both1<__STDCPP_DEFAULT_NEW_ALIGNMENT__ * 2, Arg>; // expected-error {{deleted}} -auto *b2ap = new (arg) Both2<__STDCPP_DEFAULT_NEW_ALIGNMENT__, Arg>; // expected-error {{deleted}} -auto *b2bp = new (arg) Both2<__STDCPP_DEFAULT_NEW_ALIGNMENT__ * 2, Arg>; - -// Note that the aligned form can select a function with a parameter different -// from std::align_val_t. - -struct alignas(__STDCPP_DEFAULT_NEW_ALIGNMENT__ * 2) WeirdAlignedAlloc1 { - void *operator new(size_t, ...) = delete; // expected-note 2{{deleted}} -}; -auto *waa1 = new WeirdAlignedAlloc1; // expected-error {{deleted}} -auto *waa1p = new (arg) WeirdAlignedAlloc1; // expected-error {{deleted}} - -struct alignas(__STDCPP_DEFAULT_NEW_ALIGNMENT__ * 2) WeirdAlignedAlloc2 { - template<typename ...T> - void *operator new(size_t, T...) { - using U = void(T...); // expected-note 2{{previous}} - using U = void; // expected-error {{different types ('void' vs 'void (std::align_val_t)')}} \ - expected-error {{different types ('void' vs 'void (std::align_val_t, Arg)')}} - } -}; -auto *waa2 = new WeirdAlignedAlloc2; // expected-note {{instantiation of}} -auto *waa2p = new (arg) WeirdAlignedAlloc2; // expected-note {{instantiation of}} diff --git a/test/CXX/expr/expr.unary/expr.new/p17-crash.cpp b/test/CXX/expr/expr.unary/expr.new/p17-crash.cpp deleted file mode 100644 index 27b915e95965..000000000000 --- a/test/CXX/expr/expr.unary/expr.new/p17-crash.cpp +++ /dev/null @@ -1,14 +0,0 @@ -// RUN: %clang_cc1 -emit-llvm-only %s - -// this used to crash due to templ<int>'s dtor not being marked as used by the -// new expression in func() -struct non_trivial { - non_trivial() {} - ~non_trivial() {} -}; -template < typename T > class templ { - non_trivial n; -}; -void func() { - new templ<int>[1][1]; -} diff --git a/test/CXX/expr/expr.unary/expr.new/p17.cpp b/test/CXX/expr/expr.unary/expr.new/p17.cpp deleted file mode 100644 index 0d108eb6a894..000000000000 --- a/test/CXX/expr/expr.unary/expr.new/p17.cpp +++ /dev/null @@ -1,16 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s - -class ctor { - ctor(); // expected-note{{implicitly declared private here}} -}; - -class dtor { - ~dtor(); // expected-note 3 {{implicitly declared private here}} -}; - -void test() { - new ctor[0]; // expected-error{{calling a private constructor of class 'ctor'}} - new dtor[0]; // expected-error{{calling a private destructor of class 'dtor'}} - new dtor[3]; // expected-error{{calling a private destructor of class 'dtor'}} - new dtor[3][3]; // expected-error{{calling a private destructor of class 'dtor'}} -} diff --git a/test/CXX/expr/expr.unary/expr.new/p19.cpp b/test/CXX/expr/expr.unary/expr.new/p19.cpp deleted file mode 100644 index bb69fd55fd80..000000000000 --- a/test/CXX/expr/expr.unary/expr.new/p19.cpp +++ /dev/null @@ -1,46 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -fexceptions %s -typedef __SIZE_TYPE__ size_t; - -// Operator delete template for placement new with global lookup -template<int I> -struct X0 { - X0(); - - static void* operator new(size_t) { - return I; // expected-error{{cannot initialize}} - } - - static void operator delete(void*) { - int *ip = I; // expected-error{{cannot initialize}} - } -}; - -void test_X0() { - // Using the global operator new suppresses the search for a - // operator delete in the class. - ::new X0<2>; - - new X0<3>; // expected-note 2{{instantiation}} -} - -// Operator delete template for placement new[] with global lookup -template<int I> -struct X1 { - X1(); - - static void* operator new[](size_t) { - return I; // expected-error{{cannot initialize}} - } - - static void operator delete[](void*) { - int *ip = I; // expected-error{{cannot initialize}} - } -}; - -void test_X1() { - // Using the global operator new suppresses the search for a - // operator delete in the class. - ::new X1<2> [17]; - - new X1<3> [17]; // expected-note 2{{instantiation}} -} diff --git a/test/CXX/expr/expr.unary/expr.new/p2-cxx0x.cpp b/test/CXX/expr/expr.unary/expr.new/p2-cxx0x.cpp deleted file mode 100644 index a3a2f712c800..000000000000 --- a/test/CXX/expr/expr.unary/expr.new/p2-cxx0x.cpp +++ /dev/null @@ -1,27 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11 - -template<typename T> -struct only { - only(T); - template<typename U> only(U) = delete; -}; - -void f() { - only<const int*> p = new const auto (0); - only<double*> q = new (auto) (0.0); - only<char*> r = new auto {'a'}; - - new auto; // expected-error{{new expression for type 'auto' requires a constructor argument}} - new (const auto)(); // expected-error{{new expression for type 'const auto' requires a constructor argument}} - new (auto) (1,2,3); // expected-error{{new expression for type 'auto' contains multiple constructor arguments}} - new auto {}; // expected-error{{new expression for type 'auto' requires a constructor argument}} - new auto {1,2,3}; // expected-error{{new expression for type 'auto' contains multiple constructor arguments}} - new auto ({1,2,3}); // expected-error{{new expression for type 'auto' contains multiple constructor arguments}} -} - -void p2example() { - only<int*> r = new auto(1); - auto x = new auto('a'); - - only<char*> testX = x; -} diff --git a/test/CXX/expr/expr.unary/expr.new/p2-cxx14.cpp b/test/CXX/expr/expr.unary/expr.new/p2-cxx14.cpp deleted file mode 100644 index 70bbc4805c43..000000000000 --- a/test/CXX/expr/expr.unary/expr.new/p2-cxx14.cpp +++ /dev/null @@ -1,10 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++14 -pedantic - -void f() { - new auto('a'); - new auto {2}; // expected-warning {{ISO C++ standards before C++17 do not allow new expression for type 'auto' to use list-initialization}} - new auto {1, 2}; // expected-error{{new expression for type 'auto' contains multiple constructor arguments}} - new auto {}; // expected-error{{new expression for type 'auto' requires a constructor argument}} - new decltype(auto)({1}); // expected-warning {{ISO C++ standards before C++17 do not allow new expression for type 'decltype(auto)' to use list-initialization}} - new decltype(auto)({1, 2}); // expected-error{{new expression for type 'decltype(auto)' contains multiple constructor arguments}} -} diff --git a/test/CXX/expr/expr.unary/expr.new/p2-cxx1z.cpp b/test/CXX/expr/expr.unary/expr.new/p2-cxx1z.cpp deleted file mode 100644 index 6e76075ab16f..000000000000 --- a/test/CXX/expr/expr.unary/expr.new/p2-cxx1z.cpp +++ /dev/null @@ -1,11 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++14 -// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++17 -pedantic - -void f() { - new auto('a'); - new auto {2}; - new auto {1, 2}; // expected-error{{new expression for type 'auto' contains multiple constructor arguments}} - new auto {}; // expected-error{{new expression for type 'auto' requires a constructor argument}} - new decltype(auto)({1}); - new decltype(auto)({1, 2}); // expected-error{{new expression for type 'decltype(auto)' contains multiple constructor arguments}} -} diff --git a/test/CXX/expr/expr.unary/expr.new/p20-0x.cpp b/test/CXX/expr/expr.unary/expr.new/p20-0x.cpp deleted file mode 100644 index 13676a8a07ce..000000000000 --- a/test/CXX/expr/expr.unary/expr.new/p20-0x.cpp +++ /dev/null @@ -1,68 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 -fexceptions %s -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++14 -fexceptions %s -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++1z -fexceptions %s -typedef __SIZE_TYPE__ size_t; - -namespace std { enum class align_val_t : size_t {}; } - -struct S { - // Placement allocation function: - static void* operator new(size_t, size_t); - // Usual (non-placement) deallocation function: - static void operator delete(void*, size_t); // expected-note{{declared here}} -}; - -void testS() { - S* p = new (0) S; // expected-error{{'new' expression with placement arguments refers to non-placement 'operator delete'}} -} - -struct T { - // Placement allocation function: - static void* operator new(size_t, size_t); - // Usual (non-placement) deallocation function: - static void operator delete(void*); - // Placement deallocation function: - static void operator delete(void*, size_t); -}; - -void testT() { - T* p = new (0) T; // ok -} - -#if __cplusplus > 201402L -struct U { - // Placement allocation function: - static void* operator new(size_t, size_t, std::align_val_t); - // Placement deallocation function: - static void operator delete(void*, size_t, std::align_val_t); // expected-note{{declared here}} -}; - -void testU() { - U* p = new (0, std::align_val_t(0)) U; // expected-error{{'new' expression with placement arguments refers to non-placement 'operator delete'}} -} - -struct V { - // Placement allocation function: - static void* operator new(size_t, size_t, std::align_val_t); - // Usual (non-placement) deallocation function: - static void operator delete(void*, std::align_val_t); - // Placement deallocation function: - static void operator delete(void*, size_t, std::align_val_t); -}; - -void testV() { - V* p = new (0, std::align_val_t(0)) V; -} - -struct W { - // Placement allocation function: - static void* operator new(size_t, size_t, std::align_val_t); - // Usual (non-placement) deallocation functions: - static void operator delete(void*); - static void operator delete(void*, size_t, std::align_val_t); // expected-note {{declared here}} -}; - -void testW() { - W* p = new (0, std::align_val_t(0)) W; // expected-error{{'new' expression with placement arguments refers to non-placement 'operator delete'}} -} -#endif diff --git a/test/CXX/expr/expr.unary/expr.new/p20.cpp b/test/CXX/expr/expr.unary/expr.new/p20.cpp deleted file mode 100644 index 8cbe2b9be3be..000000000000 --- a/test/CXX/expr/expr.unary/expr.new/p20.cpp +++ /dev/null @@ -1,141 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -fexceptions %s -typedef __SIZE_TYPE__ size_t; - -// Overloaded operator delete with two arguments -template<int I> -struct X0 { - X0(); - static void* operator new(size_t); - static void operator delete(void*, size_t) { - int *ip = I; // expected-error{{cannot initialize}} - } -}; - -void test_X0() { - new X0<1>; // expected-note{{instantiation}} -} - -// Overloaded operator delete with one argument -template<int I> -struct X1 { - X1(); - - static void* operator new(size_t); - static void operator delete(void*) { - int *ip = I; // expected-error{{cannot initialize}} - } -}; - -void test_X1() { - new X1<1>; // expected-note{{instantiation}} -} - -// Overloaded operator delete for placement new -template<int I> -struct X2 { - X2(); - - static void* operator new(size_t, double, double); - static void* operator new(size_t, int, int); - - static void operator delete(void*, const int, int) { - int *ip = I; // expected-error{{cannot initialize}} - } - - static void operator delete(void*, double, double); -}; - -void test_X2() { - new (0, 0) X2<1>; // expected-note{{instantiation}} -} - -// Operator delete template for placement new -struct X3 { - X3(); - - static void* operator new(size_t, double, double); - - template<typename T> - static void operator delete(void*, T x, T) { - double *dp = &x; - int *ip = &x; // expected-error{{cannot initialize}} - } -}; - -void test_X3() { - new (0, 0) X3; // expected-note{{instantiation}} -} - -// Operator delete template for placement new in global scope. -struct X4 { - X4(); - static void* operator new(size_t, double, double); -}; - -template<typename T> -void operator delete(void*, T x, T) { - double *dp = &x; - int *ip = &x; // expected-error{{cannot initialize}} -} - -void test_X4() { - new (0, 0) X4; // expected-note{{instantiation}} -} - -// Useless operator delete hides global operator delete template. -struct X5 { - X5(); - static void* operator new(size_t, double, double); - void operator delete(void*, double*, double*); -}; - -void test_X5() { - new (0, 0) X5; // okay, we found X5::operator delete but didn't pick it -} - -// Operator delete template for placement new -template<int I> -struct X6 { - X6(); - - static void* operator new(size_t) { - return I; // expected-error{{cannot initialize}} - } - - static void operator delete(void*) { - int *ip = I; // expected-error{{cannot initialize}} - } -}; - -void test_X6() { - new X6<3>; // expected-note 2{{instantiation}} -} - -void *operator new(size_t, double, double, double); - -template<typename T> -void operator delete(void*, T x, T, T) { - double *dp = &x; - int *ip = &x; // expected-error{{cannot initialize}} -} -void test_int_new() { - new (1.0, 1.0, 1.0) int; // expected-note{{instantiation}} -} - -// We don't need an operator delete if the type has a trivial -// constructor, since we know that constructor cannot throw. -// FIXME: Is this within the standard? Seems fishy, but both EDG+GCC do it. -#if 0 -template<int I> -struct X7 { - static void* operator new(size_t); - static void operator delete(void*, size_t) { - int *ip = I; // okay, since it isn't instantiated. - } -}; - -void test_X7() { - new X7<1>; -} -#endif - diff --git a/test/CXX/expr/expr.unary/expr.sizeof/p1.cpp b/test/CXX/expr/expr.unary/expr.sizeof/p1.cpp deleted file mode 100644 index aa76b3a73462..000000000000 --- a/test/CXX/expr/expr.unary/expr.sizeof/p1.cpp +++ /dev/null @@ -1,48 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s - -struct A { - unsigned bitX : 4; - unsigned bitY : 4; - unsigned var; - - void foo(); -}; - -void test(A *a) { - int x; - x = sizeof(a->bitX); // expected-error {{invalid application of 'sizeof' to bit-field}} - x = sizeof((unsigned) a->bitX); - x = sizeof(a->foo(), a->bitX); // expected-error {{invalid application of 'sizeof' to bit-field}} - x = sizeof(a->var ? a->bitX : a->bitY); // expected-error {{invalid application of 'sizeof' to bit-field}} - x = sizeof(a->var ? a->bitX : a->bitX); // expected-error {{invalid application of 'sizeof' to bit-field}} - x = sizeof(a->bitX = 3); // expected-error {{invalid application of 'sizeof' to bit-field}} - x = sizeof(a->bitY += 3); // expected-error {{invalid application of 'sizeof' to bit-field}} -} - -void test2() { - int x; - x = sizeof(void); // expected-error {{invalid application of 'sizeof' to an incomplete type 'void'}} - x = sizeof(int()); // expected-error {{invalid application of 'sizeof' to a function type}} - x = sizeof(test2()); // expected-error {{invalid application of 'sizeof' to an incomplete type 'void'}} - x = sizeof(test2); // expected-error {{invalid application of 'sizeof' to a function type}} -} - -namespace pr16992 { - -template<typename T> struct ABC { - int func () { - return sizeof T; // expected-error {{expected parentheses around type name in sizeof expression}} - } -}; - -ABC<int> qq; - -template<typename T> struct ABC2 { - int func () { - return sizeof T::A; - } -}; - -struct QQ { int A; }; -ABC2<QQ> qq2; -} diff --git a/test/CXX/expr/expr.unary/expr.sizeof/p5-0x.cpp b/test/CXX/expr/expr.unary/expr.sizeof/p5-0x.cpp deleted file mode 100644 index afd8ef05302f..000000000000 --- a/test/CXX/expr/expr.unary/expr.sizeof/p5-0x.cpp +++ /dev/null @@ -1,38 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s - -// Test parsing + semantic analysis -template<typename ...Types> struct count_types { - static const unsigned value = sizeof...(Types); -}; - -template<int ...Values> struct count_ints { - static const unsigned value = sizeof...(Values); -}; - -// Test instantiation -int check_types[count_types<short, int, long>::value == 3? 1 : -1]; -int check_ints[count_ints<1, 2, 3, 4, 5>::value == 5? 1 : -1]; - -// Test instantiation involving function parameter packs. -struct any { - template<typename T> any(T); -}; - -template<typename ...Inits> -void init_me(Inits ...inits) { - any array[sizeof...(inits)] = { inits... }; -} - -template void init_me<int, float, double*>(int, float, double*); - -// Test parser and semantic recovery. -template<int Value> struct count_ints_2 { - static const unsigned value = sizeof...(Value); // expected-error{{'Value' does not refer to the name of a parameter pack}} -}; - -template<typename ...Types> // expected-note{{parameter pack 'Types' declared here}} -struct count_types_2 { - static const unsigned value = sizeof... Type; // expected-error{{missing parentheses around the size of parameter pack 'Type'}} \ - // expected-error{{Type' does not refer to the name of a parameter pack; did you mean 'Types'?}} -}; - diff --git a/test/CXX/expr/expr.unary/expr.unary.noexcept/cg.cpp b/test/CXX/expr/expr.unary/expr.unary.noexcept/cg.cpp deleted file mode 100644 index e299705a4c11..000000000000 --- a/test/CXX/expr/expr.unary/expr.unary.noexcept/cg.cpp +++ /dev/null @@ -1,27 +0,0 @@ -// REQUIRES: x86-registered-target -// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -triple x86_64-apple-darwin10 -S -emit-llvm -std=c++11 -include %S/ser.h %s -o - | FileCheck %s -// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -triple x86_64-apple-darwin10 -emit-pch -o %t-ser.pch -std=c++11 -x c++ %S/ser.h -// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -triple x86_64-apple-darwin10 -S -emit-llvm -std=c++11 -include-pch %t-ser.pch %s -o - | FileCheck %s - -struct D { - ~D() throw(); -}; -struct E { - ~E() throw(); -}; - -void test() { - bool b; - // CHECK: store i8 1 - b = noexcept(0); - // CHECK: store i8 0 - b = noexcept(throw 0); - b = f1(); - b = f2(); - - // CHECK-NOT: call void @_ZN1ED1Ev - // CHECK: call void @_ZN1DD1Ev - D(), noexcept(E()); -} -// CHECK: ret i1 true -// CHECK: ret i1 false diff --git a/test/CXX/expr/expr.unary/expr.unary.noexcept/sema.cpp b/test/CXX/expr/expr.unary/expr.unary.noexcept/sema.cpp deleted file mode 100644 index a2a57956df9b..000000000000 --- a/test/CXX/expr/expr.unary/expr.unary.noexcept/sema.cpp +++ /dev/null @@ -1,197 +0,0 @@ -// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -fsyntax-only -verify -std=c++11 -fms-extensions -Wno-delete-incomplete -Wno-unused-value %s -// expected-no-diagnostics - -#define P(e) static_assert(noexcept(e), "expected nothrow") -#define N(e) static_assert(!noexcept(e), "expected throw") -#define B(b, e) static_assert(b == noexcept(e), "expectation failed") - -void simple() { - P(0); - P(0 + 0); - int i; - P(i); - P(sizeof(0)); - P(static_cast<int>(0)); - N(throw 0); - N((throw 0, 0)); -} - -void nospec(); -void allspec() throw(...); -void intspec() throw(int); -void emptyspec() throw(); -void nothrowattr() __attribute__((nothrow)); -void noexcept_true() noexcept; -void noexcept_false() noexcept(false); - -void call() { - N(nospec()); - N(allspec()); - N(intspec()); - P(emptyspec()); - P(nothrowattr()); - P(noexcept_true()); - N(noexcept_false()); -} - -void (*pnospec)(); -void (*pallspec)() throw(...); -void (*pintspec)() throw(int); -void (*pemptyspec)() throw(); - -typedef void (*funcptr)(); -funcptr returnsptr() throw(); - -void callptr() { - N(pnospec()); - N((*pnospec)()); - N(pallspec()); - N((*pallspec)()); - N(pintspec()); - N((*pintspec)()); - P(pemptyspec()); - P((*pemptyspec)()); - N(returnsptr()()); -} - -struct S1 { - void nospec(); - void allspec() throw(...); - void intspec() throw(int); - void emptyspec() throw(); -}; - -void callmem() { - S1 s; - N(s.nospec()); - N(s.allspec()); - N(s.intspec()); - P(s.emptyspec()); -} - -void (S1::*mpnospec)(); -void (S1::*mpallspec)() throw(...); -void (S1::*mpintspec)() throw(int); -void (S1::*mpemptyspec)() throw(); - -void callmemptr() { - S1 s; - N((s.*mpnospec)()); - N((s.*mpallspec)()); - N((s.*mpintspec)()); - P((s.*mpemptyspec)()); -} - -struct S2 { - S2(); - S2(int, int) throw(); - void operator +(); - void operator -() throw(); - void operator +(int); - void operator -(int) throw(); - operator int(); - operator float() throw(); -}; - -void *operator new(__typeof__(sizeof(int)) sz, int) throw(); - -struct IncompleteStruct; - -struct Bad1 { - ~Bad1() throw(int); -}; -struct Bad2 { - void operator delete(void*) throw(int); -}; - -typedef int X; - -void implicits() { - N(new int); - P(new (0) int); - P(delete (int*)0); - P(delete (IncompleteStruct*)0); - N(delete (Bad1*)0); - N(delete (Bad2*)0); - N(S2()); - P(S2(0, 0)); - S2 s; - N(+s); - P(-s); - N(s + 0); - P(s - 0); - N(static_cast<int>(s)); - P(static_cast<float>(s)); - N(Bad1()); - P(X().~X()); -} - -struct V { - virtual ~V() throw(); -}; -struct D : V {}; - -void dyncast() { - V *pv = 0; - D *pd = 0; - P(dynamic_cast<V&>(*pd)); - P(dynamic_cast<V*>(pd)); - N(dynamic_cast<D&>(*pv)); - P(dynamic_cast<D*>(pv)); -} - -namespace std { - struct type_info {}; -} - -void idtype() { - P(typeid(V)); - P(typeid((V*)0)); - P(typeid(*(S1*)0)); - N(typeid(*(V*)0)); -} - -void uneval() { - P(sizeof(typeid(*(V*)0))); - P(typeid(typeid(*(V*)0))); -} - -struct G1 {}; -struct G2 { int i; }; -struct G3 { S2 s; }; - -void gencon() { - P(G1()); - P(G2()); - N(G3()); -} - -template <class T> void f(T&&) noexcept; -template <typename T, bool b> -void late() { - B(b, typeid(*(T*)0)); - B(b, T(1)); - B(b, static_cast<T>(S2(0, 0))); - B(b, S1() + T()); - P(f(T())); - P(new (0) T); - P(delete (T*)0); -} -struct S3 { - virtual ~S3() throw(); - S3() throw(); - explicit S3(int); - S3(const S2&); -}; -template <class T> T&& f2() noexcept; -template <typename T> -void late2() { - P(dynamic_cast<S3&>(f2<T&>())); -} -void operator +(const S1&, float) throw(); -void operator +(const S1&, const S3&); -void tlate() { - late<float, true>(); - late<S3, false>(); - late2<S3>(); -} diff --git a/test/CXX/expr/expr.unary/expr.unary.noexcept/ser.h b/test/CXX/expr/expr.unary/expr.unary.noexcept/ser.h deleted file mode 100644 index e6e7b795d25a..000000000000 --- a/test/CXX/expr/expr.unary/expr.unary.noexcept/ser.h +++ /dev/null @@ -1,8 +0,0 @@ -// Serialization testing helper for noexcept, included by cg.cpp. - -inline bool f1() { - return noexcept(0); -} -inline bool f2() { - return noexcept(throw 0); -} diff --git a/test/CXX/expr/expr.unary/expr.unary.op/p3.cpp b/test/CXX/expr/expr.unary/expr.unary.op/p3.cpp deleted file mode 100644 index 08ab0ca56fb6..000000000000 --- a/test/CXX/expr/expr.unary/expr.unary.op/p3.cpp +++ /dev/null @@ -1,29 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only %s -verify -// expected-no-diagnostics - -namespace rdar10544564 { - // Check that we don't attempt to use an overloaded operator& when - // naming a pointer-to-member. - struct X { - void** operator & (); - }; - - struct Y - { - public: - X member; - X memfunc1(); - X memfunc2(); - X memfunc2(int); - - void test() { - X Y::*data_mem_ptr = &Y::member; - X (Y::*func_mem_ptr1)() = &Y::memfunc1; - X (Y::*func_mem_ptr2)() = &Y::memfunc2; - } - }; - - X Y::*data_mem_ptr = &Y::member; - X (Y::*func_mem_ptr1)() = &Y::memfunc1; - X (Y::*func_mem_ptr2)() = &Y::memfunc2; -} diff --git a/test/CXX/expr/expr.unary/expr.unary.op/p4.cpp b/test/CXX/expr/expr.unary/expr.unary.op/p4.cpp deleted file mode 100644 index 48c47f74ac6c..000000000000 --- a/test/CXX/expr/expr.unary/expr.unary.op/p4.cpp +++ /dev/null @@ -1,45 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s - -// rdar://problem/8347416 -namespace test0 { - struct A { - void foo(void (A::*)(int)); // expected-note {{passing argument to parameter here}} - template<typename T> void g(T); - - void test() { - foo(&g<int>); // expected-error-re {{cannot form member pointer of type 'void (test0::A::*)(int){{( __attribute__\(\(thiscall\)\))?}}' without '&' and class name}} - } - }; -} - -// This should succeed. -namespace test1 { - struct A { - static void f(void (A::*)()); - static void f(void (*)(int)); - void g(); - static void g(int); - - void test() { - f(&g); - } - }; -} - -// Also rdar://problem/8347416 -namespace test2 { - struct A { - static int foo(short); - static int foo(float); - int foo(int); - int foo(double); - - void test(); - }; - - void A::test() { - // FIXME: The error message in this case is less than clear, we can do - // better. - int (A::*ptr)(int) = &(A::foo); // expected-error {{cannot create a non-constant pointer to member function}} - } -} diff --git a/test/CXX/expr/expr.unary/expr.unary.op/p6.cpp b/test/CXX/expr/expr.unary/expr.unary.op/p6.cpp deleted file mode 100644 index 833a4014e868..000000000000 --- a/test/CXX/expr/expr.unary/expr.unary.op/p6.cpp +++ /dev/null @@ -1,35 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s - -// -- prvalue of arithmetic - -bool b = !0; - -bool b2 = !1.2; //expected-warning{{implicit conversion from 'double' to 'bool' changes value from 1.2 to true}} - -bool b3 = !4; - -// -- unscoped enumeration -enum { E, F }; - -bool b4 = !E; -bool b5 = !F; - -// -- pointer, -bool b6 = !&b4; // expected-warning{{address of 'b4' will always evaluate to 'true'}} -void f(); -bool b61 = !&f; - -// -- or pointer to member type can be converted to a prvalue of type bool. -struct S { void f() { } }; - -bool b7 = !&S::f; - - -bool b8 = !S(); //expected-error {{invalid argument type 'S'}} - -namespace PR8181 -{ - bool f() { } // expected-note{{possible target for call}} - void f(char) { } // expected-note{{possible target for call}} - bool b = !&f; //expected-error {{reference to overloaded function could not be resolved; did you mean to call it with no arguments?}} -} diff --git a/test/CXX/expr/p10-0x.cpp b/test/CXX/expr/p10-0x.cpp deleted file mode 100644 index a42986c85fef..000000000000 --- a/test/CXX/expr/p10-0x.cpp +++ /dev/null @@ -1,46 +0,0 @@ -// RUN: %clang_cc1 -emit-llvm -triple x86_64-pc-linux-gnu %s -o - -std=c++11 | FileCheck %s - -volatile int g1; -struct S { - volatile int a; -} g2; - -volatile int& refcall(); - -// CHECK: define void @_Z2f1PViPV1S -void f1(volatile int *x, volatile S* s) { - // We should perform the load in these cases. - // CHECK: load volatile i32, i32* - (*x); - // CHECK: load volatile i32, i32* - __extension__ g1; - // CHECK: load volatile i32, i32* - s->a; - // CHECK: load volatile i32, i32* - g2.a; - // CHECK: load volatile i32, i32* - s->*(&S::a); - // CHECK: load volatile i32, i32* - // CHECK: load volatile i32, i32* - x[0], 1 ? x[0] : *x; - - // CHECK: load volatile i32, i32* - // CHECK: load volatile i32, i32* - // CHECK: load volatile i32, i32* - *x ?: *x; - - // CHECK: load volatile i32, i32* - ({ *x; }); - - // CHECK-NOT: load volatile - // CHECK: ret -} - -// CHECK: define void @_Z2f2PVi -// CHECK-NOT: load volatile -// CHECK: ret -void f2(volatile int *x) { - // We shouldn't perform the load in these cases. - refcall(); - 1 ? refcall() : *x; -} diff --git a/test/CXX/expr/p13.cpp b/test/CXX/expr/p13.cpp deleted file mode 100644 index 0f22ce0b7ceb..000000000000 --- a/test/CXX/expr/p13.cpp +++ /dev/null @@ -1,51 +0,0 @@ -// RUN: %clang_cc1 -std=c++1z -verify %s -fexceptions -fcxx-exceptions -Wno-dynamic-exception-spec - -struct X {}; -struct Y : X {}; - -using A = void (*)() noexcept; -using B = void (*)(); -using C = void (X::*)() noexcept; -using D = void (X::*)(); -using E = void (Y::*)() noexcept; -using F = void (Y::*)(); - -void f(A a, B b, C c, D d, E e, F f, bool k) { - a = k ? a : b; // expected-error {{different exception specifications}} - b = k ? a : b; - - c = k ? c : d; // expected-error {{different exception specifications}} - d = k ? c : d; - - e = k ? c : f; // expected-error {{different exception specifications}} - e = k ? d : e; // expected-error {{different exception specifications}} - f = k ? c : f; - f = k ? d : e; - - const A ak = a; - const B bk = b; - const A &ak2 = k ? ak : ak; - const A &ak3 = k ? ak : bk; // expected-error {{could not bind}} - const B &bk3 = k ? ak : bk; -} - -namespace dynamic_exception_spec { - // Prior to P0012, we had: - // "[...] the target entity shall allow at least the exceptions allowed - // by the source value in the assignment or initialization" - // - // There's really only one way we can coherently apply this to conditional - // expressions: this must hold no matter which branch was taken. - using X = void (*)() throw(int); - using Y = void (*)() throw(float); - using Z = void (*)() throw(int, float); - void g(X x, Y y, Z z, bool k) { - x = k ? X() : Y(); // expected-warning {{not superset}} - y = k ? X() : Y(); // expected-warning {{not superset}} - z = k ? X() : Y(); - - x = k ? x : y; // expected-warning {{not superset}} - y = k ? x : y; // expected-warning {{not superset}} - z = k ? x : y; - } -} diff --git a/test/CXX/expr/p3.cpp b/test/CXX/expr/p3.cpp deleted file mode 100644 index 6b243c26cc31..000000000000 --- a/test/CXX/expr/p3.cpp +++ /dev/null @@ -1,15 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s - -double operator +(double, double); // expected-error{{overloaded 'operator+' must have at least one parameter of class or enumeration type}} - -struct A -{ - operator int(); -}; - -int main() -{ - A a, b; - int i0 = a + 1; - int i1 = a + b; -} diff --git a/test/CXX/expr/p8.cpp b/test/CXX/expr/p8.cpp deleted file mode 100644 index 471d1c5a3020..000000000000 --- a/test/CXX/expr/p8.cpp +++ /dev/null @@ -1,19 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -// expected-no-diagnostics - -int a0; -const volatile int a1 = 2; -int a2[16]; -int a3(); - -void f0(int); -void f1(int *); -void f2(int (*)()); - -int main() -{ - f0(a0); - f0(a1); - f1(a2); - f2(a3); -} diff --git a/test/CXX/expr/p9.cpp b/test/CXX/expr/p9.cpp deleted file mode 100644 index 4c60b8ba62e4..000000000000 --- a/test/CXX/expr/p9.cpp +++ /dev/null @@ -1,51 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -// expected-no-diagnostics - -// floating-point overloads - -__typeof__(0 + 0.0L) ld0; -long double &ldr = ld0; - -__typeof__(0 + 0.0) d0; -double &dr = d0; - -__typeof__(0 + 0.0f) f0; -float &fr = f0; - -// integral promotions - -signed char c0; -__typeof__(c0 + c0) c1; -int &cr = c1; - -unsigned char uc0; -__typeof__(uc0 + uc0) uc1; -int &ucr = uc1; - -short s0; -__typeof__(s0 + s0) s1; -int &sr = s1; - -unsigned short us0; -__typeof__(us0 + us0) us1; -int &usr = us1; - -// integral overloads - -__typeof__(0 + 0UL) ul0; -unsigned long &ulr = ul0; - -template<bool T> struct selector; -template<> struct selector<true> { typedef long type; }; -template<> struct selector<false> {typedef unsigned long type; }; -__typeof__(0U + 0L) ui_l0; -selector<(sizeof(long) > sizeof(unsigned int))>::type &ui_lr = ui_l0; - -__typeof__(0 + 0L) l0; -long &lr = l0; - -__typeof__(0 + 0U) u0; -unsigned &ur = u0; - -__typeof__(0 + 0) i0; -int &ir = i0; diff --git a/test/CXX/lex/lex.charset/p2-cxx11.cpp b/test/CXX/lex/lex.charset/p2-cxx11.cpp deleted file mode 100644 index b9192cebe61e..000000000000 --- a/test/CXX/lex/lex.charset/p2-cxx11.cpp +++ /dev/null @@ -1,42 +0,0 @@ -// RUN: %clang_cc1 -verify -std=c++11 %s - -char c00 = '\u0000'; // ok -char c01 = '\u0001'; // ok -char c1f = '\u001f'; // ok -char c20 = '\u0020'; // ' ', ok -char c22 = '\u0022'; // ", ok -char c23 = '\u0023'; // #, ok -char c24 = '\u0024'; // $, ok -char c25 = '\u0025'; // %, ok -char c27 = '\u0027'; // ', ok -char c3f = '\u003f'; // ?, ok -char c40 = '\u0040'; // @, ok -char c41 = '\u0041'; // A, ok -char c5f = '\u005f'; // _, ok -char c60 = '\u0060'; // `, ok -char c7e = '\u007e'; // ~, ok -char c7f = '\u007f'; // ok - -wchar_t w007f = L'\u007f'; -wchar_t w0080 = L'\u0080'; -wchar_t w009f = L'\u009f'; -wchar_t w00a0 = L'\u00a0'; - -wchar_t wd799 = L'\ud799'; -wchar_t wd800 = L'\ud800'; // expected-error {{invalid universal character}} -wchar_t wdfff = L'\udfff'; // expected-error {{invalid universal character}} -wchar_t we000 = L'\ue000'; - -char32_t w10fffe = U'\U0010fffe'; -char32_t w10ffff = U'\U0010ffff'; -char32_t w110000 = U'\U00110000'; // expected-error {{invalid universal character}} - -const char *p1 = "\u0000\u0001\u001f\u0020\u0022\u0023\u0024\u0025\u0027\u003f\u0040\u0041\u005f\u0060\u007e\u007f"; -const wchar_t *p2 = L"\u0000\u0012\u004e\u007f\u0080\u009f\u00a0\ud799\ue000"; -const char *p3 = u8"\u0000\u0012\u004e\u007f\u0080\u009f\u00a0\ud799\ue000"; -const char16_t *p4 = u"\u0000\u0012\u004e\u007f\u0080\u009f\u00a0\ud799\ue000"; -const char32_t *p5 = U"\u0000\u0012\u004e\u007f\u0080\u009f\u00a0\ud799\ue000"; -const wchar_t *p6 = L"foo \U00110000 bar"; // expected-error {{invalid universal character}} -const char *p7 = u8"foo \U0000d800 bar"; // expected-error {{invalid universal character}} -const char16_t *p8 = u"foo \U0000dfff bar"; // expected-error {{invalid universal character}} -const char32_t *p9 = U"foo \U0010ffff bar"; // ok diff --git a/test/CXX/lex/lex.charset/p2-cxx98.cpp b/test/CXX/lex/lex.charset/p2-cxx98.cpp deleted file mode 100644 index a5b7ab648821..000000000000 --- a/test/CXX/lex/lex.charset/p2-cxx98.cpp +++ /dev/null @@ -1,55 +0,0 @@ -// RUN: %clang_cc1 -verify -std=c++98 %s - -char c00 = '\u0000'; // expected-error {{universal character name refers to a control character}} -char c01 = '\u0001'; // expected-error {{universal character name refers to a control character}} -char c1f = '\u001f'; // expected-error {{universal character name refers to a control character}} -char c20 = '\u0020'; // ' ', expected-error {{character ' ' cannot be specified by a universal character name}} -char c22 = '\u0022'; // ", expected-error {{character '"' cannot be specified by a universal character name}} -char c23 = '\u0023'; // #, expected-error {{character '#' cannot be specified by a universal character name}} -char c24 = '\u0024'; // $, ok -char c25 = '\u0025'; // %, expected-error {{character '%' cannot be specified by a universal character name}} -char c27 = '\u0027'; // ', expected-error {{character ''' cannot be specified by a universal character name}} -char c3f = '\u003f'; // ?, expected-error {{character '?' cannot be specified by a universal character name}} -char c40 = '\u0040'; // @, ok -char c41 = '\u0041'; // A, expected-error {{character 'A' cannot be specified by a universal character name}} -char c5f = '\u005f'; // _, expected-error {{character '_' cannot be specified by a universal character name}} -char c60 = '\u0060'; // `, ok -char c7e = '\u007e'; // ~, expected-error {{character '~' cannot be specified by a universal character name}} -char c7f = '\u007f'; // expected-error {{universal character name refers to a control character}} - -wchar_t w007f = L'\u007f'; // expected-error {{universal character name refers to a control character}} -wchar_t w0080 = L'\u0080'; // expected-error {{universal character name refers to a control character}} -wchar_t w009f = L'\u009f'; // expected-error {{universal character name refers to a control character}} -wchar_t w00a0 = L'\u00a0'; - -wchar_t wd799 = L'\ud799'; -wchar_t wd800 = L'\ud800'; // expected-error {{invalid universal character}} -wchar_t wdfff = L'\udfff'; // expected-error {{invalid universal character}} -wchar_t we000 = L'\ue000'; - -const char *s00 = "\u0000"; // expected-error {{universal character name refers to a control character}} -const char *s01 = "\u0001"; // expected-error {{universal character name refers to a control character}} -const char *s1f = "\u001f"; // expected-error {{universal character name refers to a control character}} -const char *s20 = "\u0020"; // ' ', expected-error {{character ' ' cannot be specified by a universal character name}} -const char *s22 = "\u0022"; // ", expected-error {{character '"' cannot be specified by a universal character name}} -const char *s23 = "\u0023"; // #, expected-error {{character '#' cannot be specified by a universal character name}} -const char *s24 = "\u0024"; // $, ok -const char *s25 = "\u0025"; // %, expected-error {{character '%' cannot be specified by a universal character name}} -const char *s27 = "\u0027"; // ', expected-error {{character ''' cannot be specified by a universal character name}} -const char *s3f = "\u003f"; // ?, expected-error {{character '?' cannot be specified by a universal character name}} -const char *s40 = "\u0040"; // @, ok -const char *s41 = "\u0041"; // A, expected-error {{character 'A' cannot be specified by a universal character name}} -const char *s5f = "\u005f"; // _, expected-error {{character '_' cannot be specified by a universal character name}} -const char *s60 = "\u0060"; // `, ok -const char *s7e = "\u007e"; // ~, expected-error {{character '~' cannot be specified by a universal character name}} -const char *s7f = "\u007f"; // expected-error {{universal character name refers to a control character}} - -const wchar_t *ws007f = L"\u007f"; // expected-error {{universal character name refers to a control character}} -const wchar_t *ws0080 = L"\u0080"; // expected-error {{universal character name refers to a control character}} -const wchar_t *ws009f = L"\u009f"; // expected-error {{universal character name refers to a control character}} -const wchar_t *ws00a0 = L"\u00a0"; - -const wchar_t *wsd799 = L"\ud799"; -const wchar_t *wsd800 = L"\ud800"; // expected-error {{invalid universal character}} -const wchar_t *wsdfff = L"\udfff"; // expected-error {{invalid universal character}} -const wchar_t *wse000 = L"\ue000"; diff --git a/test/CXX/lex/lex.literal/lex.ccon/p1.cpp b/test/CXX/lex/lex.literal/lex.ccon/p1.cpp deleted file mode 100644 index f84f5fba3e0a..000000000000 --- a/test/CXX/lex/lex.literal/lex.ccon/p1.cpp +++ /dev/null @@ -1,17 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s -// expected-no-diagnostics - -// Check types of char literals -extern char a; -extern __typeof('a') a; -extern int b; -extern __typeof('asdf') b; -extern wchar_t c; -extern __typeof(L'a') c; -#if __cplusplus >= 201103L -extern char16_t d; -extern __typeof(u'a') d; -extern char32_t e; -extern __typeof(U'a') e; -#endif diff --git a/test/CXX/lex/lex.literal/lex.ext/p1.cpp b/test/CXX/lex/lex.literal/lex.ext/p1.cpp deleted file mode 100644 index 1c227a1b10d3..000000000000 --- a/test/CXX/lex/lex.literal/lex.ext/p1.cpp +++ /dev/null @@ -1,7 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s - -void operator "" p31(long double); // expected-warning{{user-defined literal suffixes not starting with '_' are reserved}} -void operator "" _p31(long double); -long double operator "" pi(long double); // expected-warning{{user-defined literal suffixes not starting with '_' are reserved}} - -float hexfloat = 0x1p31; // allow hexfloats diff --git a/test/CXX/lex/lex.literal/lex.ext/p10.cpp b/test/CXX/lex/lex.literal/lex.ext/p10.cpp deleted file mode 100644 index 1b5d3880cb61..000000000000 --- a/test/CXX/lex/lex.literal/lex.ext/p10.cpp +++ /dev/null @@ -1,14 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -verify %s - -using size_t = decltype(sizeof(int)); -void operator "" wibble(const char *); // expected-warning {{user-defined literal suffixes not starting with '_' are reserved; no literal will invoke this operator}} -void operator "" wibble(const char *, size_t); // expected-warning {{user-defined literal suffixes not starting with '_' are reserved; no literal will invoke this operator}} - -template<typename T> -void f() { - // A program containing a reserved ud-suffix is ill-formed. - 123wibble; // expected-error {{invalid suffix 'wibble'}} - 123.0wibble; // expected-error {{invalid suffix 'wibble'}} - const char *p = ""wibble; // expected-error {{invalid suffix on literal; C++11 requires a space between literal and identifier}} expected-error {{expected ';'}} - const char *q = R"x("hello")x"wibble; // expected-error {{invalid suffix on literal; C++11 requires a space between literal and identifier}} expected-error {{expected ';'}} -} diff --git a/test/CXX/lex/lex.literal/lex.ext/p11.cpp b/test/CXX/lex/lex.literal/lex.ext/p11.cpp deleted file mode 100644 index 8b5fcf4b609b..000000000000 --- a/test/CXX/lex/lex.literal/lex.ext/p11.cpp +++ /dev/null @@ -1,22 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s - -using size_t = decltype(sizeof(int)); - -template<typename T, typename U> struct same_type; -template<typename T> struct same_type<T, T> {}; -template<typename T> using X = T; -template<typename CharT, X<CharT>...> -int operator "" _x(); // expected-warning {{string literal operator templates are a GNU extension}} -template<char...> -double operator "" _x(); - -auto a="string"_x; -auto b=42_x; -same_type<decltype(a), int> test_a; -same_type<decltype(b), double> test_b; - -char operator "" _x(const char *begin, size_t size); -auto c="string"_x; -auto d=L"string"_x; -same_type<decltype(c), char> test_c; -same_type<decltype(d), int> test_d; diff --git a/test/CXX/lex/lex.literal/lex.ext/p12.cpp b/test/CXX/lex/lex.literal/lex.ext/p12.cpp deleted file mode 100644 index 34a2f5c67820..000000000000 --- a/test/CXX/lex/lex.literal/lex.ext/p12.cpp +++ /dev/null @@ -1,21 +0,0 @@ -// RUN: %clang_cc1 -std=gnu++11 -verify %s - -template<typename T, T... cs> struct check; // expected-note {{template is declared here}} expected-note {{template is declared here}} -template<> -struct check<char, 34, -47, -126, -48, -75, -47, -127, -47, -126, 32, -16, -112, -128, -128>{}; -template<> -struct check<char16_t, 34, 1090, 1077, 1089, 1090, 32, 55296, 56320>{}; -template<> -struct check<char32_t, 34, 1090, 1077, 1089, 1090, 32, 65536>{}; -template<typename T, T... str> int operator""_x() { // #1 expected-warning {{string literal operator templates are a GNU extension}} - check<T, str...> chars; // expected-error {{implicit instantiation of undefined template 'check<char, 't', 'e', 's', 't'>'}} expected-error {{implicit instantiation of undefined template 'check<char32_t, 34, 1090, 1077, 1089, 1090, 95, 65536>'}} - return 1; -} -void *operator""_x(const char*); // #2 -void *a = 123_x; // ok, calls #2 -int b = u8"\"тест 𐀀"_x; // ok, calls #1 -int c = u8R"("тест 𐀀)"_x; // ok, calls #1 -int d = "test"_x; // expected-note {{in instantiation of function template specialization 'operator""_x<char, 't', 'e', 's', 't'>' requested here}} -int e = uR"("тест 𐀀)"_x; -int f = UR"("тест 𐀀)"_x; -int g = UR"("тест_𐀀)"_x; // expected-note {{in instantiation of function template specialization 'operator""_x<char32_t, 34, 1090, 1077, 1089, 1090, 95, 65536>' requested here}} diff --git a/test/CXX/lex/lex.literal/lex.ext/p2.cpp b/test/CXX/lex/lex.literal/lex.ext/p2.cpp deleted file mode 100644 index 6942b68690c5..000000000000 --- a/test/CXX/lex/lex.literal/lex.ext/p2.cpp +++ /dev/null @@ -1,16 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s - -typedef decltype(sizeof(int)) size_t; - -// FIXME: These diagnostics should say 'size_t' instead of 'unsigned long' -int a = 123_x; // expected-error {{no matching literal operator for call to 'operator""_x' with argument of type 'unsigned long long' or 'const char *', and no matching literal operator template}} -int b = 4.2_x; // expected-error {{no matching literal operator for call to 'operator""_x' with argument of type 'long double' or 'const char *', and no matching literal operator template}} -int c = "foo"_x; // expected-error {{no matching literal operator for call to 'operator""_x' with arguments of types 'const char *' and 'unsigned}} -int d = L"foo"_x; // expected-error {{no matching literal operator for call to 'operator""_x' with arguments of types 'const wchar_t *' and 'unsigned}} -int e = u8"foo"_x; // expected-error {{no matching literal operator for call to 'operator""_x' with arguments of types 'const char *' and 'unsigned}} -int f = u"foo"_x; // expected-error {{no matching literal operator for call to 'operator""_x' with arguments of types 'const char16_t *' and 'unsigned}} -int g = U"foo"_x; // expected-error {{no matching literal operator for call to 'operator""_x' with arguments of types 'const char32_t *' and 'unsigned}} -int h = 'y'_x; // expected-error {{no matching literal operator for call to 'operator""_x' with argument of type 'char'}} -int i = L'y'_x; // expected-error {{no matching literal operator for call to 'operator""_x' with argument of type 'wchar_t'}} -int j = u'y'_x; // expected-error {{no matching literal operator for call to 'operator""_x' with argument of type 'char16_t'}} -int k = U'y'_x; // expected-error {{no matching literal operator for call to 'operator""_x' with argument of type 'char32_t'}} diff --git a/test/CXX/lex/lex.literal/lex.ext/p3.cpp b/test/CXX/lex/lex.literal/lex.ext/p3.cpp deleted file mode 100644 index d764989312c2..000000000000 --- a/test/CXX/lex/lex.literal/lex.ext/p3.cpp +++ /dev/null @@ -1,18 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s - -int &operator "" _x1 (unsigned long long); -int &i1 = 0x123_x1; - -double &operator "" _x1 (const char *); -int &i2 = 45_x1; - -template<char...> char &operator "" _x1 (); -int &i3 = 0377_x1; - -int &i4 = 90000000000000000000000000000000000000000000000_x1; // expected-error {{integer literal is too large to be represented in any integer type}} - -double &operator "" _x2 (const char *); -double &i5 = 123123123123123123123123123123123123123123123_x2; - -template<char...Cs> constexpr int operator "" _x3() { return sizeof...(Cs); } -static_assert(123456789012345678901234567890123456789012345678901234567890_x3 == 60, ""); diff --git a/test/CXX/lex/lex.literal/lex.ext/p4.cpp b/test/CXX/lex/lex.literal/lex.ext/p4.cpp deleted file mode 100644 index 011e832c69d7..000000000000 --- a/test/CXX/lex/lex.literal/lex.ext/p4.cpp +++ /dev/null @@ -1,18 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s - -int &operator "" _x1 (long double); -int &i1 = 0.123_x1; - -double &operator "" _x1 (const char *); -int &i2 = 45._x1; - -template<char...> char &operator "" _x1 (); -int &i3 = 0377e-1_x1; - -int &i4 = 1e1000000_x1; // expected-warning {{too large for type 'long double'}} - -double &operator "" _x2 (const char *); -double &i5 = 1e1000000_x2; - -template<char...Cs> constexpr int operator "" _x3() { return sizeof...(Cs); } -static_assert(1e1000000_x3 == 9, ""); diff --git a/test/CXX/lex/lex.literal/lex.ext/p5.cpp b/test/CXX/lex/lex.literal/lex.ext/p5.cpp deleted file mode 100644 index a516168a69b6..000000000000 --- a/test/CXX/lex/lex.literal/lex.ext/p5.cpp +++ /dev/null @@ -1,20 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s -triple=x86_64-linux-gnu - -using size_t = decltype(sizeof(int)); - -int &operator "" _x1 (const char *); -double &operator "" _x1 (const char *, size_t); -double &i1 = "foo"_x1; -double &i2 = u8"foo"_x1; -double &i3 = L"foo"_x1; // expected-error {{no matching literal operator for call to 'operator""_x1' with arguments of types 'const wchar_t *' and 'unsigned long'}} - -char &operator "" _x1(const wchar_t *, size_t); -char &i4 = L"foo"_x1; // ok -double &i5 = R"(foo)"_x1; // ok -double &i6 = u\ -8\ -R\ -"(foo)"\ -_\ -x\ -1; // ok diff --git a/test/CXX/lex/lex.literal/lex.ext/p6.cpp b/test/CXX/lex/lex.literal/lex.ext/p6.cpp deleted file mode 100644 index 23cd7081d5e3..000000000000 --- a/test/CXX/lex/lex.literal/lex.ext/p6.cpp +++ /dev/null @@ -1,14 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s - -using size_t = decltype(sizeof(int)); - -int &operator "" _x1 (const char *); -double &i1 = 'a'_x1; // expected-error {{no matching literal operator}} -double &operator "" _x1 (wchar_t); -double &i2 = L'a'_x1; -double &i3 = 'a'_x1; // expected-error {{no matching literal operator}} -double &i4 = operator"" _x1('a'); // ok - -char &operator "" _x1(char16_t); -char &i5 = u'a'_x1; // ok -double &i6 = L'a'_x1; // ok diff --git a/test/CXX/lex/lex.literal/lex.ext/p7.cpp b/test/CXX/lex/lex.literal/lex.ext/p7.cpp deleted file mode 100644 index 0b40ecdc143f..000000000000 --- a/test/CXX/lex/lex.literal/lex.ext/p7.cpp +++ /dev/null @@ -1,27 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s -triple=x86_64-linux-gnu - -using size_t = decltype(sizeof(int)); -namespace std { - struct string {}; -} - -template<typename T, typename U> struct same_type; -template<typename T> struct same_type<T, T> {}; - -namespace std_example { - -long double operator "" _w(long double); -std::string operator "" _w(const char16_t*, size_t); -unsigned operator "" _w(const char*); -int main() { - auto v1 = 1.2_w; // calls operator""_w(1.2L) - auto v2 = u"one"_w; // calls operator""_w(u"one", 3) - auto v3 = 12_w; // calls operator""_w("12") - "two"_w; // expected-error {{no matching literal operator for call to 'operator""_w' with arguments of types 'const char *' and 'unsigned long'}} - - same_type<decltype(v1), long double> test1; - same_type<decltype(v2), std::string> test2; - same_type<decltype(v3), unsigned> test3; -} - -} diff --git a/test/CXX/lex/lex.literal/lex.ext/p8.cpp b/test/CXX/lex/lex.literal/lex.ext/p8.cpp deleted file mode 100644 index d9078221ff5e..000000000000 --- a/test/CXX/lex/lex.literal/lex.ext/p8.cpp +++ /dev/null @@ -1,18 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -verify %s - -using size_t = decltype(sizeof(int)); -constexpr const char *operator "" _id(const char *p, size_t) { return p; } -constexpr const char *s = "foo"_id "bar" "baz"_id "quux"; - -constexpr bool streq(const char *p, const char *q) { - return *p == *q && (!*p || streq(p+1, q+1)); -} -static_assert(streq(s, "foobarbazquux"), ""); - -constexpr const char *operator "" _trim(const char *p, size_t n) { - return *p == ' ' ? operator "" _trim(p + 1, n - 1) : p; -} -constexpr const char *t = " " " "_trim " foo"; -static_assert(streq(t, "foo"), ""); - -const char *u = "foo" "bar"_id "baz" "quux"_di "corge"; // expected-error {{differing user-defined suffixes ('_id' and '_di') in string literal concatenation}} diff --git a/test/CXX/lex/lex.literal/lex.ext/p9.cpp b/test/CXX/lex/lex.literal/lex.ext/p9.cpp deleted file mode 100644 index 65e27b41b066..000000000000 --- a/test/CXX/lex/lex.literal/lex.ext/p9.cpp +++ /dev/null @@ -1,13 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s - -using size_t = decltype(sizeof(int)); -void operator "" _x(const wchar_t *, size_t); - -namespace std_example { - -int main() { - L"A" "B" "C"_x; - "P"_x "Q" "R"_y; // expected-error {{differing user-defined suffixes ('_x' and '_y') in string literal concatenation}} -} - -} diff --git a/test/CXX/lex/lex.literal/lex.string/p4.cpp b/test/CXX/lex/lex.literal/lex.string/p4.cpp deleted file mode 100644 index b73c8ed711a9..000000000000 --- a/test/CXX/lex/lex.literal/lex.string/p4.cpp +++ /dev/null @@ -1,17 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s -// expected-no-diagnostics - -// NOTE: This file intentionally uses DOS-style line endings to test -// that we don't propagate them into string literals as per [lex.string]p4. - -constexpr const char* p = R"(a\ -b -c)"; - -static_assert(p[0] == 'a', ""); -static_assert(p[1] == '\\', ""); -static_assert(p[2] == '\n', ""); -static_assert(p[3] == 'b', ""); -static_assert(p[4] == '\n', ""); -static_assert(p[5] == 'c', ""); -static_assert(p[6] == '\0', ""); diff --git a/test/CXX/lex/lex.pptoken/p3-0x.cpp b/test/CXX/lex/lex.pptoken/p3-0x.cpp deleted file mode 100644 index 418a0f3ae3f8..000000000000 --- a/test/CXX/lex/lex.pptoken/p3-0x.cpp +++ /dev/null @@ -1,15 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s - -int a<::> = { 1, 2, 3 }; -int b = a<:::a<:0:>:>; -bool c = a<:0:><::b; - -template<int &n> void f() {} -template void f<::b>(); - -#define x a<:: ## : b :> -int d = x; // expected-error {{pasting formed ':::', an invalid preprocessing token}} expected-error {{expected unqualified-id}} - -const char xs[] = R"(\ -??=\U0000)"; -static_assert(sizeof(xs) == 12, "did not revert all changes"); diff --git a/test/CXX/lex/lex.trigraph/p1.cpp b/test/CXX/lex/lex.trigraph/p1.cpp deleted file mode 100644 index a80b00eabe7e..000000000000 --- a/test/CXX/lex/lex.trigraph/p1.cpp +++ /dev/null @@ -1,19 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -ftrigraphs -Wtrigraphs -verify %s - -??=pragma // expected-warning {{trigraph converted to '#' character}} - -int a = '??/0'; // expected-warning {{trigraph converted to '\' character}} - -int b = 1 ??' 0; // expected-warning {{trigraph converted to '^' character}} - -int c ??(1]; // expected-warning {{trigraph converted to '[' character}} - -int d [1??); // expected-warning {{trigraph converted to ']' character}} - -int e = 1 ??! 0; // expected-warning {{trigraph converted to '|' character}} - -void f() ??<} // expected-warning {{trigraph converted to '{' character}} - -void g() {??> // expected-warning {{trigraph converted to '}' character}} - -int h = ??- 0; // expected-warning {{trigraph converted to '~' character}} diff --git a/test/CXX/lex/lex.trigraph/p2.cpp b/test/CXX/lex/lex.trigraph/p2.cpp deleted file mode 100644 index 6502aa8d7921..000000000000 --- a/test/CXX/lex/lex.trigraph/p2.cpp +++ /dev/null @@ -1,3 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -ftrigraphs -Wtrigraphs -verify %s - -??=define arraycheck(a,b) a??(b??) ??!??! b??(a??) // expected-warning {{trigraph converted to '#' character}} expected-warning {{trigraph converted to '[' character}} expected-warning {{trigraph converted to ']' character}} expected-warning {{trigraph converted to '|' character}} expected-warning {{trigraph converted to '|' character}} expected-warning {{trigraph converted to '[' character}} expected-warning {{trigraph converted to ']' character}} diff --git a/test/CXX/lex/lex.trigraph/p3.cpp b/test/CXX/lex/lex.trigraph/p3.cpp deleted file mode 100644 index bf935708a243..000000000000 --- a/test/CXX/lex/lex.trigraph/p3.cpp +++ /dev/null @@ -1,9 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -ftrigraphs -Wtrigraphs -verify %s -// expected-no-diagnostics - -char a[] = -"?? ??\"??#??$??%??&??*??+??,??.??0??1??2??3??4??5??6" -"??7??8??9??:??;?????@??A??B??C??D??E??F??G??H??I??J" -"??K??L??M??N??O??P??Q??R??S??T??U??V??W??X??Y??Z??[" -"??\\??]??^??_??`??a??b??c??d??e??f??g??h??i??j??k??l" -"??m??n??o??p??q??r??s??t??u??v??w??x??y??z??{??|??}??~"; diff --git a/test/CXX/modules-ts/basic/basic.def.odr/p4/module.cpp b/test/CXX/modules-ts/basic/basic.def.odr/p4/module.cpp deleted file mode 100644 index ad03191363e5..000000000000 --- a/test/CXX/modules-ts/basic/basic.def.odr/p4/module.cpp +++ /dev/null @@ -1,41 +0,0 @@ -// RUN: %clang_cc1 -fmodules-ts %S/module.cppm -triple %itanium_abi_triple -emit-module-interface -o %t -// RUN: %clang_cc1 -fmodules-ts %s -triple %itanium_abi_triple -fmodule-file=%t -emit-llvm -o - | FileCheck %s --implicit-check-not=unused --implicit-check-not=global_module - -// CHECK-DAG: @extern_var_exported = external {{(dso_local )?}}global -// CHECK-DAG: @inline_var_exported = linkonce_odr {{(dso_local )?}}global -// CHECK-DAG: @_ZW6ModuleE19static_var_exported = available_externally {{(dso_local )?}}global i32 0, -// CHECK-DAG: @const_var_exported = available_externally {{(dso_local )?}}constant i32 3, -// -// CHECK-DAG: @_ZW6ModuleE25extern_var_module_linkage = external {{(dso_local )?}}global -// CHECK-DAG: @_ZW6ModuleE25inline_var_module_linkage = linkonce_odr {{(dso_local )?}}global -// CHECK-DAG: @_ZW6ModuleE25static_var_module_linkage = available_externally {{(dso_local )?}}global i32 0, -// CHECK-DAG: @_ZW6ModuleE24const_var_module_linkage = available_externally {{(dso_local )?}}constant i32 3, - -module Module; - -void use() { - // CHECK: define linkonce_odr {{.*}}@_Z20used_inline_exportedv - used_inline_exported(); - // CHECK: declare {{.*}}@_Z18noninline_exportedv - noninline_exported(); - - (void)&extern_var_exported; - (void)&inline_var_exported; - (void)&static_var_exported; // FIXME: Should not be exported. - (void)&const_var_exported; - - // FIXME: This symbol should not be visible here. - // CHECK: declare {{.*}}@_ZW6ModuleE26used_static_module_linkagev - used_static_module_linkage(); - - // CHECK: define linkonce_odr {{.*}}@_ZW6ModuleE26used_inline_module_linkagev - used_inline_module_linkage(); - - // CHECK: declare {{.*}}@_ZW6ModuleE24noninline_module_linkagev - noninline_module_linkage(); - - (void)&extern_var_module_linkage; - (void)&inline_var_module_linkage; - (void)&static_var_module_linkage; // FIXME: Should not be visible here. - (void)&const_var_module_linkage; -} diff --git a/test/CXX/modules-ts/basic/basic.def.odr/p4/module.cppm b/test/CXX/modules-ts/basic/basic.def.odr/p4/module.cppm deleted file mode 100644 index 0f2c0db66e9c..000000000000 --- a/test/CXX/modules-ts/basic/basic.def.odr/p4/module.cppm +++ /dev/null @@ -1,129 +0,0 @@ -// RUN: %clang_cc1 -fmodules-ts %s -triple %itanium_abi_triple -emit-llvm -o - | FileCheck %s --implicit-check-not unused_inline --implicit-check-not unused_stastic_global_module - -// CHECK-DAG: @extern_var_global_module = external {{(dso_local )?}}global -// CHECK-DAG: @inline_var_global_module = linkonce_odr {{(dso_local )?}}global -// CHECK-DAG: @_ZL24static_var_global_module = internal global -// CHECK-DAG: @_ZL23const_var_global_module = internal constant -// -// For ABI compatibility, these symbols do not include the module name. -// CHECK-DAG: @extern_var_exported = external {{(dso_local )?}}global -// FIXME: Should this be 'weak_odr global'? Presumably it must be, since we -// can discard this global and its initializer (if any), and other TUs are not -// permitted to run the initializer for this variable. -// CHECK-DAG: @inline_var_exported = linkonce_odr {{(dso_local )?}}global -// CHECK-DAG: @_ZW6ModuleE19static_var_exported = {{(dso_local )?}}global -// CHECK-DAG: @const_var_exported = {{(dso_local )?}}constant -// -// CHECK-DAG: @_ZW6ModuleE25extern_var_module_linkage = external {{(dso_local )?}}global -// FIXME: Should this be 'weak_odr global'? Presumably it must be, since we -// can discard this global and its initializer (if any), and other TUs are not -// permitted to run the initializer for this variable. -// CHECK-DAG: @_ZW6ModuleE25inline_var_module_linkage = linkonce_odr {{(dso_local )?}}global -// CHECK-DAG: @_ZW6ModuleE25static_var_module_linkage = {{(dso_local )?}}global -// CHECK-DAG: @_ZW6ModuleE24const_var_module_linkage = {{(dso_local )?}}constant -// -// CHECK-DAG: @_ZW6ModuleE25unused_var_module_linkage = {{(dso_local )?}}global i32 4 -// CHECK-DAG: @_ZW6ModuleE32unused_static_var_module_linkage = {{(dso_local )?}}global i32 5 -// CHECK-DAG: @_ZW6ModuleE31unused_const_var_module_linkage = {{(dso_local )?}}constant i32 7 - -static void unused_static_global_module() {} -static void used_static_global_module() {} - -inline void unused_inline_global_module() {} -inline void used_inline_global_module() {} - -extern int extern_var_global_module; -inline int inline_var_global_module; -static int static_var_global_module; -const int const_var_global_module = 3; - -// CHECK: define {{(dso_local )?}}void {{.*}}@_Z23noninline_global_modulev -void noninline_global_module() { - // FIXME: This should be promoted to module linkage and given a - // module-mangled name, if it's called from an inline function within - // the module interface. - // (We should try to avoid this when it's not reachable from outside - // the module interface unit.) - // CHECK: define internal {{.*}}@_ZL25used_static_global_modulev - used_static_global_module(); - // CHECK: define linkonce_odr {{.*}}@_Z25used_inline_global_modulev - used_inline_global_module(); - - (void)&extern_var_global_module; - (void)&inline_var_global_module; - (void)&static_var_global_module; - (void)&const_var_global_module; -} - -export module Module; - -export { - // FIXME: These should be ill-formed: you can't export an internal linkage - // symbol, per [dcl.module.interface]p2. - // CHECK: define {{(dso_local )?}}void {{.*}}@_ZW6ModuleE22unused_static_exportedv - static void unused_static_exported() {} - // CHECK: define {{(dso_local )?}}void {{.*}}@_ZW6ModuleE20used_static_exportedv - static void used_static_exported() {} - - inline void unused_inline_exported() {} - inline void used_inline_exported() {} - - extern int extern_var_exported; - inline int inline_var_exported; - // FIXME: This should be ill-formed: you can't export an internal linkage - // symbol. - static int static_var_exported; - const int const_var_exported = 3; - - // CHECK: define {{(dso_local )?}}void {{.*}}@_Z18noninline_exportedv - void noninline_exported() { - used_static_exported(); - // CHECK: define linkonce_odr {{.*}}@_Z20used_inline_exportedv - used_inline_exported(); - - (void)&extern_var_exported; - (void)&inline_var_exported; - (void)&static_var_exported; - (void)&const_var_exported; - } -} - -// FIXME: Ideally we wouldn't emit this as its name is not visible outside this -// TU, but this module interface might contain a template that can use this -// function so we conservatively emit it for now. -// CHECK: define {{(dso_local )?}}void {{.*}}@_ZW6ModuleE28unused_static_module_linkagev -static void unused_static_module_linkage() {} -// CHECK: define {{(dso_local )?}}void {{.*}}@_ZW6ModuleE26used_static_module_linkagev -static void used_static_module_linkage() {} - -inline void unused_inline_module_linkage() {} -inline void used_inline_module_linkage() {} - -extern int extern_var_module_linkage; -inline int inline_var_module_linkage; -static int static_var_module_linkage; -const int const_var_module_linkage = 3; - -// CHECK: define {{(dso_local )?}}void {{.*}}@_ZW6ModuleE24noninline_module_linkagev -void noninline_module_linkage() { - used_static_module_linkage(); - // CHECK: define linkonce_odr {{.*}}@_ZW6ModuleE26used_inline_module_linkagev - used_inline_module_linkage(); - - (void)&extern_var_module_linkage; - (void)&inline_var_module_linkage; - (void)&static_var_module_linkage; - (void)&const_var_module_linkage; -} - -int unused_var_module_linkage = 4; -static int unused_static_var_module_linkage = 5; -inline int unused_inline_var_module_linkage = 6; -const int unused_const_var_module_linkage = 7; - -struct a { - struct b {}; - struct c {}; -}; -// CHECK: define {{(dso_local )?}}void @_ZW6ModuleE1fW_0EN1a1bEW_0ENS_1cE( -void f(a::b, a::c) {} diff --git a/test/CXX/modules-ts/basic/basic.def.odr/p4/user.cpp b/test/CXX/modules-ts/basic/basic.def.odr/p4/user.cpp deleted file mode 100644 index 97c69fa0bbee..000000000000 --- a/test/CXX/modules-ts/basic/basic.def.odr/p4/user.cpp +++ /dev/null @@ -1,23 +0,0 @@ -// RUN: %clang_cc1 -fmodules-ts %S/module.cppm -triple %itanium_abi_triple -emit-module-interface -o %t -// RUN: %clang_cc1 -fmodules-ts %s -triple %itanium_abi_triple -fmodule-file=%t -emit-llvm -o - | FileCheck %s --implicit-check-not=unused --implicit-check-not=global_module - -// CHECK-DAG: @extern_var_exported = external {{(dso_local )?}}global -// CHECK-DAG: @inline_var_exported = linkonce_odr {{(dso_local )?}}global -// CHECK-DAG: @_ZW6ModuleE19static_var_exported = available_externally {{(dso_local )?}}global i32 0 -// CHECK-DAG: @const_var_exported = available_externally {{(dso_local )?}}constant i32 3 - -import Module; - -void use() { - // CHECK: define linkonce_odr {{.*}}@_Z20used_inline_exportedv - used_inline_exported(); - // CHECK: declare {{.*}}@_Z18noninline_exportedv - noninline_exported(); - - (void)&extern_var_exported; - (void)&inline_var_exported; - (void)&static_var_exported; - (void)&const_var_exported; - - // Module-linkage declarations are not visible here. -} diff --git a/test/CXX/modules-ts/basic/basic.def.odr/p6/global-vs-module.cpp b/test/CXX/modules-ts/basic/basic.def.odr/p6/global-vs-module.cpp deleted file mode 100644 index cceca5106cae..000000000000 --- a/test/CXX/modules-ts/basic/basic.def.odr/p6/global-vs-module.cpp +++ /dev/null @@ -1,55 +0,0 @@ -// RUN: %clang_cc1 -fmodules-ts -verify -std=c++17 %s -// RUN: %clang_cc1 -fmodules-ts -verify -std=c++17 %s -DEXPORT -// RUN: %clang_cc1 -fmodules-ts -verify -std=c++17 %s -DUSING - -#ifndef NO_GLOBAL -extern int var; // expected-note {{previous declaration is here}} -int func(); // expected-note {{previous declaration is here}} -struct str; // expected-note {{previous declaration is here}} -using type = int; - -template<typename> extern int var_tpl; // expected-note {{previous declaration is here}} -template<typename> int func_tpl(); // expected-note-re {{{{previous declaration is here|target of using declaration}}}} -template<typename> struct str_tpl; // expected-note {{previous declaration is here}} -template<typename> using type_tpl = int; // expected-note {{previous declaration is here}} - -typedef int type; -namespace ns { using ::func; } -namespace ns_alias = ns; -#endif - -export module M; - -#ifdef USING -using ::var; -using ::func; -using ::str; -using ::type; -using ::var_tpl; -using ::func_tpl; // expected-note {{using declaration}} -using ::str_tpl; -using ::type_tpl; -#endif - -#ifdef EXPORT -export { -#endif - -extern int var; // expected-error {{declaration of 'var' in module M follows declaration in the global module}} -int func(); // expected-error {{declaration of 'func' in module M follows declaration in the global module}} -struct str; // expected-error {{declaration of 'str' in module M follows declaration in the global module}} -using type = int; - -template<typename> extern int var_tpl; // expected-error {{declaration of 'var_tpl' in module M follows declaration in the global module}} -// FIXME: Is this the right diagnostic in the -DUSING case? -template<typename> int func_tpl(); // expected-error-re {{{{declaration of 'func_tpl' in module M follows declaration in the global module|conflicts with target of using declaration}}}} -template<typename> struct str_tpl; // expected-error {{declaration of 'str_tpl' in module M follows declaration in the global module}} -template<typename> using type_tpl = int; // expected-error {{declaration of 'type_tpl' in module M follows declaration in the global module}} - -typedef int type; -namespace ns { using ::func; } -namespace ns_alias = ns; - -#ifdef EXPORT -} -#endif diff --git a/test/CXX/modules-ts/basic/basic.def.odr/p6/module-vs-global.cpp b/test/CXX/modules-ts/basic/basic.def.odr/p6/module-vs-global.cpp deleted file mode 100644 index f58506dd9c46..000000000000 --- a/test/CXX/modules-ts/basic/basic.def.odr/p6/module-vs-global.cpp +++ /dev/null @@ -1,19 +0,0 @@ -// RUN: rm -rf %t -// RUN: %clang_cc1 -fmodules-ts -emit-module-interface -std=c++17 %S/global-vs-module.cpp -o %t -DNO_GLOBAL -DEXPORT -// RUN: %clang_cc1 -fmodules-ts -verify -std=c++17 %s -fmodule-file=%t - -import M; - -extern int var; // expected-error {{declaration of 'var' in the global module follows declaration in module M}} expected-note@global-vs-module.cpp:38 {{previous}} -int func(); // expected-error {{declaration of 'func' in the global module follows declaration in module M}} expected-note@global-vs-module.cpp:39 {{previous}} -struct str; // expected-error {{declaration of 'str' in the global module follows declaration in module M}} expected-note@global-vs-module.cpp:40 {{previous}} -using type = int; - -template<typename> extern int var_tpl; // expected-error {{declaration of 'var_tpl' in the global module follows declaration in module M}} expected-note@global-vs-module.cpp:43 {{previous}} -template<typename> int func_tpl(); // expected-error {{declaration of 'func_tpl' in the global module follows declaration in module M}} expected-note@global-vs-module.cpp:45 {{previous}} -template<typename> struct str_tpl; // expected-error {{declaration of 'str_tpl' in the global module follows declaration in module M}} expected-note@global-vs-module.cpp:46 {{previous}} -template<typename> using type_tpl = int; // expected-error {{declaration of 'type_tpl' in the global module follows declaration in module M}} expected-note@global-vs-module.cpp:47 {{previous}} - -typedef int type; -namespace ns { using ::func; } -namespace ns_alias = ns; diff --git a/test/CXX/modules-ts/basic/basic.def.odr/p6/module-vs-module.cpp b/test/CXX/modules-ts/basic/basic.def.odr/p6/module-vs-module.cpp deleted file mode 100644 index 39e210c4ad80..000000000000 --- a/test/CXX/modules-ts/basic/basic.def.odr/p6/module-vs-module.cpp +++ /dev/null @@ -1,44 +0,0 @@ -// RUN: rm -rf %t -// RUN: mkdir %t -// -// Some of the following tests intentionally have no -verify in their RUN -// lines; we are testing that those cases do not produce errors. -// -// RUN: %clang_cc1 -fmodules-ts -std=c++17 %S/global-vs-module.cpp -emit-module-interface -o %t/M.pcm -DNO_GLOBAL -DEXPORT -// RUN: %clang_cc1 -fmodules-ts -std=c++17 %s -fmodule-file=%t/M.pcm -DMODULE_INTERFACE -verify -// RUN: %clang_cc1 -fmodules-ts -std=c++17 %s -fmodule-file=%t/M.pcm -DMODULE_INTERFACE -DNO_IMPORT -// -// RUN: %clang_cc1 -fmodules-ts -std=c++17 %s -fmodule-file=%t/M.pcm -emit-module-interface -o %t/N.pcm -DMODULE_INTERFACE -DNO_ERRORS -// RUN: %clang_cc1 -fmodules-ts -std=c++17 %s -fmodule-file=%t/N.pcm -verify -// FIXME: Once we start importing "import" declarations properly, this should -// be rejected (-verify should be added to the following line). -// RUN: %clang_cc1 -fmodules-ts -std=c++17 %s -fmodule-file=%t/N.pcm -DNO_IMPORT -// -// RUN: %clang_cc1 -fmodules-ts -std=c++17 %s -fmodule-file=%t/M.pcm -emit-module-interface -o %t/N-no-M.pcm -DMODULE_INTERFACE -DNO_ERRORS -DNO_IMPORT -// RUN: %clang_cc1 -fmodules-ts -std=c++17 %s -fmodule-file=%t/N-no-M.pcm -verify -// RUN: %clang_cc1 -fmodules-ts -std=c++17 %s -fmodule-file=%t/N-no-M.pcm -DNO_IMPORT - -#ifdef MODULE_INTERFACE -export -#endif -module N; - -#ifndef NO_IMPORT -import M; -#endif - -#ifndef NO_ERRORS -extern int var; // expected-error {{declaration of 'var' in module N follows declaration in module M}} expected-note@global-vs-module.cpp:38 {{previous}} -int func(); // expected-error {{declaration of 'func' in module N follows declaration in module M}} expected-note@global-vs-module.cpp:39 {{previous}} -struct str; // expected-error {{declaration of 'str' in module N follows declaration in module M}} expected-note@global-vs-module.cpp:40 {{previous}} -using type = int; - -template<typename> extern int var_tpl; // expected-error {{declaration of 'var_tpl' in module N follows declaration in module M}} expected-note@global-vs-module.cpp:43 {{previous}} -template<typename> int func_tpl(); // expected-error {{declaration of 'func_tpl' in module N follows declaration in module M}} expected-note@global-vs-module.cpp:45 {{previous}} -template<typename> struct str_tpl; // expected-error {{declaration of 'str_tpl' in module N follows declaration in module M}} expected-note@global-vs-module.cpp:46 {{previous}} -template<typename> using type_tpl = int; // expected-error {{declaration of 'type_tpl' in module N follows declaration in module M}} expected-note@global-vs-module.cpp:47 {{previous}} - -typedef int type; -namespace ns { using ::func; } -namespace ns_alias = ns; -#endif diff --git a/test/CXX/modules-ts/basic/basic.link/module-declaration.cpp b/test/CXX/modules-ts/basic/basic.link/module-declaration.cpp deleted file mode 100644 index feb0afdda07b..000000000000 --- a/test/CXX/modules-ts/basic/basic.link/module-declaration.cpp +++ /dev/null @@ -1,56 +0,0 @@ -// Tests for module-declaration syntax. -// -// RUN: rm -rf %t -// RUN: mkdir -p %t -// RUN: echo 'export module x; int a, b;' > %t/x.cppm -// RUN: echo 'export module x.y; int c;' > %t/x.y.cppm -// -// RUN: %clang_cc1 -std=c++1z -fmodules-ts -emit-module-interface %t/x.cppm -o %t/x.pcm -// RUN: %clang_cc1 -std=c++1z -fmodules-ts -emit-module-interface -fmodule-file=%t/x.pcm %t/x.y.cppm -o %t/x.y.pcm -// -// Module implementation for unknown and known module. (The former is ill-formed.) -// RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=%t/x.y.pcm -verify %s \ -// RUN: -DTEST=1 -DEXPORT= -DPARTITION= -DMODULE_NAME=z -// RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=%t/x.y.pcm -verify %s \ -// RUN: -DTEST=2 -DEXPORT= -DPARTITION= -DMODULE_NAME=x -// -// Module interface for unknown and known module. (The latter is ill-formed due to -// redefinition.) -// RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=%t/x.y.pcm -verify %s \ -// RUN: -DTEST=3 -DEXPORT=export -DPARTITION= -DMODULE_NAME=z -// RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=%t/x.y.pcm -verify %s \ -// RUN: -DTEST=4 -DEXPORT=export -DPARTITION= -DMODULE_NAME=x -// -// Defining a module partition. -// RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=%t/x.y.pcm -verify %s \ -// RUN: -DTEST=5 -DEXPORT=export -DPARTITION=partition -DMODULE_NAME=z -// RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=%t/x.y.pcm -verify %s \ -// RUN: -DTEST=6 -DEXPORT= -DPARTITION=partition -DMODULE_NAME=z -// -// Miscellaneous syntax. -// RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=%t/x.y.pcm -verify %s \ -// RUN: -DTEST=7 -DEXPORT= -DPARTITION=elderberry -DMODULE_NAME=z -// RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=%t/x.y.pcm -verify %s \ -// RUN: -DTEST=8 -DEXPORT=export -DPARTITION= -DMODULE_NAME='z [[]]' -// RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=%t/x.y.pcm -verify %s \ -// RUN: -DTEST=9 -DEXPORT=export -DPARTITION= -DMODULE_NAME='z [[fancy]]' -// RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=%t/x.y.pcm -verify %s \ -// RUN: -DTEST=10 -DEXPORT=export -DPARTITION= -DMODULE_NAME='z [[maybe_unused]]' - -EXPORT module PARTITION MODULE_NAME; -#if TEST == 4 -// expected-error@-2 {{redefinition of module 'x'}} -// expected-note-re@module-declaration.cpp:* {{loaded from '{{.*[/\\]}}x.pcm'}} -#elif TEST == 6 -// expected-error@-5 {{module partition must be declared 'export'}} -#elif TEST == 7 -// expected-error@-7 {{expected ';'}} expected-error@-7 {{requires a type specifier}} expected-error@-7 {{definition of module 'elderberry' is not available}} -#elif TEST == 9 -// expected-warning@-9 {{unknown attribute 'fancy' ignored}} -#elif TEST == 10 -// expected-error-re@-11 {{'maybe_unused' attribute cannot be applied to a module{{$}}}} -#elif TEST == 1 -// expected-error@-13 {{definition of module 'z' is not available}} -#else -// expected-no-diagnostics -#endif diff --git a/test/CXX/modules-ts/basic/basic.link/p2/module.cpp b/test/CXX/modules-ts/basic/basic.link/p2/module.cpp deleted file mode 100644 index 3fc6044d8e94..000000000000 --- a/test/CXX/modules-ts/basic/basic.link/p2/module.cpp +++ /dev/null @@ -1,17 +0,0 @@ -// RUN: %clang_cc1 -std=c++1z -fmodules-ts %S/module.cppm -emit-module-interface -o %t -// RUN: %clang_cc1 -std=c++1z -fmodules-ts -fmodule-file=%t %s -verify -// expected-no-diagnostics -module M; - -// FIXME: Use of internal linkage entities should be rejected. -void use_from_module_impl() { - external_linkage_fn(); - module_linkage_fn(); - internal_linkage_fn(); - (void)external_linkage_class{}; - (void)module_linkage_class{}; - (void)internal_linkage_class{}; - (void)external_linkage_var; - (void)module_linkage_var; - (void)internal_linkage_var; -} diff --git a/test/CXX/modules-ts/basic/basic.link/p2/module.cppm b/test/CXX/modules-ts/basic/basic.link/p2/module.cppm deleted file mode 100644 index bb261700db84..000000000000 --- a/test/CXX/modules-ts/basic/basic.link/p2/module.cppm +++ /dev/null @@ -1,29 +0,0 @@ -// RUN: %clang_cc1 -std=c++1z -fmodules-ts %s -verify -// expected-no-diagnostics -export module M; - -export int external_linkage_var; -int module_linkage_var; -static int internal_linkage_var; - -export void external_linkage_fn() {} -void module_linkage_fn() {} -static void internal_linkage_fn() {} - -export struct external_linkage_class {}; -struct module_linkage_class {}; -namespace { - struct internal_linkage_class {}; -} - -void use() { - external_linkage_fn(); - module_linkage_fn(); - internal_linkage_fn(); - (void)external_linkage_class{}; - (void)module_linkage_class{}; - (void)internal_linkage_class{}; - (void)external_linkage_var; - (void)module_linkage_var; - (void)internal_linkage_var; -} diff --git a/test/CXX/modules-ts/basic/basic.link/p2/other.cpp b/test/CXX/modules-ts/basic/basic.link/p2/other.cpp deleted file mode 100644 index 8370777e7ed4..000000000000 --- a/test/CXX/modules-ts/basic/basic.link/p2/other.cpp +++ /dev/null @@ -1,16 +0,0 @@ -// RUN: %clang_cc1 -std=c++1z -fmodules-ts %S/module.cppm -emit-module-interface -o %t -// RUN: %clang_cc1 -std=c++1z -fmodules-ts -fmodule-file=%t %s -verify -import M; - -void use_from_module_impl() { - external_linkage_fn(); - module_linkage_fn(); // expected-error {{undeclared identifier}} - internal_linkage_fn(); // expected-error {{undeclared identifier}} - (void)external_linkage_class{}; - (void)module_linkage_class{}; // expected-error {{undeclared identifier}} expected-error 0+{{}} - (void)internal_linkage_class{}; // expected-error {{undeclared identifier}} expected-error 0+{{}} - // expected-note@module.cppm:9 {{here}} - (void)external_linkage_var; - (void)module_linkage_var; // expected-error {{undeclared identifier}} - (void)internal_linkage_var; // expected-error {{undeclared identifier}} -} diff --git a/test/CXX/modules-ts/basic/basic.link/p3.cppm b/test/CXX/modules-ts/basic/basic.link/p3.cppm deleted file mode 100644 index 8ff141c5ff6b..000000000000 --- a/test/CXX/modules-ts/basic/basic.link/p3.cppm +++ /dev/null @@ -1,11 +0,0 @@ -// RUN: %clang_cc1 -fmodules-ts -triple x86_64-linux %s -emit-module-interface -o %t -// RUN: %clang_cc1 -fmodules-ts -triple x86_64-linux -x pcm %t -emit-llvm -o - | FileCheck %s - -export module M; - -// CHECK-DAG: @_ZW1ME1a = constant i32 1 -const int a = 1; -// CHECK-DAG: @b = constant i32 2 -export const int b = 2; - -export int f() { return a + b; } diff --git a/test/CXX/modules-ts/basic/basic.search/module-import.cpp b/test/CXX/modules-ts/basic/basic.search/module-import.cpp deleted file mode 100644 index 0b5f39d072a3..000000000000 --- a/test/CXX/modules-ts/basic/basic.search/module-import.cpp +++ /dev/null @@ -1,39 +0,0 @@ -// Tests for imported module search. -// -// RUN: rm -rf %t -// RUN: mkdir -p %t -// RUN: echo 'export module x; int a, b;' > %t/x.cppm -// RUN: echo 'export module y; import x; int c;' > %t/y.cppm -// RUN: echo 'export module z; import y; int d;' > %t/z.cppm -// -// RUN: %clang_cc1 -std=c++1z -fmodules-ts -emit-module-interface %t/x.cppm -o %t/x.pcm -// RUN: %clang_cc1 -std=c++1z -fmodules-ts -emit-module-interface -fmodule-file=%t/x.pcm %t/y.cppm -o %t/y.pcm -// -// RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=%t/x.pcm -verify %s \ -// RUN: -DMODULE_NAME=x -// RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=%t/y.pcm -verify %s \ -// RUN: -DMODULE_NAME=y -// -// RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=x=%t/x.pcm -verify %s \ -// RUN: -DMODULE_NAME=x -// RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=y=%t/y.pcm -verify %s \ -// RUN: -DMODULE_NAME=y -// -// RUN: mv %t/x.pcm %t/a.pcm -// -// RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=x=%t/a.pcm -verify %s \ -// RUN: -DMODULE_NAME=x -// RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=%t/y.pcm -fmodule-file=x=%t/a.pcm -verify %s \ -// RUN: -DMODULE_NAME=y -// RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=y=%t/y.pcm -fmodule-file=x=%t/a.pcm -verify %s \ -// RUN: -DMODULE_NAME=y -// -// RUN: %clang_cc1 -std=c++1z -fmodules-ts -emit-module-interface -fmodule-file=y=%t/y.pcm -fmodule-file=x=%t/a.pcm %t/z.cppm -o %t/z.pcm -// -// RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=z=%t/z.pcm -fmodule-file=y=%t/y.pcm -fmodule-file=x=%t/a.pcm -verify %s \ -// RUN: -DMODULE_NAME=z -// - -import MODULE_NAME; - -// expected-no-diagnostics diff --git a/test/CXX/modules-ts/codegen-basics.cppm b/test/CXX/modules-ts/codegen-basics.cppm deleted file mode 100644 index a85e12df26f6..000000000000 --- a/test/CXX/modules-ts/codegen-basics.cppm +++ /dev/null @@ -1,21 +0,0 @@ -// RUN: %clang_cc1 -fmodules-ts -std=c++1z -triple=x86_64-linux-gnu -fmodules-codegen -emit-module-interface %s -o %t.pcm -// RUN: %clang_cc1 -fmodules-ts -std=c++1z -triple=x86_64-linux-gnu %t.pcm -emit-llvm -o - | FileCheck %s - -export module FooBar; - -export { - // CHECK-DAG: define i32 @_Z1fv( - int f() { return 0; } -} - -// CHECK-DAG: define weak_odr void @_ZW6FooBarE2f2v( -inline void f2() { } - -// CHECK-DAG: define void @_ZW6FooBarE2f3v( -static void f3() {} -export void use_f3() { f3(); } - -// FIXME: Emit global variables and their initializers with this TU. -// Emit an initialization function that other TUs can call, with guard variable? - -// FIXME: const-qualified variables don't have implicit internal linkage when owned by a module. diff --git a/test/CXX/modules-ts/dcl.dcl/dcl.module/dcl.module.export/p1.cpp b/test/CXX/modules-ts/dcl.dcl/dcl.module/dcl.module.export/p1.cpp deleted file mode 100644 index ab8c690441ca..000000000000 --- a/test/CXX/modules-ts/dcl.dcl/dcl.module/dcl.module.export/p1.cpp +++ /dev/null @@ -1,40 +0,0 @@ -// RUN: rm -rf %t -// RUN: mkdir -p %t -// -// RUN: echo 'export module a; export class A{};' | %clang_cc1 -x c++ -fmodules-ts -emit-module-interface - -o %t/a.pcm -// RUN: echo 'export module b; export class B{};' | %clang_cc1 -x c++ -fmodules-ts -emit-module-interface - -o %t/b.pcm -// RUN: echo 'export module c; export class C{};' | %clang_cc1 -x c++ -fmodules-ts -emit-module-interface - -o %t/c.pcm -// -// RUN: %clang_cc1 -fmodules-ts -fprebuilt-module-path=%t -emit-module-interface %s -o %t/aggregate.internal.pcm -DAGGREGATE_INTERNAL -// RUN: %clang_cc1 -fmodules-ts -fprebuilt-module-path=%t -emit-module-interface %s -o %t/aggregate.pcm -DAGGREGATE -// -// RUN: %clang_cc1 -fmodules-ts -fprebuilt-module-path=%t %s -verify -DTEST -// expected-no-diagnostics - - -#ifdef AGGREGATE_INTERNAL -export module aggregate.internal; -export import a; -export { - import b; - import c; -} -#endif - - -// Export the above aggregate module. -// This is done to ensure that re-exports are transitive. -#ifdef AGGREGATE -export module aggregate; -export import aggregate.internal; -#endif - - -// For the actual test, just try using the classes from the exported modules -// and hope that they're accessible. -#ifdef TEST -import aggregate; -A a; -B b; -C c; -#endif diff --git a/test/CXX/modules-ts/dcl.dcl/dcl.module/dcl.module.import/p1.cpp b/test/CXX/modules-ts/dcl.dcl/dcl.module/dcl.module.import/p1.cpp deleted file mode 100644 index 15900c1f6a3a..000000000000 --- a/test/CXX/modules-ts/dcl.dcl/dcl.module/dcl.module.import/p1.cpp +++ /dev/null @@ -1,49 +0,0 @@ -// RUN: rm -rf %t -// RUN: mkdir -p %t -// RUN: echo 'export module x; export int a, b;' > %t/x.cppm -// RUN: echo 'export module x.y; export int c;' > %t/x.y.cppm -// RUN: echo 'export module a.b; export int d;' > %t/a.b.cppm -// -// RUN: %clang_cc1 -std=c++1z -fmodules-ts -emit-module-interface %t/x.cppm -o %t/x.pcm -// RUN: %clang_cc1 -std=c++1z -fmodules-ts -emit-module-interface -fmodule-file=%t/x.pcm %t/x.y.cppm -o %t/x.y.pcm -// RUN: %clang_cc1 -std=c++1z -fmodules-ts -emit-module-interface %t/a.b.cppm -o %t/a.b.pcm -// -// RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=%t/x.y.pcm -fmodule-file=%t/a.b.pcm -verify %s \ -// RUN: -DMODULE_NAME=z -DINTERFACE -// RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=%t/x.y.pcm -fmodule-file=%t/a.b.pcm -verify %s \ -// RUN: -DMODULE_NAME=a.b -// RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=%t/x.y.pcm -fmodule-file=%t/a.b.pcm -verify %s \ -// RUN: -DMODULE_X -DMODULE_NAME=x - -#ifdef INTERFACE -export -#endif -module MODULE_NAME; - -int use_1 = a; -#if !MODULE_X -// expected-error@-2 {{declaration of 'a' must be imported from module 'x' before it is required}} -// expected-note@x.cppm:1 {{here}} -#endif - -import x; - -int use_2 = b; // ok - -// There is no relation between module x and module x.y. -int use_3 = c; // expected-error {{declaration of 'c' must be imported from module 'x.y'}} - // expected-note@x.y.cppm:1 {{here}} - -import x [[]]; -import x [[foo]]; // expected-warning {{unknown attribute 'foo' ignored}} -import x [[noreturn]]; // expected-error {{'noreturn' attribute cannot be applied to a module import}} -import x [[blarg::noreturn]]; // expected-warning {{unknown attribute 'noreturn' ignored}} - -import x.y; -import a.b; // Does not imply existence of module a. -import x.; // expected-error {{expected a module name after 'import'}} -import .x; // expected-error {{expected a module name after 'import'}} - -int use_4 = c; // ok - -import blarg; // expected-error {{module 'blarg' not found}} diff --git a/test/CXX/modules-ts/dcl.dcl/dcl.module/dcl.module.interface/p1.cpp b/test/CXX/modules-ts/dcl.dcl/dcl.module/dcl.module.interface/p1.cpp deleted file mode 100644 index 68f2570dd3e6..000000000000 --- a/test/CXX/modules-ts/dcl.dcl/dcl.module/dcl.module.interface/p1.cpp +++ /dev/null @@ -1,28 +0,0 @@ -// RUN: %clang_cc1 -fmodules-ts %s -verify -o /dev/null -// RUN: %clang_cc1 -fmodules-ts %s -DINTERFACE -verify -emit-module-interface -o %t -// RUN: %clang_cc1 -fmodules-ts %s -DIMPLEMENTATION -verify -fmodule-file=%t -o /dev/null -// -// RUN: %clang_cc1 -fmodules-ts %s -DBUILT_AS_INTERFACE -emit-module-interface -verify -o /dev/null -// RUN: %clang_cc1 -fmodules-ts %s -DINTERFACE -DBUILT_AS_INTERFACE -emit-module-interface -verify -o /dev/null -// RUN: %clang_cc1 -fmodules-ts %s -DIMPLEMENTATION -DBUILT_AS_INTERFACE -emit-module-interface -verify -o /dev/null - -#if INTERFACE -// expected-no-diagnostics -export module A; -#elif IMPLEMENTATION -module A; - #ifdef BUILT_AS_INTERFACE - // expected-error@-2 {{missing 'export' specifier in module declaration while building module interface}} - #define INTERFACE - #endif -#else - #ifdef BUILT_AS_INTERFACE - // expected-error@1 {{missing 'export module' declaration in module interface unit}} - #endif -#endif - -#ifndef INTERFACE -export int b; // expected-error {{export declaration can only be used within a module interface unit}} -#else -export int a; -#endif diff --git a/test/CXX/modules-ts/dcl.dcl/dcl.module/p1.cpp b/test/CXX/modules-ts/dcl.dcl/dcl.module/p1.cpp deleted file mode 100644 index 2393aa184317..000000000000 --- a/test/CXX/modules-ts/dcl.dcl/dcl.module/p1.cpp +++ /dev/null @@ -1,14 +0,0 @@ -// RUN: %clang_cc1 -std=c++17 -fmodules-ts -verify %s -DFOO=export -DBAR=export -// RUN: %clang_cc1 -std=c++17 -fmodules-ts -verify %s -DFOO=export -DBAR= -// RUN: %clang_cc1 -std=c++17 -fmodules-ts %s -DFOO=export -emit-module-interface -o %t -// RUN: %clang_cc1 -std=c++17 -fmodules-ts %s -fmodule-file=%t -DFOO= -// RUN: %clang_cc1 -std=c++17 -fmodules-ts %s -fmodule-file=%t -DBAR=export -// RUN: %clang_cc1 -std=c++17 -fmodules-ts -verify %s -fmodule-file=%t -DFOO= -DBAR=export - -#ifdef FOO -FOO module foo; // expected-note {{previous module declaration is here}} -#endif - -#ifdef BAR -BAR module bar; // expected-error {{translation unit contains multiple module declarations}} -#endif diff --git a/test/CXX/modules-ts/dcl.dcl/dcl.module/p2.cpp b/test/CXX/modules-ts/dcl.dcl/dcl.module/p2.cpp deleted file mode 100644 index 992715e6b102..000000000000 --- a/test/CXX/modules-ts/dcl.dcl/dcl.module/p2.cpp +++ /dev/null @@ -1,6 +0,0 @@ -// RUN: %clang_cc1 -fmodules-ts -verify %s - -// A named module shall contain exactly one module interface unit. -module M; // expected-error {{definition of module 'M' is not available; use -fmodule-file= to specify path to precompiled module interface}} - -// FIXME: How do we ensure there is not more than one? diff --git a/test/CXX/modules-ts/dcl.dcl/dcl.module/p5.cpp b/test/CXX/modules-ts/dcl.dcl/dcl.module/p5.cpp deleted file mode 100644 index 734b89173df9..000000000000 --- a/test/CXX/modules-ts/dcl.dcl/dcl.module/p5.cpp +++ /dev/null @@ -1,33 +0,0 @@ -// RUN: rm -f %t -// RUN: %clang_cc1 -std=c++1z -fmodules-ts -emit-module-interface %s -o %t -DINTERFACE -// RUN: %clang_cc1 -std=c++1z -fmodules-ts -fmodule-file=%t %s -verify -DIMPLEMENTATION -// RUN: %clang_cc1 -std=c++1z -fmodules-ts -fmodule-file=%t %s -verify -DEARLY_IMPLEMENTATION -// RUN: %clang_cc1 -std=c++1z -fmodules-ts -fmodule-file=%t %s -verify -DUSER - -// expected-no-diagnostics - -#ifdef USER -import Foo; -#endif - -#ifdef EARLY_IMPLEMENTATION -module Foo; -#endif - -template<typename T> struct type_template { - typedef T type; - void f(type); -}; - -template<typename T> void type_template<T>::f(type) {} - -template<int = 0, typename = int, template<typename> class = type_template> -struct default_template_args {}; - -#ifdef INTERFACE -export module Foo; -#endif - -#ifdef IMPLEMENTATION -module Foo; -#endif diff --git a/test/CXX/over/over.built/p15.cpp b/test/CXX/over/over.built/p15.cpp deleted file mode 100644 index 9b223bcbc24d..000000000000 --- a/test/CXX/over/over.built/p15.cpp +++ /dev/null @@ -1,75 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -verify %s -Wno-tautological-compare - -struct A { operator decltype(nullptr)(); }; // expected-note 16{{implicitly converted}} -struct B { operator const int *(); }; // expected-note 8{{implicitly converted}} -void f(A a, B b, volatile int *pi) { - (void)(a == a); - (void)(a != a); - (void)(a < a); // expected-error {{invalid operands}} - (void)(a > a); // expected-error {{invalid operands}} - (void)(a <= a); // expected-error {{invalid operands}} - (void)(a >= a); // expected-error {{invalid operands}} - - (void)(a == b); - (void)(a != b); - (void)(a < b); // expected-error {{invalid operands}} - (void)(a > b); // expected-error {{invalid operands}} - (void)(a <= b); // expected-error {{invalid operands}} - (void)(a >= b); // expected-error {{invalid operands}} - - (void)(b == a); - (void)(b != a); - (void)(b < a); // expected-error {{invalid operands}} - (void)(b > a); // expected-error {{invalid operands}} - (void)(b <= a); // expected-error {{invalid operands}} - (void)(b >= a); // expected-error {{invalid operands}} - - (void)(a == pi); - (void)(a != pi); - (void)(a < pi); // expected-error {{invalid operands}} - (void)(a > pi); // expected-error {{invalid operands}} - (void)(a <= pi); // expected-error {{invalid operands}} - (void)(a >= pi); // expected-error {{invalid operands}} - - (void)(pi == a); - (void)(pi != a); - (void)(pi < a); // expected-error {{invalid operands}} - (void)(pi > a); // expected-error {{invalid operands}} - (void)(pi <= a); // expected-error {{invalid operands}} - (void)(pi >= a); // expected-error {{invalid operands}} - - (void)(b == pi); - (void)(b != pi); - (void)(b < pi); - (void)(b > pi); - (void)(b <= pi); - (void)(b >= pi); - - (void)(pi == b); - (void)(pi != b); - (void)(pi < b); - (void)(pi > b); - (void)(pi <= b); - (void)(pi >= b); - - (void)(b == b); - (void)(b != b); - (void)(b < b); - (void)(b > b); - (void)(b <= b); - (void)(b >= b); - - (void)(pi == pi); - (void)(pi != pi); - (void)(pi < pi); - (void)(pi > pi); - (void)(pi <= pi); - (void)(pi >= pi); -} - -// FIXME: This is wrong: the type T = 'const volatile int * const * const *' -// would work here, and there exists a builtin candidate for that type. -struct C { operator const int ***(); }; -void g(C c, volatile int ***p) { - (void)(c < p); // expected-error {{invalid operands}} -} diff --git a/test/CXX/over/over.built/p16.cpp b/test/CXX/over/over.built/p16.cpp deleted file mode 100644 index 139e86447524..000000000000 --- a/test/CXX/over/over.built/p16.cpp +++ /dev/null @@ -1,75 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -verify %s -Wno-tautological-compare - -struct A { operator decltype(nullptr)(); }; -struct B { operator int A::*(); }; -void f(A a, B b, int A::*pi) { - (void)(a == a); - (void)(a != a); - (void)(a < a); // expected-error {{invalid operands}} - (void)(a > a); // expected-error {{invalid operands}} - (void)(a <= a); // expected-error {{invalid operands}} - (void)(a >= a); // expected-error {{invalid operands}} - - (void)(a == b); - (void)(a != b); - (void)(a < b); // expected-error {{invalid operands}} - (void)(a > b); // expected-error {{invalid operands}} - (void)(a <= b); // expected-error {{invalid operands}} - (void)(a >= b); // expected-error {{invalid operands}} - - (void)(b == a); - (void)(b != a); - (void)(b < a); // expected-error {{invalid operands}} - (void)(b > a); // expected-error {{invalid operands}} - (void)(b <= a); // expected-error {{invalid operands}} - (void)(b >= a); // expected-error {{invalid operands}} - - (void)(a == pi); - (void)(a != pi); - (void)(a < pi); // expected-error {{invalid operands}} - (void)(a > pi); // expected-error {{invalid operands}} - (void)(a <= pi); // expected-error {{invalid operands}} - (void)(a >= pi); // expected-error {{invalid operands}} - - (void)(pi == a); - (void)(pi != a); - (void)(pi < a); // expected-error {{invalid operands}} - (void)(pi > a); // expected-error {{invalid operands}} - (void)(pi <= a); // expected-error {{invalid operands}} - (void)(pi >= a); // expected-error {{invalid operands}} - - (void)(b == pi); - (void)(b != pi); - (void)(b < pi); // expected-error {{invalid operands}} - (void)(b > pi); // expected-error {{invalid operands}} - (void)(b <= pi); // expected-error {{invalid operands}} - (void)(b >= pi); // expected-error {{invalid operands}} - - (void)(pi == b); - (void)(pi != b); - (void)(pi < b); // expected-error {{invalid operands}} - (void)(pi > b); // expected-error {{invalid operands}} - (void)(pi <= b); // expected-error {{invalid operands}} - (void)(pi >= b); // expected-error {{invalid operands}} - - (void)(b == b); - (void)(b != b); - (void)(b < b); // expected-error {{invalid operands}} - (void)(b > b); // expected-error {{invalid operands}} - (void)(b <= b); // expected-error {{invalid operands}} - (void)(b >= b); // expected-error {{invalid operands}} - - (void)(pi == pi); - (void)(pi != pi); - (void)(pi < pi); // expected-error {{invalid operands}} - (void)(pi > pi); // expected-error {{invalid operands}} - (void)(pi <= pi); // expected-error {{invalid operands}} - (void)(pi >= pi); // expected-error {{invalid operands}} -} - -// FIXME: This is wrong: type T = 'const volatile int * const A::* const B::*' -// would work here, and there exists a builtin candidate for that type. -struct C { operator const int *A::*B::*(); }; -void g(C c, volatile int *A::*B::*p) { - (void)(c == p); // expected-error {{invalid operands}} -} diff --git a/test/CXX/over/over.built/p23.cpp b/test/CXX/over/over.built/p23.cpp deleted file mode 100644 index a1c0d4f3f612..000000000000 --- a/test/CXX/over/over.built/p23.cpp +++ /dev/null @@ -1,26 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s -// expected-no-diagnostics - -struct Variant { - template <typename T> operator T(); -}; - -Variant getValue(); - -void testVariant() { - bool ret1 = getValue() || getValue(); - bool ret2 = getValue() && getValue(); - bool ret3 = !getValue(); -} - -struct ExplicitVariant { - template <typename T> explicit operator T(); -}; - -ExplicitVariant getExplicitValue(); - -void testExplicitVariant() { - bool ret1 = getExplicitValue() || getExplicitValue(); - bool ret2 = getExplicitValue() && getExplicitValue(); - bool ret3 = !getExplicitValue(); -} diff --git a/test/CXX/over/over.built/p25.cpp b/test/CXX/over/over.built/p25.cpp deleted file mode 100644 index 09e550ddc0ec..000000000000 --- a/test/CXX/over/over.built/p25.cpp +++ /dev/null @@ -1,16 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s -// expected-no-diagnostics - -enum class Color { Red, Green, Blue }; - -struct ConvertsToColorA { - operator Color(); -}; - -struct ConvertsToColorB { - operator Color(); -}; - -Color foo(bool cond, ConvertsToColorA ca, ConvertsToColorB cb) { - return cond? ca : cb; -} diff --git a/test/CXX/over/over.load/p2-0x.cpp b/test/CXX/over/over.load/p2-0x.cpp deleted file mode 100644 index cf38741056ab..000000000000 --- a/test/CXX/over/over.load/p2-0x.cpp +++ /dev/null @@ -1,24 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s - -// Member function declarations with the same name and the same -// parameter-type-list as well as mem- ber function template -// declarations with the same name, the same parameter-type-list, and -// the same template parameter lists cannot be overloaded if any of -// them, but not all, have a ref-qualifier (8.3.5). - -class Y { - void h() &; - void h() const &; - void h() &&; - void i() &; // expected-note{{previous declaration}} - void i() const; // expected-error{{cannot overload a member function without a ref-qualifier with a member function with ref-qualifier '&'}} - - template<typename T> void f(T*) &; - template<typename T> void f(T*) &&; - - template<typename T> void g(T*) &; // expected-note{{previous declaration}} - template<typename T> void g(T*); // expected-error{{cannot overload a member function without a ref-qualifier with a member function with ref-qualifier '&'}} - - void k(); // expected-note{{previous declaration}} - void k() &&; // expected-error{{cannot overload a member function with ref-qualifier '&&' with a member function without a ref-qualifier}} -}; diff --git a/test/CXX/over/over.match/over.match.best/over.best.ics/over.ics.list/p6.cpp b/test/CXX/over/over.match/over.match.best/over.best.ics/over.ics.list/p6.cpp deleted file mode 100644 index ea059cef7c80..000000000000 --- a/test/CXX/over/over.match/over.match.best/over.best.ics/over.ics.list/p6.cpp +++ /dev/null @@ -1,15 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s - -// rdar://problem/11120365 -namespace test0 { - template <class T> struct A { - static void foo(const T &t) {} - static void foo(T &&t) { - t.foo(); // expected-error {{member reference base type 'int' is not a structure or union}} - } - }; - - void test() { - A<int>::foo({}); // expected-note {{requested here}} - } -} diff --git a/test/CXX/over/over.match/over.match.best/over.best.ics/over.ics.scs/p3.cpp b/test/CXX/over/over.match/over.match.best/over.best.ics/over.ics.scs/p3.cpp deleted file mode 100644 index df2fc2cd2e82..000000000000 --- a/test/CXX/over/over.match/over.match.best/over.best.ics/over.ics.scs/p3.cpp +++ /dev/null @@ -1,12 +0,0 @@ -// RUN: %clang_cc1 -std=c++1z -verify %s - -void f(void() noexcept); // expected-note {{no known conversion from 'void ()' to 'void (*)() noexcept'}} -void f(void()) = delete; // expected-note {{explicitly deleted}} - -void g(); -void h() noexcept; - -void test() { - f(g); // expected-error {{call to deleted}} - f(h); -} diff --git a/test/CXX/over/over.match/over.match.best/over.best.ics/over.ics.user/p3-0x.cpp b/test/CXX/over/over.match/over.match.best/over.best.ics/over.ics.user/p3-0x.cpp deleted file mode 100644 index 1c71468e453d..000000000000 --- a/test/CXX/over/over.match/over.match.best/over.best.ics/over.ics.user/p3-0x.cpp +++ /dev/null @@ -1,14 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s - -namespace PR6285 { - template<typename T> struct identity - { typedef T type; }; - - struct D { - template<typename T = short> - operator typename identity<T>::type(); // expected-note{{candidate}} - }; - - int f() { return D(); } // expected-error{{no viable conversion}} -} - diff --git a/test/CXX/over/over.match/over.match.best/over.ics.rank/p3-0x.cpp b/test/CXX/over/over.match/over.match.best/over.ics.rank/p3-0x.cpp deleted file mode 100644 index f813305b4a19..000000000000 --- a/test/CXX/over/over.match/over.match.best/over.ics.rank/p3-0x.cpp +++ /dev/null @@ -1,60 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s -// expected-no-diagnostics -namespace std_example { - int i; - int f1(); - int&& f2(); - int &g(const int &); - float &g(const int &&); - int &j = g(i); - float &k = g(f1()); - float &l = g(f2()); - - int &g2(const int &); - float &g2(int &&); - int &j2 = g2(i); - float &k2 = g2(f1()); - float &l2 = g2(f2()); - - // FIXME: We don't support ref-qualifiers yet. -#if 0 - struct A { - A& operator<<(int); - void p() &; - void p() &&; - }; - - A& operator<<(A&&, char); - A() << 1; - A() << 'c'; - A a; - a << 1; - a << 'c'; - A().p(); - a.p(); -#endif -} - -template<typename T> -struct remove_reference { - typedef T type; -}; - -template<typename T> -struct remove_reference<T&> { - typedef T type; -}; - -template<typename T> -struct remove_reference<T&&> { - typedef T type; -}; - -namespace FunctionReferencesOverloading { - template<typename T> int &f(typename remove_reference<T>::type&); - template<typename T> float &f(typename remove_reference<T>::type&&); - - void test_f(int (&func_ref)(int)) { - int &ir = f<int (&)(int)>(func_ref); - } -} diff --git a/test/CXX/over/over.match/over.match.best/p1.cpp b/test/CXX/over/over.match/over.match.best/p1.cpp deleted file mode 100644 index a933f62a3061..000000000000 --- a/test/CXX/over/over.match/over.match.best/p1.cpp +++ /dev/null @@ -1,39 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++1z %s -// expected-no-diagnostics - -template<typename T> int &f0(T*, int); -float &f0(void*, int); - -void test_f0(int* ip, void *vp) { - // One argument is better... - int &ir = f0(ip, 0); - - // Prefer non-templates to templates - float &fr = f0(vp, 0); -} - -namespace deduction_guide_example { - template<typename T> struct A { - A(T, int*); - A(A<T>&, int*); - enum { value }; - }; - - template<typename T> struct remove_ref_impl; - template<typename T> struct remove_ref_impl<T&> { using type = T; }; - template<typename T> using remove_ref = typename remove_ref_impl<T>::type; - - // FIXME: The standard's example is wrong; we add a remove_ref<...> here to - // fix it. - template<typename T, int N = remove_ref<T>::value> A(T&&, int*) -> A<T**>; - A a{1, 0}; - extern A<int> a; - A b{a, 0}; // uses the implicit ctor that is more specialized - - A<int> *pa = &a; - A<int> *pb = &b; -} - -// Partial ordering of function template specializations will be tested -// elsewhere -// FIXME: Initialization by user-defined conversion is tested elsewhere diff --git a/test/CXX/over/over.match/over.match.funcs/over.match.class.deduct/p2.cpp b/test/CXX/over/over.match/over.match.funcs/over.match.class.deduct/p2.cpp deleted file mode 100644 index cb9541caaddd..000000000000 --- a/test/CXX/over/over.match/over.match.funcs/over.match.class.deduct/p2.cpp +++ /dev/null @@ -1,87 +0,0 @@ -// RUN: %clang_cc1 -verify -std=c++1z %s - -namespace Explicit { - // Each notional constructor is explicit if the function or function template - // was generated from a constructor or deduction-guide that was declared explicit. - template<typename T> struct A { - A(T); - A(T*); - A(...); - }; - template<typename T> A(T) -> A<T>; - template<typename T> explicit A(T*) -> A<T**>; // expected-note {{explicit}} - - int *p; - A a(p); - A b = p; - A c{p}; - A d = {p}; // expected-error {{selected an explicit deduction guide}} - - using X = A<int**>; - using Y = A<int>; // uses the implicit guide, being more specialized than the eligible user-defined deduction guides. - - using X = decltype(a); - using Y = decltype(b); - using X = decltype(c); -} - - -namespace std { - template<typename T> struct initializer_list { - const T *ptr; - __SIZE_TYPE__ size; - initializer_list(); - }; -} - -namespace p0702r1 { - template<typename T> struct X { // expected-note {{candidate}} - X(std::initializer_list<T>); // expected-note {{candidate}} - }; - - X xi = {0}; - X xxi = {xi}; - extern X<int> xi; - // Prior to P0702R1, this is X<X<int>>. - extern X<int> xxi; - - struct Y : X<int> {}; - Y y {{0}}; - X xy {y}; - extern X<int> xy; - - struct Z : X<int>, X<float> {}; - Z z = {{0}, {0.0f}}; - // This is not X<Z> even though that would work. Instead, it's ambiguous - // between X<int> and X<float>. - X xz = {z}; // expected-error {{no viable constructor or deduction guide}} -} -namespace pr34970 { -//https://bugs.llvm.org/show_bug.cgi?id=34970 - -template <typename X, typename Y> struct IsSame { - static constexpr bool value = false; -}; - -template <typename Z> struct IsSame<Z, Z> { - static constexpr bool value = true; -}; - -template <typename T> struct Optional { - template <typename U> Optional(U&&) { } -}; - -template <typename A> Optional(A) -> Optional<A>; - -int main() { - Optional opt(1729); - Optional dupe(opt); - - static_assert(IsSame<decltype(opt), Optional<int>>::value); - static_assert(IsSame<decltype(dupe), Optional<int>>::value); - static_assert(!IsSame<decltype(dupe), Optional<Optional<int>>>::value); - return 0; -} - - -}
\ No newline at end of file diff --git a/test/CXX/over/over.match/over.match.funcs/over.match.class.deduct/p3.cpp b/test/CXX/over/over.match/over.match.funcs/over.match.class.deduct/p3.cpp deleted file mode 100644 index 4ed1d30b83d5..000000000000 --- a/test/CXX/over/over.match/over.match.funcs/over.match.class.deduct/p3.cpp +++ /dev/null @@ -1,41 +0,0 @@ -// RUN: %clang_cc1 -std=c++1z -verify %s - -namespace std_example { - template <class T> struct A { - explicit A(const T &, ...) noexcept; // expected-note {{explicit}} expected-note 2{{candidate}} - A(T &&, ...); // expected-note 2{{candidate}} - }; - - int i; - A a1 = {i, i}; // expected-error {{class template argument deduction for 'A' selected an explicit constructor for copy-list-initialization}} - A a2{i, i}; - A a3{0, i}; - A a4 = {0, i}; - - template <class T> A(const T &, const T &) -> A<T &>; // expected-note 2{{candidate}} - template <class T> explicit A(T &&, T &&) -> A<T>; // expected-note {{explicit deduction guide declared here}} - - // FIXME: The standard gives an incorrect explanation for why a5, a7, and a8 are ill-formed. - A a5 = {0, 1}; // expected-error {{class template argument deduction for 'A' selected an explicit deduction guide}} - A a6{0, 1}; - A a7 = {0, i}; // expected-error {{ambiguous deduction}} - A a8{0, i}; // expected-error {{ambiguous deduction}} - - template <class T> struct B { - template <class U> using TA = T; - template <class U> B(U, TA<U>); - }; - B b{(int *)0, (char *)0}; -} - -namespace check { - using namespace std_example; - template<typename T, typename U> constexpr bool same = false; - template<typename T> constexpr bool same<T, T> = true; - - static_assert(same<decltype(a2), A<int>>); - static_assert(same<decltype(a3), A<int>>); - static_assert(same<decltype(a4), A<int>>); - static_assert(same<decltype(a6), A<int>>); - static_assert(same<decltype(b), B<char*>>); -} diff --git a/test/CXX/over/over.match/over.match.funcs/over.match.copy/p1.cpp b/test/CXX/over/over.match/over.match.funcs/over.match.copy/p1.cpp deleted file mode 100644 index 31a679f1ebc0..000000000000 --- a/test/CXX/over/over.match/over.match.funcs/over.match.copy/p1.cpp +++ /dev/null @@ -1,37 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -fsyntax-only %s -verify - -namespace ExplicitConv { - struct X { }; // expected-note 2{{candidate constructor}} - - struct Y { - explicit operator X() const; - }; - - void test(const Y& y) { - X x(static_cast<X>(y)); - X x2((X)y); - X x3 = y; // expected-error{{no viable conversion from 'const ExplicitConv::Y' to 'ExplicitConv::X'}} - } -} - -namespace DR899 { - struct C { }; // expected-note 2 {{candidate constructor}} - - struct A { - explicit operator int() const; - explicit operator C() const; - }; - - struct B { - int i; - B(const A& a): i(a) { } - }; - - int main() { - A a; - int i = a; // expected-error{{no viable conversion}} - int j(a); - C c = a; // expected-error{{no viable conversion}} - C c2(a); - } -} diff --git a/test/CXX/over/over.match/over.match.funcs/over.match.oper/p3.cpp b/test/CXX/over/over.match/over.match.funcs/over.match.oper/p3.cpp deleted file mode 100644 index d88d5beb4e99..000000000000 --- a/test/CXX/over/over.match/over.match.funcs/over.match.oper/p3.cpp +++ /dev/null @@ -1,53 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s - -namespace bullet2 { - -// For non-member candidates, if no operand has a class type, only those -// non-member functions that have a matching enumeration parameter are -// candidates. - -struct B { template<typename T> B(T); }; -int operator~(B); -template<typename T> int operator%(B, T); -enum class E { e }; - -template<typename T> int f(T t) { return ~t; } // expected-error {{invalid argument type}} -template<typename T, typename U> int f(T t, U u) { return t % u; } // expected-error {{invalid operands to}} - -int b1 = ~E::e; // expected-error {{invalid argument type}} -int b2 = f(E::e); // expected-note {{in instantiation of}} -int b3 = f(0, E::e); -int b4 = f(E::e, 0); // expected-note {{in instantiation of}} - -} - -namespace bullet3 { - -// This is specifically testing the bullet: -// "do not have the same parameter-type-list as any non-template -// non-member candidate." -// The rest is sort of hard to test separately. - -enum E1 { one }; -enum E2 { two }; - -struct A; - -A operator >= (E1, E1); -A operator >= (E1, const E2); - -E1 a; -E2 b; - -extern A test1; -extern decltype(a >= a) test1; -extern decltype(a >= b) test1; - -template <typename T> A operator <= (E1, T); -extern bool test2; -extern decltype(a <= a) test2; - -extern A test3; -extern decltype(a <= b) test3; - -} diff --git a/test/CXX/over/over.match/over.match.funcs/p4-0x.cpp b/test/CXX/over/over.match/over.match.funcs/p4-0x.cpp deleted file mode 100644 index df7762703c0f..000000000000 --- a/test/CXX/over/over.match/over.match.funcs/p4-0x.cpp +++ /dev/null @@ -1,105 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s - -template<typename T> T &lvalue(); -template<typename T> T &&xvalue(); -template<typename T> T prvalue(); - -struct X0 { - int &f() &; - float &f() &&; - - template<typename T> int &ft(T) &; - template<typename T> float &ft(T) &&; - - typedef int &(*func_int_ref)(); - typedef float &(*func_float_ref)(); - - operator func_int_ref() &; - operator func_float_ref() &&; - - void g(); - - void c() const; // expected-note {{'c' declared here}} - void v() volatile; // expected-note {{'v' declared here}} - void r() __restrict__; // expected-note {{'r' declared here}} - void cr() const __restrict__; // expected-note {{'cr' declared here}} - void cv() const volatile; - void vr() volatile __restrict__; // expected-note {{'vr' declared here}} - void cvr() const volatile __restrict__; - - void lvalue() &; // expected-note 2 {{'lvalue' declared here}} - void const_lvalue() const&; - void rvalue() &&; // expected-note {{'rvalue' declared here}} - - int &operator+(const X0&) &; - float &operator+(const X0&) &&; - - template<typename T> int &operator+(const T&) &; - template<typename T> float &operator+(const T&) &&; - - int &h() const&; - float &h() &&; - int &h2() const&; - float &h2() const&&; -}; - -void X0::g() { // expected-note {{'g' declared here}} - int &ir1 = f(); - int &ir2 = X0::f(); -} - -void test_ref_qualifier_binding() { - int &ir1 = lvalue<X0>().f(); - float &fr1 = xvalue<X0>().f(); - float &fr2 = prvalue<X0>().f(); - int &ir2 = lvalue<X0>().ft(1); - float &fr3 = xvalue<X0>().ft(2); - float &fr4 = prvalue<X0>().ft(3); -} - -void test_ref_qualifier_binding_with_surrogates() { - int &ir1 = lvalue<X0>()(); - float &fr1 = xvalue<X0>()(); - float &fr2 = prvalue<X0>()(); -} - -void test_ref_qualifier_binding_operators() { - int &ir1 = lvalue<X0>() + prvalue<X0>(); - float &fr1 = xvalue<X0>() + prvalue<X0>(); - float &fr2 = prvalue<X0>() + prvalue<X0>(); - int &ir2 = lvalue<X0>() + 1; - float &fr3 = xvalue<X0>() + 2; - float &fr4 = prvalue<X0>() + 3; -} - -void test_ref_qualifier_overloading() { - int &ir1 = lvalue<X0>().h(); - float &fr1 = xvalue<X0>().h(); - float &fr2 = prvalue<X0>().h(); - int &ir2 = lvalue<X0>().h2(); - float &fr3 = xvalue<X0>().h2(); - float &fr4 = prvalue<X0>().h2(); -} - -void test_diagnostics(const volatile X0 &__restrict__ cvr) { - cvr.g(); // expected-error {{'this' argument to member function 'g' has type 'const volatile X0', but function is not marked const or volatile}} - cvr.c(); // expected-error {{not marked volatile}} - cvr.v(); // expected-error {{not marked const}} - cvr.r(); // expected-error {{not marked const or volatile}} - cvr.cr(); // expected-error {{not marked volatile}} - cvr.cv(); - cvr.vr(); // expected-error {{not marked const}} - cvr.cvr(); - - lvalue<X0>().lvalue(); - lvalue<X0>().const_lvalue(); - lvalue<X0>().rvalue(); // expected-error {{'this' argument to member function 'rvalue' is an lvalue, but function has rvalue ref-qualifier}} - - xvalue<X0>().lvalue(); // expected-error {{'this' argument to member function 'lvalue' is an rvalue, but function has non-const lvalue ref-qualifier}} - xvalue<X0>().const_lvalue(); - xvalue<X0>().rvalue(); - - prvalue<X0>().lvalue(); // expected-error {{'this' argument to member function 'lvalue' is an rvalue, but function has non-const lvalue ref-qualifier}} - prvalue<X0>().const_lvalue(); - prvalue<X0>().rvalue(); -} diff --git a/test/CXX/over/over.oper/over.literal/p2.cpp b/test/CXX/over/over.oper/over.literal/p2.cpp deleted file mode 100644 index f3ebadd2b8b9..000000000000 --- a/test/CXX/over/over.oper/over.literal/p2.cpp +++ /dev/null @@ -1,44 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 %s -verify - -void operator "" _a(const char *); - -namespace N { - using ::operator "" _a; - - void operator "" _b(const char *); -} - -using N::operator "" _b; - -class C { - void operator "" _c(const char *); // expected-error {{must be in a namespace or global scope}} - - static void operator "" _c(unsigned long long); // expected-error {{must be in a namespace or global scope}} - - friend void operator "" _d(const char *); -}; - -int operator "" _e; // expected-error {{cannot be the name of a variable}} - -void f() { - int operator "" _f; // expected-error {{cannot be the name of a variable}} -} - -extern "C++" { - void operator "" _g(const char *); -} - -template<char...> void operator "" _h() {} - -template<> void operator "" _h<'a', 'b', 'c'>() {} - -template void operator "" _h<'a', 'b', 'c', 'd'>(); - -namespace rdar13605348 { - -class C { - double operator"" _x(long double value) { return double(value); } // expected-error{{literal operator 'operator""_x' must be in a namespace or global scope}} - double value() { return 3.2_x; } // expected-error{{no matching literal operator for call to}} -}; - -} diff --git a/test/CXX/over/over.oper/over.literal/p3.cpp b/test/CXX/over/over.oper/over.literal/p3.cpp deleted file mode 100644 index 674ace9aee19..000000000000 --- a/test/CXX/over/over.oper/over.literal/p3.cpp +++ /dev/null @@ -1,40 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 %s -verify - -using size_t = decltype(sizeof(int)); - -// Acceptable parameter declarations -char operator "" _a(const char *); -char operator "" _a(const char []); -char operator "" _a(unsigned long long); -char operator "" _a(long double); -char operator "" _a(char); -char operator "" _a(const volatile char); -char operator "" _a(wchar_t); -char operator "" _a(char16_t); -char operator "" _a(char32_t); -char operator "" _a(const char *, size_t); -char operator "" _a(const wchar_t *, size_t); -char operator "" _a(const char16_t *, size_t); -char operator "" _a(const char32_t *, size_t); -char operator "" _a(const char [32], size_t); - -// Unacceptable parameter declarations -char operator "" _b(); // expected-error {{parameter}} -char operator "" _b(const wchar_t *); // expected-error {{parameter}} -char operator "" _b(long long); // expected-error {{parameter}} -char operator "" _b(double); // expected-error {{parameter}} -char operator "" _b(short); // expected-error {{parameter}} -char operator "" _a(char, int = 0); // expected-error {{parameter}} -char operator "" _b(unsigned short); // expected-error {{parameter}} -char operator "" _b(signed char); // expected-error {{parameter}} -char operator "" _b(unsigned char); // expected-error {{parameter}} -char operator "" _b(const short *, size_t); // expected-error {{parameter}} -char operator "" _b(const unsigned short *, size_t); // expected-error {{parameter}} -char operator "" _b(const signed char *, size_t); // expected-error {{parameter}} -char operator "" _b(const unsigned char *, size_t); // expected-error {{parameter}} -char operator "" _a(const volatile char *, size_t); // expected-error {{parameter}} -char operator "" _a(volatile wchar_t *, size_t); // expected-error {{parameter}} -char operator "" _a(char16_t *, size_t); // expected-error {{parameter}} -char operator "" _a(const char32_t *, size_t, bool = false); // expected-error {{parameter}} -char operator "" _a(const char *, signed long); // expected-error {{parameter}} -char operator "" _a(const char *, size_t = 0); // expected-error {{default argument}} diff --git a/test/CXX/over/over.oper/over.literal/p5.cpp b/test/CXX/over/over.oper/over.literal/p5.cpp deleted file mode 100644 index bfad5f00cf6c..000000000000 --- a/test/CXX/over/over.oper/over.literal/p5.cpp +++ /dev/null @@ -1,22 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 %s -verify - -using size_t = decltype(sizeof(int)); -template<char...> struct S {}; - -template<char...> void operator "" _a(); -template<char... C> S<C...> operator "" _a(); - -template<typename T> struct U { - friend int operator "" _a(const char *, size_t); - // FIXME: It's not entirely clear whether this is intended to be legal. - friend U operator "" _a(const T *, size_t); // expected-error {{parameter}} -}; -template<char...> struct V { - friend void operator "" _b(); // expected-error {{parameters}} -}; - -template<char... C, int N = 0> void operator "" _b(); // expected-error {{template}} -template<char... C> void operator "" _b(int N = 0); // expected-error {{template}} -template<char, char...> void operator "" _b(); // expected-error {{template}} -template<typename T> T operator "" _b(const char *); // expected-error {{template}} -template<typename T> int operator "" _b(const T *, size_t); // expected-error {{template}} diff --git a/test/CXX/over/over.oper/over.literal/p6.cpp b/test/CXX/over/over.oper/over.literal/p6.cpp deleted file mode 100644 index 9ecf9ccccb14..000000000000 --- a/test/CXX/over/over.oper/over.literal/p6.cpp +++ /dev/null @@ -1,15 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 %s -verify - -// expected-note@+1 {{extern "C" language linkage specification begins here}} -extern "C" void operator "" _a(const char *); // expected-error {{must have C++ linkage}} -extern "C" template<char...> void operator "" _b(); // expected-error {{must have C++ linkage}} -// expected-note@-1 {{extern "C" language linkage specification begins here}} - -extern "C" { // expected-note 4 {{extern "C" language linkage specification begins here}} - void operator "" _c(const char *); // expected-error {{must have C++ linkage}} - template<char...> void operator "" _d(); // expected-error {{must have C++ linkage}} - namespace N { - void operator "" _e(const char *); // expected-error {{must have C++ linkage}} - template<char...> void operator "" _f(); // expected-error {{must have C++ linkage}} - } -} diff --git a/test/CXX/over/over.oper/over.literal/p7.cpp b/test/CXX/over/over.oper/over.literal/p7.cpp deleted file mode 100644 index 74e9457bb55c..000000000000 --- a/test/CXX/over/over.oper/over.literal/p7.cpp +++ /dev/null @@ -1,17 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 %s -verify -// expected-no-diagnostics - -constexpr int operator "" _a(const char *c) { - return c[0]; -} - -static_assert(operator "" _a("foo") == 'f', ""); - -void puts(const char *); -static inline void operator "" _puts(const char *c) { - puts(c); -} -void f() { - operator "" _puts("foo"); - operator "" _puts("bar"); -} diff --git a/test/CXX/over/over.oper/over.literal/p8.cpp b/test/CXX/over/over.oper/over.literal/p8.cpp deleted file mode 100644 index 6644bae7e610..000000000000 --- a/test/CXX/over/over.oper/over.literal/p8.cpp +++ /dev/null @@ -1,17 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 %s -verify - -struct string; -namespace std { - using size_t = decltype(sizeof(int)); -} - -void operator "" _km(long double); // ok -string operator "" _i18n(const char*, std::size_t); // ok -template<char...> int operator "" \u03C0(); // ok, UCN for lowercase pi // expected-warning {{reserved}} -float operator ""E(const char *); // expected-error {{invalid suffix on literal}} expected-warning {{reserved}} -float operator " " B(const char *); // expected-error {{must be '""'}} expected-warning {{reserved}} -string operator "" 5X(const char *, std::size_t); // expected-error {{expected identifier}} -double operator "" _miles(double); // expected-error {{parameter}} -template<char...> int operator "" j(const char*); // expected-error {{template}} - -float operator ""_E(const char *); diff --git a/test/CXX/over/over.over/p1.cpp b/test/CXX/over/over.over/p1.cpp deleted file mode 100644 index e31a2c506756..000000000000 --- a/test/CXX/over/over.over/p1.cpp +++ /dev/null @@ -1,111 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -DNOEXCEPT= -verify %s -// RUN: %clang_cc1 -fsyntax-only -std=c++1z -DNOEXCEPT= -verify %s -// RUN: %clang_cc1 -fsyntax-only -std=c++1z -DNOEXCEPT=noexcept -verify %s - -template<typename T> T f0(T) NOEXCEPT; -int f0(int) NOEXCEPT; - -// -- an object or reference being initialized -struct S { - int (*f0)(int); - float (*f1)(float); -}; - -void test_init_f0() { - int (*f0a)(int) = f0; - int (*f0b)(int) = &f0; - int (*f0c)(int) = (f0); - float (*f0d)(float) = f0; - float (*f0e)(float) = &f0; - float (*f0f)(float) = (f0); - int (&f0g)(int) = f0; - int (&f0h)(int) = (f0); - float (&f0i)(float) = f0; - float (&f0j)(float) = (f0); - S s = { f0, f0 }; -} - -// -- the left side of an assignment (5.17), -void test_assign_f0() { - int (*f0a)(int) = 0; - float (*f0b)(float) = 0; - - f0a = f0; - f0a = &f0; - f0a = (f0); - f0b = f0; - f0b = &f0; - f0b = (f0); -} - -// -- a parameter of a function (5.2.2), -void eat_f0(int a(int), float (*b)(float), int (&c)(int), float (&d)(float)); - -void test_pass_f0() { - eat_f0(f0, f0, f0, f0); - eat_f0(&f0, &f0, (f0), (f0)); -} - -// -- a parameter of a user-defined operator (13.5), -struct X { }; -void operator+(X, int(int)); -void operator-(X, float(*)(float)); -void operator*(X, int (&)(int)); -void operator/(X, float (&)(float)); - -void test_operator_pass_f0(X x) { - x + f0; - x + &f0; - x - f0; - x - &f0; - x * f0; - x * (f0); - x / f0; - x / (f0); -} - -// -- the return value of a function, operator function, or conversion (6.6.3), -int (*test_return_f0_a())(int) { return f0; } -int (*test_return_f0_b())(int) { return &f0; } -int (*test_return_f0_c())(int) { return (f0); } -float (*test_return_f0_d())(float) { return f0; } -float (*test_return_f0_e())(float) { return &f0; } -float (*test_return_f0_f())(float) { return (f0); } - -// -- an explicit type conversion (5.2.3, 5.2.9, 5.4), or -void test_convert_f0() { - (void)((int (*)(int))f0); - (void)((int (*)(int))&f0); - (void)((int (*)(int))(f0)); - (void)((float (*)(float))f0); - (void)((float (*)(float))&f0); - (void)((float (*)(float))(f0)); -} - -// -- a non-type template-parameter(14.3.2). -template<int(int)> struct Y0 { }; -template<float(float)> struct Y1 { }; -template<int (&)(int)> struct Y2 { }; -template<float (&)(float)> struct Y3 { }; - -Y0<f0> y0; -Y0<&f0> y0a; -Y1<f0> y1; -Y1<&f0> y1a; -Y2<f0> y2; -Y3<f0> y3; - -#if __cplusplus > 201402L -namespace MixedNoexcept { - inline namespace A { - void f() noexcept; // expected-note {{candidate}} - } - inline namespace B { - void f(); // expected-note {{candidate}} - } - void (*p)() noexcept = &f; // ok - void (*q)() = &f; // expected-error {{ambiguous}} -} -#else -// expected-no-diagnostics -#endif diff --git a/test/CXX/over/over.over/p2-resolve-single-template-id.cpp b/test/CXX/over/over.over/p2-resolve-single-template-id.cpp deleted file mode 100644 index e538b99a1eb0..000000000000 --- a/test/CXX/over/over.over/p2-resolve-single-template-id.cpp +++ /dev/null @@ -1,191 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -Wno-bool-conversion %s - -typedef __typeof__(((int*)0)-((int*)0)) ptrdiff_t; - -namespace DontResolveTooEarly_WaitForOverloadResolution -{ - template <class T> T* f(int); // #1 - template <class T, class U> T& f(U); // #2 - - void g() { - int *ip = f<int>(1); // calls #1 - } - - template <class T> - T* f2(int); - template <class T, class U> - T& f2(U); - - void g2() { - int*ip = (f2<int>)(1); // ok - } - -} // End namespace - -namespace DontAllowUnresolvedOverloadedExpressionInAnUnusedExpression -{ - void one() { } - template<class T> void oneT() { } - - void two() { } // expected-note 2 {{possible target for call}} - void two(int) { } // expected-note 2 {{possible target for call}} - template<class T> void twoT() { } // expected-note 2 {{possible target for call}} - template<class T> void twoT(T) { } // expected-note 2 {{possible target for call}} - - void check() - { - one; // expected-warning {{expression result unused}} - two; // expected-error{{reference to overloaded function could not be resolved; did you mean to call it with no arguments?}} - oneT<int>; // expected-warning {{expression result unused}} - twoT<int>; // expected-error {{reference to overloaded function could not be resolved; did you mean to call it?}} - } - - // check the template function case - template<class T> void check() - { - one; // expected-warning {{expression result unused}} - two; // expected-error{{reference to overloaded function could not be resolved; did you mean to call it with no arguments?}} - oneT<int>; // expected-warning {{expression result unused}} - twoT<int>; // expected-error {{reference to overloaded function could not be resolved; did you mean to call it?}} - - } - -} - - template<typename T> - void twoT() { } - template<typename T, typename U> - void twoT(T) { } - - - void two() { }; //expected-note 5{{candidate}} - void two(int) { }; //expected-note 5{{candidate}} - - - - void one() { } - template<class T> - void oneT() { } - - template<class T> - void cant_resolve() { } //expected-note 3{{candidate}} - - template<class T> void cant_resolve(T) { }//expected-note 3{{candidate}} - - -int main() -{ - - { static_cast<void>(one); } - { (void)(one); } - { static_cast<void>(oneT<int>); } - { (void)(oneT<int>); } - - { static_cast<void>(two); } // expected-error {{address of overloaded function 'two' cannot be static_cast to type 'void'}} - { (void)(two); } // expected-error {{address of overloaded function 'two' cannot be cast to type 'void'}} - { static_cast<void>(twoT<int>); } - { (void)(twoT<int>); } - - - { ptrdiff_t x = reinterpret_cast<ptrdiff_t>(oneT<int>); } - { (void) reinterpret_cast<int (*)(char, double)>(oneT<int>); } - { (void) reinterpret_cast<ptrdiff_t>(one); } - { (void) reinterpret_cast<int (*)(char, double)>(one); } - - { ptrdiff_t x = reinterpret_cast<ptrdiff_t>(twoT<int>); } - { (void) reinterpret_cast<int (*)(char, double)>(twoT<int>); } - { (void) reinterpret_cast<void (*)(int)>(two); } //expected-error {{reinterpret_cast}} - { (void) static_cast<void (*)(int)>(two); } //ok - - { (void) reinterpret_cast<int>(two); } //expected-error {{reinterpret_cast}} - { (void) reinterpret_cast<int (*)(char, double)>(two); } //expected-error {{reinterpret_cast}} - - { bool b = (twoT<int>); } - { bool b = (twoT<int, int>); } - - { bool b = &twoT<int>; //&foo<int>; } - b = &(twoT<int>); } - - { ptrdiff_t x = (ptrdiff_t) &twoT<int>; - x = (ptrdiff_t) &twoT<int>; } - - { ptrdiff_t x = (ptrdiff_t) twoT<int>; - x = (ptrdiff_t) twoT<int>; } - - - { ptrdiff_t x = (ptrdiff_t) &twoT<int,int>; - x = (ptrdiff_t) &twoT<int>; } - - { oneT<int>; &oneT<int>; } //expected-warning 2{{expression result unused}} - { static_cast<void>(cant_resolve<int>); } // expected-error {{address of overload}} - { bool b = cant_resolve<int>; } // expected-error {{address of overload}} - { (void) cant_resolve<int>; } // expected-error {{address of overload}} - -} - -namespace member_pointers { - struct S { - template <typename T> bool f(T) { return false; } // expected-note 4 {{possible target for call}} - template <typename T> static bool g(T) { return false; } - - template <typename T> bool h(T) { return false; } // expected-note 3 {{possible target for call}} - template <int N> static bool h(int) { return false; } // expected-note 3 {{possible target for call}} - }; - - void test(S s) { - if (S::f<char>) return; // expected-error {{call to non-static member function without an object argument}} - if (S::f<int>) return; // expected-error {{call to non-static member function without an object argument}} - if (&S::f<char>) return; - if (&S::f<int>) return; - if (s.f<char>) return; // expected-error {{reference to non-static member function must be called}} - if (s.f<int>) return; // expected-error {{reference to non-static member function must be called}} - if (&s.f<char>) return; // expected-error {{cannot create a non-constant pointer to member function}} - if (&s.f<int>) return; // expected-error {{cannot create a non-constant pointer to member function}} - - if (S::g<char>) return; - if (S::g<int>) return; - if (&S::g<char>) return; - if (&S::g<int>) return; - if (s.g<char>) return; - if (s.g<int>) return; - if (&s.g<char>) return; - if (&s.g<int>) return; - - if (S::h<42>) return; - if (S::h<int>) return; // expected-error {{reference to overloaded function could not be resolved; did you mean to call it?}} - if (&S::h<42>) return; - if (&S::h<int>) return; - if (s.h<42>) return; - if (s.h<int>) return; // expected-error {{reference to overloaded function could not be resolved; did you mean to call it?}} - if (&s.h<42>) return; - if (&s.h<int>) return; // expected-error {{reference to overloaded function could not be resolved; did you mean to call it?}} - - { bool b = S::f<char>; } // expected-error {{call to non-static member function without an object argument}} - { bool b = S::f<int>; } // expected-error {{call to non-static member function without an object argument}} - { bool b = &S::f<char>; } - { bool b = &S::f<int>; } - // These next two errors are terrible. - { bool b = s.f<char>; } // expected-error {{reference to non-static member function must be called}} - { bool b = s.f<int>; } // expected-error {{reference to non-static member function must be called}} - { bool b = &s.f<char>; } // expected-error {{cannot create a non-constant pointer to member function}} - { bool b = &s.f<int>; } // expected-error {{cannot create a non-constant pointer to member function}} - - { bool b = S::g<char>; } - { bool b = S::g<int>; } - { bool b = &S::g<char>; } - { bool b = &S::g<int>; } - { bool b = s.g<char>; } - { bool b = s.g<int>; } - { bool b = &s.g<char>; } - { bool b = &s.g<int>; } - - { bool b = S::h<42>; } - { bool b = S::h<int>; } // expected-error {{cannot form member pointer of type 'bool' without '&' and class name}} - { bool b = &S::h<42>; } - { bool b = &S::h<int>; } - { bool b = s.h<42>; } - { bool b = s.h<int>; } // expected-error {{cannot form member pointer of type 'bool' without '&' and class name}} - { bool b = &s.h<42>; } - { bool b = &s.h<int>; } // expected-error {{cannot form member pointer of type 'bool' without '&' and class name}} - } -} diff --git a/test/CXX/over/over.over/p2.cpp b/test/CXX/over/over.over/p2.cpp deleted file mode 100644 index d03b84a2d15b..000000000000 --- a/test/CXX/over/over.over/p2.cpp +++ /dev/null @@ -1,10 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s - -template <typename T> -T f0(T, T); // expected-note{{deduced conflicting types for parameter 'T' ('int' vs. 'float')}} - -void test_f0() { - int (*f0a)(int, int) = f0; - int (*f0b)(int, int) = &f0; - int (*f0c)(int, float) = f0; // expected-error{{address of overloaded function 'f0' does not match required type 'int (int, float)'}} -} diff --git a/test/CXX/over/over.over/p4.cpp b/test/CXX/over/over.over/p4.cpp deleted file mode 100644 index 27d070eff209..000000000000 --- a/test/CXX/over/over.over/p4.cpp +++ /dev/null @@ -1,20 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s - -template<typename T> T f0(T); // expected-note{{candidate function}} -int f0(int); // expected-note{{candidate function}} - -void test_f0() { - int (*fp0)(int) = f0; - int (*fp1)(int) = &f0; - float (*fp2)(float) = &f0; -} - -namespace N { - int f0(int); // expected-note{{candidate function}} -} - -void test_f0_2() { - using namespace N; - int (*fp0)(int) = f0; // expected-error{{address of overloaded function 'f0' is ambiguous}} - float (*fp1)(float) = f0; -} diff --git a/test/CXX/special/class.conv/class.conv.ctor/p1.cpp b/test/CXX/special/class.conv/class.conv.ctor/p1.cpp deleted file mode 100644 index 5a45f7c358a3..000000000000 --- a/test/CXX/special/class.conv/class.conv.ctor/p1.cpp +++ /dev/null @@ -1,22 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 %s -verify -// expected-no-diagnostics - -namespace PR13003 { - struct void_type - { - template <typename Arg0, typename... Args> - void_type(Arg0&&, Args&&...) { } - }; - - struct void_type2 - { - template <typename... Args> - void_type2(Args&&...) { } - }; - - struct atom { }; - - void_type v1 = atom(); - void_type2 v2 = atom(); -} - diff --git a/test/CXX/special/class.copy/implicit-move-def.cpp b/test/CXX/special/class.copy/implicit-move-def.cpp deleted file mode 100644 index 7a6a1ee984e9..000000000000 --- a/test/CXX/special/class.copy/implicit-move-def.cpp +++ /dev/null @@ -1,117 +0,0 @@ -// FIXME: %clang_cc1 -emit-llvm -triple %itanium_abi_triple -o - -std=c++11 %s | FileCheck %s -// RUN: %clang_cc1 -emit-llvm -triple %itanium_abi_triple -o - -std=c++11 %s | FileCheck -check-prefix=CHECK-ASSIGN %s -// RUN: %clang_cc1 -emit-llvm -triple %itanium_abi_triple -o - -std=c++11 %s | FileCheck -check-prefix=CHECK-CTOR %s - -// construct - -struct E { - E(); - E(E&&); -}; - -struct F { - F(); - F(F&&); -}; - -struct G { - E e; -}; - -struct H : G { - F l; - E m; - F ar[2]; -}; - -void f() { - H s; - // CHECK: call void @_ZN1HC1EOS_ - H t(static_cast<H&&>(s)); -} - - -// assign - -struct A { - A &operator =(A&&); -}; - -struct B { - B &operator =(B&&); -}; - -struct C { - A a; -}; - -struct D : C { - A a; - B b; - A ar[2]; -}; - -void g() { - D d; - // CHECK: call {{.*}} @_ZN1DaSEOS_ - d = D(); -} - -// PR10822 -struct I { - unsigned var[1]; -}; - -// CHECK: define void @_Z1hv() nounwind { -void h() { - I i; - // CHECK: call void @llvm.memcpy. - i = I(); - // CHECK-NEXT: ret void -} - -// PR10860 -struct Empty { }; -struct VirtualWithEmptyBase : Empty { - virtual void f(); -}; - -// CHECK: define void @_Z25move_VirtualWithEmptyBaseR20VirtualWithEmptyBaseS0_ -void move_VirtualWithEmptyBase(VirtualWithEmptyBase &x, VirtualWithEmptyBase &y) { - // CHECK: call {{.*}} @_ZN20VirtualWithEmptyBaseaSEOS_ - x = static_cast<VirtualWithEmptyBase&&>(y); - // CHECK-NEXT: ret void -} - -// move assignment ops - -// CHECK-ASSIGN: define linkonce_odr {{.*}} @_ZN1DaSEOS_ -// CHECK-ASSIGN: call {{.*}} @_ZN1CaSEOS_ -// CHECK-ASSIGN: call {{.*}} @_ZN1AaSEOS_ -// CHECK-ASSIGN: call {{.*}} @_ZN1BaSEOS_ -// array loop -// CHECK-ASSIGN: br i1 -// CHECK-ASSIGN: call {{.*}} @_ZN1AaSEOS_ - -// VirtualWithEmptyBase move assignment operatpr -// CHECK-ASSIGN: define linkonce_odr {{.*}} @_ZN20VirtualWithEmptyBaseaSEOS_ -// CHECK-ASSIGN: store -// CHECK-ASSIGN-NEXT: store -// CHECK-ASSIGN-NOT: call -// CHECK-ASSIGN: ret - -// CHECK-ASSIGN: define linkonce_odr {{.*}} @_ZN1CaSEOS_ -// CHECK-ASSIGN: call {{.*}} @_ZN1AaSEOS_ - -// move ctors - -// CHECK-CTOR: define linkonce_odr {{.*}} @_ZN1HC2EOS_ -// CHECK-CTOR: call {{.*}} @_ZN1GC2EOS_ -// CHECK-CTOR: call {{.*}} @_ZN1FC1EOS_ -// CHECK-CTOR: call {{.*}} @_ZN1EC1EOS_ -// array loop -// CHECK-CTOR: call {{.*}} @_ZN1FC1EOS_ -// CHECK-CTOR: br i1 - -// CHECK-CTOR: define linkonce_odr {{.*}} @_ZN1GC2EOS_ -// CHECK-CTOR: call {{.*}} @_ZN1EC1EOS_ diff --git a/test/CXX/special/class.copy/implicit-move.cpp b/test/CXX/special/class.copy/implicit-move.cpp deleted file mode 100644 index 588778c400b3..000000000000 --- a/test/CXX/special/class.copy/implicit-move.cpp +++ /dev/null @@ -1,308 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 -Wno-inaccessible-base %s - -// Tests for implicit (non-)declaration of move constructor and -// assignment: p9, p11, p20, p23. - -// This class, used as a member, allows to distinguish move from copy because -// move operations are no-throw, copy operations aren't. -struct ThrowingCopy { - ThrowingCopy() noexcept; - ThrowingCopy(ThrowingCopy &&) noexcept; - ThrowingCopy(const ThrowingCopy &) noexcept(false); - ThrowingCopy & operator =(ThrowingCopy &&) noexcept; - ThrowingCopy & operator =(const ThrowingCopy &) noexcept(false); -}; - -struct HasCopyConstructor { - ThrowingCopy tc; - HasCopyConstructor() noexcept; - HasCopyConstructor(const HasCopyConstructor &) noexcept(false); -}; - -struct HasCopyAssignment { - ThrowingCopy tc; - HasCopyAssignment() noexcept; - HasCopyAssignment & operator =(const HasCopyAssignment &) noexcept(false); -}; - -struct HasMoveConstructor { - ThrowingCopy tc; - HasMoveConstructor() noexcept; - HasMoveConstructor(HasMoveConstructor &&) noexcept; // expected-note {{copy assignment operator is implicitly deleted because 'HasMoveConstructor' has a user-declared move constructor}} -}; - -struct HasMoveAssignment { // expected-note {{implicit copy constructor}} - ThrowingCopy tc; - HasMoveAssignment() noexcept; - HasMoveAssignment & operator =(HasMoveAssignment &&) noexcept; -}; - -struct HasDestructor { - ThrowingCopy tc; - HasDestructor() noexcept; - ~HasDestructor() noexcept; -}; - -void test_basic_exclusion() { - static_assert(!noexcept(HasCopyConstructor((HasCopyConstructor()))), ""); - HasCopyConstructor hcc; - static_assert(!noexcept(hcc = HasCopyConstructor()), ""); - - static_assert(!noexcept(HasCopyAssignment((HasCopyAssignment()))), ""); - HasCopyAssignment hca; - static_assert(!noexcept(hca = HasCopyAssignment()), ""); - - static_assert(noexcept(HasMoveConstructor((HasMoveConstructor()))), ""); - HasMoveConstructor hmc; - hmc = HasMoveConstructor(); // expected-error {{object of type 'HasMoveConstructor' cannot be assigned because its copy assignment operator is implicitly deleted}} - - (HasMoveAssignment(HasMoveAssignment())); // expected-error {{uses deleted function}} - HasMoveAssignment hma; - static_assert(noexcept(hma = HasMoveAssignment()), ""); - - static_assert(!noexcept(HasDestructor((HasDestructor()))), ""); - HasDestructor hd; - static_assert(!noexcept(hd = HasDestructor()), ""); -} - -struct PrivateMove { - PrivateMove() noexcept; - PrivateMove(const PrivateMove &) noexcept(false); - PrivateMove & operator =(const PrivateMove &) noexcept(false); -private: - PrivateMove(PrivateMove &&) noexcept; - PrivateMove & operator =(PrivateMove &&) noexcept; -}; - -struct InheritsPrivateMove : PrivateMove {}; -struct ContainsPrivateMove { - PrivateMove pm; -}; - -struct PrivateDestructor { - PrivateDestructor() noexcept; - PrivateDestructor(const PrivateDestructor &) noexcept(false); - PrivateDestructor(PrivateDestructor &&) noexcept; -private: - ~PrivateDestructor() noexcept; -}; - -struct InheritsPrivateDestructor : PrivateDestructor {}; // expected-note{{base class 'PrivateDestructor' has an inaccessible destructor}} -struct ContainsPrivateDestructor { - PrivateDestructor pd; // expected-note{{field 'pd' has an inaccessible destructor}} -}; - -struct NonTrivialCopyOnly { - NonTrivialCopyOnly() noexcept; - NonTrivialCopyOnly(const NonTrivialCopyOnly &) noexcept(false); - NonTrivialCopyOnly & operator =(const NonTrivialCopyOnly &) noexcept(false); -}; - -struct InheritsNonTrivialCopyOnly : NonTrivialCopyOnly {}; -struct ContainsNonTrivialCopyOnly { - NonTrivialCopyOnly ntco; -}; - -struct ContainsConst { - const int i; - ContainsConst() noexcept; - ContainsConst & operator =(ContainsConst &); // expected-note {{not viable}} -}; - -struct ContainsRef { - int &i; - ContainsRef() noexcept; - ContainsRef & operator =(ContainsRef &); // expected-note {{not viable}} -}; - -struct Base { - Base & operator =(Base &); -}; -struct DirectVirtualBase : virtual Base {}; // expected-note {{copy assignment operator) not viable}} -struct IndirectVirtualBase : DirectVirtualBase {}; // expected-note {{copy assignment operator) not viable}} - -void test_deletion_exclusion() { - // FIXME: How to test the union thing? - - static_assert(!noexcept(InheritsPrivateMove(InheritsPrivateMove())), ""); - static_assert(!noexcept(ContainsPrivateMove(ContainsPrivateMove())), ""); - InheritsPrivateMove ipm; - static_assert(!noexcept(ipm = InheritsPrivateMove()), ""); - ContainsPrivateMove cpm; - static_assert(!noexcept(cpm = ContainsPrivateMove()), ""); - - (InheritsPrivateDestructor(InheritsPrivateDestructor())); // expected-error {{call to implicitly-deleted default constructor}} - (ContainsPrivateDestructor(ContainsPrivateDestructor())); // expected-error {{call to implicitly-deleted default constructor}} - - static_assert(!noexcept(InheritsNonTrivialCopyOnly(InheritsNonTrivialCopyOnly())), ""); - static_assert(!noexcept(ContainsNonTrivialCopyOnly(ContainsNonTrivialCopyOnly())), ""); - InheritsNonTrivialCopyOnly intco; - static_assert(!noexcept(intco = InheritsNonTrivialCopyOnly()), ""); - ContainsNonTrivialCopyOnly cntco; - static_assert(!noexcept(cntco = ContainsNonTrivialCopyOnly()), ""); - - ContainsConst cc; - cc = ContainsConst(); // expected-error {{no viable}} - - ContainsRef cr; - cr = ContainsRef(); // expected-error {{no viable}} - - DirectVirtualBase dvb; - dvb = DirectVirtualBase(); // expected-error {{no viable}} - - IndirectVirtualBase ivb; - ivb = IndirectVirtualBase(); // expected-error {{no viable}} -} - -struct ContainsRValueRef { - int&& ri; - ContainsRValueRef() noexcept; -}; - -void test_contains_rref() { - (ContainsRValueRef(ContainsRValueRef())); -} - - -namespace DR1402 { - struct NonTrivialCopyCtor { - NonTrivialCopyCtor(const NonTrivialCopyCtor &); - }; - struct NonTrivialCopyAssign { - NonTrivialCopyAssign &operator=(const NonTrivialCopyAssign &); - }; - - struct NonTrivialCopyCtorVBase : virtual NonTrivialCopyCtor { - NonTrivialCopyCtorVBase(NonTrivialCopyCtorVBase &&); - NonTrivialCopyCtorVBase &operator=(NonTrivialCopyCtorVBase &&) = default; - }; - struct NonTrivialCopyAssignVBase : virtual NonTrivialCopyAssign { - NonTrivialCopyAssignVBase(NonTrivialCopyAssignVBase &&); - NonTrivialCopyAssignVBase &operator=(NonTrivialCopyAssignVBase &&) = default; - }; - - struct NonTrivialMoveAssign { - NonTrivialMoveAssign(NonTrivialMoveAssign&&); - NonTrivialMoveAssign &operator=(NonTrivialMoveAssign &&); - }; - struct NonTrivialMoveAssignVBase : virtual NonTrivialMoveAssign { - NonTrivialMoveAssignVBase(NonTrivialMoveAssignVBase &&); - NonTrivialMoveAssignVBase &operator=(NonTrivialMoveAssignVBase &&) = default; - }; - - // DR1402: A non-movable, non-trivially-copyable class type as a subobject no - // longer inhibits the declaration of a move operation. - struct NoMove1 { NonTrivialCopyCtor ntcc; }; - struct NoMove2 { NonTrivialCopyAssign ntcc; }; - struct NoMove3 : NonTrivialCopyCtor {}; - struct NoMove4 : NonTrivialCopyAssign {}; - struct NoMove5 : virtual NonTrivialCopyCtor {}; - struct NoMove6 : virtual NonTrivialCopyAssign {}; - struct NoMove7 : NonTrivialCopyCtorVBase {}; - struct NoMove8 : NonTrivialCopyAssignVBase {}; - - // DR1402: A non-trivially-move-assignable virtual base class no longer - // inhibits the declaration of a move assignment (even though it might - // move-assign the base class multiple times). - struct NoMove9 : NonTrivialMoveAssign {}; - struct NoMove10 : virtual NonTrivialMoveAssign {}; - struct NoMove11 : NonTrivialMoveAssignVBase {}; - - template<typename T> void test(T t) { - (void)T(static_cast<T&&>(t)); // ok - t = static_cast<T&&>(t); // ok - } - template void test(NoMove1); - template void test(NoMove2); - template void test(NoMove3); - template void test(NoMove4); - template void test(NoMove5); - template void test(NoMove6); - template void test(NoMove7); - template void test(NoMove8); - template void test(NoMove9); - template void test(NoMove10); - template void test(NoMove11); - - struct CopyOnly { - CopyOnly(const CopyOnly&); - CopyOnly &operator=(const CopyOnly&); - }; - struct MoveOnly { - MoveOnly(MoveOnly&&); // expected-note {{user-declared move}} - MoveOnly &operator=(MoveOnly&&); - }; - template void test(CopyOnly); // ok, copies - template void test(MoveOnly); // ok, moves - struct CopyAndMove { // expected-note {{implicitly deleted}} - CopyOnly co; - MoveOnly mo; // expected-note {{deleted copy}} - }; - template void test(CopyAndMove); // ok, copies co, moves mo - void test2(CopyAndMove cm) { - (void)CopyAndMove(cm); // expected-error {{deleted}} - cm = cm; // expected-error {{deleted}} - } - - namespace VbaseMove { - struct A {}; - struct B { B &operator=(B&&); }; - struct C { C &operator=(const C&); }; - struct D { B b; }; - - template<typename T, unsigned I, bool NonTrivialMove = false> - struct E : virtual T {}; - - template<typename T, unsigned I> - struct E<T, I, true> : virtual T { E &operator=(E&&); }; - - template<typename T> - struct F : - E<T, 0>, // expected-note-re 2{{'{{[BD]}}' is a virtual base class of base class 'E<}} - E<T, 1> {}; // expected-note-re 2{{'{{[BD]}}' is a virtual base class of base class 'E<}} - - template<typename T> - struct G : E<T, 0, true>, E<T, 0> {}; - - template<typename T> - struct H : E<T, 0, true>, E<T, 1, true> {}; - - template<typename T> - struct I : E<T, 0>, T {}; - - template<typename T> - struct J : - E<T, 0>, // expected-note-re 2{{'{{[BD]}}' is a virtual base class of base class 'E<}} - virtual T {}; // expected-note-re 2{{virtual base class '{{[BD]}}' declared here}} - - template<typename T> void move(T t) { t = static_cast<T&&>(t); } - // expected-warning-re@-1 4{{defaulted move assignment operator of {{.*}} will move assign virtual base class '{{[BD]}}' multiple times}} - template void move(F<A>); - template void move(F<B>); // expected-note {{in instantiation of}} - template void move(F<C>); - template void move(F<D>); // expected-note {{in instantiation of}} - template void move(G<A>); - template void move(G<B>); - template void move(G<C>); - template void move(G<D>); - template void move(H<A>); - template void move(H<B>); - template void move(H<C>); - template void move(H<D>); - template void move(I<A>); - template void move(I<B>); - template void move(I<C>); - template void move(I<D>); - template void move(J<A>); - template void move(J<B>); // expected-note {{in instantiation of}} - template void move(J<C>); - template void move(J<D>); // expected-note {{in instantiation of}} - } -} - -namespace PR12625 { - struct X; // expected-note {{forward decl}} - struct Y { - X x; // expected-error {{incomplete}} - } y = Y(); -} diff --git a/test/CXX/special/class.copy/p11.0x.copy.cpp b/test/CXX/special/class.copy/p11.0x.copy.cpp deleted file mode 100644 index e7256bcf9485..000000000000 --- a/test/CXX/special/class.copy/p11.0x.copy.cpp +++ /dev/null @@ -1,168 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s - -struct Trivial {}; -struct NonTrivial { - NonTrivial(const NonTrivial&); -}; - -// A defaulted copy constructor for a class X is defined as deleted if X has: - -// -- a variant member with a non-trivial corresponding constructor -union DeletedNTVariant { - NonTrivial NT; // expected-note{{copy constructor of 'DeletedNTVariant' is implicitly deleted because variant field 'NT' has a non-trivial copy constructor}} - DeletedNTVariant(); -}; -DeletedNTVariant DVa; -DeletedNTVariant DVb(DVa); // expected-error{{call to implicitly-deleted copy constructor}} - -struct DeletedNTVariant2 { - union { - NonTrivial NT; // expected-note{{copy constructor of 'DeletedNTVariant2' is implicitly deleted because variant field 'NT' has a non-trivial copy constructor}} - }; - DeletedNTVariant2(); -}; -DeletedNTVariant2 DV2a; -DeletedNTVariant2 DV2b(DV2a); // expected-error{{call to implicitly-deleted copy constructor}} - -// -- a non-static data member of class type M (or array thereof) that cannot be -// copied because overload resolution results in an ambiguity or a function -// that is deleted or inaccessible -struct NoAccess { - NoAccess() = default; -private: - NoAccess(const NoAccess&); - - friend struct HasAccess; -}; - -struct HasNoAccess { - NoAccess NA; // expected-note{{copy constructor of 'HasNoAccess' is implicitly deleted because field 'NA' has an inaccessible copy constructor}} -}; -HasNoAccess HNAa; -HasNoAccess HNAb(HNAa); // expected-error{{call to implicitly-deleted copy constructor}} - -struct HasAccess { - NoAccess NA; -}; - -HasAccess HAa; -HasAccess HAb(HAa); - -struct NonConst { - NonConst(NonConst&); -}; -struct Ambiguity { - Ambiguity(const Ambiguity&); - Ambiguity(volatile Ambiguity&); -}; - -struct IsAmbiguous { - NonConst NC; - Ambiguity A; // expected-note 2{{copy constructor of 'IsAmbiguous' is implicitly deleted because field 'A' has multiple copy constructors}} - IsAmbiguous(); -}; -IsAmbiguous IAa; -IsAmbiguous IAb(IAa); // expected-error{{call to implicitly-deleted copy constructor}} - -struct Deleted { - IsAmbiguous IA; // expected-note{{copy constructor of 'Deleted' is implicitly deleted because field 'IA' has a deleted copy constructor}} -}; -Deleted Da; -Deleted Db(Da); // expected-error{{call to implicitly-deleted copy constructor}} - -// It's implied (but not stated) that this also applies in the case where -// overload resolution would fail. -struct VolatileMember { - volatile Trivial vm; // expected-note {{has no copy}} -} vm1, vm2(vm1); // expected-error {{deleted}} - -// -- a direct or virtual base class B that cannot be copied because overload -// resolution results in an ambiguity or a function that is deleted or -// inaccessible -struct AmbiguousCopyBase : Ambiguity { // expected-note 2{{copy constructor of 'AmbiguousCopyBase' is implicitly deleted because base class 'Ambiguity' has multiple copy constructors}} - NonConst NC; -}; -extern AmbiguousCopyBase ACBa; -AmbiguousCopyBase ACBb(ACBa); // expected-error {{deleted copy constructor}} - -struct DeletedCopyBase : AmbiguousCopyBase {}; // expected-note {{copy constructor of 'DeletedCopyBase' is implicitly deleted because base class 'AmbiguousCopyBase' has a deleted copy constructor}} -extern DeletedCopyBase DCBa; -DeletedCopyBase DCBb(DCBa); // expected-error {{deleted copy constructor}} - -struct InaccessibleCopyBase : NoAccess {}; // expected-note {{copy constructor of 'InaccessibleCopyBase' is implicitly deleted because base class 'NoAccess' has an inaccessible copy constructor}} -extern InaccessibleCopyBase ICBa; -InaccessibleCopyBase ICBb(ICBa); // expected-error {{deleted copy constructor}} - -// -- any direct or virtual base class or non-static data member of a type with -// a destructor that is deleted or inaccessible -struct NoAccessDtor { -private: - ~NoAccessDtor(); - friend struct HasAccessDtor; -}; - -struct HasNoAccessDtor { - NoAccessDtor NAD; // expected-note{{copy constructor of 'HasNoAccessDtor' is implicitly deleted because field 'NAD' has an inaccessible destructor}} - HasNoAccessDtor(); - ~HasNoAccessDtor(); -}; -HasNoAccessDtor HNADa; -HasNoAccessDtor HNADb(HNADa); // expected-error{{call to implicitly-deleted copy constructor}} - -struct HasAccessDtor { - NoAccessDtor NAD; -}; -HasAccessDtor HADa; -HasAccessDtor HADb(HADa); - -struct HasNoAccessDtorBase : NoAccessDtor { // expected-note{{copy constructor of 'HasNoAccessDtorBase' is implicitly deleted because base class 'NoAccessDtor' has an inaccessible destructor}} -}; -extern HasNoAccessDtorBase HNADBa; -HasNoAccessDtorBase HNADBb(HNADBa); // expected-error{{implicitly-deleted copy constructor}} - -// -- a non-static data member of rvalue reference type -int some_int; -struct RValue { - int && ri = static_cast<int&&>(some_int); // expected-note{{copy constructor of 'RValue' is implicitly deleted because field 'ri' is of rvalue reference type 'int &&'}} -}; -RValue RVa; -RValue RVb(RVa); // expected-error{{call to implicitly-deleted copy constructor}} - -// FIXME: The error on the class-name is attached to the location of the -// constructor. This is not especially clear. -struct RValueTmp { // expected-error {{reference member 'ri' binds to a temporary}} - int && ri = 1; // expected-note{{copy constructor of 'RValueTmp' is implicitly deleted because field 'ri' is of rvalue reference type 'int &&'}} // expected-note {{default member init}} -}; -RValueTmp RVTa; // expected-note {{implicit default constructor for 'RValueTmp' first required here}} -RValueTmp RVTb(RVTa); // expected-error{{call to implicitly-deleted copy constructor}} - -namespace PR13381 { - struct S { - S(const S&); - S(const volatile S&) = delete; // expected-note{{deleted here}} - }; - struct T { - volatile S s; // expected-note{{field 's' has a deleted copy constructor}} - }; - T &f(); - T t = f(); // expected-error{{call to implicitly-deleted copy constructor}} -} - -namespace Mutable { - struct A { - A(const A &); - A(A &) = delete; // expected-note {{deleted here}} - }; - - struct B { - A a; - B(const B &); - }; - B::B(const B &) = default; - - struct C { - mutable A a; // expected-note {{deleted because field 'a' has a deleted copy constructor}} - C(const C &); - }; - C::C(const C &) = default; // expected-error{{would delete}} -} diff --git a/test/CXX/special/class.copy/p11.0x.move.cpp b/test/CXX/special/class.copy/p11.0x.move.cpp deleted file mode 100644 index 5b016836e9ef..000000000000 --- a/test/CXX/special/class.copy/p11.0x.move.cpp +++ /dev/null @@ -1,201 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s - -struct Trivial {}; -struct NonTrivial { - NonTrivial(NonTrivial&&); // expected-note{{copy constructor is implicitly deleted}} -}; -struct DeletedCopy { - DeletedCopy(const DeletedCopy&) = delete; -}; - -// A defaulted move constructor for a class X is defined as deleted if X has: - -// -- a variant member with a non-trivial corresponding constructor -union DeletedNTVariant { - NonTrivial NT; // expected-note{{deleted because variant field 'NT' has a non-trivial move constructor}} - DeletedNTVariant(DeletedNTVariant&&); -}; -DeletedNTVariant::DeletedNTVariant(DeletedNTVariant&&) = default; // expected-error{{would delete}} - -struct DeletedNTVariant2 { - union { - NonTrivial NT; // expected-note{{deleted because variant field 'NT' has a non-trivial move constructor}} - }; - DeletedNTVariant2(DeletedNTVariant2&&); -}; -DeletedNTVariant2::DeletedNTVariant2(DeletedNTVariant2&&) = default; // expected-error{{would delete}} - -// Note, move constructor is not a candidate because it is deleted. -template<typename T> struct DeletedNTVariant3 { // expected-note 2{{default}} expected-note 2{{copy}} - union { - T NT; - }; -}; -extern DeletedNTVariant3<NonTrivial> dntv3a(0); // expected-error {{no matching}} -extern DeletedNTVariant3<DeletedCopy> dntv3a(0); // expected-error {{no matching}} - -// -- a non-static data member of class type M (or array thereof) that cannot be -// copied because overload resolution results in an ambiguity or a function -// that is deleted or inaccessible -struct NoAccess { - NoAccess() = default; -private: - NoAccess(NoAccess&&); - - friend struct HasAccess; -}; - -struct HasNoAccess { - NoAccess NA; // expected-note{{deleted because field 'NA' has an inaccessible move constructor}} - HasNoAccess(HasNoAccess&&); -}; -HasNoAccess::HasNoAccess(HasNoAccess&&) = default; // expected-error{{would delete}} - -struct HasAccess { - NoAccess NA; - HasAccess(HasAccess&&); -}; -HasAccess::HasAccess(HasAccess&&) = default; - -struct Ambiguity { - Ambiguity(const Ambiguity&&); - Ambiguity(volatile Ambiguity&&); -}; - -struct IsAmbiguous { - Ambiguity A; // expected-note{{deleted because field 'A' has multiple move constructors}} - IsAmbiguous(IsAmbiguous&&); // expected-note{{copy constructor is implicitly deleted because 'IsAmbiguous' has a user-declared move constructor}} -}; -IsAmbiguous::IsAmbiguous(IsAmbiguous&&) = default; // expected-error{{would delete}} - -struct Deleted { - // FIXME: This diagnostic is slightly wrong: the constructor we select to move - // 'IA' is deleted, but we select the copy constructor (we ignore the move - // constructor, because it was defaulted and deleted). - IsAmbiguous IA; // expected-note{{deleted because field 'IA' has a deleted move constructor}} - Deleted(Deleted&&); -}; -Deleted::Deleted(Deleted&&) = default; // expected-error{{would delete}} - -// It's implied (but not stated) that this should also happen if overload -// resolution fails. -struct ConstMember { - const Trivial ct; - ConstMember(ConstMember&&); -}; -ConstMember::ConstMember(ConstMember&&) = default; // ok, calls copy ctor -struct ConstMoveOnlyMember { - // FIXME: This diagnostic is slightly wrong: the constructor we select to move - // 'cnt' is deleted, but we select the copy constructor, because the object is - // const. - const NonTrivial cnt; // expected-note{{deleted because field 'cnt' has a deleted move constructor}} - ConstMoveOnlyMember(ConstMoveOnlyMember&&); -}; -ConstMoveOnlyMember::ConstMoveOnlyMember(ConstMoveOnlyMember&&) = default; // expected-error{{would delete}} -struct VolatileMember { - volatile Trivial vt; // expected-note{{deleted because field 'vt' has no move constructor}} - VolatileMember(VolatileMember&&); -}; -VolatileMember::VolatileMember(VolatileMember&&) = default; // expected-error{{would delete}} - -// -- a direct or virtual base class B that cannot be moved because overload -// resolution results in an ambiguity or a function that is deleted or -// inaccessible -struct AmbiguousMoveBase : Ambiguity { // expected-note{{deleted because base class 'Ambiguity' has multiple move constructors}} - AmbiguousMoveBase(AmbiguousMoveBase&&); // expected-note{{copy constructor is implicitly deleted}} -}; -AmbiguousMoveBase::AmbiguousMoveBase(AmbiguousMoveBase&&) = default; // expected-error{{would delete}} - -struct DeletedMoveBase : AmbiguousMoveBase { // expected-note{{deleted because base class 'AmbiguousMoveBase' has a deleted move constructor}} - DeletedMoveBase(DeletedMoveBase&&); -}; -DeletedMoveBase::DeletedMoveBase(DeletedMoveBase&&) = default; // expected-error{{would delete}} - -struct InaccessibleMoveBase : NoAccess { // expected-note{{deleted because base class 'NoAccess' has an inaccessible move constructor}} - InaccessibleMoveBase(InaccessibleMoveBase&&); -}; -InaccessibleMoveBase::InaccessibleMoveBase(InaccessibleMoveBase&&) = default; // expected-error{{would delete}} - -// -- any direct or virtual base class or non-static data member of a type with -// a destructor that is deleted or inaccessible -struct NoAccessDtor { - NoAccessDtor(NoAccessDtor&&); // expected-note{{copy constructor is implicitly deleted because 'NoAccessDtor' has a user-declared move constructor}} -private: - ~NoAccessDtor(); - friend struct HasAccessDtor; -}; - -struct HasNoAccessDtor { - NoAccessDtor NAD; // expected-note {{deleted because field 'NAD' has an inaccessible destructor}} - HasNoAccessDtor(HasNoAccessDtor&&); -}; -HasNoAccessDtor::HasNoAccessDtor(HasNoAccessDtor&&) = default; // expected-error{{would delete}} - -struct HasAccessDtor { - NoAccessDtor NAD; - HasAccessDtor(HasAccessDtor&&); -}; -HasAccessDtor::HasAccessDtor(HasAccessDtor&&) = default; - -struct HasNoAccessDtorBase : NoAccessDtor { // expected-note{{copy constructor of 'HasNoAccessDtorBase' is implicitly deleted because base class 'NoAccessDtor' has a deleted copy constructor}} -}; -extern HasNoAccessDtorBase HNADBa; -HasNoAccessDtorBase HNADBb(HNADBa); // expected-error{{implicitly-deleted copy constructor}} - -// The restriction on rvalue reference members applies to only the copy -// constructor. -struct RValue { - int &&ri = 1; - RValue(RValue&&); -}; -RValue::RValue(RValue&&) = default; - -// -- a non-static data member or direct or virtual base class with a type that -// does not have a move constructor and is not trivially copyable -struct CopyOnly { - CopyOnly(const CopyOnly&); -}; - -struct NonMove { - CopyOnly CO; - NonMove(NonMove&&); -}; -NonMove::NonMove(NonMove&&) = default; // ok under DR1402 - -struct Moveable { - Moveable(); - Moveable(Moveable&&); -}; - -struct HasMove { - Moveable M; - HasMove(HasMove&&); -}; -HasMove::HasMove(HasMove&&) = default; - -namespace DR1402 { - struct member { - member(); - member(const member&); - member& operator=(const member&); - ~member(); - }; - - struct A { - member m_; - - A() = default; - A(const A&) = default; - A& operator=(const A&) = default; - A(A&&) = default; - A& operator=(A&&) = default; - ~A() = default; - }; - - // ok, A's explicitly-defaulted move operations copy m_. - void f() { - A a, b(a), c(static_cast<A&&>(a)); - a = b; - b = static_cast<A&&>(c); - } -} diff --git a/test/CXX/special/class.copy/p12-0x.cpp b/test/CXX/special/class.copy/p12-0x.cpp deleted file mode 100644 index a0ef49d9b64d..000000000000 --- a/test/CXX/special/class.copy/p12-0x.cpp +++ /dev/null @@ -1,216 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -verify %s -Wno-defaulted-function-deleted - -// expected-no-diagnostics - -template<typename T, bool B> struct trivially_copyable_check { - static_assert(B == __has_trivial_copy(T), ""); - static_assert(B == __is_trivially_constructible(T, T), ""); - static_assert(B == __is_trivially_constructible(T, const T &), ""); - static_assert(B == __is_trivially_constructible(T, T &&), ""); - typedef void type; -}; -template<typename T> using trivially_copyable = - typename trivially_copyable_check<T, true>::type; -template<typename T> using not_trivially_copyable = - typename trivially_copyable_check<T, false>::type; - -struct Trivial {}; -using _ = trivially_copyable<Trivial>; - -// A copy/move constructor for class X is trivial if it is not user-provided, -struct UserProvided { - UserProvided(const UserProvided &); -}; -using _ = not_trivially_copyable<UserProvided>; - -// its declared parameter type is the same as if it had been implicitly -// declared, -struct NonConstCopy { - NonConstCopy(NonConstCopy &) = default; -}; -using _ = not_trivially_copyable<NonConstCopy>; - -// class X has no virtual functions -struct VFn { - virtual void f(); -}; -using _ = not_trivially_copyable<VFn>; - -// and no virtual base classes -struct VBase : virtual Trivial {}; -using _ = not_trivially_copyable<VBase>; - -// and the constructor selected to copy/move each [direct subobject] is trivial -struct TemplateCtor { - template<typename T> TemplateCtor(T &); -}; -using _ = trivially_copyable<TemplateCtor>; -struct TemplateCtorMember { - TemplateCtor tc; -}; -using _ = trivially_copyable<TemplateCtorMember>; - -// We can select a non-trivial copy ctor even if there is a trivial one. -struct MutableTemplateCtorMember { - mutable TemplateCtor mtc; -}; -static_assert(!__is_trivially_constructible(MutableTemplateCtorMember, const MutableTemplateCtorMember &), ""); -static_assert(__is_trivially_constructible(MutableTemplateCtorMember, MutableTemplateCtorMember &&), ""); -struct MutableTemplateCtorMember2 { - MutableTemplateCtorMember2(const MutableTemplateCtorMember2 &) = default; - MutableTemplateCtorMember2(MutableTemplateCtorMember2 &&) = default; - mutable TemplateCtor mtc; -}; -static_assert(!__is_trivially_constructible(MutableTemplateCtorMember2, const MutableTemplateCtorMember2 &), ""); -static_assert(__is_trivially_constructible(MutableTemplateCtorMember2, MutableTemplateCtorMember2 &&), ""); - -// Both trivial and non-trivial special members. -struct TNT { - TNT(const TNT &) = default; // trivial - TNT(TNT &); // non-trivial - - TNT(TNT &&) = default; // trivial - TNT(const TNT &&); // non-trivial -}; - -static_assert(!__has_trivial_copy(TNT), "lie deliberately for gcc compatibility"); -static_assert(__is_trivially_constructible(TNT, TNT), ""); -static_assert(!__is_trivially_constructible(TNT, TNT &), ""); -static_assert(__is_trivially_constructible(TNT, const TNT &), ""); -static_assert(!__is_trivially_constructible(TNT, volatile TNT &), ""); -static_assert(__is_trivially_constructible(TNT, TNT &&), ""); -static_assert(!__is_trivially_constructible(TNT, const TNT &&), ""); -static_assert(!__is_trivially_constructible(TNT, volatile TNT &&), ""); - -// This has only trivial special members. -struct DerivedFromTNT : TNT {}; - -static_assert(__has_trivial_copy(DerivedFromTNT), ""); -static_assert(__is_trivially_constructible(DerivedFromTNT, DerivedFromTNT), ""); -static_assert(__is_trivially_constructible(DerivedFromTNT, DerivedFromTNT &), ""); -static_assert(__is_trivially_constructible(DerivedFromTNT, const DerivedFromTNT &), ""); -static_assert(!__is_trivially_constructible(DerivedFromTNT, volatile DerivedFromTNT &), ""); -static_assert(__is_trivially_constructible(DerivedFromTNT, DerivedFromTNT &&), ""); -static_assert(__is_trivially_constructible(DerivedFromTNT, const DerivedFromTNT &&), ""); -static_assert(!__is_trivially_constructible(DerivedFromTNT, volatile DerivedFromTNT &&), ""); - -// This has only trivial special members. -struct TNTMember { - TNT tnt; -}; - -static_assert(__has_trivial_copy(TNTMember), ""); -static_assert(__is_trivially_constructible(TNTMember, TNTMember), ""); -static_assert(__is_trivially_constructible(TNTMember, TNTMember &), ""); -static_assert(__is_trivially_constructible(TNTMember, const TNTMember &), ""); -static_assert(!__is_trivially_constructible(TNTMember, volatile TNTMember &), ""); -static_assert(__is_trivially_constructible(TNTMember, TNTMember &&), ""); -static_assert(__is_trivially_constructible(TNTMember, const TNTMember &&), ""); -static_assert(!__is_trivially_constructible(TNTMember, volatile TNTMember &&), ""); - -struct NCCTNT : NonConstCopy, TNT {}; - -static_assert(!__has_trivial_copy(NCCTNT), ""); -static_assert(!__is_trivially_constructible(NCCTNT, NCCTNT), ""); -static_assert(!__is_trivially_constructible(NCCTNT, NCCTNT &), ""); -static_assert(!__is_trivially_constructible(NCCTNT, const NCCTNT &), ""); -static_assert(!__is_trivially_constructible(NCCTNT, volatile NCCTNT &), ""); -static_assert(!__is_trivially_constructible(NCCTNT, NCCTNT &&), ""); -static_assert(!__is_trivially_constructible(NCCTNT, const NCCTNT &&), ""); -static_assert(!__is_trivially_constructible(NCCTNT, volatile NCCTNT &&), ""); - -struct TemplateCtorNoMove { - TemplateCtorNoMove(const TemplateCtorNoMove &) = default; - template<typename T> TemplateCtorNoMove(T &&); -}; -static_assert(__is_trivially_constructible(TemplateCtorNoMove, const TemplateCtorNoMove &), ""); -static_assert(!__is_trivially_constructible(TemplateCtorNoMove, TemplateCtorNoMove &&), ""); - -struct UseTemplateCtorNoMove { - TemplateCtorNoMove tcnm; -}; -static_assert(__is_trivially_constructible(UseTemplateCtorNoMove, const UseTemplateCtorNoMove &), ""); -static_assert(!__is_trivially_constructible(UseTemplateCtorNoMove, UseTemplateCtorNoMove &&), ""); - -struct TemplateCtorNoMoveSFINAE { - TemplateCtorNoMoveSFINAE(const TemplateCtorNoMoveSFINAE &) = default; - template<typename T, typename U = typename T::error> TemplateCtorNoMoveSFINAE(T &&); -}; -static_assert(__is_trivially_constructible(TemplateCtorNoMoveSFINAE, const TemplateCtorNoMoveSFINAE &), ""); -static_assert(__is_trivially_constructible(TemplateCtorNoMoveSFINAE, TemplateCtorNoMoveSFINAE &&), ""); - -struct UseTemplateCtorNoMoveSFINAE { - TemplateCtorNoMoveSFINAE tcnm; -}; -static_assert(__is_trivially_constructible(UseTemplateCtorNoMoveSFINAE, const UseTemplateCtorNoMoveSFINAE &), ""); -static_assert(__is_trivially_constructible(UseTemplateCtorNoMoveSFINAE, UseTemplateCtorNoMoveSFINAE &&), ""); - -namespace TrivialityDependsOnImplicitDeletion { - struct PrivateMove { - PrivateMove(const PrivateMove &) = default; - private: - PrivateMove(PrivateMove &&); - friend class Access; - }; - static_assert(__is_trivially_constructible(PrivateMove, const PrivateMove &), ""); - static_assert(!__is_trivially_constructible(PrivateMove, PrivateMove &&), ""); - - struct NoAccess { - PrivateMove pm; - // NoAccess's move is deleted, so moves of it use PrivateMove's copy ctor, - // which is trivial. - }; - static_assert(__is_trivially_constructible(NoAccess, const NoAccess &), ""); - static_assert(__is_trivially_constructible(NoAccess, NoAccess &&), ""); - struct TopNoAccess : NoAccess {}; - static_assert(__is_trivially_constructible(TopNoAccess, const TopNoAccess &), ""); - static_assert(__is_trivially_constructible(TopNoAccess, TopNoAccess &&), ""); - - struct Access { - PrivateMove pm; - // NoAccess's move would *not* be deleted, so is *not* suppressed, - // so moves of it use PrivateMove's move ctor, which is not trivial. - }; - static_assert(__is_trivially_constructible(Access, const Access &), ""); - static_assert(!__is_trivially_constructible(Access, Access &&), ""); - struct TopAccess : Access {}; - static_assert(__is_trivially_constructible(TopAccess, const TopAccess &), ""); - static_assert(!__is_trivially_constructible(TopAccess, TopAccess &&), ""); -} - -namespace TrivialityDependsOnDestructor { - class HasInaccessibleDestructor { ~HasInaccessibleDestructor() = default; }; - struct HasImplicitlyDeletedDestructor : HasInaccessibleDestructor {}; - struct HasImplicitlyDeletedCopyCtor : HasImplicitlyDeletedDestructor { - HasImplicitlyDeletedCopyCtor() = default; - template<typename T> HasImplicitlyDeletedCopyCtor(T &&); - // Copy ctor is deleted but trivial. - // Move ctor is suppressed. - HasImplicitlyDeletedCopyCtor(const HasImplicitlyDeletedCopyCtor&) = default; - HasImplicitlyDeletedCopyCtor(HasImplicitlyDeletedCopyCtor&&) = default; - }; - struct Test : HasImplicitlyDeletedCopyCtor { - Test(const Test&) = default; - Test(Test&&) = default; - }; - // Implicit copy ctor calls deleted trivial copy ctor. - static_assert(__has_trivial_copy(Test), ""); - // This is false because the destructor is deleted. - static_assert(!__is_trivially_constructible(Test, const Test &), ""); - // Implicit move ctor calls template ctor. - static_assert(!__is_trivially_constructible(Test, Test &&), ""); - - struct HasAccessibleDestructor { ~HasAccessibleDestructor() = default; }; - struct HasImplicitlyDefaultedDestructor : HasAccessibleDestructor {}; - struct HasImplicitlyDefaultedCopyCtor : HasImplicitlyDefaultedDestructor { - template<typename T> HasImplicitlyDefaultedCopyCtor(T &&); - // Copy ctor is trivial. - // Move ctor is trivial. - }; - struct Test2 : HasImplicitlyDefaultedCopyCtor {}; - // Implicit copy ctor calls trivial copy ctor. - static_assert(__has_trivial_copy(Test2), ""); - static_assert(__is_trivially_constructible(Test2, const Test2 &), ""); - // Implicit move ctor calls trivial move ctor. - static_assert(__is_trivially_constructible(Test2, Test2 &&), ""); -} diff --git a/test/CXX/special/class.copy/p13-0x.cpp b/test/CXX/special/class.copy/p13-0x.cpp deleted file mode 100644 index 16c8a4029cba..000000000000 --- a/test/CXX/special/class.copy/p13-0x.cpp +++ /dev/null @@ -1,131 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s - -// If the implicitly-defined constructor would satisfy the requirements of a -// constexpr constructor, the implicitly-defined constructor is constexpr. -struct Constexpr1 { - constexpr Constexpr1() : n(0) {} - int n; -}; -constexpr Constexpr1 c1a = Constexpr1(Constexpr1()); // ok -constexpr Constexpr1 c1b = Constexpr1(Constexpr1(c1a)); // ok - -struct Constexpr2 { - Constexpr1 ce1; - constexpr Constexpr2() = default; - constexpr Constexpr2(const Constexpr2 &o) : ce1(o.ce1) {} - // no move constructor -}; - -constexpr Constexpr2 c2a = Constexpr2(Constexpr2()); // ok -constexpr Constexpr2 c2b = Constexpr2(Constexpr2(c2a)); // ok - -struct Constexpr3 { - Constexpr2 ce2; - // all special constructors are constexpr, move ctor calls ce2's copy ctor -}; - -constexpr Constexpr3 c3a = Constexpr3(Constexpr3()); // ok -constexpr Constexpr3 c3b = Constexpr3(Constexpr3(c3a)); // ok - -struct NonConstexprCopy { - constexpr NonConstexprCopy() = default; - NonConstexprCopy(const NonConstexprCopy &); - constexpr NonConstexprCopy(NonConstexprCopy &&) = default; - - int n = 42; -}; - -NonConstexprCopy::NonConstexprCopy(const NonConstexprCopy &) = default; // expected-note {{here}} - -constexpr NonConstexprCopy ncc1 = NonConstexprCopy(NonConstexprCopy()); // ok -constexpr NonConstexprCopy ncc2 = ncc1; // expected-error {{constant expression}} expected-note {{non-constexpr constructor}} - -struct NonConstexprDefault { - NonConstexprDefault() = default; - constexpr NonConstexprDefault(int n) : n(n) {} - int n; -}; -struct Constexpr4 { - NonConstexprDefault ncd; -}; - -constexpr NonConstexprDefault ncd = NonConstexprDefault(NonConstexprDefault(1)); -constexpr Constexpr4 c4a = { ncd }; -constexpr Constexpr4 c4b = Constexpr4(c4a); -constexpr Constexpr4 c4c = Constexpr4(static_cast<Constexpr4&&>(const_cast<Constexpr4&>(c4b))); - -struct Constexpr5Base {}; -struct Constexpr5 : Constexpr5Base { constexpr Constexpr5() {} }; -constexpr Constexpr5 ce5move = Constexpr5(); -constexpr Constexpr5 ce5copy = ce5move; - -// An explicitly-defaulted constructor doesn't become constexpr until the end of -// its class. Make sure we note that the class has a constexpr constructor when -// that happens. -namespace PR13052 { - template<typename T> struct S { - S() = default; // expected-note 2{{here}} - S(S&&) = default; - S(const S&) = default; - T t; - }; - - struct U { - U() = default; - U(U&&) = default; - U(const U&) = default; - }; - - struct V { - V(); // expected-note {{here}} - V(V&&) = default; - V(const V&) = default; - }; - - struct W { - W(); // expected-note {{here}} - }; - - static_assert(__is_literal_type(U), ""); - static_assert(!__is_literal_type(V), ""); - static_assert(!__is_literal_type(W), ""); - static_assert(__is_literal_type(S<U>), ""); - static_assert(!__is_literal_type(S<V>), ""); - static_assert(!__is_literal_type(S<W>), ""); - - struct X { - friend constexpr U::U() noexcept; - friend constexpr U::U(U&&) noexcept; - friend constexpr U::U(const U&) noexcept; - friend constexpr V::V(); // expected-error {{follows non-constexpr declaration}} - friend constexpr V::V(V&&) noexcept; - friend constexpr V::V(const V&) noexcept; - friend constexpr W::W(); // expected-error {{follows non-constexpr declaration}} - friend constexpr W::W(W&&) noexcept; - friend constexpr W::W(const W&) noexcept; - friend constexpr S<U>::S() noexcept; - friend constexpr S<U>::S(S<U>&&) noexcept; - friend constexpr S<U>::S(const S<U>&) noexcept; - friend constexpr S<V>::S(); // expected-error {{follows non-constexpr declaration}} - friend constexpr S<V>::S(S<V>&&) noexcept; - friend constexpr S<V>::S(const S<V>&) noexcept; - friend constexpr S<W>::S(); // expected-error {{follows non-constexpr declaration}} - friend constexpr S<W>::S(S<W>&&) noexcept; - friend constexpr S<W>::S(const S<W>&) noexcept; - }; -} - -namespace Mutable { - struct A { - constexpr A(A &); - A(const A &); - }; - struct B { - constexpr B(const B &) = default; // ok - mutable A a; - }; - struct C { - constexpr C(const C &) = default; // expected-error {{not constexpr}} - A a; - }; -} diff --git a/test/CXX/special/class.copy/p15-0x.cpp b/test/CXX/special/class.copy/p15-0x.cpp deleted file mode 100644 index 9d03a55423db..000000000000 --- a/test/CXX/special/class.copy/p15-0x.cpp +++ /dev/null @@ -1,42 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s -// expected-no-diagnostics - -namespace PR10622 { - struct foo { - const int first; - foo(const foo&) = default; - }; - void find_or_insert(const foo& __obj) { - foo x(__obj); - } - - struct bar : foo { - bar(const bar&) = default; - }; - void test_bar(const bar &obj) { - bar obj2(obj); - } -} - -namespace PR11418 { - template<typename T> - T may_throw() { - return T(); - } - - template<typename T> T &&declval() noexcept; - - struct NonPOD { - NonPOD(); - NonPOD(const NonPOD &) noexcept; - NonPOD(NonPOD &&) noexcept; - }; - - struct X { - NonPOD np = may_throw<NonPOD>(); - }; - - static_assert(noexcept(declval<X>()), "noexcept isn't working at all"); - static_assert(noexcept(X(declval<X&>())), "copy constructor can't throw"); - static_assert(noexcept(X(declval<X>())), "move constructor can't throw"); -} diff --git a/test/CXX/special/class.copy/p15-inclass.cpp b/test/CXX/special/class.copy/p15-inclass.cpp deleted file mode 100644 index 7e716fd6c92f..000000000000 --- a/test/CXX/special/class.copy/p15-inclass.cpp +++ /dev/null @@ -1,42 +0,0 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c++11 -emit-llvm -o - %s | FileCheck %s - -namespace PR11418 { - struct NonPOD { - NonPOD(); - NonPOD(const NonPOD &); - NonPOD(NonPOD &&); - }; - - struct X { - NonPOD np; - int a = 17; - }; - - void check_copy(X x) { - X x2(x); - } - - void check_move(X x) { - X x3(static_cast<X&&>(x)); - } - - // CHECK: define linkonce_odr void @_ZN7PR114181XC2ERKS0_ - // CHECK-NOT: 17 - // CHECK: call void @_ZN7PR114186NonPODC1ERKS0_ - // CHECK-NOT: 17 - // CHECK: load i32, i32* - // CHECK-NOT: 17 - // CHECK: store i32 - // CHECK-NOT: 17 - // CHECK: ret - - // CHECK: define linkonce_odr void @_ZN7PR114181XC2EOS0_ - // CHECK-NOT: 17 - // CHECK: call void @_ZN7PR114186NonPODC1EOS0_ - // CHECK-NOT: 17 - // CHECK: load i32, i32* - // CHECK-NOT: 17 - // CHECK: store i32 - // CHECK-NOT: 17 - // CHECK: ret -} diff --git a/test/CXX/special/class.copy/p18-cxx11.cpp b/test/CXX/special/class.copy/p18-cxx11.cpp deleted file mode 100644 index 7b09dd679f2d..000000000000 --- a/test/CXX/special/class.copy/p18-cxx11.cpp +++ /dev/null @@ -1,62 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 %s -verify -// expected-no-diagnostics - -// C++98 [class.copy]p10 / C++11 [class.copy]p18. - -// The implicitly-declared copy assignment operator for a class X will have the form -// X& X::operator=(const X&) -// if [every direct subobject] has a copy assignment operator whose first parameter is -// of type 'const volatile[opt] T &' or 'T'. Otherwise, it will have the form -// X &X::operator=(X&) - -struct ConstCopy { - ConstCopy &operator=(const ConstCopy &); -}; - -struct NonConstCopy { - NonConstCopy &operator=(NonConstCopy &); -}; - -struct DeletedConstCopy { - DeletedConstCopy &operator=(const DeletedConstCopy &) = delete; -}; - -struct DeletedNonConstCopy { - DeletedNonConstCopy &operator=(DeletedNonConstCopy &) = delete; -}; - -struct ImplicitlyDeletedConstCopy { - ImplicitlyDeletedConstCopy &operator=(ImplicitlyDeletedConstCopy &&); -}; - -struct ByValueCopy { - ByValueCopy &operator=(ByValueCopy); -}; - -struct AmbiguousConstCopy { - AmbiguousConstCopy &operator=(const AmbiguousConstCopy&); - AmbiguousConstCopy &operator=(AmbiguousConstCopy); -}; - - -struct A : ConstCopy {}; -struct B : NonConstCopy { ConstCopy a; }; -struct C : ConstCopy { NonConstCopy a; }; -struct D : DeletedConstCopy {}; -struct E : DeletedNonConstCopy {}; -struct F { ImplicitlyDeletedConstCopy a; }; -struct G : virtual B {}; -struct H : ByValueCopy {}; -struct I : AmbiguousConstCopy {}; - -struct Test { - friend A &A::operator=(const A &); - friend B &B::operator=(B &); - friend C &C::operator=(C &); - friend D &D::operator=(const D &); - friend E &E::operator=(E &); - friend F &F::operator=(const F &); - friend G &G::operator=(G &); - friend H &H::operator=(const H &); - friend I &I::operator=(const I &); -}; diff --git a/test/CXX/special/class.copy/p20.cpp b/test/CXX/special/class.copy/p20.cpp deleted file mode 100644 index 4f17879ecfb7..000000000000 --- a/test/CXX/special/class.copy/p20.cpp +++ /dev/null @@ -1,47 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s - -struct ConstCopy { - ConstCopy(); - ConstCopy &operator=(const ConstCopy&); -}; - -struct NonConstCopy { - NonConstCopy(); - NonConstCopy &operator=(NonConstCopy&); -}; - -struct VirtualInheritsNonConstCopy : virtual NonConstCopy { - VirtualInheritsNonConstCopy(); - VirtualInheritsNonConstCopy &operator=(const VirtualInheritsNonConstCopy&); -}; - -struct ImplicitNonConstCopy1 : NonConstCopy { // expected-note{{the implicit copy assignment operator}} - ImplicitNonConstCopy1(); -}; - -struct ImplicitNonConstCopy2 { // expected-note{{the implicit copy assignment operator}} - ImplicitNonConstCopy2(); - NonConstCopy ncc; -}; - -struct ImplicitNonConstCopy3 { // expected-note{{the implicit copy assignment operator}} - ImplicitNonConstCopy3(); - NonConstCopy ncc_array[2][3]; -}; - -struct ImplicitNonConstCopy4 : VirtualInheritsNonConstCopy { - ImplicitNonConstCopy4(); -}; - -void test_non_const_copy(const ImplicitNonConstCopy1 &cincc1, - const ImplicitNonConstCopy2 &cincc2, - const ImplicitNonConstCopy3 &cincc3, - const ImplicitNonConstCopy4 &cincc4, - const VirtualInheritsNonConstCopy &vincc) { - (void)sizeof(ImplicitNonConstCopy1() = cincc1); // expected-error{{no viable overloaded '='}} - (void)sizeof(ImplicitNonConstCopy2() = cincc2); // expected-error{{no viable overloaded '='}} - (void)sizeof(ImplicitNonConstCopy3() = cincc3); // expected-error{{no viable overloaded '='}} - (void)sizeof(ImplicitNonConstCopy4() = cincc4); // okay - (void)sizeof(VirtualInheritsNonConstCopy() = vincc); -} diff --git a/test/CXX/special/class.copy/p23-cxx11.cpp b/test/CXX/special/class.copy/p23-cxx11.cpp deleted file mode 100644 index 0b9652b50fcf..000000000000 --- a/test/CXX/special/class.copy/p23-cxx11.cpp +++ /dev/null @@ -1,191 +0,0 @@ -// RUN: %clang_cc1 -verify %s -std=c++11 -Wno-defaulted-function-deleted - -struct Trivial {}; - -template<typename T> struct CopyAssign { - static T t; - void test() { - t = t; // expected-error +{{deleted}} - } -}; -template<typename T> struct MoveAssign { - static T t; - void test() { - // Overload resolution will ignore a defaulted, deleted move assignment, - // so check for it in a different way. - T &(T::*f)(T&&) = &T::operator=; // expected-error +{{deleted}} - } -}; -template<typename T> struct MoveOrCopyAssign { - static T t; - void test() { - t = static_cast<T&&>(t); // expected-error +{{copy assignment operator is implicitly deleted}} - } -}; - -struct NonTrivialCopyAssign { - NonTrivialCopyAssign &operator=(const NonTrivialCopyAssign &); -}; -struct NonTrivialMoveAssign { - NonTrivialMoveAssign &operator=(NonTrivialMoveAssign &&); -}; -struct AmbiguousCopyAssign { - AmbiguousCopyAssign &operator=(const AmbiguousCopyAssign &) volatile; - AmbiguousCopyAssign &operator=(const AmbiguousCopyAssign &) const; -}; -struct AmbiguousMoveAssign { - AmbiguousMoveAssign &operator=(const AmbiguousMoveAssign &&); - AmbiguousMoveAssign &operator=(volatile AmbiguousMoveAssign &&); -}; -struct DeletedCopyAssign { - DeletedCopyAssign &operator=(const DeletedCopyAssign &) = delete; // expected-note 2{{deleted}} -}; -struct DeletedMoveAssign { - DeletedMoveAssign &operator=(DeletedMoveAssign &&) = delete; // expected-note 2{{deleted}} -}; -class InaccessibleCopyAssign { - InaccessibleCopyAssign &operator=(const InaccessibleCopyAssign &); -}; -class InaccessibleMoveAssign { - InaccessibleMoveAssign &operator=(InaccessibleMoveAssign &&); -}; -class NonConstCopyAssign { - NonConstCopyAssign &operator=(NonConstCopyAssign &); -}; - -// A defaulted copy/move assignment operator for class X is defined as deleted -// if X has: - -// -- a variant member with a non-trivial corresponding assignment operator -// and X is a union-like class -struct A1 { - union { - NonTrivialCopyAssign x; // expected-note {{variant field 'x' has a non-trivial copy assign}} - }; -}; -template struct CopyAssign<A1>; // expected-note {{here}} - -struct A2 { - A2 &operator=(A2 &&) = default; // expected-note {{here}} - union { - NonTrivialMoveAssign x; // expected-note {{variant field 'x' has a non-trivial move assign}} - }; -}; -template struct MoveAssign<A2>; // expected-note {{here}} - -// -- a non-static const data member of (array of) non-class type -struct B1 { - const int a; // expected-note 2{{field 'a' is of const-qualified type}} -}; -struct B2 { - const void *const a[3][9][2]; // expected-note 2{{field 'a' is of const-qualified type 'const void *const [3][9][2]'}} -}; -struct B3 { - const void *a[3]; -}; -template struct CopyAssign<B1>; // expected-note {{here}} -template struct MoveAssign<B1>; // expected-note {{here}} -template struct CopyAssign<B2>; // expected-note {{here}} -template struct MoveAssign<B2>; // expected-note {{here}} -template struct CopyAssign<B3>; -template struct MoveAssign<B3>; - -// -- a non-static data member of reference type -struct C1 { - int &a; // expected-note 2{{field 'a' is of reference type 'int &'}} -}; -template struct CopyAssign<C1>; // expected-note {{here}} -template struct MoveAssign<C1>; // expected-note {{here}} - -// -- a non-static data member of class type M that cannot be copied/moved -struct D1 { - AmbiguousCopyAssign a; // expected-note {{field 'a' has multiple copy}} -}; -struct D2 { - D2 &operator=(D2 &&) = default; // expected-note {{here}} expected-note {{copy assignment operator is implicitly deleted}} - AmbiguousMoveAssign a; // expected-note {{field 'a' has multiple move}} -}; -struct D3 { - DeletedCopyAssign a; // expected-note {{field 'a' has a deleted copy}} -}; -struct D4 { - D4 &operator=(D4 &&) = default; // expected-note {{here}} expected-note {{copy assignment operator is implicitly deleted}} - DeletedMoveAssign a; // expected-note {{field 'a' has a deleted move}} -}; -struct D5 { - InaccessibleCopyAssign a; // expected-note {{field 'a' has an inaccessible copy}} -}; -struct D6 { - D6 &operator=(D6 &&) = default; // expected-note {{here}} expected-note {{copy assignment operator is implicitly deleted}} - InaccessibleMoveAssign a; // expected-note {{field 'a' has an inaccessible move}} -}; -struct D7 { - const Trivial a; // expected-note 3{{field 'a' has no }} -}; -struct D8 { - volatile Trivial a; // expected-note 3{{field 'a' has no }} -}; -template struct CopyAssign<D1>; // expected-note {{here}} -template struct MoveAssign<D2>; // expected-note {{here}} -template struct MoveOrCopyAssign<D2>; // expected-note {{here}} -template struct CopyAssign<D3>; // expected-note {{here}} -template struct MoveAssign<D4>; // expected-note {{here}} -template struct MoveOrCopyAssign<D4>; // expected-note {{here}} -template struct CopyAssign<D5>; // expected-note {{here}} -template struct MoveAssign<D6>; // expected-note {{here}} -template struct MoveOrCopyAssign<D6>; // expected-note {{here}} -template struct CopyAssign<D7>; // expected-note {{here}} -template struct MoveAssign<D7>; // expected-note {{here}} -template struct MoveOrCopyAssign<D7>; // expected-note {{here}} -template struct CopyAssign<D8>; // expected-note {{here}} -template struct MoveAssign<D8>; // expected-note {{here}} -template struct MoveOrCopyAssign<D8>; // expected-note {{here}} - -// -- a direct or virtual base that cannot be copied/moved -struct E1 : AmbiguousCopyAssign {}; // expected-note {{base class 'AmbiguousCopyAssign' has multiple copy}} -struct E2 : AmbiguousMoveAssign { // expected-note {{base class 'AmbiguousMoveAssign' has multiple move}} - E2 &operator=(E2 &&) = default; // expected-note {{here}} -}; -struct E3 : DeletedCopyAssign {}; // expected-note {{base class 'DeletedCopyAssign' has a deleted copy}} -struct E4 : DeletedMoveAssign { // expected-note {{base class 'DeletedMoveAssign' has a deleted move}} - E4 &operator=(E4 &&) = default; // expected-note {{here}} -}; -struct E5 : InaccessibleCopyAssign {}; // expected-note {{base class 'InaccessibleCopyAssign' has an inaccessible copy}} -struct E6 : InaccessibleMoveAssign { // expected-note {{base class 'InaccessibleMoveAssign' has an inaccessible move}} - E6 &operator=(E6 &&) = default; // expected-note {{here}} -}; -template struct CopyAssign<E1>; // expected-note {{here}} -template struct MoveAssign<E2>; // expected-note {{here}} -template struct CopyAssign<E3>; // expected-note {{here}} -template struct MoveAssign<E4>; // expected-note {{here}} -template struct CopyAssign<E5>; // expected-note {{here}} -template struct MoveAssign<E6>; // expected-note {{here}} - -namespace PR13381 { - struct S { - S &operator=(const S&); - S &operator=(const volatile S&) volatile = delete; // expected-note{{deleted here}} - }; - struct T { - volatile S s; // expected-note{{field 's' has a deleted copy assignment}} - }; - void g() { - T t; - t = T(); // expected-error{{object of type 'PR13381::T' cannot be assigned because its copy assignment operator is implicitly deleted}} - } -} - -namespace Mutable { - struct AmbiguousCopyAssign { - AmbiguousCopyAssign &operator=(const AmbiguousCopyAssign &); - AmbiguousCopyAssign &operator=(volatile AmbiguousCopyAssign &); - }; - struct X { - AmbiguousCopyAssign a; - }; - struct Y { - mutable AmbiguousCopyAssign a; // expected-note {{multiple copy assignment operators}} - }; -} -template struct CopyAssign<Mutable::X>; -template struct CopyAssign<Mutable::Y>; // expected-note {{here}} diff --git a/test/CXX/special/class.copy/p25-0x.cpp b/test/CXX/special/class.copy/p25-0x.cpp deleted file mode 100644 index c7224aea9590..000000000000 --- a/test/CXX/special/class.copy/p25-0x.cpp +++ /dev/null @@ -1,202 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -verify %s - -// expected-no-diagnostics - -template<typename T, bool B> struct trivially_assignable_check { - static_assert(B == __has_trivial_assign(T), ""); - static_assert(B == __is_trivially_assignable(T&, T), ""); - static_assert(B == __is_trivially_assignable(T&, const T &), ""); - static_assert(B == __is_trivially_assignable(T&, T &&), ""); - static_assert(B == __is_trivially_assignable(T&&, T), ""); - static_assert(B == __is_trivially_assignable(T&&, const T &), ""); - static_assert(B == __is_trivially_assignable(T&&, T &&), ""); - typedef void type; -}; -template<typename T> using trivially_assignable = - typename trivially_assignable_check<T, true>::type; -template<typename T> using not_trivially_assignable = - typename trivially_assignable_check<T, false>::type; - -struct Trivial {}; -using _ = trivially_assignable<Trivial>; - -// A copy/move assignment operator for class X is trivial if it is not user-provided, -struct UserProvided { - UserProvided &operator=(const UserProvided &); -}; -using _ = not_trivially_assignable<UserProvided>; - -// its declared parameter type is the same as if it had been implicitly -// declared, -struct NonConstCopy { - NonConstCopy &operator=(NonConstCopy &) = default; -}; -using _ = not_trivially_assignable<NonConstCopy>; - -// class X has no virtual functions -struct VFn { - virtual void f(); -}; -using _ = not_trivially_assignable<VFn>; - -// and no virtual base classes -struct VBase : virtual Trivial {}; -using _ = not_trivially_assignable<VBase>; - -// and the assignment operator selected to copy/move each [direct subobject] is trivial -struct TemplateCtor { - template<typename T> TemplateCtor operator=(T &); -}; -using _ = trivially_assignable<TemplateCtor>; -struct TemplateCtorMember { - TemplateCtor tc; -}; -using _ = trivially_assignable<TemplateCtorMember>; -struct MutableTemplateCtorMember { - mutable TemplateCtor mtc; -}; -static_assert(!__is_trivially_assignable(MutableTemplateCtorMember, const MutableTemplateCtorMember &), ""); -static_assert(__is_trivially_assignable(MutableTemplateCtorMember, MutableTemplateCtorMember &&), ""); - -// Both trivial and non-trivial special members. -struct TNT { - TNT &operator=(const TNT &) = default; // trivial - TNT &operator=(TNT &); // non-trivial - - TNT &operator=(TNT &&) = default; // trivial - TNT &operator=(const TNT &&); // non-trivial -}; - -static_assert(!__has_trivial_assign(TNT), "lie deliberately for gcc compatibility"); -static_assert(__is_trivially_assignable(TNT, TNT), ""); -static_assert(!__is_trivially_assignable(TNT, TNT &), ""); -static_assert(__is_trivially_assignable(TNT, const TNT &), ""); -static_assert(!__is_trivially_assignable(TNT, volatile TNT &), ""); -static_assert(__is_trivially_assignable(TNT, TNT &&), ""); -static_assert(!__is_trivially_assignable(TNT, const TNT &&), ""); -static_assert(!__is_trivially_assignable(TNT, volatile TNT &&), ""); - -// This has only trivial special members. -struct DerivedFromTNT : TNT {}; - -static_assert(__has_trivial_assign(DerivedFromTNT), ""); -static_assert(__is_trivially_assignable(DerivedFromTNT, DerivedFromTNT), ""); -static_assert(__is_trivially_assignable(DerivedFromTNT, DerivedFromTNT &), ""); -static_assert(__is_trivially_assignable(DerivedFromTNT, const DerivedFromTNT &), ""); -static_assert(!__is_trivially_assignable(DerivedFromTNT, volatile DerivedFromTNT &), ""); -static_assert(__is_trivially_assignable(DerivedFromTNT, DerivedFromTNT &&), ""); -static_assert(__is_trivially_assignable(DerivedFromTNT, const DerivedFromTNT &&), ""); -static_assert(!__is_trivially_assignable(DerivedFromTNT, volatile DerivedFromTNT &&), ""); - -// This has only trivial special members. -struct TNTMember { - TNT tnt; -}; - -static_assert(__has_trivial_assign(TNTMember), ""); -static_assert(__is_trivially_assignable(TNTMember, TNTMember), ""); -static_assert(__is_trivially_assignable(TNTMember, TNTMember &), ""); -static_assert(__is_trivially_assignable(TNTMember, const TNTMember &), ""); -static_assert(!__is_trivially_assignable(TNTMember, volatile TNTMember &), ""); -static_assert(__is_trivially_assignable(TNTMember, TNTMember &&), ""); -static_assert(__is_trivially_assignable(TNTMember, const TNTMember &&), ""); -static_assert(!__is_trivially_assignable(TNTMember, volatile TNTMember &&), ""); - -struct NCCTNT : NonConstCopy, TNT {}; - -static_assert(!__has_trivial_assign(NCCTNT), ""); -static_assert(!__is_trivially_assignable(NCCTNT, NCCTNT), ""); -static_assert(!__is_trivially_assignable(NCCTNT, NCCTNT &), ""); -static_assert(!__is_trivially_assignable(NCCTNT, const NCCTNT &), ""); -static_assert(!__is_trivially_assignable(NCCTNT, volatile NCCTNT &), ""); -static_assert(!__is_trivially_assignable(NCCTNT, NCCTNT &&), ""); -static_assert(!__is_trivially_assignable(NCCTNT, const NCCTNT &&), ""); -static_assert(!__is_trivially_assignable(NCCTNT, volatile NCCTNT &&), ""); - -struct MultipleTrivial { - // All four of these are trivial. - MultipleTrivial &operator=(const MultipleTrivial &) & = default; - MultipleTrivial &operator=(const MultipleTrivial &) && = default; - MultipleTrivial &operator=(MultipleTrivial &&) & = default; - MultipleTrivial &operator=(MultipleTrivial &&) && = default; -}; - -using _ = trivially_assignable<MultipleTrivial>; - -struct RefQualifier { - RefQualifier &operator=(const RefQualifier &) & = default; - RefQualifier &operator=(const RefQualifier &) &&; - RefQualifier &operator=(RefQualifier &&) &; - RefQualifier &operator=(RefQualifier &&) && = default; -}; -struct DerivedFromRefQualifier : RefQualifier { - // Both of these call the trivial copy operation. - DerivedFromRefQualifier &operator=(const DerivedFromRefQualifier &) & = default; - DerivedFromRefQualifier &operator=(const DerivedFromRefQualifier &) && = default; - // Both of these call the non-trivial move operation. - DerivedFromRefQualifier &operator=(DerivedFromRefQualifier &&) & = default; - DerivedFromRefQualifier &operator=(DerivedFromRefQualifier &&) && = default; -}; -static_assert(__is_trivially_assignable(DerivedFromRefQualifier&, const DerivedFromRefQualifier&), ""); -static_assert(__is_trivially_assignable(DerivedFromRefQualifier&&, const DerivedFromRefQualifier&), ""); -static_assert(!__is_trivially_assignable(DerivedFromRefQualifier&, DerivedFromRefQualifier&&), ""); -static_assert(!__is_trivially_assignable(DerivedFromRefQualifier&&, DerivedFromRefQualifier&&), ""); - -struct TemplateAssignNoMove { - TemplateAssignNoMove &operator=(const TemplateAssignNoMove &) = default; - template<typename T> TemplateAssignNoMove &operator=(T &&); -}; -static_assert(__is_trivially_assignable(TemplateAssignNoMove, const TemplateAssignNoMove &), ""); -static_assert(!__is_trivially_assignable(TemplateAssignNoMove, TemplateAssignNoMove &&), ""); - -struct UseTemplateAssignNoMove { - TemplateAssignNoMove tanm; -}; -static_assert(__is_trivially_assignable(UseTemplateAssignNoMove, const UseTemplateAssignNoMove &), ""); -static_assert(!__is_trivially_assignable(UseTemplateAssignNoMove, UseTemplateAssignNoMove &&), ""); - -struct TemplateAssignNoMoveSFINAE { - TemplateAssignNoMoveSFINAE &operator=(const TemplateAssignNoMoveSFINAE &) = default; - template<typename T, typename U = typename T::error> TemplateAssignNoMoveSFINAE &operator=(T &&); -}; -static_assert(__is_trivially_assignable(TemplateAssignNoMoveSFINAE, const TemplateAssignNoMoveSFINAE &), ""); -static_assert(__is_trivially_assignable(TemplateAssignNoMoveSFINAE, TemplateAssignNoMoveSFINAE &&), ""); - -struct UseTemplateAssignNoMoveSFINAE { - TemplateAssignNoMoveSFINAE tanm; -}; -static_assert(__is_trivially_assignable(UseTemplateAssignNoMoveSFINAE, const UseTemplateAssignNoMoveSFINAE &), ""); -static_assert(__is_trivially_assignable(UseTemplateAssignNoMoveSFINAE, UseTemplateAssignNoMoveSFINAE &&), ""); - -namespace TrivialityDependsOnImplicitDeletion { - struct PrivateMove { - PrivateMove &operator=(const PrivateMove &) = default; - private: - PrivateMove &operator=(PrivateMove &&); - friend class Access; - }; - static_assert(__is_trivially_assignable(PrivateMove, const PrivateMove &), ""); - static_assert(!__is_trivially_assignable(PrivateMove, PrivateMove &&), ""); - - struct NoAccess { - PrivateMove pm; - // NoAccess's move would be deleted, so is suppressed, - // so moves of it use PrivateMove's copy ctor, which is trivial. - }; - static_assert(__is_trivially_assignable(NoAccess, const NoAccess &), ""); - static_assert(__is_trivially_assignable(NoAccess, NoAccess &&), ""); - struct TopNoAccess : NoAccess {}; - static_assert(__is_trivially_assignable(TopNoAccess, const TopNoAccess &), ""); - static_assert(__is_trivially_assignable(TopNoAccess, TopNoAccess &&), ""); - - struct Access { - PrivateMove pm; - // NoAccess's move would *not* be deleted, so is *not* suppressed, - // so moves of it use PrivateMove's move ctor, which is not trivial. - }; - static_assert(__is_trivially_assignable(Access, const Access &), ""); - static_assert(!__is_trivially_assignable(Access, Access &&), ""); - struct TopAccess : Access {}; - static_assert(__is_trivially_assignable(TopAccess, const TopAccess &), ""); - static_assert(!__is_trivially_assignable(TopAccess, TopAccess &&), ""); -} diff --git a/test/CXX/special/class.copy/p28-cxx11.cpp b/test/CXX/special/class.copy/p28-cxx11.cpp deleted file mode 100644 index dc501d91f713..000000000000 --- a/test/CXX/special/class.copy/p28-cxx11.cpp +++ /dev/null @@ -1,19 +0,0 @@ -// RUN: %clang_cc1 -std=c++98 %s -fsyntax-only -// RUN: %clang_cc1 -std=c++11 %s -verify - -// In C++11, we must perform overload resolution to determine which function is -// called by a defaulted assignment operator, and the selected operator might -// not be a copy or move assignment (it might be a specialization of a templated -// 'operator=', for instance). -struct A { - A &operator=(const A &); - - template<typename T> - A &operator=(T &&) { return T::error; } // expected-error {{no member named 'error' in 'A'}} -}; - -struct B : A { - B &operator=(B &&); -}; - -B &B::operator=(B &&) = default; // expected-note {{here}} diff --git a/test/CXX/special/class.copy/p3.cpp b/test/CXX/special/class.copy/p3.cpp deleted file mode 100644 index 3d87266ef327..000000000000 --- a/test/CXX/special/class.copy/p3.cpp +++ /dev/null @@ -1,27 +0,0 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -o - %s | FileCheck %s - -// PR6141 -template<typename T> -struct X { - X(); - template<typename U> X(X<U>); - X(const X<T>&); -}; - -void f(X<int>) { } - -struct Y : X<int> { }; -struct Z : X<float> { }; - -// CHECK: define i32 @main() -int main() { - // CHECK: call void @_ZN1YC1Ev - // CHECK: call void @_ZN1XIiEC1ERKS0_ - // CHECK: call void @_Z1f1XIiE - f(Y()); - // CHECK: call void @_ZN1ZC1Ev - // CHECK: call void @_ZN1XIfEC1ERKS0_ - // CHECK: call void @_ZN1XIiEC1IfEES_IT_E - // CHECK: call void @_Z1f1XIiE - f(Z()); -} diff --git a/test/CXX/special/class.copy/p33-0x.cpp b/test/CXX/special/class.copy/p33-0x.cpp deleted file mode 100644 index 28cd4f33a8aa..000000000000 --- a/test/CXX/special/class.copy/p33-0x.cpp +++ /dev/null @@ -1,57 +0,0 @@ -// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -std=c++11 -fsyntax-only -verify %s -class X { - X(const X&); - -public: - X(); - X(X&&); -}; - -X return_by_move(int i, X x) { - X x2; - if (i == 0) - return x; - else if (i == 1) - return x2; - else - return x; -} - -void throw_move_only(X x) { - X x2; - throw x; - throw x2; -} - -namespace PR10142 { - struct X { - X(); - X(X&&); - X(const X&) = delete; // expected-note 2{{'X' 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/special/class.copy/p8-cxx11.cpp b/test/CXX/special/class.copy/p8-cxx11.cpp deleted file mode 100644 index 4a9f3f2113df..000000000000 --- a/test/CXX/special/class.copy/p8-cxx11.cpp +++ /dev/null @@ -1,49 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 %s -verify -// expected-no-diagnostics - -// C++98 [class.copy]p5 / C++11 [class.copy]p8. - -// The implicitly-declared copy constructor for a class X will have the form -// X::X(const X&) -// if [every direct subobject] has a copy constructor whose first parameter is -// of type 'const volatile[opt] T &'. Otherwise, it will have the form -// X::X(X&) - -struct ConstCopy { - ConstCopy(const ConstCopy &); -}; - -struct NonConstCopy { - NonConstCopy(NonConstCopy &); -}; - -struct DeletedConstCopy { - DeletedConstCopy(const DeletedConstCopy &) = delete; -}; - -struct DeletedNonConstCopy { - DeletedNonConstCopy(DeletedNonConstCopy &) = delete; -}; - -struct ImplicitlyDeletedConstCopy { - ImplicitlyDeletedConstCopy(ImplicitlyDeletedConstCopy &&); -}; - - -struct A : ConstCopy {}; -struct B : NonConstCopy { ConstCopy a; }; -struct C : ConstCopy { NonConstCopy a; }; -struct D : DeletedConstCopy {}; -struct E : DeletedNonConstCopy {}; -struct F { ImplicitlyDeletedConstCopy a; }; -struct G : virtual B {}; - -struct Test { - friend A::A(const A &); - friend B::B(B &); - friend C::C(C &); - friend D::D(const D &); - friend E::E(E &); - constexpr friend F::F(const F &); - friend G::G(G &); -}; diff --git a/test/CXX/special/class.copy/p9.cpp b/test/CXX/special/class.copy/p9.cpp deleted file mode 100644 index 77ab19e21069..000000000000 --- a/test/CXX/special/class.copy/p9.cpp +++ /dev/null @@ -1,44 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s - -struct ConstCopy { - ConstCopy(); - ConstCopy(const ConstCopy&); -}; - -struct NonConstCopy { - NonConstCopy(); - NonConstCopy(NonConstCopy&); -}; - -struct VirtualInheritsNonConstCopy : virtual NonConstCopy { - VirtualInheritsNonConstCopy(); - VirtualInheritsNonConstCopy(const VirtualInheritsNonConstCopy&); -}; - -struct ImplicitNonConstCopy1 : NonConstCopy { // expected-note {{candidate constructor}} - ImplicitNonConstCopy1(); // expected-note {{candidate constructor}} -}; - -struct ImplicitNonConstCopy2 { // expected-note {{candidate constructor}} - ImplicitNonConstCopy2(); // expected-note {{candidate constructor}} - NonConstCopy ncc; -}; - -struct ImplicitNonConstCopy3 { // expected-note {{candidate constructor}} - ImplicitNonConstCopy3(); // expected-note {{candidate constructor}} - NonConstCopy ncc_array[2][3]; -}; - -struct ImplicitNonConstCopy4 : VirtualInheritsNonConstCopy { // expected-note {{candidate constructor}} - ImplicitNonConstCopy4(); // expected-note {{candidate constructor}} -}; - -void test_non_const_copy(const ImplicitNonConstCopy1 &cincc1, - const ImplicitNonConstCopy2 &cincc2, - const ImplicitNonConstCopy3 &cincc3, - const ImplicitNonConstCopy4 &cincc4) { - (void)sizeof(ImplicitNonConstCopy1(cincc1)); // expected-error{{no matching conversion for functional-style cast from 'const ImplicitNonConstCopy1' to 'ImplicitNonConstCopy1'}} - (void)sizeof(ImplicitNonConstCopy2(cincc2)); // expected-error{{no matching conversion for functional-style cast from 'const ImplicitNonConstCopy2' to 'ImplicitNonConstCopy2'}} - (void)sizeof(ImplicitNonConstCopy3(cincc3)); // expected-error{{no matching conversion for functional-style cast from 'const ImplicitNonConstCopy3' to 'ImplicitNonConstCopy3'}} - (void)sizeof(ImplicitNonConstCopy4(cincc4)); // expected-error{{no matching conversion for functional-style cast from 'const ImplicitNonConstCopy4' to 'ImplicitNonConstCopy4'}} -} diff --git a/test/CXX/special/class.ctor/p1.cpp b/test/CXX/special/class.ctor/p1.cpp deleted file mode 100644 index e19dc8660707..000000000000 --- a/test/CXX/special/class.ctor/p1.cpp +++ /dev/null @@ -1,55 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s - -struct X0 { - struct type { }; - - X0(); - X0(int); - (X0)(float); - X0 (f0)(int); - X0 (f0)(type); - - X0 f1(); - X0 f1(double); -}; - -X0::X0() { } -(X0::X0)(int) { } - -X0 (X0::f0)(int) { return X0(); } - -template<typename T> -struct X1 { - struct type { }; - - X1<T>(); - X1<T>(int); - (X1<T>)(float); - X1(float, float); - (X1)(double); - X1<T> (f0)(int); - X1<T> (f0)(type); - X1 (f1)(int); - X1 (f1)(type); - - template<typename U> X1(U); - X1 f2(); - X1 f2(int); -}; - -template<typename T> X1<T>::X1() { } -template<typename T> (X1<T>::X1)(double) { } -template<typename T> X1<T> X1<T>::f1(int) { return 0; } -template<typename T> X1<T> (X1<T>::f1)(type) { return 0; } - -class X2 { - X2::X2(); // expected-error {{extra qualification on member 'X2'}} -}; - -// We used to parse 'X3::X3' as a member function declaration. -// DR 1435 and DR 1310 made this invalid. -typedef int T1; -struct X3 { - X3::X3(T1()); // expected-error {{extra qualification on member 'X3'}} -}; - diff --git a/test/CXX/special/class.ctor/p4-0x.cpp b/test/CXX/special/class.ctor/p4-0x.cpp deleted file mode 100644 index 509beb490302..000000000000 --- a/test/CXX/special/class.ctor/p4-0x.cpp +++ /dev/null @@ -1,7 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s - -// A constructor shall not be declared with a ref-qualifier. -struct X { - X() &; // expected-error{{ref-qualifier '&' is not allowed on a constructor}} - X(int) &&; // expected-error{{ref-qualifier '&&' is not allowed on a constructor}} -}; diff --git a/test/CXX/special/class.ctor/p5-0x.cpp b/test/CXX/special/class.ctor/p5-0x.cpp deleted file mode 100644 index 5fa61008e8b7..000000000000 --- a/test/CXX/special/class.ctor/p5-0x.cpp +++ /dev/null @@ -1,213 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11 -Wno-defaulted-function-deleted - -struct DefaultedDefCtor1 {}; -struct DefaultedDefCtor2 { DefaultedDefCtor2() = default; }; -struct DeletedDefCtor { DeletedDefCtor() = delete; DeletedDefCtor(int); }; // expected-note {{explicitly marked deleted here}} -class PrivateDefCtor { PrivateDefCtor() = default; public: PrivateDefCtor(int); }; -struct DeletedDtor { ~DeletedDtor() = delete; }; // expected-note 4{{explicitly marked deleted here}} -class PrivateDtor { ~PrivateDtor() = default; }; -class Friend { - Friend() = default; ~Friend() = default; - friend struct NotDeleted6c; - friend struct NotDeleted7i; - friend struct NotDeleted7j; - friend struct NotDeleted7k; -}; -struct UserProvidedDefCtor { UserProvidedDefCtor() {} }; -int n; - - -// A defaulted default constructor for a class X is defined as deleted if: - -// - X is a union-like class that has a variant member with a non-trivial -// default constructor, -union Deleted1a { UserProvidedDefCtor u; }; // expected-note {{default constructor of 'Deleted1a' is implicitly deleted because variant field 'u' has a non-trivial default constructor}} -Deleted1a d1a; // expected-error {{implicitly-deleted default constructor}} -union NotDeleted1a { DefaultedDefCtor1 nu; }; -NotDeleted1a nd1a; -union NotDeleted1b { DefaultedDefCtor2 nu; }; -NotDeleted1b nd1b; - -// - any non-static data member with no brace-or-equal-initializer is of -// reference type, -class Deleted2a { - Deleted2a() = default; // expected-note 4{{implicitly deleted here}} - int &a; // expected-note 4{{because field 'a' of reference type 'int &' would not be initialized}} -}; -Deleted2a d2a; // expected-error {{implicitly-deleted default constructor}} -struct Deleted2b { - int &&b; // expected-note {{default constructor of 'Deleted2b' is implicitly deleted because field 'b' of reference type 'int &&' would not be initialized}} -}; -Deleted2b d2b; // expected-error {{deleted default constructor}} -class NotDeleted2a { int &a = n; }; -NotDeleted2a nd2a; -class NotDeleted2b { int &a = error; }; // expected-error {{undeclared identifier}} -NotDeleted2b nd2b; -class NotDeleted2c { int &&a = static_cast<int&&>(n); }; -NotDeleted2c nd2c; -// Note: this one does not have a deleted default constructor even though the -// implicit default constructor is ill-formed! -class NotDeleted2d { int &&a = 0; }; // expected-error {{reference member 'a' binds to a temporary object}} expected-note {{default member init}} -NotDeleted2d nd2d; // expected-note {{first required here}} - -// - any non-variant non-static data member of const qualified type (or array -// thereof) with no brace-or-equal-initializer does not have a user-provided -// default constructor, -class Deleted3a { const int a; }; // expected-note {{because field 'a' of const-qualified type 'const int' would not be initialized}} \ - expected-warning {{does not declare any constructor}} \ - expected-note {{will never be initialized}} -Deleted3a d3a; // expected-error {{implicitly-deleted default constructor}} -class Deleted3b { const DefaultedDefCtor1 a[42]; }; // expected-note {{because field 'a' of const-qualified type 'const DefaultedDefCtor1 [42]' would not be initialized}} -Deleted3b d3b; // expected-error {{implicitly-deleted default constructor}} -class Deleted3c { const DefaultedDefCtor2 a; }; // expected-note {{because field 'a' of const-qualified type 'const DefaultedDefCtor2' would not be initialized}} -Deleted3c d3c; // expected-error {{implicitly-deleted default constructor}} -class NotDeleted3a { const int a = 0; }; -NotDeleted3a nd3a; -class NotDeleted3b { const DefaultedDefCtor1 a[42] = {}; }; -NotDeleted3b nd3b; -class NotDeleted3c { const DefaultedDefCtor2 a = DefaultedDefCtor2(); }; -NotDeleted3c nd3c; -union NotDeleted3d { const int a; int b; }; -NotDeleted3d nd3d; -union NotDeleted3e { const DefaultedDefCtor1 a[42]; int b; }; -NotDeleted3e nd3e; -union NotDeleted3f { const DefaultedDefCtor2 a; int b; }; -NotDeleted3f nd3f; -struct NotDeleted3g { union { const int a; int b; }; }; -NotDeleted3g nd3g; - -// - X is a union and all of its variant members are of const-qualified type (or -// array thereof), -union Deleted4a { - const int a; - const int b; - const UserProvidedDefCtor c; // expected-note {{because variant field 'c' has a non-trivial default constructor}} -}; -Deleted4a d4a; // expected-error {{implicitly-deleted default constructor}} -union NotDeleted4a { const int a; int b; }; -NotDeleted4a nd4a; - -// - X is a non-union class and all members of any anonymous union member are of -// const-qualified type (or array thereof), -struct Deleted5a { - union { const int a; }; // expected-note {{because all data members of an anonymous union member are const-qualified}} - union { int b; }; -}; -Deleted5a d5a; // expected-error {{implicitly-deleted default constructor}} -struct NotDeleted5a { union { const int a; int b; }; union { const int c; int d; }; }; -NotDeleted5a nd5a; - -// - any direct or virtual base class, or non-static data member with no -// brace-or-equal-initializer, has class type M (or array thereof) and either -// M has no default constructor or overload resolution as applied to M's default -// constructor results in an ambiguity or in a function that is deleted or -// inaccessible from the defaulted default constructor, or -struct Deleted6a : Deleted2a {}; // expected-note {{because base class 'Deleted2a' has a deleted default constructor}} -Deleted6a d6a; // expected-error {{implicitly-deleted default constructor}} -struct Deleted6b : virtual Deleted2a {}; // expected-note {{because base class 'Deleted2a' has a deleted default constructor}} -Deleted6b d6b; // expected-error {{implicitly-deleted default constructor}} -struct Deleted6c { Deleted2a a; }; // expected-note {{because field 'a' has a deleted default constructor}} -Deleted6c d6c; // expected-error {{implicitly-deleted default constructor}} -struct Deleted6d { DeletedDefCtor a; }; // expected-note {{because field 'a' has a deleted default constructor}} -Deleted6d d6d; // expected-error {{implicitly-deleted default constructor}} -struct NotDeleted6a { DeletedDefCtor a = 0; }; -NotDeleted6a nd6a; -struct Deleted6e { PrivateDefCtor a; }; // expected-note {{because field 'a' has an inaccessible default constructor}} -Deleted6e d6e; // expected-error {{implicitly-deleted default constructor}} -struct NotDeleted6b { PrivateDefCtor a = 0; }; -NotDeleted6b nd6b; -struct NotDeleted6c { Friend a; }; -NotDeleted6c nd6c; - -// - any direct or virtual base class or non-static data member has a type with -// a destructor that is deleted or inaccessible from the defaulted default -// constructor. -struct Deleted7a : DeletedDtor {}; // expected-note {{because base class 'DeletedDtor' has a deleted destructor}} -Deleted7a d7a; // expected-error {{implicitly-deleted default constructor}} -struct Deleted7b : virtual DeletedDtor {}; // expected-note {{because base class 'DeletedDtor' has a deleted destructor}} -Deleted7b d7b; // expected-error {{implicitly-deleted default constructor}} -struct Deleted7c { DeletedDtor a; }; // expected-note {{because field 'a' has a deleted destructor}} -Deleted7c d7c; // expected-error {{implicitly-deleted default constructor}} -struct Deleted7d { DeletedDtor a = {}; }; // expected-note {{because field 'a' has a deleted destructor}} -Deleted7d d7d; // expected-error {{implicitly-deleted default constructor}} -struct Deleted7e : PrivateDtor {}; // expected-note {{base class 'PrivateDtor' has an inaccessible destructor}} -Deleted7e d7e; // expected-error {{implicitly-deleted default constructor}} -struct Deleted7f : virtual PrivateDtor {}; // expected-note {{base class 'PrivateDtor' has an inaccessible destructor}} -Deleted7f d7f; // expected-error {{implicitly-deleted default constructor}} -struct Deleted7g { PrivateDtor a; }; // expected-note {{field 'a' has an inaccessible destructor}} -Deleted7g d7g; // expected-error {{implicitly-deleted default constructor}} -struct Deleted7h { PrivateDtor a = {}; }; // expected-note {{field 'a' has an inaccessible destructor}} -Deleted7h d7h; // expected-error {{implicitly-deleted default constructor}} -struct NotDeleted7i : Friend {}; -NotDeleted7i d7i; -struct NotDeleted7j : virtual Friend {}; -NotDeleted7j d7j; -struct NotDeleted7k { Friend a; }; -NotDeleted7k d7k; - - -class Trivial { static const int n = 42; }; -static_assert(__has_trivial_constructor(Trivial), "Trivial is nontrivial"); - -// A default constructor is trivial if it is not user-provided and if: -class NonTrivialDefCtor1 { NonTrivialDefCtor1(); }; -static_assert(!__has_trivial_constructor(NonTrivialDefCtor1), "NonTrivialDefCtor1 is trivial"); - -#define ASSERT_NONTRIVIAL_IMPL(Class, Bases, Body) \ - class Class Bases { Body }; \ - static_assert(!__has_trivial_constructor(Class), ""); -#define ASSERT_NONTRIVIAL(Class, Bases, Body) \ - ASSERT_NONTRIVIAL_IMPL(Class, Bases, Body) \ - ASSERT_NONTRIVIAL_IMPL(Def ## Class, Bases, Def ## Class() = default; Body) \ - ASSERT_NONTRIVIAL_IMPL(Del ## Class, Bases, Del ## Class() = delete; Body) - -// - its class has no virtual functions (10.3) and no virtual base classes (10.1), and -ASSERT_NONTRIVIAL(NonTrivialDefCtor2, , virtual void f();) -ASSERT_NONTRIVIAL(NonTrivialDefCtor3, : virtual Trivial, ) - -// - no non-static data member of its class has a brace-or-equal-initializer, and -ASSERT_NONTRIVIAL(NonTrivialDefCtor4, , int m = 52;) - -// - all the direct base classes of its class have trivial default constructors, and -ASSERT_NONTRIVIAL(NonTrivialDefCtor5, : NonTrivialDefCtor1, ) - -// - for all the non-static data members of its class that are of class type (or array thereof), each such class -// has a trivial default constructor. -ASSERT_NONTRIVIAL(NonTrivialDefCtor6, , NonTrivialDefCtor1 t;) - -// FIXME: No core issue number yet. -// - its parameter-declaration-clause is equivalent to that of an implicit declaration. -struct NonTrivialDefCtor7 { - NonTrivialDefCtor7(...) = delete; -}; -static_assert(!__has_trivial_constructor(NonTrivialDefCtor7), ""); -struct NonTrivialDefCtor8 { - NonTrivialDefCtor8(int = 0) = delete; -}; -static_assert(!__has_trivial_constructor(NonTrivialDefCtor8), ""); - -// Otherwise, the default constructor is non-trivial. - -class Trivial2 { Trivial2() = delete; }; -static_assert(__has_trivial_constructor(Trivial2), "Trivial2 is trivial"); - -class Trivial3 { Trivial3() = default; }; -static_assert(__has_trivial_constructor(Trivial3), "Trivial3 is trivial"); - -template<typename T> class Trivial4 { Trivial4() = default; }; -static_assert(__has_trivial_constructor(Trivial4<int>), "Trivial4 is trivial"); - -template<typename T> class Trivial5 { Trivial5() = delete; }; -static_assert(__has_trivial_constructor(Trivial5<int>), "Trivial5 is trivial"); - -namespace PR14558 { - // Ensure we determine whether an explicitly-defaulted or deleted special - // member is trivial before we return to parsing the containing class. - struct A { - struct B { B() = default; } b; - struct C { C() = delete; } c; - }; - - static_assert(__has_trivial_constructor(A), ""); - static_assert(__has_trivial_constructor(A::B), ""); -} diff --git a/test/CXX/special/class.ctor/p6-0x.cpp b/test/CXX/special/class.ctor/p6-0x.cpp deleted file mode 100644 index 9860317aa122..000000000000 --- a/test/CXX/special/class.ctor/p6-0x.cpp +++ /dev/null @@ -1,96 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11 - -// Implicitly-defined default constructors are constexpr if the implicit -// definition would be. -struct NonConstexpr1 { // expected-note {{here}} - int a; -}; -struct NonConstexpr2 { // expected-note {{here}} - NonConstexpr1 nl; -}; -struct NonConstexpr2a : NonConstexpr1 { }; -constexpr NonConstexpr1 nc1 = NonConstexpr1(); // ok, does not call constructor -constexpr NonConstexpr2 nc2 = NonConstexpr2(); // ok, does not call constructor -constexpr NonConstexpr2a nc2a = NonConstexpr2a(); // ok, does not call constructor -constexpr int nc2_a = NonConstexpr2().nl.a; // ok -constexpr int nc2a_a = NonConstexpr2a().a; // ok -struct Helper { - friend constexpr NonConstexpr1::NonConstexpr1(); // expected-error {{follows non-constexpr declaration}} - friend constexpr NonConstexpr2::NonConstexpr2(); // expected-error {{follows non-constexpr declaration}} -}; - -struct Constexpr1 {}; -constexpr Constexpr1 c1 = Constexpr1(); // ok -struct NonConstexpr3 : virtual Constexpr1 {}; // expected-note {{struct with virtual base}} expected-note {{declared here}} -constexpr NonConstexpr3 nc3 = NonConstexpr3(); // expected-error {{non-literal type 'const NonConstexpr3'}} - -struct Constexpr2 { - int a = 0; -}; -constexpr Constexpr2 c2 = Constexpr2(); // ok - -int n; -struct Member { - Member() : a(n) {} - constexpr Member(int&a) : a(a) {} - int &a; -}; -struct NonConstexpr4 { // expected-note {{here}} - Member m; -}; -constexpr NonConstexpr4 nc4 = NonConstexpr4(); // expected-error {{constant expression}} expected-note {{non-constexpr constructor 'NonConstexpr4'}} -struct Constexpr3 { - constexpr Constexpr3() : m(n) {} - Member m; -}; -constexpr Constexpr3 c3 = Constexpr3(); // ok -struct Constexpr4 { - Constexpr3 m; -}; -constexpr Constexpr4 c4 = Constexpr4(); // ok - - -// This rule breaks some legal C++98 programs! -struct A {}; // expected-note {{here}} -struct B { - friend A::A(); // expected-error {{non-constexpr declaration of 'A' follows constexpr declaration}} -}; - -namespace UnionCtors { - union A { // expected-note {{here}} - int a; - int b; - }; - union B { - int a; - int b = 5; - }; - union C { - int a = 5; - int b; - }; - struct D { - union { - int a = 5; - int b; - }; - union { - int c; - int d = 5; - }; - }; - struct E { // expected-note {{here}} - union { - int a; - int b; - }; - }; - - struct Test { - friend constexpr A::A() noexcept; // expected-error {{follows non-constexpr declaration}} - friend constexpr B::B() noexcept; - friend constexpr C::C() noexcept; - friend constexpr D::D() noexcept; - friend constexpr E::E() noexcept; // expected-error {{follows non-constexpr declaration}} - }; -} diff --git a/test/CXX/special/class.dtor/p10-0x.cpp b/test/CXX/special/class.dtor/p10-0x.cpp deleted file mode 100644 index 3be0a98d47d7..000000000000 --- a/test/CXX/special/class.dtor/p10-0x.cpp +++ /dev/null @@ -1,39 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s - -// PR10127/N3031 -struct A { ~A(); }; -struct B {}; -template<typename T> -void b(const T *x, const A *y) { - x->~decltype(T())(); - x->~decltype(*x)(); // expected-error{{the type of object expression ('const int') does not match the type being destroyed ('decltype(*x)' (aka 'const int &')) in pseudo-destructor expression}} \ - expected-error{{no member named '~const A &' in 'A'}} - x->~decltype(int())(); // expected-error{{no member named '~int' in 'A'}} - - y->~decltype(*y)(); // expected-error{{destructor type 'decltype(*y)' (aka 'const A &') in object destruction expression does not match the type 'const A' of the object being destroyed}} - y->~decltype(T())(); // expected-error{{destructor type 'decltype(T())' in object destruction expression does not match the type 'const A' of the object being destroyed}} - y->~decltype(A())(); -} -template void b(const int*, const A*); // expected-note{{in instantiation of function template specialization 'b<int>' requested here}} -template void b(const A*,const A*); // expected-note{{in instantiation of function template specialization 'b<A>' requested here}} -void a(const A *x, int i, int *pi) { - x->~decltype(A())(); - x->~decltype(*x)(); // expected-error{{destructor type 'decltype(*x)' (aka 'const A &') in object destruction expression does not match the type 'const A' of the object being destroyed}} - x->~decltype()(); // expected-error{{expected expression}} - x->~decltype(B())(); // expected-error{{destructor type 'decltype(B())' (aka 'B') in object destruction expression does not match the type 'const A' of the object being destroyed}} - x->~decltype(x)(); // expected-error{{destructor type 'decltype(x)' (aka 'const A *') in object destruction expression does not match the type 'const A' of the object being destroyed}} - // this last one could be better, mentioning that the nested-name-specifier could be removed or a type name after the ~ - x->::A::~decltype(*x)(); // expected-error{{expected a class name after '~' to name a destructor}} - y->~decltype(A())(); // expected-error{{use of undeclared identifier 'y'}} - - typedef int *intp; - i->~decltype(int())(); // expected-error{{member reference type 'int' is not a pointer; did you mean to use '.'?}} - i.~decltype(int())(); - i->~decltype(intp())(); // expected-error{{member reference type 'int' is not a pointer; did you mean to use '.'?}} \ - expected-error{{the type of object expression ('int') does not match the type being destroyed ('decltype(intp())' (aka 'int *')) in pseudo-destructor expression}} - i.~decltype(intp())(); // expected-error{{the type of object expression ('int') does not match the type being destroyed ('decltype(intp())' (aka 'int *')) in pseudo-destructor expression}} - pi->~decltype(int())(); - pi.~decltype(int())(); // expected-error{{member reference type 'int *' is a pointer; did you mean to use '->'?}} - pi.~decltype(intp())(); - pi->~decltype(intp())(); // expected-error{{the type of object expression ('int') does not match the type being destroyed ('decltype(intp())' (aka 'int *')) in pseudo-destructor expression}} -} diff --git a/test/CXX/special/class.dtor/p2-0x.cpp b/test/CXX/special/class.dtor/p2-0x.cpp deleted file mode 100644 index c7b1b586fbcb..000000000000 --- a/test/CXX/special/class.dtor/p2-0x.cpp +++ /dev/null @@ -1,10 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s - -// A destructor shall not be declared with a ref-qualifier. -struct X { - ~X() &; // expected-error{{ref-qualifier '&' is not allowed on a destructor}} -}; - -struct Y { - ~Y() &&; // expected-error{{ref-qualifier '&&' is not allowed on a destructor}} -}; diff --git a/test/CXX/special/class.dtor/p2.cpp b/test/CXX/special/class.dtor/p2.cpp deleted file mode 100644 index 4a10eb9e0d0b..000000000000 --- a/test/CXX/special/class.dtor/p2.cpp +++ /dev/null @@ -1,8 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -// expected-no-diagnostics - -// PR5548 -struct A {~A();}; -void a(const A* x) { - x->~A(); -} diff --git a/test/CXX/special/class.dtor/p3-0x.cpp b/test/CXX/special/class.dtor/p3-0x.cpp deleted file mode 100644 index f6a64260e0df..000000000000 --- a/test/CXX/special/class.dtor/p3-0x.cpp +++ /dev/null @@ -1,179 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -triple %itanium_abi_triple -fexceptions -fcxx-exceptions -emit-llvm -o - %s | FileCheck %s - -struct A { - ~A(); -}; - -struct B { - ~B() throw(int); -}; - -struct C { - B b; - ~C() {} -}; - -struct D { - ~D() noexcept(false); -}; - -struct E { - D d; - ~E() {} -}; - -void foo() { - A a; - C c; - E e; - // CHECK: invoke {{.*}} @_ZN1ED1Ev - // CHECK: invoke {{.*}} @_ZN1CD1Ev - // CHECK: call {{.*}} @_ZN1AD1Ev -} - -struct F { - D d; - ~F(); -}; -F::~F() noexcept(false) {} - -struct G { - D d; - ~G(); -}; -G::~G() {} - -struct H { - B b; - ~H() throw(int); -}; -H::~H() throw(int) {} - -struct I { - B b; - ~I(); -}; -I::~I() {} - -// Template variants. - -template <typename T> -struct TA { - ~TA(); -}; - -template <typename T> -struct TB { - ~TB() throw(int); -}; - -template <typename T> -struct TC { - TB<T> b; - ~TC() {} -}; - -template <typename T> -struct TD { - ~TD() noexcept(false); -}; - -template <typename T> -struct TE { - TD<T> d; - ~TE() {} -}; - -void tfoo() { - TA<int> a; - TC<int> c; - TE<int> e; - // CHECK: invoke {{.*}} @_ZN2TEIiED1Ev - // CHECK: invoke {{.*}} @_ZN2TCIiED1Ev - // CHECK: call {{.*}} @_ZN2TAIiED1Ev -} - -template <typename T> -struct TF { - TD<T> d; - ~TF(); -}; -template <typename T> -TF<T>::~TF() noexcept(false) {} - -template <typename T> -struct TG { - TD<T> d; - ~TG(); -}; -template <typename T> -TG<T>::~TG() {} - -template <typename T> -struct TH { - TB<T> b; - ~TH(); -}; -template <typename T> -TH<T>::~TH() {} - -void tinst() { - TF<int> f; - TG<int> g; - TH<int> h; -} -// CHECK: define linkonce_odr {{.*}} @_ZN2THIiED1Ev -// CHECK: _ZTIi -// CHECK: __cxa_call_unexpected - -struct VX -{ virtual ~VX() {} }; - -struct VY : VX -{ virtual ~VY() {} }; - -template<typename T> -struct TVY : VX -{ virtual ~TVY() {} }; - - -struct VA { - B b; - virtual ~VA() {} -}; - -struct VB : VA -{ virtual ~VB() {} }; - -template<typename T> -struct TVB : VA -{ virtual ~TVB() {} }; - -void tinst2() { - TVY<int> tvy; - TVB<int> tvb; -} - -template <typename T> -struct Sw { - T t; - ~Sw() {} -}; - -void tsw() { - Sw<int> swi; - Sw<B> swb; -} -// CHECK-NOT: define linkonce_odr {{.*}} @_ZN2SwI1BED1Ev({{.*}} # -// CHECK: define linkonce_odr {{.*}} @_ZN2SwI1BED1Ev({{.*}} -// CHECK: _ZTIi -// CHECK: __cxa_call_unexpected -// CHECK: define linkonce_odr {{.*}} @_ZN2SwIiED1Ev({{.*}} [[ATTRGRP:#[0-9]+]] - -template <typename T> -struct TVC : VX -{ virtual ~TVC(); }; -template <typename T> -TVC<T>::~TVC() {} - -// CHECK: attributes [[ATTRGRP]] = { noinline nounwind{{.*}} } diff --git a/test/CXX/special/class.dtor/p3.cpp b/test/CXX/special/class.dtor/p3.cpp deleted file mode 100644 index 6f4d5c7f3184..000000000000 --- a/test/CXX/special/class.dtor/p3.cpp +++ /dev/null @@ -1,17 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -fcxx-exceptions -verify %s - -// The exception specification of a destructor declaration is matched *before* -// the exception specification adjustment occurs. -namespace DR1492 { - struct A { ~A(); }; // expected-note {{here}} - A::~A() noexcept {} // expected-warning {{previously declared with an implicit exception specification}} - - struct B { ~B() noexcept; }; // expected-note {{here}} - B::~B() {} // expected-warning {{previously declared with an explicit exception specification}} - - template<typename T> struct C { - T t; - ~C(); // expected-note {{here}} - }; - template<typename T> C<T>::~C() noexcept {} // expected-error {{does not match previous}} -} diff --git a/test/CXX/special/class.dtor/p5-0x.cpp b/test/CXX/special/class.dtor/p5-0x.cpp deleted file mode 100644 index f69baca53bf3..000000000000 --- a/test/CXX/special/class.dtor/p5-0x.cpp +++ /dev/null @@ -1,105 +0,0 @@ -// RUN: %clang_cc1 -verify -std=c++11 %s -Wno-defaulted-function-deleted - -struct NonTrivDtor { - ~NonTrivDtor(); -}; -struct DeletedDtor { - ~DeletedDtor() = delete; // expected-note 5 {{deleted here}} -}; -class InaccessibleDtor { - ~InaccessibleDtor() = default; -}; - -// A defaulted destructor for a class X is defined as deleted if: - -// -- X is a union-like class that has a variant member with a non-trivial -// destructor. -union A1 { - A1(); - NonTrivDtor n; // expected-note {{destructor of 'A1' is implicitly deleted because variant field 'n' has a non-trivial destructor}} -}; -A1 a1; // expected-error {{deleted function}} -struct A2 { - A2(); - union { - NonTrivDtor n; // expected-note {{because variant field 'n' has a non-trivial destructor}} - }; -}; -A2 a2; // expected-error {{deleted function}} -union A3 { - A3(); - NonTrivDtor n[3]; // expected-note {{because variant field 'n' has a non-trivial destructor}} -}; -A3 a3; // expected-error {{deleted function}} -struct A4 { - A4(); - union { - NonTrivDtor n[3]; // expected-note {{because variant field 'n' has a non-trivial destructor}} - }; -}; -A4 a4; // expected-error {{deleted function}} - -// -- any of the non-static data members has class type M (or array thereof) and -// M has a deleted or inaccessible destructor. -struct B1 { - B1(); - DeletedDtor a; // expected-note {{because field 'a' has a deleted destructor}} -}; -B1 b1; // expected-error {{deleted function}} -struct B2 { - B2(); - InaccessibleDtor a; // expected-note {{because field 'a' has an inaccessible destructor}} -}; -B2 b2; // expected-error {{deleted function}} -struct B3 { - B3(); - DeletedDtor a[4]; // expected-note {{because field 'a' has a deleted destructor}} -}; -B3 b3; // expected-error {{deleted function}} -struct B4 { - B4(); - InaccessibleDtor a[4]; // expected-note {{because field 'a' has an inaccessible destructor}} -}; -B4 b4; // expected-error {{deleted function}} -union B5 { - B5(); - // FIXME: Describe the anonymous union member better than ''. - union { // expected-note {{because field '' has a deleted destructor}} - DeletedDtor a; // expected-note {{because field 'a' has a deleted destructor}} - }; -}; -B5 b5; // expected-error {{deleted function}} -union B6 { - B6(); - union { // expected-note {{because field '' has a deleted destructor}} - InaccessibleDtor a; // expected-note {{because field 'a' has an inaccessible destructor}} - }; -}; -B6 b6; // expected-error {{deleted function}} - -// -- any direct or virtual base class has a deleted or inaccessible destructor. -struct C1 : DeletedDtor { C1(); } c1; // expected-error {{deleted function}} expected-note {{base class 'DeletedDtor' has a deleted destructor}} -struct C2 : InaccessibleDtor { C2(); } c2; // expected-error {{deleted function}} expected-note {{base class 'InaccessibleDtor' has an inaccessible destructor}} -struct C3 : virtual DeletedDtor { C3(); } c3; // expected-error {{deleted function}} expected-note {{base class 'DeletedDtor' has a deleted destructor}} -struct C4 : virtual InaccessibleDtor { C4(); } c4; // expected-error {{deleted function}} expected-note {{base class 'InaccessibleDtor' has an inaccessible destructor}} - -// -- for a virtual destructor, lookup of the non-array deallocation function -// results in an ambiguity or a function that is deleted or inaccessible. -class D1 { - void operator delete(void*); -public: - virtual ~D1() = default; // expected-note {{here}} -} d1; // ok -struct D2 : D1 { // expected-note 2{{virtual destructor requires an unambiguous, accessible 'operator delete'}} \ - // expected-error {{deleted function '~D2' cannot override a non-deleted}} - // implicitly-virtual destructor -} d2; // expected-error {{deleted function}} -struct D3 { // expected-note {{virtual destructor requires an unambiguous, accessible 'operator delete'}} - virtual ~D3() = default; // expected-note {{explicitly defaulted function was implicitly deleted here}} - void operator delete(void*, double = 0.0); - void operator delete(void*, char = 0); -} d3; // expected-error {{deleted function}} -struct D4 { // expected-note {{virtual destructor requires an unambiguous, accessible 'operator delete'}} - virtual ~D4() = default; // expected-note {{implicitly deleted here}} - void operator delete(void*) = delete; -} d4; // expected-error {{deleted function}} diff --git a/test/CXX/special/class.dtor/p5-implicit.cpp b/test/CXX/special/class.dtor/p5-implicit.cpp deleted file mode 100644 index 703be15b70cd..000000000000 --- a/test/CXX/special/class.dtor/p5-implicit.cpp +++ /dev/null @@ -1,21 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 %s -ast-dump | FileCheck %s - -struct A { ~A() = delete; }; -// CHECK-LABEL: CXXRecordDecl {{.*}} struct A -// CHECK: Destructor trivial user_declared - -struct B : A {}; -// CHECK-LABEL: CXXRecordDecl {{.*}} struct B -// CHECK: Destructor trivial needs_overload_resolution - -struct C : B {}; -// CHECK-LABEL: CXXRecordDecl {{.*}} struct C -// CHECK: Destructor trivial needs_overload_resolution - -struct D { ~D(); }; -struct E : D {}; -union U { - E e; -}; -// CHECK-LABEL: CXXRecordDecl {{.*}} union U -// CHECK: Destructor non_trivial needs_implicit defaulted_is_deleted diff --git a/test/CXX/special/class.dtor/p9.cpp b/test/CXX/special/class.dtor/p9.cpp deleted file mode 100644 index e812491fbb4b..000000000000 --- a/test/CXX/special/class.dtor/p9.cpp +++ /dev/null @@ -1,124 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -triple %itanium_abi_triple -verify -std=c++98 %s -// RUN: %clang_cc1 -fsyntax-only -triple %ms_abi_triple -DMSABI -verify -std=c++98 %s -// RUN: %clang_cc1 -fsyntax-only -triple %itanium_abi_triple -verify -std=c++11 %s -// RUN: %clang_cc1 -fsyntax-only -triple %ms_abi_triple -DMSABI -verify -std=c++11 %s - -typedef __typeof(sizeof(int)) size_t; - -// PR7803 -namespace test0 { - class A { - public: - static void operator delete(void *p) {}; - virtual ~A(); - }; - - class B : protected A { - public: - ~B(); - }; - - class C : protected B { - public: - using B::operator delete; - ~C(); - }; - - // Shouldn't have an error. - C::~C() {} -} - -namespace test1 { - class A { - public: - static void operator delete(void *p) {}; - virtual ~A(); - }; - - class B : protected A { - public: - static void operator delete(void *, size_t) {}; - ~B(); - }; - - class C : protected B { - public: - using A::operator delete; - using B::operator delete; - - ~C(); - }; - - // We assume that the intent is to treat C::operator delete(void*, size_t) as - // /not/ being a usual deallocation function, as it would be if it were - // declared with in C directly. - C::~C() {} - - struct D { - void operator delete(void*); // expected-note {{member 'operator delete' declared here}} - void operator delete(void*, ...); // expected-note {{member 'operator delete' declared here}} - virtual ~D(); - }; - // FIXME: The standard doesn't say this is ill-formed, but presumably either - // it should be or the variadic operator delete should not be a usual - // deallocation function. - D::~D() {} // expected-error {{multiple suitable 'operator delete' functions in 'D'}} -} - -// ...at the point of definition of a virtual destructor... -namespace test2 { - struct A { - virtual ~A(); - static void operator delete(void*, const int &); - }; - - struct B { - virtual ~B(); - static void operator delete(void*, const int &); // expected-note {{declared here}} - }; - B::~B() {} // expected-error {{no suitable member 'operator delete' in 'B'}} - -#if __cplusplus < 201103L - struct CBase { virtual ~CBase(); }; - struct C : CBase { // expected-error {{no suitable member 'operator delete' in 'C'}} - static void operator delete(void*, const int &); // expected-note {{declared here}} - }; - void test() { - C c; // expected-note {{first required here}} - } -#else - struct CBase { virtual ~CBase(); }; // expected-note {{overridden virtual function is here}} - struct C : CBase { // expected-error {{deleted function '~C' cannot override a non-deleted function}} expected-note 2{{requires an unambiguous, accessible 'operator delete'}} - static void operator delete(void*, const int &); - }; - void test() { - C c; // expected-error {{attempt to use a deleted function}} - } -#endif -} - -// PR7346 -namespace test3 { - struct A { -#ifdef MSABI - // expected-error@+2 {{no suitable member 'operator delete' in 'A'}} -#endif - virtual ~A(); -#ifdef MSABI - // expected-note@+2 {{declared here}} -#endif - static void operator delete(void*, const int &); - }; - - struct B : A { - virtual ~B() {} - static void operator delete(void*); - }; - - void f() { -#ifdef MSABI - // expected-note@+2 {{implicit default constructor for 'test3::B' first required here}} -#endif - B use_vtable; - } -} diff --git a/test/CXX/special/class.free/p1.cpp b/test/CXX/special/class.free/p1.cpp deleted file mode 100644 index 5c0240b5dadc..000000000000 --- a/test/CXX/special/class.free/p1.cpp +++ /dev/null @@ -1,11 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -#include <stddef.h> - -struct A { - void *operator new(size_t) { - return this; // expected-error {{invalid use of 'this' outside of a non-static member function}} - } - void *operator new[](size_t) { - return this; // expected-error {{invalid use of 'this' outside of a non-static member function}} - } -}; diff --git a/test/CXX/special/class.free/p6.cpp b/test/CXX/special/class.free/p6.cpp deleted file mode 100644 index fc4b2ae1acfd..000000000000 --- a/test/CXX/special/class.free/p6.cpp +++ /dev/null @@ -1,11 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -#include <stddef.h> - -struct A { - void operator delete(void*) { - (void)this; // expected-error {{invalid use of 'this' outside of a non-static member function}} - } - void operator delete[](void*) { - (void)this; // expected-error {{invalid use of 'this' outside of a non-static member function}} - } -}; diff --git a/test/CXX/special/class.inhctor/elsewhere.cpp b/test/CXX/special/class.inhctor/elsewhere.cpp deleted file mode 100644 index c042834b2147..000000000000 --- a/test/CXX/special/class.inhctor/elsewhere.cpp +++ /dev/null @@ -1,64 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s - -// Tests related to constructor inheriting, but not specified in [class.inhctor] - -// [namespace.udecl]p8: -// A using-declaration for a class member shall be a member-declaration. - -struct B1 { - B1(int); -}; - -using B1::B1; // expected-error {{using declaration cannot refer to class member}} - -// C++11 [namespace.udecl]p10: -// A using-declaration is a declaration and can therefore be used repeatedly -// where (and only where) multiple declarations are allowed. - -struct I1 : B1 { - using B1::B1; // expected-note {{previous using declaration}} - using B1::B1; // expected-error {{redeclaration of using decl}} -}; - -// C++11 [namespace.udecl]p3: -// In a using declaration used as a member-declaration, the nested-name- -// specifier shall name a base class of the class being defined. -// If such a using-declaration names a constructor, the nested-name-specifier -// shall name a direct base class of the class being defined. - -struct D1 : I1 { - using B1::B1; // expected-error {{'B1' is not a direct base of 'D1', cannot inherit constructors}} -}; - -template<typename T> struct A {}; - -template<typename T> struct B : A<bool>, A<char> { - using A<T>::A; // expected-error {{'A<double>::', which is not a base class of 'B<double>'}} -}; -B<bool> bb; -B<char> bc; -B<double> bd; // expected-note {{here}} - -template<typename T> struct C : A<T> { - using A<bool>::A; // expected-error {{'A<bool>::', which is not a base class of 'C<char>'}} -}; -C<bool> cb; -C<char> cc; // expected-note {{here}} - -template<typename T> struct D : A<T> {}; -template<typename T> struct E : D<T> { - using A<bool>::A; // expected-error {{'A<bool>' is not a direct base of 'E<bool>', cannot inherit}} -}; -E<bool> eb; // expected-note {{here}} - -template<typename T> struct F : D<bool> { - using A<T>::A; // expected-error {{'A<bool>' is not a direct base of 'F<bool>'}} -}; -F<bool> fb; // expected-note {{here}} - -template<typename T> -struct G : T { - using T::T; - G(int &) : G(0) {} -}; -G<B1> g(123); diff --git a/test/CXX/special/class.inhctor/p1.cpp b/test/CXX/special/class.inhctor/p1.cpp deleted file mode 100644 index 842b725cb0b3..000000000000 --- a/test/CXX/special/class.inhctor/p1.cpp +++ /dev/null @@ -1,65 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -verify %s -// -// Note: [class.inhctor] was removed by P0136R1. This tests the new behavior -// for the wording that used to be there. - -struct A { // expected-note 4{{candidate constructor (the implicit}} - A(...); // expected-note 4{{candidate constructor}} expected-note 4{{candidate inherited constructor}} - A(int = 0, int = 0, int = 0, int = 0, ...); // expected-note 3{{candidate constructor}} expected-note 3{{candidate inherited constructor}} - A(int = 0, int = 0, ...); // expected-note 3{{candidate constructor}} expected-note 3{{candidate inherited constructor}} - - template<typename T> A(T, int = 0, ...); // expected-note 3{{candidate constructor}} expected-note 3{{candidate inherited constructor}} - - template<typename T, int N> A(const T (&)[N]); // expected-note {{candidate constructor}} expected-note {{candidate inherited constructor}} - template<typename T, int N> A(const T (&)[N], int = 0); // expected-note {{candidate constructor}} expected-note {{candidate inherited constructor}} -}; - -struct B : A { // expected-note 4{{candidate constructor (the implicit}} - using A::A; // expected-note 15{{inherited here}} - B(void*); -}; - -struct C {} c; - -A a0{}; // expected-error {{ambiguous}} -B b0{}; // expected-error {{ambiguous}} - -A a1{1}; // expected-error {{ambiguous}} -B b1{1}; // expected-error {{ambiguous}} - -A a2{1,2}; // expected-error {{ambiguous}} -B b2{1,2}; // expected-error {{ambiguous}} - -A a3{1,2,3}; // ok -B b3{1,2,3}; // ok - -A a4{1,2,3,4}; // ok -B b4{1,2,3,4}; // ok - -A a5{1,2,3,4,5}; // ok -B b5{1,2,3,4,5}; // ok - -A a6{c}; // ok -B b6{c}; // ok - -A a7{c,0}; // ok -B b7{c,0}; // ok - -A a8{c,0,1}; // ok -B b8{c,0,1}; // ok - -A a9{"foo"}; // expected-error {{ambiguous}} -B b9{"foo"}; // expected-error {{ambiguous}} - -namespace PR15755 { - struct X { - template<typename...Ts> X(int, Ts...); - }; - struct Y : X { - using X::X; - }; - struct Z : Y { - using Y::Y; - }; - Z z(0); -} diff --git a/test/CXX/special/class.inhctor/p2.cpp b/test/CXX/special/class.inhctor/p2.cpp deleted file mode 100644 index f84dc6487573..000000000000 --- a/test/CXX/special/class.inhctor/p2.cpp +++ /dev/null @@ -1,133 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -verify %s -// -// Note: [class.inhctor] was removed by P0136R1. This tests the new behavior -// for the wording that used to be there. - -template<int> struct X {}; - -// Constructor characteristics are: -// - the template parameter list -// - the parameter-type-list -// - absence or presence of explicit -// - absence or presence of constexpr -struct A { - A(X<0>) {} // expected-note 4{{here}} - constexpr A(X<1>) {} - explicit A(X<2>) {} // expected-note 6{{here}} - explicit constexpr A(X<3>) {} // expected-note 4{{here}} -}; - -A a0 { X<0>{} }; -A a0i = { X<0>{} }; -constexpr A a0c { X<0>{} }; // expected-error {{must be initialized by a constant expression}} expected-note {{non-constexpr}} -constexpr A a0ic = { X<0>{} }; // expected-error {{must be initialized by a constant expression}} expected-note {{non-constexpr}} - -A a1 { X<1>{} }; -A a1i = { X<1>{} }; -constexpr A a1c { X<1>{} }; -constexpr A a1ic = { X<1>{} }; - -A a2 { X<2>{} }; -A a2i = { X<2>{} }; // expected-error {{constructor is explicit}} -constexpr A a2c { X<2>{} }; // expected-error {{must be initialized by a constant expression}} expected-note {{non-constexpr}} -constexpr A a2ic = { X<2>{} }; // expected-error {{constructor is explicit}} - -A a3 { X<3>{} }; -A a3i = { X<3>{} }; // expected-error {{constructor is explicit}} -constexpr A a3c { X<3>{} }; -constexpr A a3ic = { X<3>{} }; // expected-error {{constructor is explicit}} - - -struct B : A { - using A::A; -}; - -B b0 { X<0>{} }; -B b0i = { X<0>{} }; -constexpr B b0c { X<0>{} }; // expected-error {{must be initialized by a constant expression}} expected-note {{non-constexpr}} -constexpr B b0ic = { X<0>{} }; // expected-error {{must be initialized by a constant expression}} expected-note {{non-constexpr}} - -B b1 { X<1>{} }; -B b1i = { X<1>{} }; -constexpr B b1c { X<1>{} }; -constexpr B b1ic = { X<1>{} }; - -B b2 { X<2>{} }; -B b2i = { X<2>{} }; // expected-error {{constructor is explicit}} -constexpr B b2c { X<2>{} }; // expected-error {{must be initialized by a constant expression}} expected-note {{non-constexpr}} -constexpr B b2ic = { X<2>{} }; // expected-error {{constructor is explicit}} - -B b3 { X<3>{} }; -B b3i = { X<3>{} }; // expected-error {{constructor is explicit}} -constexpr B b3c { X<3>{} }; -constexpr B b3ic = { X<3>{} }; // expected-error {{constructor is explicit}} - - -// 'constexpr' is OK even if the constructor doesn't obey the constraints. -struct NonLiteral { NonLiteral(); }; -struct NonConstexpr { NonConstexpr(); constexpr NonConstexpr(int); }; -struct Constexpr { constexpr Constexpr(int) {} }; - -struct BothNonLiteral : NonLiteral, Constexpr { using Constexpr::Constexpr; }; // expected-note {{base class 'NonLiteral' of non-literal type}} -constexpr BothNonLiteral bothNL{42}; // expected-error {{constexpr variable cannot have non-literal type 'const BothNonLiteral'}} - -// FIXME: This diagnostic is not very good. We should explain that the problem is that base class NonConstexpr cannot be initialized. -struct BothNonConstexpr - : NonConstexpr, - Constexpr { - using Constexpr::Constexpr; // expected-note {{here}} -}; -constexpr BothNonConstexpr bothNC{42}; // expected-error {{must be initialized by a constant expression}} expected-note {{inherited from base class 'Constexpr'}} - - -struct ConstexprEval { - constexpr ConstexprEval(int a, const char *p) : k(p[a]) {} - char k; -}; -struct ConstexprEval2 { - char k2 = 'x'; -}; -struct ConstexprEval3 : ConstexprEval, ConstexprEval2 { - using ConstexprEval::ConstexprEval; -}; -constexpr ConstexprEval3 ce{4, "foobar"}; -static_assert(ce.k == 'a', ""); -static_assert(ce.k2 == 'x', ""); - - -struct TemplateCtors { // expected-note 2{{candidate constructor (the implicit}} - constexpr TemplateCtors() {} // expected-note {{candidate inherited constructor}} - template<template<int> class T> TemplateCtors(X<0>, T<0>); // expected-note {{here}} expected-note {{candidate inherited constructor}} - template<int N> TemplateCtors(X<1>, X<N>); // expected-note {{here}} expected-note {{candidate inherited constructor}} - template<typename T> TemplateCtors(X<2>, T); // expected-note {{here}} expected-note {{candidate inherited constructor}} - - template<typename T = int> TemplateCtors(int, int = 0, int = 0); -}; - -struct UsingTemplateCtors : TemplateCtors { // expected-note 2{{candidate constructor (the implicit}} - using TemplateCtors::TemplateCtors; // expected-note 6{{inherited here}} - - constexpr UsingTemplateCtors(X<0>, X<0>) {} // expected-note {{not viable}} - constexpr UsingTemplateCtors(X<1>, X<1>) {} // expected-note {{not viable}} - constexpr UsingTemplateCtors(X<2>, X<2>) {} // expected-note {{not viable}} - - template<int = 0> constexpr UsingTemplateCtors(int) {} // expected-note {{not viable}} - template<typename T = void> constexpr UsingTemplateCtors(int, int) {} // expected-note {{not viable}} - template<typename T, typename U> constexpr UsingTemplateCtors(int, int, int) {} // expected-note {{couldn't infer}} -}; - -template<int> struct Y {}; -constexpr UsingTemplateCtors uct1{ X<0>{}, X<0>{} }; -constexpr UsingTemplateCtors uct2{ X<0>{}, Y<0>{} }; // expected-error {{must be initialized by a constant expression}} expected-note {{non-constexpr}} -constexpr UsingTemplateCtors uct3{ X<1>{}, X<0>{} }; // expected-error {{must be initialized by a constant expression}} expected-note {{non-constexpr}} -constexpr UsingTemplateCtors uct4{ X<1>{}, X<1>{} }; -constexpr UsingTemplateCtors uct5{ X<2>{}, 0 }; // expected-error {{must be initialized by a constant expression}} expected-note {{non-constexpr}} -constexpr UsingTemplateCtors uct6{ X<2>{}, X<2>{} }; - -constexpr UsingTemplateCtors utc7{ 0 }; // ok -constexpr UsingTemplateCtors utc8{ 0, 0 }; // ok -// FIXME: The standard says that UsingTemplateCtors' (int, int, int) constructor -// hides the one from TemplateCtors, even though the template parameter lists -// don't match. It's not clear that that's *really* the intent, and it's not -// what other compilers do. -constexpr UsingTemplateCtors utc9{ 0, 0, 0 }; // expected-error {{no matching constructor}} diff --git a/test/CXX/special/class.inhctor/p3.cpp b/test/CXX/special/class.inhctor/p3.cpp deleted file mode 100644 index 19f15ebe0f0b..000000000000 --- a/test/CXX/special/class.inhctor/p3.cpp +++ /dev/null @@ -1,69 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s -// -// Note: [class.inhctor] was removed by P0136R1. This tests the new behavior -// for the wording that used to be there. - -struct B1 { - B1(int); // expected-note 3{{target of using}} - B1(int, int); // expected-note 3{{target of using}} -}; -struct D1 : B1 { - using B1::B1; -}; -D1 d1a(1), d1b(1, 1); - -D1 fd1() { return 1; } - -struct B2 { - explicit B2(int, int = 0, int = 0); -}; -struct D2 : B2 { // expected-note 2{{candidate constructor}} - using B2::B2; -}; -D2 d2a(1), d2b(1, 1), d2c(1, 1, 1); - -D2 fd2() { return 1; } // expected-error {{no viable conversion}} - -struct B3 { - B3(void*); // expected-note {{candidate}} -}; -struct D3 : B3 { // expected-note 2{{candidate constructor}} - using B3::B3; // expected-note {{inherited here}} -}; -D3 fd3() { return 1; } // expected-error {{no viable conversion}} - -template<typename T> struct T1 : B1 { - using B1::B1; // expected-note 2{{using declaration}} -}; -template<typename T> struct T2 : T1<T> { - using T1<int>::T1; // expected-note 2{{using declaration}} -}; -template<typename T> struct T3 : T1<int> { - using T1<T>::T1; // expected-note 2{{using declaration}} -}; -struct U { - // [dcl.meaning]p1: "the member shall not merely hav ebeen introduced by a - // using-declaration in the scope of the class [...] nominated by the - // nested-name-specifier of the declarator-id" - friend T1<int>::T1(int); // expected-error {{cannot befriend target of using declaration}} - friend T1<int>::T1(int, int); // expected-error {{cannot befriend target of using declaration}} - friend T2<int>::T2(int); // expected-error {{cannot befriend target of using declaration}} - friend T2<int>::T2(int, int); // expected-error {{cannot befriend target of using declaration}} - friend T3<int>::T3(int); // expected-error {{cannot befriend target of using declaration}} - friend T3<int>::T3(int, int); // expected-error {{cannot befriend target of using declaration}} -}; - -struct B4 { - template<typename T> explicit B4(T, int = 0); // expected-note 2{{here}} -}; -template<typename T> struct T4 : B4 { - using B4::B4; - template<typename U> T4(U); -}; -template<typename T> struct U4 : T4<T> { - using T4<T>::T4; -}; -T4<void> t4a = {0}; -T4<void> t4b = {0, 0}; // expected-error {{chosen constructor is explicit}} -U4<void> u4a = {0}; -U4<void> u4b = {0, 0}; // expected-error {{chosen constructor is explicit}} diff --git a/test/CXX/special/class.inhctor/p4.cpp b/test/CXX/special/class.inhctor/p4.cpp deleted file mode 100644 index 69fbea3e0eb0..000000000000 --- a/test/CXX/special/class.inhctor/p4.cpp +++ /dev/null @@ -1,74 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -verify %s -// -// Note: [class.inhctor] was removed by P0136R1. This tests the new behavior -// for the wording that used to be there. - -template<int> struct X {}; - -// A[n inheriting] constructor [...] has the same access as the corresponding -// constructor [in the base class]. -struct A { -public: - A(X<0>) {} -protected: - A(X<1>) {} // expected-note 2{{declared protected here}} -private: - A(X<2>) {} // expected-note 2{{declared private here}} - friend class FA; -}; - -struct B : A { - using A::A; - friend class FB; -}; - -B b0{X<0>{}}; -B b1{X<1>{}}; // expected-error {{calling a protected constructor}} -B b2{X<2>{}}; // expected-error {{calling a private constructor}} - -struct C : B { - C(X<0> x) : B(x) {} - C(X<1> x) : B(x) {} -}; - -struct FB { - B b0{X<0>{}}; - B b1{X<1>{}}; -}; - -struct FA : A { - using A::A; -}; -FA fa0{X<0>{}}; -FA fa1{X<1>{}}; // expected-error {{calling a protected constructor}} -FA fa2{X<2>{}}; // expected-error {{calling a private constructor}} - - -// It is deleted if the corresponding constructor [...] is deleted. -struct G { - G(int) = delete; // expected-note {{'G' has been explicitly marked deleted here}} - template<typename T> G(T*) = delete; // expected-note {{'G<const char>' has been explicitly marked deleted here}} -}; -struct H : G { - using G::G; -}; -H h1(5); // expected-error {{call to deleted constructor of 'H'}} -H h2("foo"); // expected-error {{call to deleted constructor of 'H'}} - - -// Core defect: It is also deleted if multiple base constructors generate the -// same signature. -namespace DRnnnn { - struct A { - constexpr A(int, float = 0) {} // expected-note {{candidate}} - explicit A(int, int = 0) {} // expected-note {{candidate}} - - A(int, int, int = 0) = delete; // expected-note {{deleted}} - }; - struct B : A { - using A::A; // expected-note 3{{inherited here}} - }; - - constexpr B b0(0, 0.0f); // ok, constexpr - B b1(0, 1); // expected-error {{call to constructor of 'DRnnnn::B' is ambiguous}} -} diff --git a/test/CXX/special/class.inhctor/p7.cpp b/test/CXX/special/class.inhctor/p7.cpp deleted file mode 100644 index 2d7acdcc2ce2..000000000000 --- a/test/CXX/special/class.inhctor/p7.cpp +++ /dev/null @@ -1,48 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s -// -// Note: [class.inhctor] was removed by P0136R1. This tests the new behavior -// for the wording that used to be there. - -struct B1 { - B1(int); // expected-note {{candidate}} -}; -struct B2 { - B2(int); // expected-note {{candidate}} -}; -struct D1 : B1, B2 { // expected-note 2{{candidate}} - using B1::B1; // expected-note {{inherited here}} - using B2::B2; // expected-note {{inherited here}} -}; -struct D2 : B1, B2 { - using B1::B1; - using B2::B2; - D2(int); -}; -D1 d1(0); // expected-error {{ambiguous}} -D2 d2(0); - -template<typename T> struct B3 { - B3(T); -}; -template<typename T> struct B4 : B3<T>, B1 { - B4(); - using B3<T>::B3; - using B1::B1; -}; -B4<char> b4c; -B4<int> b4i; - -struct B5 { - template<typename T> B5(T); -}; -struct D6 : B5 { - using B5::B5; - template<typename T> D6(T); -}; -D6 d6(0); -struct D7 : B5 { - using B5::B5; - template<typename T> D7(T, ...); -}; -// DRxxx (no number yet): derived class ctor beats base class ctor. -D7 d7(0); diff --git a/test/CXX/special/class.inhctor/p8.cpp b/test/CXX/special/class.inhctor/p8.cpp deleted file mode 100644 index 58c01d2b912d..000000000000 --- a/test/CXX/special/class.inhctor/p8.cpp +++ /dev/null @@ -1,32 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -verify %s -// -// Note: [class.inhctor] was removed by P0136R1. This tests the new behavior -// for the wording that used to be there. - -struct A { - constexpr A(const int&) : rval(false) {} - constexpr A(const int&&) : rval(true) {} - bool rval; -}; -struct B : A { - using A::A; -}; - -constexpr int k = 0; -constexpr A a0{0}; -constexpr A a1{k}; -constexpr B b0{0}; -constexpr B b1{k}; - -static_assert(a0.rval && !a1.rval && b0.rval && !b1.rval, ""); - -struct C { - template<typename T> constexpr C(T t) : v(t) {} - int v; -}; -struct D : C { - using C::C; -}; -static_assert(D(123).v == 123, ""); - -template<typename T> constexpr D::D(T t) : C(t) {} // expected-error {{does not match any declaration in 'D'}} diff --git a/test/CXX/special/class.init/class.base.init/p8-0x.cpp b/test/CXX/special/class.init/class.base.init/p8-0x.cpp deleted file mode 100644 index 45755caa8ecb..000000000000 --- a/test/CXX/special/class.init/class.base.init/p8-0x.cpp +++ /dev/null @@ -1,59 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s - -int n; -struct S { - int &a; // expected-note 2{{here}} - int &b = n; - - union { - const int k = 42; - }; - - S() {} // expected-error {{constructor for 'S' must explicitly initialize the reference member 'a'}} - S(int) : a(n) {} // ok - S(char) : b(n) {} // expected-error {{constructor for 'S' must explicitly initialize the reference member 'a'}} - S(double) : a(n), b(n) {} // ok -} s(0); - -union U { - int a = 0; // expected-note {{previous initialization}} - char b = 'x'; // expected-error {{initializing multiple members of union}} - - U() {} - U(int) : a(1) {} - U(char) : b('y') {} - U(double) : a(1), // expected-note{{previous initialization is here}} - b('y') {} // expected-error{{initializing multiple members of union}} -}; - -// PR10954: variant members do not acquire an implicit initializer. -namespace VariantMembers { - struct NoDefaultCtor { - NoDefaultCtor(int); - }; - union V { - NoDefaultCtor ndc; - int n; - - V() {} - V(int n) : n(n) {} - V(int n, bool) : ndc(n) {} - }; - struct K { - union { - NoDefaultCtor ndc; - int n; - }; - K() {} - K(int n) : n(n) {} - K(int n, bool) : ndc(n) {} - }; - struct Nested { - Nested() {} - union { - struct { - NoDefaultCtor ndc; - }; - }; - }; -} diff --git a/test/CXX/special/class.init/class.base.init/p9-0x.cpp b/test/CXX/special/class.init/class.base.init/p9-0x.cpp deleted file mode 100644 index ca5e8072d82f..000000000000 --- a/test/CXX/special/class.init/class.base.init/p9-0x.cpp +++ /dev/null @@ -1,36 +0,0 @@ -// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -std=c++11 %s -O1 -emit-llvm -o - | FileCheck %s - -struct S { - int n = 10; - int m = 2 * n; - - S() {} - S(int a) : n(a) {} - S(int a, int b) : n(a), m(b) {} - - struct T { - T *that = this; - }; -}; - -template<typename T> -struct U { - T *r = &q; - T q = 42; - U *p = this; -}; - -S a; -// CHECK: @a = {{.*}} { i32 10, i32 20 } - -S b(5); -// CHECK: @b = {{.*}} { i32 5, i32 10 } - -S c(3, 9); -// CHECK: @c = {{.*}} { i32 3, i32 9 } - -S::T d; -// CHECK: @d = {{.*}} { {{.*}} @d } - -U<S> e; -// CHECK: @e = {{.*}} { {{.*}} { i32 42, i32 84 }, {{.*}} @e } diff --git a/test/CXX/special/class.init/class.inhctor.init/p1.cpp b/test/CXX/special/class.init/class.inhctor.init/p1.cpp deleted file mode 100644 index 87fb195604d3..000000000000 --- a/test/CXX/special/class.init/class.inhctor.init/p1.cpp +++ /dev/null @@ -1,131 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -verify %s - -namespace std_example { - struct B1 { - B1(int, ...) {} - }; - - struct B2 { - B2(double) {} - }; - - int get(); - - struct D1 : B1 { // expected-note {{no default constructor}} - using B1::B1; // inherits B1(int, ...) - int x; - int y = get(); - }; - - void test() { - D1 d(2, 3, 4); // OK: B1 is initialized by calling B1(2, 3, 4), - // then d.x is default-initialized (no initialization is performed), - // then d.y is initialized by calling get() - D1 e; // expected-error {{implicitly-deleted}} - } - - struct D2 : B2 { - using B2::B2; - B1 b; // expected-note {{constructor inherited by 'D2' is implicitly deleted because field 'b' has no default constructor}} - }; - - D2 f(1.0); // expected-error {{constructor inherited by 'D2' from base class 'B2' is implicitly deleted}} - - struct W { - W(int); - }; - struct X : virtual W { - using W::W; - X() = delete; - }; - struct Y : X { - using X::X; - }; - struct Z : Y, virtual W { - using Y::Y; - }; - Z z(0); // OK: initialization of Y does not invoke default constructor of X - - template <class T> struct Log : T { - using T::T; // inherits all constructors from class T - ~Log() { /* ... */ } - }; -} - -namespace vbase { - struct V { - V(int); - }; - - struct A : virtual V { - A() = delete; // expected-note 2{{deleted here}} expected-note {{deleted}} - using V::V; - }; - struct B : virtual V { // expected-note {{no default constructor}} - B() = delete; // expected-note 2{{deleted here}} - B(int, int); - using V::V; - }; - struct C : B { // expected-note {{deleted default constructor}} - using B::B; - }; - struct D : A, C { // expected-note {{deleted default constructor}} expected-note {{deleted corresponding constructor}} - using A::A; - using C::C; - }; - - A a0; // expected-error {{deleted}} - A a1(0); - B b0; // expected-error {{deleted}} - B b1(0); - B b2(0, 0); - C c0; // expected-error {{deleted}} - C c1(0); - C c2(0, 0); // expected-error {{deleted}} - D d0; // expected-error {{deleted}} - D d1(0); - D d2(0, 0); // expected-error {{deleted}} -} - -namespace vbase_of_vbase { - struct V { V(int); }; - struct W : virtual V { using V::V; }; - struct X : virtual W, virtual V { using W::W; }; - X x(0); -} - -namespace constexpr_init_order { - struct Param; - struct A { - constexpr A(Param); - int a; - }; - - struct B : A { B(); using A::A; int b = 2; }; - extern const B b; - - struct Param { - constexpr Param(int c) : n(4 * b.a + b.b + c) {} - int n; - }; - - constexpr A::A(Param p) : a(p.n) {} - - constexpr B b(1); - constexpr B c(1); - static_assert(b.a == 1, "p should be initialized before B() is executed"); - static_assert(c.a == 7, "b not initialized properly"); -} - -namespace default_args { - // We work around a defect in P0136R1 where it would reject reasonable - // code like the following: - struct Base { - Base(int = 0); - }; - struct Derived : Base { - using Base::Base; - }; - Derived d; - // FIXME: Once a fix is standardized, implement it. -} diff --git a/test/CXX/special/class.init/class.inhctor.init/p2.cpp b/test/CXX/special/class.init/class.inhctor.init/p2.cpp deleted file mode 100644 index 7ea2ccc3605f..000000000000 --- a/test/CXX/special/class.init/class.inhctor.init/p2.cpp +++ /dev/null @@ -1,33 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -verify %s - -namespace std_example { - struct A { A(int); }; - struct B : A { using A::A; }; - - struct C1 : B { using B::B; }; - struct C2 : B { using B::B; }; - - struct D1 : C1, C2 { - using C1::C1; // expected-note {{inherited from base class 'C1' here}} - using C2::C2; // expected-note {{inherited from base class 'C2' here}} - }; - - struct V1 : virtual B { using B::B; }; - struct V2 : virtual B { using B::B; }; - - struct D2 : V1, V2 { - using V1::V1; - using V2::V2; - }; - - D1 d1(0); // expected-error {{constructor of 'A' inherited from multiple base class subobjects}} - D2 d2(0); // OK: initializes virtual B base class, which initializes the A base class - // then initializes the V1 and V2 base classes as if by a defaulted default constructor - - struct M { M(); M(int); }; - struct N : M { using M::M; }; - struct O : M {}; - struct P : N, O { using N::N; using O::O; }; - P p(0); // OK: use M(0) to initialize N's base class, - // use M() to initialize O's base class -} diff --git a/test/CXX/special/class.temporary/p1.cpp b/test/CXX/special/class.temporary/p1.cpp deleted file mode 100644 index 75a56df1e9c3..000000000000 --- a/test/CXX/special/class.temporary/p1.cpp +++ /dev/null @@ -1,57 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s - -namespace test0 { - struct A { - A() = default; - int x; - int y; - - A(const A&) = delete; // expected-note {{'A' has been explicitly marked deleted here}} - }; - - void foo(...); - - void test() { - A a; - foo(a); // expected-error {{call to deleted constructor of 'test0::A'}} - } -} - -namespace test1 { - struct A { - A() = default; - int x; - int y; - - private: - A(const A&) = default; // expected-note {{declared private here}} - }; - - void foo(...); - - void test() { - A a; - foo(a); // expected-error {{calling a private constructor of class 'test1::A'}} - } -} - -// Don't enforce this in an unevaluated context. -namespace test2 { - struct A { - A(const A&) = delete; // expected-note {{marked deleted here}} - }; - - typedef char one[1]; - typedef char two[2]; - - one &meta(bool); - two &meta(...); - - void a(A &a) { - char check[sizeof(meta(a)) == 2 ? 1 : -1]; - } - - void b(A &a) { - meta(a); // expected-error {{call to deleted constructor}} - } -} diff --git a/test/CXX/special/class.temporary/p6.cpp b/test/CXX/special/class.temporary/p6.cpp deleted file mode 100644 index 077385fb7aaa..000000000000 --- a/test/CXX/special/class.temporary/p6.cpp +++ /dev/null @@ -1,240 +0,0 @@ -// RUN: %clang_cc1 -std=c++17 %s -triple x86_64-linux-gnu -emit-llvm -o - | FileCheck %s --implicit-check-not='call{{.*}}dtor' - -namespace std { - typedef decltype(sizeof(int)) size_t; - - template <class E> - struct initializer_list { - const E *begin; - size_t size; - initializer_list() : begin(nullptr), size(0) {} - }; -} - -void then(); - -struct dtor { - ~dtor(); -}; - -dtor ctor(); - -auto &&lambda = [a = {ctor()}] {}; -// CHECK-LABEL: define -// CHECK: call {{.*}}ctor -// CHECK: call {{.*}}atexit{{.*}}global_array_dtor - -// CHECK-LABEL: define{{.*}}global_array_dtor -// CHECK: call {{.*}}dtor - -// [lifetime extension occurs if the object was obtained by] -// -- a temporary materialization conversion -// CHECK-LABEL: ref_binding -void ref_binding() { - // CHECK: call {{.*}}ctor - auto &&x = ctor(); - // CHECK: call {{.*}}then - then(); - // CHECK: call {{.*}}dtor - // CHECK: } -} - -// -- ( expression ) -// CHECK-LABEL: parens -void parens() { - // CHECK: call {{.*}}ctor - auto &&x = ctor(); - // CHECK: call {{.*}}then - then(); - // CHECK: call {{.*}}dtor - // CHECK: } -} - -// -- subscripting of an array -// CHECK-LABEL: array_subscript_1 -void array_subscript_1() { - using T = dtor[1]; - // CHECK: call {{.*}}ctor - auto &&x = T{ctor()}[0]; - // CHECK: call {{.*}}then - then(); - // CHECK: call {{.*}}dtor - // CHECK: } -} -// CHECK-LABEL: array_subscript_2 -void array_subscript_2() { - using T = dtor[1]; - // CHECK: call {{.*}}ctor - auto &&x = ((dtor*)T{ctor()})[0]; - // CHECK: call {{.*}}dtor - // CHECK: call {{.*}}then - then(); - // CHECK: } -} - -struct with_member { dtor d; ~with_member(); }; -struct with_ref_member { dtor &&d; ~with_ref_member(); }; - -// -- a class member access using the . operator [...] -// CHECK-LABEL: member_access_1 -void member_access_1() { - // CHECK: call {{.*}}ctor - auto &&x = with_member{ctor()}.d; - // CHECK: call {{.*}}then - then(); - // CHECK: call {{.*}}with_member - // CHECK: } -} -// CHECK-LABEL: member_access_2 -void member_access_2() { - // CHECK: call {{.*}}ctor - auto &&x = with_ref_member{ctor()}.d; - // CHECK: call {{.*}}with_ref_member - // CHECK: call {{.*}}dtor - // CHECK: call {{.*}}then - then(); - // CHECK: } -} -// CHECK-LABEL: member_access_3 -void member_access_3() { - // CHECK: call {{.*}}ctor - auto &&x = (&(const with_member&)with_member{ctor()})->d; - // CHECK: call {{.*}}with_member - // CHECK: call {{.*}}then - then(); - // CHECK: } -} - -// -- a pointer-to-member operation using the .* operator [...] -// CHECK-LABEL: member_ptr_access_1 -void member_ptr_access_1() { - // CHECK: call {{.*}}ctor - auto &&x = with_member{ctor()}.*&with_member::d; - // CHECK: call {{.*}}then - then(); - // CHECK: call {{.*}}with_member - // CHECK: } -} -// CHECK-LABEL: member_ptr_access_2 -void member_ptr_access_2() { - // CHECK: call {{.*}}ctor - auto &&x = (&(const with_member&)with_member{ctor()})->*&with_member::d; - // CHECK: call {{.*}}with_member - // CHECK: call {{.*}}then - then(); - // CHECK: } -} - -// -- a [named] cast [...] -// CHECK-LABEL: static_cast -void test_static_cast() { - // CHECK: call {{.*}}ctor - auto &&x = static_cast<dtor&&>(ctor()); - // CHECK: call {{.*}}then - then(); - // CHECK: call {{.*}}dtor - // CHECK: } -} -// CHECK-LABEL: const_cast -void test_const_cast() { - // CHECK: call {{.*}}ctor - auto &&x = const_cast<dtor&&>(ctor()); - // CHECK: call {{.*}}then - then(); - // CHECK: call {{.*}}dtor - // CHECK: } -} -// CHECK-LABEL: reinterpret_cast -void test_reinterpret_cast() { - // CHECK: call {{.*}}ctor - auto &&x = reinterpret_cast<dtor&&>(static_cast<dtor&&>(ctor())); - // CHECK: call {{.*}}then - then(); - // CHECK: call {{.*}}dtor - // CHECK: } -} -// CHECK-LABEL: dynamic_cast -void test_dynamic_cast() { - // CHECK: call {{.*}}ctor - auto &&x = dynamic_cast<dtor&&>(ctor()); - // CHECK: call {{.*}}then - then(); - // CHECK: call {{.*}}dtor - // CHECK: } -} - -// -- [explicit cast notation is defined in terms of the above] -// CHECK-LABEL: c_style_cast -void c_style_cast() { - // CHECK: call {{.*}}ctor - auto &&x = (dtor&&)ctor(); - // CHECK: call {{.*}}then - then(); - // CHECK: call {{.*}}dtor - // CHECK: } -} -// CHECK-LABEL: function_style_cast -void function_style_cast() { - // CHECK: call {{.*}}ctor - using R = dtor&&; - auto &&x = R(ctor()); - // CHECK: call {{.*}}then - then(); - // CHECK: call {{.*}}dtor - // CHECK: } -} - -// -- a conditional operator -// CHECK-LABEL: conditional -void conditional(bool b) { - // CHECK: call {{.*}}ctor - // CHECK: call {{.*}}ctor - auto &&x = b ? (dtor&&)ctor() : (dtor&&)ctor(); - // CHECK: call {{.*}}then - then(); - // CHECK: call {{.*}}dtor - // CHECK: call {{.*}}dtor - // CHECK: } -} - -// -- a comma expression -// CHECK-LABEL: comma -void comma() { - // CHECK: call {{.*}}ctor - auto &&x = (true, (dtor&&)ctor()); - // CHECK: call {{.*}}then - then(); - // CHECK: call {{.*}}dtor - // CHECK: } -} - - -// This applies recursively: if an object is lifetime-extended and contains a -// reference, the referent is also extended. -// CHECK-LABEL: init_capture_ref -void init_capture_ref() { - // CHECK: call {{.*}}ctor - auto x = [&a = (const dtor&)ctor()] {}; - // CHECK: call {{.*}}then - then(); - // CHECK: call {{.*}}dtor - // CHECK: } -} -// CHECK-LABEL: init_capture_ref_indirect -void init_capture_ref_indirect() { - // CHECK: call {{.*}}ctor - auto x = [&a = (const dtor&)ctor()] {}; - // CHECK: call {{.*}}then - then(); - // CHECK: call {{.*}}dtor - // CHECK: } -} -// CHECK-LABEL: init_capture_init_list -void init_capture_init_list() { - // CHECK: call {{.*}}ctor - auto x = [a = {ctor()}] {}; - // CHECK: call {{.*}}then - then(); - // CHECK: call {{.*}}dtor - // CHECK: } -} diff --git a/test/CXX/stmt.stmt/stmt.ambig/p1-0x.cpp b/test/CXX/stmt.stmt/stmt.ambig/p1-0x.cpp deleted file mode 100644 index 81e8e25b4c4f..000000000000 --- a/test/CXX/stmt.stmt/stmt.ambig/p1-0x.cpp +++ /dev/null @@ -1,40 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s - -struct T { - struct x { - int m; - }; - x* operator->(); - void operator++(int); - void operator<<(int); - T(); - T(int); - T(int, int); -}; - -template<typename A, typename B, typename C, typename D, typename E> -void func(A, B, C, D, E); - -void func(int a, int c) { - T(a)->m = 7; - T(a)++; - T(a,5)<<c; - - T(*d)(int); - T(e)[5]; - T(f) = {1, 2}; - T(*g)(double(3)); // expected-error{{cannot initialize a variable of type 'T (*)' with an rvalue of type 'double'}} - func(a, d, e, f, g); -} - -void func2(int a, int c) { - decltype(T())(a)->m = 7; - decltype(T())(a)++; - decltype(T())(a,5)<<c; - - decltype(T())(*d)(int); - decltype(T())(e)[5]; - decltype(T())(f) = {1, 2}; - decltype(T())(*g)(double(3)); // expected-error{{cannot initialize a variable of type 'decltype(T()) (*)' (aka 'T *') with an rvalue of type 'double'}} - func(a, d, e, f, g); -} diff --git a/test/CXX/stmt.stmt/stmt.dcl/p3-0x.cpp b/test/CXX/stmt.stmt/stmt.dcl/p3-0x.cpp deleted file mode 100644 index d7726c944cdb..000000000000 --- a/test/CXX/stmt.stmt/stmt.dcl/p3-0x.cpp +++ /dev/null @@ -1,55 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s - -// PR10034 -struct X {}; - -void exx(X) {} - -int test_ptr10034(int argc, char **argv) -{ - if (argc > 3) - goto end; - - X x; - X xs[16]; - exx(x); - - end: - if (argc > 1) { - for (int i = 0; i < argc; ++i) - { - - } - } - return 0; -} - -struct Y { - ~Y(); -}; - -void f(); -void test_Y() { - goto end; // expected-error{{cannot jump from this goto statement to its label}} - Y y; // expected-note{{jump bypasses variable with a non-trivial destructor}} - end: - f(); - goto inner; // expected-error{{cannot jump from this goto statement to its label}} - { - Y y2; // expected-note{{jump bypasses variable with a non-trivial destructor}} - inner: - f(); - } - return; -} - -struct Z { - Z operator=(const Z&); -}; - -void test_Z() { - goto end; - Z z; - end: - return; -} diff --git a/test/CXX/stmt.stmt/stmt.dcl/p3.cpp b/test/CXX/stmt.stmt/stmt.dcl/p3.cpp deleted file mode 100644 index 03c835b21a62..000000000000 --- a/test/CXX/stmt.stmt/stmt.dcl/p3.cpp +++ /dev/null @@ -1,57 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s - -// PR10034 -struct X {}; - -void exx(X) {} - -int test_ptr10034(int argc, char **argv) -{ - if (argc > 3) - goto end; - - X x; - X xs[16]; - exx(x); - - end: - if (argc > 1) { - for (int i = 0; i < argc; ++i) - { - - } - } - return 0; -} - -struct Y { - ~Y(); -}; - -void test_Y() { - goto end; // expected-error{{cannot jump from this goto statement to its label}} - Y y; // expected-note{{jump bypasses variable with a non-trivial destructor}} - end: - return; -} - -struct Z { - Z operator=(const Z&); -}; - -void test_Z() { - goto end; -#if __cplusplus <= 199711L - // expected-error@-2 {{cannot jump from this goto statement to its label}} -#endif - - Z z; -#if __cplusplus <= 199711L - // expected-note@-2 {{jump bypasses initialization of non-POD variable}} -#endif - - end: - return; -} diff --git a/test/CXX/stmt.stmt/stmt.iter/stmt.ranged/p1.cpp b/test/CXX/stmt.stmt/stmt.iter/stmt.ranged/p1.cpp deleted file mode 100644 index f42fc9b6e5aa..000000000000 --- a/test/CXX/stmt.stmt/stmt.iter/stmt.ranged/p1.cpp +++ /dev/null @@ -1,328 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s -// RUN: %clang_cc1 -std=c++14 -fsyntax-only -verify %s -// RUN: %clang_cc1 -std=c++17 -fsyntax-only -verify %s - -struct pr12960 { - int begin; - void foo(int x) { - for (int& it : x) { // expected-error {{invalid range expression of type 'int'; no viable 'begin' function available}} - } - } -}; - -struct null_t { - operator int*(); -}; - -namespace X { - template<typename T> - auto begin(T &&t) -> decltype(t.begin()) { return t.begin(); } // expected-note 2{{ignored: substitution failure}} - template<typename T> - auto end(T &&t) -> decltype(t.end()) { return t.end(); } // expected-note {{candidate template ignored: substitution failure [with T = }} - - template<typename T> - auto begin(T &&t) -> decltype(t.alt_begin()) { return t.alt_begin(); } // expected-note {{selected 'begin' template [with T = }} \ - expected-note 2{{candidate template ignored: substitution failure [with T = }} - template<typename T> - auto end(T &&t) -> decltype(t.alt_end()) { return t.alt_end(); } // expected-note {{candidate template ignored: substitution failure [with T = }} - - namespace inner { - // These should never be considered. - int begin(int); - int end(int); - } - - using namespace inner; - - struct A { // expected-note 2 {{candidate constructor}} - A(); - int *begin(); // expected-note 3{{selected 'begin' function with iterator type 'int *'}} expected-note {{'begin' declared here}} - int *end(); - }; - - struct B { - B(); - int *alt_begin(); - int *alt_end(); - }; - - struct NoBeginADL { - null_t alt_end(); - }; - struct NoEndADL { - null_t alt_begin(); - }; - - struct C { - C(); - struct It { - int val; - operator int &() { return val; } - }; - It begin(); - It end(); - }; - - constexpr int operator*(const C::It &) { return 0; } -} - -using X::A; - -void f(); -void f(int); - -void g() { - for (int a : A()) - A __begin; - for (char *a : A()) { // expected-error {{cannot initialize a variable of type 'char *' with an lvalue of type 'int'}} - } - for (char *a : X::B()) { // expected-error {{cannot initialize a variable of type 'char *' with an lvalue of type 'int'}} - } - // FIXME: Terrible diagnostic here. auto deduction should fail, but does not! - for (double a : f) { // expected-error {{cannot use type '<overloaded function type>' as a range}} - } - for (auto a : A()) { - } - for (auto a : X::B()) { - } - for (auto *a : A()) { // expected-error {{variable 'a' with type 'auto *' has incompatible initializer of type 'int'}} - } - // : is not a typo for :: here. - for (A NS:A()) { // expected-error {{no viable conversion from 'int' to 'X::A'}} - } - for (auto not_in_scope : not_in_scope) { // expected-error {{use of undeclared identifier 'not_in_scope'}} - } - - for (auto a : A()) - for (auto b : A()) { - __range.begin(); // expected-error {{use of undeclared identifier '__range'}} - ++__begin; // expected-error {{use of undeclared identifier '__begin'}} - --__end; // expected-error {{use of undeclared identifier '__end'}} - } - - for (char c : "test") - ; - for (auto a : f()) // expected-error {{cannot use type 'void' as a range}} - ; - - extern int incomplete[]; - for (auto a : incomplete) // expected-error {{cannot use incomplete type 'int []' as a range}} - ; - extern struct Incomplete also_incomplete[2]; // expected-note 2{{forward declaration}} - for (auto &a : also_incomplete) // expected-error {{cannot use incomplete type 'struct Incomplete [2]' as a range}} - ; - - struct VoidBegin { - void begin(); // expected-note {{selected 'begin' function with iterator type 'void'}} - void end(); - }; - for (auto a : VoidBegin()) // expected-error {{cannot use type 'void' as an iterator}} - ; - - struct Differ { - int *begin(); - null_t end(); - }; - for (auto a : Differ()) -#if __cplusplus <= 201402L - // expected-warning@-2 {{'begin' and 'end' returning different types ('int *' and 'null_t') is a C++17 extension}} - // expected-note@-6 {{selected 'begin' function with iterator type 'int *'}} - // expected-note@-6 {{selected 'end' function with iterator type 'null_t'}} -#endif - ; - - for (void f() : "error") // expected-error {{for range declaration must declare a variable}} - ; - - for (extern int a : A()) {} // expected-error {{loop variable 'a' may not be declared 'extern'}} - for (static int a : A()) {} // expected-error {{loop variable 'a' may not be declared 'static'}} - for (register int a : A()) {} // expected-error {{loop variable 'a' may not be declared 'register'}} expected-warning 0-1{{register}} expected-error 0-1{{register}} - for (constexpr int a : X::C()) {} // OK per CWG issue #1204. - - for (auto u : X::NoBeginADL()) { // expected-error {{invalid range expression of type 'X::NoBeginADL'; no viable 'begin' function available}} - } - for (auto u : X::NoEndADL()) { // expected-error {{invalid range expression of type 'X::NoEndADL'; no viable 'end' function available}} - } - - struct NoBegin { - null_t end(); - }; - struct NoEnd { - null_t begin(); - }; - for (auto u : NoBegin()) { // expected-error {{no viable 'begin' function available}} - } - for (auto u : NoEnd()) { // expected-error {{no viable 'end' function available}} - } - - struct NoIncr { - void *begin(); // expected-note {{selected 'begin' function with iterator type 'void *'}} - void *end(); - }; - for (auto u : NoIncr()) { // expected-error {{arithmetic on a pointer to void}}\ - expected-note {{in implicit call to 'operator++' for iterator of type 'NoIncr'}} - } - - struct NoNotEq { - NoNotEq begin(); // expected-note {{selected 'begin' function with iterator type 'NoNotEq'}} - NoNotEq end(); - void operator++(); - }; - for (auto u : NoNotEq()) { // expected-error {{invalid operands to binary expression}}\ - expected-note {{in implicit call to 'operator!=' for iterator of type 'NoNotEq'}} - } - - struct NoDeref { - NoDeref begin(); // expected-note {{selected 'begin' function}} - NoDeref end(); - void operator++(); - bool operator!=(NoDeref &); - }; - - for (auto u : NoDeref()) { // expected-error {{indirection requires pointer operand}} \ - expected-note {{in implicit call to 'operator*' for iterator of type 'NoDeref'}} - } - - struct NoCopy { - NoCopy(); - NoCopy(const NoCopy &) = delete; - int *begin(); - int *end(); - }; - for (int n : NoCopy()) { // ok - } - - for (int n : 42) { // expected-error {{invalid range expression of type 'int'; no viable 'begin' function available}} - } - - for (auto a : *also_incomplete) { // expected-error {{cannot use incomplete type 'struct Incomplete' as a range}} - } -} - -template<typename T, typename U> -void h(T t) { - for (U u : t) { // expected-error {{no viable conversion from 'X::A' to 'int'}} - } - for (auto u : t) { - } -} - -template void h<A, int>(A); -template void h<A(&)[4], A &>(A(&)[4]); -template void h<A(&)[13], A>(A(&)[13]); -template void h<A(&)[13], int>(A(&)[13]); // expected-note {{requested here}} - -template<typename T> -void i(T t) { - for (auto u : t) { // expected-error {{invalid range expression of type 'X::A *'; no viable 'begin' function available}} \ - expected-error {{'this' argument to member function 'begin' has type 'const X::A', but function is not marked const}} \ - expected-note {{when looking up 'begin' function}} - - } -} -template void i<A[13]>(A*); // expected-note {{requested here}} -template void i<const A>(const A); // expected-note {{requested here}} - -struct StdBeginEnd {}; -namespace std { - int *begin(StdBeginEnd); - int *end(StdBeginEnd); -} -void DR1442() { - for (auto a : StdBeginEnd()) {} // expected-error {{invalid range expression of type 'StdBeginEnd'; no viable 'begin'}} -} - -namespace NS { - class ADL {}; - int *begin(ADL); // expected-note {{no known conversion from 'NS::NoADL' to 'NS::ADL'}} - int *end(ADL); - - class NoADL {}; -} -int *begin(NS::NoADL); -int *end(NS::NoADL); - -struct VoidBeginADL {}; -void begin(VoidBeginADL); // expected-note {{selected 'begin' function with iterator type 'void'}} -void end(VoidBeginADL); - -void j() { - for (auto u : NS::ADL()) { - } - for (auto u : NS::NoADL()) { // expected-error {{invalid range expression of type 'NS::NoADL'; no viable 'begin' function available}} - } - for (auto a : VoidBeginADL()) { // expected-error {{cannot use type 'void' as an iterator}} - - } -} - -void example() { - int array[5] = { 1, 2, 3, 4, 5 }; - for (int &x : array) - x *= 2; -} - -namespace rdar13712739 { - template<typename T> - void foo(const T& t) { - auto &x = t.get(); // expected-error{{member reference base type 'const int' is not a structure or union}} - for (auto &blah : x) { } - } - - template void foo(const int&); // expected-note{{in instantiation of function template specialization}} -} - -namespace p0962r1 { - namespace NA { - struct A { - void begin(); - }; - int *begin(A); - int *end(A); - } - - namespace NB { - struct B { - void end(); - }; - int *begin(B); - int *end(B); - } - - namespace NC { - struct C { - void begin(); - }; - int *begin(C); - } - - namespace ND { - struct D { - void end(); - }; - int *end(D); - } - - namespace NE { - struct E { - void begin(); // expected-note {{member is not a candidate because range type 'p0962r1::NE::E' has no 'end' member}} - }; - int *end(E); - } - - namespace NF { - struct F { - void end(); // expected-note {{member is not a candidate because range type 'p0962r1::NF::F' has no 'begin' member}} - }; - int *begin(F); - } - - void use(NA::A a, NB::B b, NC::C c, ND::D d, NE::E e, NF::F f) { - for (auto x : a) {} - for (auto x : b) {} - for (auto x : c) {} // expected-error {{no viable 'end' function}} - for (auto x : d) {} // expected-error {{no viable 'begin' function}} - for (auto x : e) {} // expected-error {{no viable 'begin' function}} - for (auto x : f) {} // expected-error {{no viable 'end' function}} - } -} diff --git a/test/CXX/stmt.stmt/stmt.label/p1.cpp b/test/CXX/stmt.stmt/stmt.label/p1.cpp deleted file mode 100644 index 90367f829566..000000000000 --- a/test/CXX/stmt.stmt/stmt.label/p1.cpp +++ /dev/null @@ -1,25 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s - -void f() -{ - int x = 0; - goto label1; - -label1: // expected-note{{previous definition is here}} - x = 1; - goto label2; // expected-error{{use of undeclared label 'label2'}} - -label1: // expected-error{{redefinition of label 'label1'}} - x = 2; -} - -void h() -{ - int x = 0; - switch (x) - { - case 1:; - default:; // expected-error{{multiple default labels in one switch}} - default:; // expected-note{{previous case defined here}} - } -} diff --git a/test/CXX/stmt.stmt/stmt.select/p3.cpp b/test/CXX/stmt.stmt/stmt.select/p3.cpp deleted file mode 100644 index 4804cc559d00..000000000000 --- a/test/CXX/stmt.stmt/stmt.select/p3.cpp +++ /dev/null @@ -1,76 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -Wno-unused-value -verify %s -// RUN: %clang_cc1 -fsyntax-only -Wno-unused-value -std=c++1z -Wc++14-compat -verify %s -DCPP17 - -int f(); - -void g() { - if (int x = f()) { // expected-note 2{{previous definition}} - int x; // expected-error{{redefinition of 'x'}} - } else { - int x; // expected-error{{redefinition of 'x'}} - } -} - -void h() { - if (int x = f()) // expected-note 2{{previous definition}} - int x; // expected-error{{redefinition of 'x'}} - else - int x; // expected-error{{redefinition of 'x'}} -} - -void ifInitStatement() { - int Var = 0; - - if (int I = 0; true) {} - if (Var + Var; true) {} - if (; true) {} -#ifdef CPP17 - // expected-warning@-4 {{if initialization statements are incompatible with C++ standards before C++17}} - // expected-warning@-4 {{if initialization statements are incompatible with C++ standards before C++17}} - // expected-warning@-4 {{if initialization statements are incompatible with C++ standards before C++17}} -#else - // expected-warning@-8 {{'if' initialization statements are a C++17 extension}} - // expected-warning@-8 {{'if' initialization statements are a C++17 extension}} - // expected-warning@-8 {{'if' initialization statements are a C++17 extension}} -#endif -} - -void switchInitStatement() { - int Var = 0; - - switch (int I = 0; Var) {} - switch (Var + Var; Var) {} - switch (; Var) {} -#ifdef CPP17 - // expected-warning@-4 {{switch initialization statements are incompatible with C++ standards before C++17}} - // expected-warning@-4 {{switch initialization statements are incompatible with C++ standards before C++17}} - // expected-warning@-4 {{switch initialization statements are incompatible with C++ standards before C++17}} -#else - // expected-warning@-8 {{'switch' initialization statements are a C++17 extension}} - // expected-warning@-8 {{'switch' initialization statements are a C++17 extension}} - // expected-warning@-8 {{'switch' initialization statements are a C++17 extension}} -#endif -} - -// TODO: Better diagnostics for while init statements. -void whileInitStatement() { - while (int I = 10; I--); // expected-error {{expected ')'}} - // expected-note@-1 {{to match this '('}} - // expected-error@-2 {{use of undeclared identifier 'I'}} - - int Var = 10; - while (Var + Var; Var--) {} // expected-error {{expected ')'}} - // expected-note@-1 {{to match this '('}} - // expected-error@-2 {{expected ';' after expression}} - // expected-error@-3 {{expected expression}} - // expected-warning@-4 {{while loop has empty body}} - // expected-note@-5 {{put the semicolon on a separate line to silence this warning}} -} - -// TODO: This is needed because clang can't seem to diagnose invalid syntax after the -// last loop above. It would be nice to remove this. -void whileInitStatement2() { - while (; false) {} // expected-error {{expected expression}} - // expected-error@-1 {{expected ';' after expression}} - // expected-error@-2 {{expected expression}} -} diff --git a/test/CXX/stmt.stmt/stmt.select/stmt.if/p2.cpp b/test/CXX/stmt.stmt/stmt.select/stmt.if/p2.cpp deleted file mode 100644 index c33bf0eba231..000000000000 --- a/test/CXX/stmt.stmt/stmt.select/stmt.if/p2.cpp +++ /dev/null @@ -1,142 +0,0 @@ -// RUN: %clang_cc1 -std=c++1z -verify %s -// RUN: %clang_cc1 -std=c++1z -verify %s -DUNDEFINED - -#ifdef UNDEFINED -// "used but not defined" errors don't get produced if we have more interesting -// errors. -namespace std_example { - template <typename T, typename... Rest> void g(T &&p, Rest &&... rs) { - // use p - if constexpr(sizeof...(rs) > 0) - g(rs...); - } - void use_g() { - g(1, 2, 3); - } - - static int x(); // no definition of x required - int f() { - if constexpr (true) - return 0; - else if (x()) - return x(); - else - return -x(); - } -} - -namespace odr_use_in_selected_arm { - static int x(); // expected-warning {{is not defined}} - int f() { - if constexpr (false) - return 0; - else if (x()) // expected-note {{here}} - return x(); - else - return -x(); - } -} -#else -namespace ccce { - void f() { - if (5) {} - if constexpr (5) {} // expected-error {{cannot be narrowed}} - } - template<int N> void g() { - if constexpr (N) {} // expected-error {{cannot be narrowed}} - } - template void g<5>(); // expected-note {{instantiation of}} - void h() { - if constexpr (4.3) {} // expected-error{{conversion from 'double' to 'bool' is not allowed in a converted constant expression}} - constexpr void *p = nullptr; - if constexpr (p) {} // expected-error{{conversion from 'void *const' to 'bool' is not allowed in a converted constant expression}} - } -} - -namespace generic_lambda { - // Substituting for T produces a hard error here, even if substituting for - // the type of x would remove the error. - template<typename T> void f() { - [](auto x) { - if constexpr (sizeof(T) == 1 && sizeof(x) == 1) - T::error(); // expected-error 2{{'::'}} - } (0); - } - - template<typename T> void g() { - [](auto x) { - if constexpr (sizeof(T) == 1) - if constexpr (sizeof(x) == 1) - T::error(); // expected-error {{'::'}} - } (0); - } - - void use() { - f<int>(); // expected-note {{instantiation of}} - f<char>(); // expected-note {{instantiation of}} - g<int>(); // ok - g<char>(); // expected-note {{instantiation of}} - } -} - -namespace potentially_discarded_branch_target { - void in_switch(int n) { - switch (n) - case 4: if constexpr(sizeof(n) == 4) return; - if constexpr(sizeof(n) == 4) - switch (n) case 4: return; - switch (n) { - if constexpr (sizeof(n) == 4) // expected-note 2{{constexpr if}} - case 4: return; // expected-error {{cannot jump}} - else - default: break; // expected-error {{cannot jump}} - } - } - - template<typename T> - void in_switch_tmpl(int n) { - switch (n) { - if constexpr (sizeof(T) == 4) // expected-note 2{{constexpr if}} - case 4: return; // expected-error {{cannot jump}} - else - default: break; // expected-error {{cannot jump}} - } - } - - void goto_scope(int n) { - goto foo; // expected-error {{cannot jump}} - if constexpr(sizeof(n) == 4) // expected-note {{constexpr if}} - foo: return; -bar: - if constexpr(sizeof(n) == 4) - goto bar; // ok - } - - template<typename T> - void goto_scope(int n) { - goto foo; // expected-error {{cannot jump}} - if constexpr(sizeof(n) == 4) // expected-note {{constexpr if}} - foo: return; -bar: - if constexpr(sizeof(n) == 4) - goto bar; // ok - } - - void goto_redef(int n) { -a: if constexpr(sizeof(n) == 4) // expected-error {{redefinition}} expected-note {{constexpr if}} - a: goto a; // expected-note 2{{previous}} - else - a: goto a; // expected-error {{redefinition}} expected-error {{cannot jump}} - } - - void evil_things() { - goto evil_label; // expected-error {{cannot jump}} - if constexpr (true || ({evil_label: false;})) {} // expected-note {{constexpr if}} - - if constexpr (true) // expected-note {{constexpr if}} - goto surprise; // expected-error {{cannot jump}} - else - surprise: {} - } -} -#endif diff --git a/test/CXX/stmt.stmt/stmt.select/stmt.switch/p2-0x.cpp b/test/CXX/stmt.stmt/stmt.select/stmt.switch/p2-0x.cpp deleted file mode 100644 index fda0c5cff153..000000000000 --- a/test/CXX/stmt.stmt/stmt.select/stmt.switch/p2-0x.cpp +++ /dev/null @@ -1,40 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 %s -verify -// expected-no-diagnostics - -struct Value { - constexpr Value(int n) : n(n) {} - constexpr operator short() const { return n; } - int n; -}; -enum E { E0, E1 }; -struct Alt { - constexpr operator E() const { return E0; } -}; - -constexpr short s = Alt(); - -void test(Value v) { - switch (v) { - case Alt(): - case E1: - case Value(2): - case 3: - break; - } - switch (Alt a = Alt()) { - case Alt(): - case E1: - case Value(2): - case 3: - break; - } - switch (E0) { - case Alt(): - case E1: - // FIXME: These should produce a warning that 2 and 3 are not values of the - // enumeration. - case Value(2): - case 3: - break; - } -} diff --git a/test/CXX/temp/p3.cpp b/test/CXX/temp/p3.cpp deleted file mode 100644 index e9fd8a3090e8..000000000000 --- a/test/CXX/temp/p3.cpp +++ /dev/null @@ -1,19 +0,0 @@ -// 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}} - -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 {{no member named 'a'}} \ - expected-warning {{extra qualification}} - -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.arg/temp.arg.nontype/p1-11.cpp b/test/CXX/temp/temp.arg/temp.arg.nontype/p1-11.cpp deleted file mode 100644 index 3f65466dfc0f..000000000000 --- a/test/CXX/temp/temp.arg/temp.arg.nontype/p1-11.cpp +++ /dev/null @@ -1,67 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 %s -verify -triple x86_64-linux-gnu - -namespace std { - typedef decltype(nullptr) nullptr_t; -} - -template<int *ip> struct IP { // expected-note 5 {{template parameter is declared here}} - IP<ip> *ip2; -}; - -template<int &ip> struct IR {}; - -constexpr std::nullptr_t get_nullptr() { return nullptr; } - -constexpr std::nullptr_t np = nullptr; - -std::nullptr_t nonconst_np; // expected-note{{declared here}} - -thread_local int tl; // expected-note {{refers here}} - -IP<0> ip0; // expected-error{{null non-type template argument must be cast to template parameter type 'int *'}} -IP<(0)> ip1; // expected-error{{null non-type template argument must be cast to template parameter type 'int *'}} -IP<nullptr> ip2; -IP<get_nullptr()> ip3; -IP<(int*)0> ip4; -IP<np> ip5; -IP<nonconst_np> ip5; // expected-error{{non-type template argument of type 'std::nullptr_t' (aka 'nullptr_t') is not a constant expression}} \ -// expected-note{{read of non-constexpr variable 'nonconst_np' is not allowed in a constant expression}} -IP<(float*)0> ip6; // expected-error{{null non-type template argument of type 'float *' does not match template parameter of type 'int *'}} -IP<&tl> ip7; // expected-error{{non-type template argument of type 'int *' is not a constant expression}} - -IR<tl> ir1; // expected-error{{non-type template argument refers to thread-local object}} - -struct X { }; -template<int X::*pm> struct PM { // expected-note 2 {{template parameter is declared here}} - PM<pm> *pm2; -}; - -PM<0> pm0; // expected-error{{null non-type template argument must be cast to template parameter type 'int X::*'}} -PM<(0)> pm1; // expected-error{{null non-type template argument must be cast to template parameter type 'int X::*'}} -PM<nullptr> pm2; -PM<get_nullptr()> pm3; -PM<(int X::*)0> pm4; -PM<np> pm5; - -template<int (X::*pmf)(int)> struct PMF { // expected-note 2 {{template parameter is declared here}} - PMF<pmf> *pmf2; -}; - -PMF<0> pmf0; // expected-error{{null non-type template argument must be cast to template parameter type 'int (X::*)(int)'}} -PMF<(0)> pmf1; // expected-error{{null non-type template argument must be cast to template parameter type 'int (X::*)(int)'}} -PMF<nullptr> pmf2; -PMF<get_nullptr()> pmf3; -PMF<(int (X::*)(int))0> pmf4; -PMF<np> pmf5; - - -template<std::nullptr_t np> struct NP { // expected-note 2{{template parameter is declared here}} - NP<np> *np2; -}; - -NP<nullptr> np1; -NP<np> np2; -NP<get_nullptr()> np3; -NP<0> np4; // expected-error{{null non-type template argument must be cast to template parameter type 'std::nullptr_t' (aka 'nullptr_t')}} -constexpr int i = 7; -NP<i> np5; // expected-error{{non-type template argument of type 'const int' cannot be converted to a value of type 'std::nullptr_t'}} diff --git a/test/CXX/temp/temp.arg/temp.arg.nontype/p1.cpp b/test/CXX/temp/temp.arg/temp.arg.nontype/p1.cpp deleted file mode 100644 index 58290ac40fdb..000000000000 --- a/test/CXX/temp/temp.arg/temp.arg.nontype/p1.cpp +++ /dev/null @@ -1,203 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -triple=x86_64-linux-gnu %s -// RUN: %clang_cc1 -fsyntax-only -verify -triple=x86_64-linux-gnu -std=c++98 %s -// RUN: %clang_cc1 -fsyntax-only -verify -triple=x86_64-linux-gnu -std=c++11 %s -// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify -triple=x86_64-linux-gnu %s -DCPP11ONLY - -// C++11 [temp.arg.nontype]p1: -// -// A template-argument for a non-type, non-template template-parameter shall -// be one of: -// -- an integral constant expression; or -// -- the name of a non-type template-parameter ; or -#ifndef CPP11ONLY - -namespace non_type_tmpl_param { - template <int N> struct X0 { X0(); }; - template <int N> X0<N>::X0() { } - template <int* N> struct X1 { X1(); }; - template <int* N> X1<N>::X1() { } - template <int& N> struct X3 { X3(); }; - template <int& N> X3<N>::X3() { } - template <int (*F)(int)> struct X4 { X4(); }; - template <int (*F)(int)> X4<F>::X4() { } - template <typename T, int (T::* M)(int)> struct X5 { X5(); }; - template <typename T, int (T::* M)(int)> X5<T, M>::X5() { } -} - -// -- a constant expression that designates the address of an object with -// static storage duration and external or internal linkage or a function -// with external or internal linkage, including function templates and -// function template-ids, but excluting non-static class members, expressed -// (ignoring parentheses) as & id-expression, except that the & may be -// omitted if the name refers to a function or array and shall be omitted -// if the corresopnding template-parameter is a reference; or -namespace addr_of_obj_or_func { - template <int* p> struct X0 { }; // expected-note 5{{here}} -#if __cplusplus >= 201103L - // expected-note@-2 2{{template parameter is declared here}} -#endif - - template <int (*fp)(int)> struct X1 { }; - template <int &p> struct X2 { }; // expected-note 4{{here}} - template <const int &p> struct X2k { }; // expected-note {{here}} - template <int (&fp)(int)> struct X3 { }; // expected-note 4{{here}} - - int i = 42; -#if __cplusplus >= 201103L - // expected-note@-2 {{declared here}} -#endif - - int iarr[10]; - int f(int i); - const int ki = 9; -#if __cplusplus <= 199711L - // expected-note@-2 5{{non-type template argument refers to object here}} -#endif - - __thread int ti = 100; // expected-note {{here}} -#if __cplusplus <= 199711L - // expected-note@-2 {{here}} -#endif - - static int f_internal(int); -#if __cplusplus <= 199711L - // expected-note@-2 4{{non-type template argument refers to function here}} -#endif - - template <typename T> T f_tmpl(T t); - struct S { union { int NonStaticMember; }; }; - - void test() { - X0<i> x0a; -#if __cplusplus <= 199711L - // expected-error@-2 {{non-type template argument for template parameter of pointer type 'int *' must have its address taken}} -#else - // expected-error@-4 {{non-type template argument of type 'int' is not a constant expression}} - // expected-note@-5 {{read of non-const variable 'i' is not allowed in a constant expression}} -#endif - X0<&i> x0a_addr; - X0<iarr> x0b; - X0<&iarr> x0b_addr; // expected-error {{cannot be converted to a value of type 'int *'}} - X0<ki> x0c; // expected-error {{must have its address taken}} -#if __cplusplus <= 199711L - // expected-warning@-2 {{internal linkage is a C++11 extension}} -#endif - - X0<&ki> x0c_addr; // expected-error {{cannot be converted to a value of type 'int *'}} -#if __cplusplus <= 199711L - // expected-warning@-2 {{internal linkage is a C++11 extension}} -#endif - - X0<&ti> x0d_addr; -#if __cplusplus <= 199711L - // expected-error@-2 {{non-type template argument refers to thread-local object}} -#else - // expected-error@-4 {{non-type template argument of type 'int *' is not a constant expression}} -#endif - - X1<f> x1a; - X1<&f> x1a_addr; - X1<f_tmpl> x1b; - X1<&f_tmpl> x1b_addr; - X1<f_tmpl<int> > x1c; - X1<&f_tmpl<int> > x1c_addr; - X1<f_internal> x1d; -#if __cplusplus <= 199711L - // expected-warning@-2 {{internal linkage is a C++11 extension}} -#endif - - X1<&f_internal> x1d_addr; -#if __cplusplus <= 199711L - // expected-warning@-2 {{internal linkage is a C++11 extension}} -#endif - - X2<i> x2a; - X2<&i> x2a_addr; // expected-error {{address taken}} - X2<iarr> x2b; // expected-error {{cannot bind to template argument of type 'int [10]'}} - X2<&iarr> x2b_addr; // expected-error {{address taken}} - X2<ki> x2c; // expected-error {{ignores qualifiers}} -#if __cplusplus <= 199711L - // expected-warning@-2 {{internal linkage is a C++11 extension}} -#endif - - X2k<ki> x2kc; -#if __cplusplus <= 199711L - // expected-warning@-2 {{internal linkage is a C++11 extension}} -#endif - - X2k<&ki> x2kc_addr; // expected-error {{address taken}} -#if __cplusplus <= 199711L - // expected-warning@-2 {{internal linkage is a C++11 extension}} -#endif - - X2<ti> x2d_addr; // expected-error {{refers to thread-local object}} - X3<f> x3a; - X3<&f> x3a_addr; // expected-error {{address taken}} - X3<f_tmpl> x3b; - X3<&f_tmpl> x3b_addr; // expected-error {{address taken}} - X3<f_tmpl<int> > x3c; - X3<&f_tmpl<int> > x3c_addr; // expected-error {{address taken}} - X3<f_internal> x3d; -#if __cplusplus <= 199711L - // expected-warning@-2 {{internal linkage is a C++11 extension}} -#endif - - X3<&f_internal> x3d_addr; // expected-error {{address taken}} -#if __cplusplus <= 199711L - // expected-warning@-2 {{internal linkage is a C++11 extension}} -#endif - - int n; -#if __cplusplus <= 199711L - // expected-note@-2 {{non-type template argument refers to object here}} -#else - // expected-note@-4 {{declared here}} -#endif - - X0<&n> x0_no_linkage; -#if __cplusplus <= 199711L - // expected-error@-2 {{non-type template argument refers to object 'n' that does not have linkage}} -#else - // expected-error@-4 {{non-type template argument of type 'int *' is not a constant expression}} - // expected-note@-5 {{pointer to 'n' is not a constant expression}} -#endif - - struct Local { static int f() {} }; // expected-note {{here}} - X1<&Local::f> x1_no_linkage; // expected-error {{non-type template argument refers to function 'f' that does not have linkage}} - X0<&S::NonStaticMember> x0_non_static; // expected-error {{non-static data member}} - } -} - -// -- a constant expression that evaluates to a null pointer value (4.10); or -// -- a constant expression that evaluates to a null member pointer value -// (4.11); or -// -- a pointer to member expressed as described in 5.3.1. - -namespace bad_args { - template <int* N> struct X0 { }; // expected-note 2{{template parameter is declared here}} - int i = 42; - X0<&i + 2> x0a; // expected-error{{non-type template argument does not refer to any declaration}} - int* iptr = &i; -#if __cplusplus >= 201103L - // expected-note@-2 {{declared here}} -#endif - - X0<iptr> x0b; -#if __cplusplus <= 199711L - // expected-error@-2 {{non-type template argument for template parameter of pointer type 'int *' must have its address taken}} -#else - // expected-error@-4 {{non-type template argument of type 'int *' is not a constant expression}} - // expected-note@-5 {{read of non-constexpr variable 'iptr' is not allowed in a constant expression}} -#endif -} -#endif // CPP11ONLY - -namespace default_args { -#ifdef CPP11ONLY -namespace lambdas { -template<int I = ([] { return 5; }())> //expected-error {{constant expression}} -int f(); -} -#endif // CPP11ONLY - -} diff --git a/test/CXX/temp/temp.arg/temp.arg.nontype/p5.cpp b/test/CXX/temp/temp.arg/temp.arg.nontype/p5.cpp deleted file mode 100644 index 5341290a1446..000000000000 --- a/test/CXX/temp/temp.arg/temp.arg.nontype/p5.cpp +++ /dev/null @@ -1,249 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++14 %s -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++1z %s -// RUN: %clang_cc1 -fsyntax-only -verify %s - -// C++0x [temp.arg.nontype] p5: -// The following conversions are performed on each expression used as -// a non-type template-argument. If a non-type template-argument cannot be -// converted to the type of the corresponding template-parameter then the -// program is ill-formed. -// -- for a non-type template-parameter of integral or enumeration type, -// integral promotions (4.5) and integral conversions (4.7) are applied. -namespace integral_parameters { - template<short s> struct X0 { }; - X0<17> x0i; - X0<'a'> x0c; - template<char c> struct X1 { }; - X1<100l> x1l; -} - -// -- for a non-type template-parameter of type pointer to object, -// qualification conversions (4.4) and the array-to-pointer conversion -// (4.2) are applied; if the template-argument is of type -// std::nullptr_t, the null pointer conversion (4.10) is applied. -namespace pointer_to_object_parameters { - // PR6226 - struct Str { - Str(const char *); - }; - - template<const char *s> - struct A { - Str get() { return s; } - }; - - char hello[6] = "Hello"; - extern const char world[6]; - const char world[6] = "world"; - void test() { - (void)A<hello>().get(); - (void)A<world>().get(); - } - - class X { - public: - X(); - X(int, int); - operator int() const; - }; - - template<X const *Ptr> struct A2; // expected-note 0-1{{template parameter is declared here}} - - X *X_ptr; // expected-note 0-1{{declared here}} - X an_X; - X array_of_Xs[10]; - A2<X_ptr> *a12; -#if __cplusplus < 201103L - // expected-error@-2 {{must have its address taken}} -#else - // expected-error@-4 {{not a constant expression}} expected-note@-4 {{read of non-constexpr variable}} -#endif - A2<array_of_Xs> *a13; - A2<&an_X> *a13_2; - A2<(&an_X)> *a13_3; -#if __cplusplus < 201103L - // expected-warning@-2 {{address non-type template argument cannot be surrounded by parentheses}} -#endif - - // PR6244 - struct X1 {} X1v; - template <X1*> struct X2 { }; - template <X1* Value> struct X3 : X2<Value> { }; - struct X4 : X3<&X1v> { }; - - // PR6563 - int *bar; // expected-note 0-1{{declared here}} - template <int *> struct zed {}; // expected-note 0-2{{template parameter is declared here}} - void g(zed<bar>*); -#if __cplusplus < 201103L - // expected-error@-2 {{must have its address taken}} -#else - // expected-error@-4 {{not a constant expression}} expected-note@-4 {{read of non-constexpr variable}} -#endif - - int baz; // expected-note 0-1{{declared here}} - void g2(zed<baz>*); -#if __cplusplus < 201103L - // expected-error@-2 {{must have its address taken}} -#elif __cplusplus <= 201402L - // expected-error@-4 {{not a constant expression}} expected-note@-4 {{read of non-const variable}} -#else - // expected-error@-6 {{not implicitly convertible to 'int *'}} -#endif - - void g3(zed<&baz>*); // okay -} - -// -- For a non-type template-parameter of type reference to object, no -// conversions apply. The type referred to by the reference may be more -// cv-qualified than the (otherwise identical) type of the -// template-argument. The template-parameter is bound directly to the -// template-argument, which shall be an lvalue. -namespace reference_parameters { - template <int& N> struct S0 { }; // expected-note 0-3{{template parameter is declared here}} - template <const int& N> struct S1 { }; // expected-note 0-2{{template parameter is declared here}} - template <volatile int& N> struct S2 { }; // expected-note 0-2{{template parameter is declared here}} - template <const volatile int& N> struct S3 { }; - int i; - extern const int ci; - volatile int vi; - extern const volatile int cvi; - void test() { - S0<i> s0; - S0<ci> s0c; // expected-error{{type 'const int'}} - S0<vi> s0v; // expected-error{{type 'volatile int'}} - S0<cvi> s0cv; // expected-error{{type 'const volatile int'}} - - S1<i> s1; - S1<ci> s1c; - S1<vi> s1v; // expected-error{{type 'volatile int'}} - S1<cvi> s1cv; // expected-error{{type 'const volatile int'}} - - S2<i> s2; - S2<ci> s2c; // expected-error{{type 'const int'}} - S2<vi> s2v; - S2<cvi> s2cv; // expected-error{{type 'const volatile int'}} - - S3<i> s3; - S3<ci> s3c; - S3<vi> s3v; - S3<cvi> s3cv; - } - - namespace PR6250 { - template <typename T, const T &ref> void inc() { - ref++; // expected-error{{read-only variable is not assignable}} - } - - template<typename T, const T &ref> void bind() { - T &ref2 = ref; // expected-error{{drops 'const' qualifier}} - } - - int counter; - void test() { - inc<int, counter>(); // expected-note{{instantiation of}} - bind<int, counter>(); // expected-note{{instantiation of}} - } - } - - namespace PR6749 { - template <int& i> struct foo {}; // expected-note 0-1{{template parameter is declared here}} - int x, &y = x; - foo<y> f; -#if __cplusplus <= 201402L - // expected-error@-2 {{is not an object}} -#endif - } -} - -// -- For a non-type template-parameter of type pointer to function, the -// function-to-pointer conversion (4.3) is applied; if the -// template-argument is of type std::nullptr_t, the null pointer -// conversion (4.10) is applied. If the template-argument represents -// a set of overloaded functions (or a pointer to such), the matching -// function is selected from the set (13.4). -namespace pointer_to_function { - template<int (*)(int)> struct X0 { }; // expected-note 0-3{{template parameter is declared here}} - int f(int); - int f(float); - int g(float); - int (*funcptr)(int); // expected-note 0-1{{declared here}} - void x0a(X0<f>); - void x0b(X0<&f>); - void x0c(X0<g>); // expected-error-re{{type 'int (float)' {{.*}}convert{{.*}} 'int (*)(int)'}} - void x0d(X0<&g>); // expected-error-re{{type 'int (*)(float)' {{.*}}convert{{.*}} 'int (*)(int)'}} - void x0e(X0<funcptr>); -#if __cplusplus < 201103L - // expected-error@-2 {{must have its address taken}} -#else - // expected-error@-4 {{not a constant expression}} expected-note@-4 {{read of non-constexpr variable}} -#endif -} - -// -- For a non-type template-parameter of type reference to function, no -// conversions apply. If the template-argument represents a set of -// overloaded functions, the matching function is selected from the set -// (13.4). -namespace reference_to_function { - template<int (&)(int)> struct X0 { }; // expected-note 0-4{{template parameter is declared here}} - int f(int); - int f(float); - int g(float); - int (*funcptr)(int); - void x0a(X0<f>); -#if __cplusplus <= 201402L - void x0b(X0<&f>); // expected-error{{address taken in non-type template argument for template parameter of reference type 'int (&)(int)'}} - void x0c(X0<g>); // expected-error{{non-type template parameter of reference type 'int (&)(int)' cannot bind to template argument of type 'int (float)'}} - void x0d(X0<&g>); // expected-error{{address taken in non-type template argument for template parameter of reference type 'int (&)(int)'}} - void x0e(X0<funcptr>); // expected-error{{non-type template parameter of reference type 'int (&)(int)' cannot bind to template argument of type 'int (*)(int)'}} -#else - void x0b(X0<&f>); // expected-error{{value of type '<overloaded function type>' is not implicitly convertible to 'int (&)(int)'}} - void x0c(X0<g>); // expected-error{{value of type 'int (float)' is not implicitly convertible to 'int (&)(int)'}} - void x0d(X0<&g>); // expected-error{{value of type 'int (*)(float)' is not implicitly convertible to 'int (&)(int)'}} - void x0e(X0<funcptr>); // expected-error{{value of type 'int (*)(int)' is not implicitly convertible to 'int (&)(int)'}} -#endif -} -// -- For a non-type template-parameter of type pointer to member function, -// if the template-argument is of type std::nullptr_t, the null member -// pointer conversion (4.11) is applied; otherwise, no conversions -// apply. If the template-argument represents a set of overloaded member -// functions, the matching member function is selected from the set -// (13.4). -namespace pointer_to_member_function { - struct X { }; - struct Y : X { - int f(int); - int g(int); - int g(float); - float h(float); - }; - - template<int (Y::*)(int)> struct X0 {}; // expected-note 0-1{{template parameter is declared here}} - X0<&Y::f> x0a; - X0<&Y::g> x0b; - X0<&Y::h> x0c; // expected-error-re{{type 'float (pointer_to_member_function::Y::*)(float){{( __attribute__\(\(thiscall\)\))?}}' {{.*}} convert{{.*}} 'int (pointer_to_member_function::Y::*)(int){{( __attribute__\(\(thiscall\)\))?}}'}} -} - -// -- For a non-type template-parameter of type pointer to data member, -// qualification conversions (4.4) are applied; if the template-argument -// is of type std::nullptr_t, the null member pointer conversion (4.11) -// is applied. -namespace pointer_to_member_data { - struct X { int x; }; - struct Y : X { int y; }; - - template<int Y::*> struct X0 {}; // expected-note 0-1{{template parameter is declared here}} - X0<&Y::y> x0a; - X0<&Y::x> x0b; -#if __cplusplus <= 201402L - // expected-error@-2 {{non-type template argument of type 'int pointer_to_member_data::X::*' cannot be converted to a value of type 'int pointer_to_member_data::Y::*'}} -#else - // expected-error@-4 {{conversion from 'int pointer_to_member_data::X::*' to 'int pointer_to_member_data::Y::*' is not allowed in a converted constant expression}} -#endif - - // Test qualification conversions - template<const int Y::*> struct X1 {}; - X1<&Y::y> x1a; -} diff --git a/test/CXX/temp/temp.arg/temp.arg.template/p3-0x.cpp b/test/CXX/temp/temp.arg/temp.arg.template/p3-0x.cpp deleted file mode 100644 index 1c13bffa212f..000000000000 --- a/test/CXX/temp/temp.arg/temp.arg.template/p3-0x.cpp +++ /dev/null @@ -1,40 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s - -template <class T> struct eval; // expected-note 3{{template is declared here}} - -template <template <class, class...> class TT, class T1, class... Rest> -struct eval<TT<T1, Rest...>> { }; - -template <class T1> struct A; -template <class T1, class T2> struct B; -template <int N> struct C; -template <class T1, int N> struct D; -template <class T1, class T2, int N = 17> struct E; - -eval<A<int>> eA; -eval<B<int, float>> eB; -eval<C<17>> eC; // expected-error{{implicit instantiation of undefined template 'eval<C<17> >'}} -eval<D<int, 17>> eD; // expected-error{{implicit instantiation of undefined template 'eval<D<int, 17> >'}} -eval<E<int, float>> eE; // expected-error{{implicit instantiation of undefined template 'eval<E<int, float, 17> >}} - -template<template <int ...N> class TT> struct X0 { }; // expected-note{{previous non-type template parameter with type 'int' is here}} -template<int I, int J, int ...Rest> struct X0a; -template<int ...Rest> struct X0b; -template<int I, long J> struct X0c; // expected-note{{template non-type parameter has a different type 'long' in template argument}} - -X0<X0a> inst_x0a; -X0<X0b> inst_x0b; -X0<X0c> inst_x0c; // expected-error{{template template argument has different template parameters than its corresponding template template parameter}} - -template<typename T, - template <T ...N> class TT> // expected-note{{previous non-type template parameter with type 'short' is here}} -struct X1 { }; -template<int I, int J, int ...Rest> struct X1a; -template<long I, long ...Rest> struct X1b; -template<short I, short J> struct X1c; -template<short I, long J> struct X1d; // expected-note{{template non-type parameter has a different type 'long' in template argument}} - -X1<int, X1a> inst_x1a; -X1<long, X1b> inst_x1b; -X1<short, X1c> inst_x1c; -X1<short, X1d> inst_x1d; // expected-error{{template template argument has different template parameters than its corresponding template template paramete}} diff --git a/test/CXX/temp/temp.arg/temp.arg.type/p2-cxx0x.cpp b/test/CXX/temp/temp.arg/temp.arg.type/p2-cxx0x.cpp deleted file mode 100644 index 67f317b01807..000000000000 --- a/test/CXX/temp/temp.arg/temp.arg.type/p2-cxx0x.cpp +++ /dev/null @@ -1,21 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s -// expected-no-diagnostics - -// C++03 imposed restrictions in this paragraph that were lifted with 0x, so we -// just test that the example given now parses cleanly. - -template <class T> class X { }; -template <class T> void f(T t) { } -struct { } unnamed_obj; -void f() { - struct A { }; - enum { e1 }; - typedef struct { } B; - B b; - X<A> x1; - X<A*> x2; - X<B> x3; - f(e1); - f(unnamed_obj); - f(b); -} diff --git a/test/CXX/temp/temp.arg/temp.arg.type/p2.cpp b/test/CXX/temp/temp.arg/temp.arg.type/p2.cpp deleted file mode 100644 index 539baecdb6a5..000000000000 --- a/test/CXX/temp/temp.arg/temp.arg.type/p2.cpp +++ /dev/null @@ -1,82 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s - -template<class T> struct A { - static T t; // expected-error{{static data member instantiated with function type 'int ()'}} -}; -typedef int function(); -A<function> a; // expected-note{{instantiation of}} - -template<typename T> struct B { - B() { T t; } // expected-error{{variable instantiated with function type 'int ()'}} -}; -B<function> b; // expected-note{{instantiation of}} - -template <typename T> int f0(void *, const T&); // expected-note{{candidate template ignored: substitution failure}} -enum {e}; -#if __cplusplus <= 199711L -// expected-note@-2 {{unnamed type used in template argument was declared here}} -#endif - -void test_f0(int n) { - int i = f0(0, e); -#if __cplusplus <= 199711L - // expected-warning@-2 {{template argument uses unnamed type}} -#endif - - int vla[n]; - f0(0, vla); // expected-error{{no matching function for call to 'f0'}} -} - -namespace N0 { - template <typename R, typename A1> void f0(R (*)(A1)); - template <typename T> int f1(T); - template <typename T, typename U> int f1(T, U); - enum {e1}; -#if __cplusplus <= 199711L - // expected-note@-2 2{{unnamed type used in template argument was declared here}} -#endif - - enum {e2}; -#if __cplusplus <= 199711L - // expected-note@-2 2{{unnamed type used in template argument was declared here}} -#endif - - enum {e3}; -#if __cplusplus <= 199711L - // expected-note@-2 {{unnamed type used in template argument was declared here}} -#endif - - template<typename T> struct X; - template<typename T> struct X<T*> { }; - - void f() { - f0( -#if __cplusplus <= 199711L - // expected-warning@-2 {{template argument uses unnamed type}} -#endif - - &f1<__typeof__(e1)>); -#if __cplusplus <= 199711L - // expected-warning@-2 {{template argument uses unnamed type}} -#endif - - int (*fp1)(int, __typeof__(e2)) = f1; -#if __cplusplus <= 199711L - // expected-warning@-2 {{template argument uses unnamed type}} -#endif - - f1(e2); -#if __cplusplus <= 199711L - // expected-warning@-2 {{template argument uses unnamed type}} -#endif - - f1(e2); - - X<__typeof__(e3)*> x; -#if __cplusplus <= 199711L - // expected-warning@-2 {{template argument uses unnamed type}} -#endif - } -} diff --git a/test/CXX/temp/temp.decls/p3.cpp b/test/CXX/temp/temp.decls/p3.cpp deleted file mode 100644 index 41811ff16531..000000000000 --- a/test/CXX/temp/temp.decls/p3.cpp +++ /dev/null @@ -1,7 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s - -template<typename T> using A = int; -template<typename T> using A<T*> = char; // expected-error {{partial specialization of alias templates is not permitted}} -template<> using A<char> = char; // expected-error {{explicit specialization of alias templates is not permitted}} -template using A<char> = char; // expected-error {{explicit instantiation of alias templates is not permitted}} -using A<char> = char; // expected-error {{name defined in alias declaration must be an identifier}} diff --git a/test/CXX/temp/temp.decls/temp.alias/p1.cpp b/test/CXX/temp/temp.decls/temp.alias/p1.cpp deleted file mode 100644 index aafe4808bb18..000000000000 --- a/test/CXX/temp/temp.decls/temp.alias/p1.cpp +++ /dev/null @@ -1,9 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s -// expected-no-diagnostics - -template<typename T> using U = T; - -// The name of the alias template is a template-name. -U<char> x; -void f(U<int>); -typedef U<U<U<U<int>>>> I; diff --git a/test/CXX/temp/temp.decls/temp.alias/p2.cpp b/test/CXX/temp/temp.decls/temp.alias/p2.cpp deleted file mode 100644 index a5b39fe5c51f..000000000000 --- a/test/CXX/temp/temp.decls/temp.alias/p2.cpp +++ /dev/null @@ -1,45 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s - -template<typename T> using U = T; - -using I = U<U<U<U<int>>>>; -using I = int; - -template<typename A, typename B> using Fst = A; -template<typename A, typename B> using Snd = B; - -using I = Fst<Snd<char,int>,double>; - -namespace StdExample { - // Prerequisites for example. - template<class T, class A> struct vector { /* ... */ }; - - - template<class T> struct Alloc {}; - template<class T> using Vec = vector<T, Alloc<T>>; - Vec<int> v; - - template<class T> - void process(Vec<T>& v) // expected-note {{previous definition is here}} - { /* ... */ } - - template<class T> - void process(vector<T, Alloc<T>>& w) // expected-error {{redefinition of 'process'}} - { /* ... */ } - - template<template<class> class TT> - void f(TT<int>); // expected-note {{candidate template ignored}} - - template<template<class,class> class TT> - void g(TT<int, Alloc<int>>); - - int h() { - f(v); // expected-error {{no matching function for call to 'f'}} - g(v); // OK: TT = vector - } - - - // v's type is same as vector<int, Alloc<int>>. - using VTest = vector<int, Alloc<int>>; - using VTest = decltype(v); -} diff --git a/test/CXX/temp/temp.decls/temp.alias/p3.cpp b/test/CXX/temp/temp.decls/temp.alias/p3.cpp deleted file mode 100644 index 2d46502e1d9b..000000000000 --- a/test/CXX/temp/temp.decls/temp.alias/p3.cpp +++ /dev/null @@ -1,17 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s - -// The example given in the standard (this is rejected for other reasons anyway). -template<class T> struct A; -template<class T> using B = typename A<T>::U; // expected-error {{no type named 'U' in 'A<T>'}} -template<class T> struct A { - typedef B<T> U; // expected-note {{in instantiation of template type alias 'B' requested here}} -}; -B<short> b; - -template<typename T> using U = int; - -template<typename ...T> void f(U<T> ...xs); -void g() { f<void,void,void>(1, 2, 3); } - -// FIXME: This is illegal, but probably only because CWG1044 missed this paragraph. -template<typename T> using U = U<T>; diff --git a/test/CXX/temp/temp.decls/temp.class.spec/p6.cpp b/test/CXX/temp/temp.decls/temp.class.spec/p6.cpp deleted file mode 100644 index d0fc797f5002..000000000000 --- a/test/CXX/temp/temp.decls/temp.class.spec/p6.cpp +++ /dev/null @@ -1,76 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s - -// Test class template partial specializations of member templates. -template<typename T> -struct X0 { - template<typename U> struct Inner0 { - static const unsigned value = 0; - }; - - template<typename U> struct Inner0<U*> { - static const unsigned value = 1; - }; -}; - -template<typename T> template<typename U> -struct X0<T>::Inner0<const U*> { - static const unsigned value = 2; -}; - -int array0[X0<int>::Inner0<int>::value == 0? 1 : -1]; -int array1[X0<int>::Inner0<int*>::value == 1? 1 : -1]; -int array2[X0<int>::Inner0<const int*>::value == 2? 1 : -1]; - -// Make sure we can provide out-of-line class template partial specializations -// for member templates (and instantiate them). -template<class T> struct A { - struct C { - template<class T2> struct B; - }; -}; - -// partial specialization of A<T>::C::B<T2> -template<class T> template<class T2> struct A<T>::C::B<T2*> { }; - -A<short>::C::B<int*> absip; - -// Check for conflicts during template instantiation. -template<typename T, typename U> -struct Outer { - template<typename X, typename Y> struct Inner; - template<typename Y> struct Inner<T, Y> {}; // expected-note{{previous}} - template<typename Y> struct Inner<U, Y> {}; // expected-error{{cannot be redeclared}} -}; - -Outer<int, int> outer; // expected-note{{instantiation}} - -// Test specialization of class template partial specialization members. -template<> template<typename Z> -struct X0<float>::Inner0<Z*> { - static const unsigned value = 3; -}; - -int array3[X0<float>::Inner0<int>::value == 0? 1 : -1]; -int array4[X0<float>::Inner0<int*>::value == 3? 1 : -1]; -int array5[X0<float>::Inner0<const int*>::value == 2? 1 : -1]; - -namespace rdar8651930 { - template<typename OuterT> - struct Outer { - template<typename T, typename U> - struct Inner; - - template<typename T> - struct Inner<T, T> { - static const bool value = true; - }; - - template<typename T, typename U> - struct Inner { - static const bool value = false; - }; - }; - - int array0[Outer<int>::Inner<int, int>::value? 1 : -1]; - int array1[Outer<int>::Inner<int, float>::value? -1 : 1]; -} diff --git a/test/CXX/temp/temp.decls/temp.class.spec/p8-0x.cpp b/test/CXX/temp/temp.decls/temp.class.spec/p8-0x.cpp deleted file mode 100644 index 52fbd9457422..000000000000 --- a/test/CXX/temp/temp.decls/temp.class.spec/p8-0x.cpp +++ /dev/null @@ -1,11 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s - -template<int ...Values> struct X1; - -template<int ...Values> // expected-note {{non-deducible}} -struct X1<0, Values+1 ...>; // expected-error{{contains a template parameter that cannot be deduced}} - -template<typename T, int ...Values> struct X2; // expected-note {{here}} -template<int ...Values> struct X2<X1<Values...>, Values+1 ...> {}; // ok (DR1315) -X2<X1<1, 2, 3>, 2, 3, 4> x2; // ok -X2<X1<1, 2, 3>, 2, 3, 4, 5> x3; // expected-error {{undefined template}} diff --git a/test/CXX/temp/temp.decls/temp.class.spec/p8-1y.cpp b/test/CXX/temp/temp.decls/temp.class.spec/p8-1y.cpp deleted file mode 100644 index 388a80ee765c..000000000000 --- a/test/CXX/temp/temp.decls/temp.class.spec/p8-1y.cpp +++ /dev/null @@ -1,36 +0,0 @@ -// RUN: %clang_cc1 -std=c++1y -fsyntax-only -verify %s - -// -- The argument list of the specialization shall not be identical -// to the implicit argument list of the primary template. - -template<typename T, int N, template<typename> class X> int v1; -template<typename T, int N, template<typename> class X> int v1<T, N, X>; -// expected-error@-1{{variable template partial specialization does not specialize any template argument; to define the primary template, remove the template argument list}} - -template<typename...T> int v2; -template<typename...T> int v2<T...>; -// expected-error@-1{{variable template partial specialization does not specialize any template argument; to define the primary template, remove the template argument list}} - -template<int...N> int v3; -template<int...N> int v3<N...>; -// expected-error@-1{{variable template partial specialization does not specialize any template argument; to define the primary template, remove the template argument list}} - -template<template<typename> class...X> int v4; -template<template<typename> class...X> int v4<X...>; -// expected-error@-1{{variable template partial specialization does not specialize any template argument; to define the primary template, remove the template argument list}} - -template<typename Outer> struct X { - template<typename Inner> static int y; - // FIXME: It would be preferable to only diagnose this once. - template<typename Inner> static int y<Outer>; // expected-error 3{{cannot be deduced}} expected-note 3{{'Inner'}} - template<typename Inner> static int y<Inner>; // expected-error {{does not specialize}} - - template<typename, int> static int z; - template<Outer N> static int z<int, N>; // expected-error {{not implicitly convertible}} -}; -template<typename Outer> template<typename Inner> int X<Outer>::y<Outer>; // expected-error {{cannot be deduced}} expected-note {{'Inner'}} -template<typename Outer> template<typename Inner> int X<Outer>::y<Inner>; // expected-error {{does not specialize}} -template<> template<typename Inner> int X<int>::y<Inner>; // expected-error {{does not specialize}} expected-note {{instantiation of}} - -X<int> xi; -X<int*> xf; // expected-note {{instantiation of}} diff --git a/test/CXX/temp/temp.decls/temp.class.spec/p9-0x.cpp b/test/CXX/temp/temp.decls/temp.class.spec/p9-0x.cpp deleted file mode 100644 index b754368600aa..000000000000 --- a/test/CXX/temp/temp.decls/temp.class.spec/p9-0x.cpp +++ /dev/null @@ -1,13 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s - -// -- The argument list of the specialization shall not be identical -// to the implicit argument list of the primary template. - -template<typename T, typename ...Types> -struct X1; - -template<typename T, typename ...Types> -struct X1<T, Types...> // expected-error{{class template partial specialization does not specialize any template argument; to define the primary template, remove the template argument list}} -{ }; - - diff --git a/test/CXX/temp/temp.decls/temp.class.spec/p9.cpp b/test/CXX/temp/temp.decls/temp.class.spec/p9.cpp deleted file mode 100644 index df0e68d29b6f..000000000000 --- a/test/CXX/temp/temp.decls/temp.class.spec/p9.cpp +++ /dev/null @@ -1,27 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -// expected-no-diagnostics - -// PR8905 -template<char C1, char C2> -struct X { - static const bool value = 0; -}; - -template<int C1> -struct X<C1, C1> { - static const bool value = 1; -}; - -int check0[X<1, 2>::value == 0? 1 : -1]; -int check1[X<1, 1>::value == 1? 1 : -1]; - -template<int, int, int> struct int_values { - static const unsigned value = 0; -}; - -template<unsigned char C1, unsigned char C3> -struct int_values<C1, 12, C3> { - static const unsigned value = 1; -}; - -int check2[int_values<256, 12, 3>::value == 0? 1 : -1]; diff --git a/test/CXX/temp/temp.decls/temp.class.spec/temp.class.order/p2.cpp b/test/CXX/temp/temp.decls/temp.class.spec/temp.class.order/p2.cpp deleted file mode 100644 index 64cc5923f008..000000000000 --- a/test/CXX/temp/temp.decls/temp.class.spec/temp.class.order/p2.cpp +++ /dev/null @@ -1,49 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -// expected-no-diagnostics -template<int I, int J, class T> struct X { - static const int value = 0; -}; - -template<int I, int J> struct X<I, J, int> { - static const int value = 1; -}; - -template<int I> struct X<I, I, int> { - static const int value = 2; -}; - -int array0[X<0, 0, float>::value == 0? 1 : -1]; -int array1[X<0, 1, int>::value == 1? 1 : -1]; -int array2[X<0, 0, int>::value == 2? 1 : -1]; - -namespace DependentSubstPartialOrdering { - template<typename T, typename U = void, typename V = void> - struct X { - static const unsigned value = 1; - }; - - template<typename T, typename U> - struct X<T, U, typename T::is_b> { - static const unsigned value = 2; - }; - - template<typename T> - struct X<T, typename T::is_a, typename T::is_b> { - static const unsigned value = 3; - }; - - struct X1 { }; - - struct X2 { - typedef void is_b; - }; - - struct X3 { - typedef void is_a; - typedef void is_b; - }; - - int check_X1[X<X1, void, void>::value == 1? 1 : -1]; - int check_X2[X<X2, void, void>::value == 2? 1 : -1]; - int check_X3[X<X3, void, void>::value == 3? 1 : -1]; -} diff --git a/test/CXX/temp/temp.decls/temp.class.spec/temp.class.spec.mfunc/p1-neg.cpp b/test/CXX/temp/temp.decls/temp.class.spec/temp.class.spec.mfunc/p1-neg.cpp deleted file mode 100644 index 59253db3c529..000000000000 --- a/test/CXX/temp/temp.decls/temp.class.spec/temp.class.spec.mfunc/p1-neg.cpp +++ /dev/null @@ -1,25 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s - -template<typename T, int N> -struct A; - -template<typename T> // expected-note{{previous template declaration}} -struct A<T*, 2> { - void f0(); - void f1(); - void f2(); -}; - -template<> -struct A<int, 1> { - void g0(); -}; - -// FIXME: We should probably give more precise diagnostics here, but the -// diagnostics we give aren't terrible. -// FIXME: why not point to the first parameter that's "too many"? -template<typename T, int N> // expected-error{{too many template parameters}} -void A<T*, 2>::f0() { } - -template<typename T, int N> -void A<T, N>::f1() { } // expected-error{{out-of-line definition}} diff --git a/test/CXX/temp/temp.decls/temp.class.spec/temp.class.spec.mfunc/p1.cpp b/test/CXX/temp/temp.decls/temp.class.spec/temp.class.spec.mfunc/p1.cpp deleted file mode 100644 index 184160ac78d1..000000000000 --- a/test/CXX/temp/temp.decls/temp.class.spec/temp.class.spec.mfunc/p1.cpp +++ /dev/null @@ -1,26 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -// expected-no-diagnostics -template<typename T, int N> -struct A; - -template<typename T> -struct A<T*, 2> { - A(T); - ~A(); - - void f(T*); - - operator T*(); - - static T value; -}; - -template<class X> void A<X*, 2>::f(X*) { } - -template<class X> X A<X*, 2>::value; - -template<class X> A<X*, 2>::A(X) { value = 0; } - -template<class X> A<X*, 2>::~A() { } - -template<class X> A<X*, 2>::operator X*() { return 0; } diff --git a/test/CXX/temp/temp.decls/temp.class/temp.mem.class/p1.cpp b/test/CXX/temp/temp.decls/temp.class/temp.mem.class/p1.cpp deleted file mode 100644 index b65e1d0194b6..000000000000 --- a/test/CXX/temp/temp.decls/temp.class/temp.mem.class/p1.cpp +++ /dev/null @@ -1,27 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s - -template<typename T, typename U> -struct X0 { - struct Inner; -}; - -template<typename T, typename U> -struct X0<T, U>::Inner { - T x; - U y; - - void f() { x = y; } // expected-error{{incompatible}} -}; - - -void test(int i, float f) { - X0<int, float>::Inner inner; - inner.x = 5; - inner.y = 3.4; - inner.f(); - - X0<int*, float *>::Inner inner2; - inner2.x = &i; - inner2.y = &f; - inner2.f(); // expected-note{{instantiation}} -} diff --git a/test/CXX/temp/temp.decls/temp.class/temp.mem.enum/p1.cpp b/test/CXX/temp/temp.decls/temp.class/temp.mem.enum/p1.cpp deleted file mode 100644 index 2884be146c7c..000000000000 --- a/test/CXX/temp/temp.decls/temp.class/temp.mem.enum/p1.cpp +++ /dev/null @@ -1,152 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -verify %s - -template<typename T> struct A { - enum E : T; // expected-note {{here}} - E v; - E f() { return A::e1; } // expected-error {{no member named 'e1' in 'A<T>'}} - E g() { return E::e1; } - E h(); -}; - -A<int> a; -A<int>::E a0 = A<int>().v; -int n = A<int>::E::e1; // expected-error {{implicit instantiation of undefined member}} - -template<typename T> enum A<T>::E : T { e1, e2 }; // expected-note 2 {{declared here}} - -// FIXME: Now that A<T>::E is defined, we are supposed to inject its enumerators -// into the already-instantiated class A<T>. This seems like a really bad idea, -// though, so we don't implement that, but what we do implement is inconsistent. -// -// Either do as the standard says, or only include enumerators lexically defined -// within the class in its scope. -A<int>::E a1 = A<int>::e1; // expected-error {{no member named 'e1' in 'A<int>'; did you mean simply 'e1'?}} - -A<char>::E a2 = A<char>::e2; - -template<typename T> typename A<T>::E A<T>::h() { return e2; } -A<short>::E a3 = A<short>().h(); - - -template<typename T> struct B { - enum class E; - E v; - E f() { return E::e1; } - E g(); -}; - -B<int> b; -B<int>::E b0 = B<int>().v; - -template<typename T> enum class B<T>::E { e1, e2 }; -B<int>::E b1 = B<int>::E::e1; - -B<char>::E b2 = B<char>::E::e2; - -template<typename T> typename B<T>::E B<T>::g() { return e2; } -B<short>::E b3 = B<short>().g(); - - -// Enumeration members of class templates can be explicitly specialized. For -// unscoped enumerations, specializations must be defined before the primary -// template is, since otherwise the primary template will be implicitly -// instantiated when we parse the nested name specifier. -template<> enum A<long long>::E : long long { e3, e4 }; // expected-error {{explicit specialization of 'E' after instantiation}} expected-note {{first required here}} - -template<> enum class B<long long>::E { e3, e4 }; -B<long long>::E b4 = B<long long>::E::e4; - -B<long>::E b5; -template<> enum class B<long>::E { e5 }; -void fb5() { b5 = decltype(b5)::e5; } -B<long>::E b6 = B<long>::E::e5; - - -template<typename T> struct C { - enum class E : T; -}; - -template<> enum class C<long long>::E : long long { e3, e4 }; -C<long long>::E c0 = C<long long>::E::e3; - -C<long>::E c1; -template<> enum class C<long>::E : long { e5 }; -void fc1() { c1 = decltype(c1)::e5; } -C<long>::E c2 = C<long>::E::e5; - -template<> enum class C<int>::E : int { e6 }; -template<typename T> enum class C<T>::E : T { e0 }; -C<int>::E c3 = C<int>::E::e6; -C<int>::E c4 = C<int>::E::e0; // expected-error {{no member named 'e0' in 'C<int>::E'}} - - -// Enumeration members can't be partially-specialized. -template<typename T> enum class B<T*>::E { e5, e6 }; // expected-error {{nested name specifier for a declaration cannot depend on a template parameter}} - - -// Explicit specializations can be forward-declared. -template<typename T> -struct D { - enum class E { e1 }; -}; -template<> enum class D<int>::E; -D<int>::E d1 = D<int>::E::e1; // expected-error {{incomplete type 'D<int>::E'}} -template<> enum class D<int>::E { e2 }; -D<int>::E d2 = D<int>::E::e2; -D<char>::E d3 = D<char>::E::e1; // expected-note {{first required here}} -D<char>::E d4 = D<char>::E::e2; // expected-error {{no member named 'e2' in 'D<char>::E'; did you mean simply 'e2'?}} -template<> enum class D<char>::E { e3 }; // expected-error {{explicit specialization of 'E' after instantiation}} - -template<> enum class D<short>::E; -struct F { - // Per C++11 [class.friend]p3, these friend declarations have no effect. - // Only classes and functions can be friends. - template<typename T> friend enum D<T>::E; - template<> friend enum D<short>::E; - - template<> friend enum D<double>::E { e3 }; // expected-error {{cannot define a type in a friend declaration}} - -private: - static const int n = 1; // expected-note {{private here}} -}; -template<> enum class D<short>::E { - e = F::n // expected-error {{private member}} -}; - -class Access { - friend class X; - - template<typename T> - class Priv { - friend class X; - - enum class E : T; - }; - - class S { - typedef int N; // expected-note {{here}} - static const int k = 3; // expected-note {{here}} - - friend class Priv<char>; - }; - - static const int k = 5; -}; - -template<> enum class Access::Priv<Access::S::N>::E - : Access::S::N { // expected-error {{private member}} - a = Access::k, // ok - b = Access::S::k // expected-error {{private member}} -}; - -template<typename T> enum class Access::Priv<T>::E : T { - c = Access::k, - d = Access::S::k -}; - -class X { - Access::Priv<int>::E a = Access::Priv<int>::E::a; - Access::Priv<char>::E c = Access::Priv<char>::E::d; - // FIXME: We should see an access error for this enumerator. - Access::Priv<short>::E b = Access::Priv<short>::E::d; -}; diff --git a/test/CXX/temp/temp.decls/temp.class/temp.mem.func/p1-retmem.cpp b/test/CXX/temp/temp.decls/temp.class/temp.mem.func/p1-retmem.cpp deleted file mode 100644 index 213f0c60d5b3..000000000000 --- a/test/CXX/temp/temp.decls/temp.class/temp.mem.func/p1-retmem.cpp +++ /dev/null @@ -1,29 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -// expected-no-diagnostics - -template<typename T> struct X1 { }; - -template<typename T> -struct X0 { - typedef int size_type; - typedef T value_type; - - size_type f0() const; - value_type *f1(); - X1<value_type*> f2(); -}; - -template<typename T> -typename X0<T>::size_type X0<T>::f0() const { - return 0; -} - -template<typename U> -typename X0<U>::value_type *X0<U>::f1() { - return 0; -}; - -template<typename U> -X1<typename X0<U>::value_type*> X0<U>::f2() { - return 0; -}; diff --git a/test/CXX/temp/temp.decls/temp.class/temp.mem.func/p1.cpp b/test/CXX/temp/temp.decls/temp.class/temp.mem.func/p1.cpp deleted file mode 100644 index 17645639fb82..000000000000 --- a/test/CXX/temp/temp.decls/temp.class/temp.mem.func/p1.cpp +++ /dev/null @@ -1,100 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -template<typename T, typename U> // expected-note{{previous template}} -class X0 { -public: - typedef int size_type; - - X0(int); - ~X0(); - - void f0(const T&, const U&); - - T& operator[](int i) const; - - void f1(size_type) const; - void f2(size_type) const; - void f3(size_type) const; - void f4() ; - - operator T*() const; - - T value; -}; - -template<typename T, typename U> -void X0<T, U>::f0(const T&, const U&) { // expected-note{{previous definition}} -} - -template<class X, class Y> -X& X0<X, Y>::operator[](int i) const { - (void)i; - return value; -} - -template<class X, class Y> -void X0<X, Y>::f1(int) const { } - -template<class X, class Y> -void X0<X, Y>::f2(size_type) const { } - -template<class X, class Y, class Z> // expected-error{{too many template parameters}} -void X0<X, Y>::f3(size_type) const { -} - -template<class X, class Y> -void X0<Y, X>::f4() { } // expected-error{{does not refer}} - -// FIXME: error message should probably say, "redefinition of 'X0<T, U>::f0'" -// rather than just "redefinition of 'f0'" -template<typename T, typename U> -void X0<T, U>::f0(const T&, const U&) { // expected-error{{redefinition}} -} - -// Test out-of-line constructors, destructors -template<typename T, typename U> -X0<T, U>::X0(int x) : value(x) { } - -template<typename T, typename U> -X0<T, U>::~X0() { } - -// Test out-of-line conversion functions. -template<typename T, typename U> -X0<T, U>::operator T*() const { - return &value; -} - -namespace N { template <class X> class A {void a();}; } -namespace N { template <class X> void A<X>::a() {} } - -// PR5566 -template<typename T> -struct X1 { - template<typename U> - struct B { void f(); }; -}; - -template<typename T> -template<typename U> -void X1<T>::template B<U>::f() { } - -// PR5527 -template <template <class> class T> -class X2 { - template <class F> - class Bar { - void Func(); - }; -}; - -template <template <class> class T> -template <class F> -void X2<T>::Bar<F>::Func() {} - -// PR5528 -template <template <class> class T> -class X3 { - void F(); -}; - -template <template <class> class T> -void X3<T>::F() {} diff --git a/test/CXX/temp/temp.decls/temp.class/temp.mem.func/p1inst.cpp b/test/CXX/temp/temp.decls/temp.class/temp.mem.func/p1inst.cpp deleted file mode 100644 index eb11e3375e5f..000000000000 --- a/test/CXX/temp/temp.decls/temp.class/temp.mem.func/p1inst.cpp +++ /dev/null @@ -1,17 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -// Test instantiation of member functions of class templates defined out-of-line -template<typename T, typename U> -struct X0 { - void f(T *t, const U &u); - void f(T *); -}; - -template<typename T, typename U> -void X0<T, U>::f(T *t, const U &u) { - *t = u; // expected-warning{{indirection on operand of type 'void *'}} expected-error{{not assignable}} -} - -void test_f(X0<float, int> xfi, X0<void, int> xvi, float *fp, void *vp, int i) { - xfi.f(fp, i); - xvi.f(vp, i); // expected-note{{instantiation}} -} diff --git a/test/CXX/temp/temp.decls/temp.class/temp.mem.func/pr5056.cpp b/test/CXX/temp/temp.decls/temp.class/temp.mem.func/pr5056.cpp deleted file mode 100644 index fcbb724a7af0..000000000000 --- a/test/CXX/temp/temp.decls/temp.class/temp.mem.func/pr5056.cpp +++ /dev/null @@ -1,18 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -// expected-no-diagnostics - -extern "C" void * malloc(int); - -template <typename T> struct A { - void *malloc(int); -}; - -template <typename T> -inline void *A<T>::malloc(int) -{ - return 0; -} - -void f() { - malloc(10); -} diff --git a/test/CXX/temp/temp.decls/temp.class/temp.static/p1-inst.cpp b/test/CXX/temp/temp.decls/temp.class/temp.static/p1-inst.cpp deleted file mode 100644 index 86b2690860c4..000000000000 --- a/test/CXX/temp/temp.decls/temp.class/temp.static/p1-inst.cpp +++ /dev/null @@ -1,33 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s - -// Test instantiation of static data members declared out-of-line. - -template<typename T> -struct X { - static T value; -}; - -template<typename T> - T X<T>::value = 17; // expected-error{{no viable conversion}} - -struct InitOkay { - InitOkay(int) { } -}; - -struct CannotInit { }; // expected-note{{candidate constructor (the implicit copy constructor) not viable}} -#if __cplusplus >= 201103L // C++11 or later -// expected-note@-2 {{candidate constructor (the implicit move constructor) not viable}} -#endif - -int &returnInt() { return X<int>::value; } -float &returnFloat() { return X<float>::value; } - -InitOkay &returnInitOkay() { return X<InitOkay>::value; } - -unsigned long sizeOkay() { return sizeof(X<CannotInit>::value); } - -CannotInit &returnError() { - return X<CannotInit>::value; // expected-note{{instantiation}} -} diff --git a/test/CXX/temp/temp.decls/temp.class/temp.static/p1.cpp b/test/CXX/temp/temp.decls/temp.class/temp.static/p1.cpp deleted file mode 100644 index 332357bb36a8..000000000000 --- a/test/CXX/temp/temp.decls/temp.class/temp.static/p1.cpp +++ /dev/null @@ -1,31 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s - -template<typename T> -struct X0 { - static T value; -}; - -template<typename T> -T X0<T>::value = 0; // expected-error{{no viable conversion}} - -struct X1 { - X1(int); -}; - -struct X2 { }; // expected-note{{candidate constructor (the implicit copy constructor) not viable}} -#if __cplusplus >= 201103L // C++11 or later -// expected-note@-2 {{candidate constructor (the implicit move constructor) not viable}} -#endif - -int& get_int() { return X0<int>::value; } -X1& get_X1() { return X0<X1>::value; } - -double*& get_double_ptr() { return X0<int*>::value; } // expected-error{{non-const lvalue reference to type 'double *' cannot bind to a value of unrelated type 'int *'}} - -X2& get_X2() { - return X0<X2>::value; // expected-note{{instantiation}} -} - -template<typename T> T x; // expected-warning 0-1{{variable templates are a C++14 extension}} diff --git a/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p3.cpp b/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p3.cpp deleted file mode 100644 index db3952a388c2..000000000000 --- a/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p3.cpp +++ /dev/null @@ -1,39 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s -// expected-no-diagnostics - -namespace OrderWithStaticMember { - struct A { - template<class T> int g(T**, int=0) { return 0; } - template<class T> static int g(T*) { return 1; } - }; - void f() { - A a; - int **p; - a.g(p); - } -} - -#if __cplusplus >= 201103L -namespace OperatorWithRefQualifier { - struct A { }; - template<class T> struct B { - template<class R> int &operator*(R&) &&; - }; - - template<class T, class R> float &operator*(T&&, R&); - void test() { - A a; - B<A> b; - float &ir = b * a; - int &ir2 = B<A>() * a; - } -} - -namespace PR17075 { - template <typename T> struct V {}; - struct S { template<typename T> S &operator>>(T &t) = delete; }; - template<typename T> S &operator>>(S &s, V<T> &v); - void f(S s, V<int> v) { s >> v; } -} -#endif diff --git a/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p4.cpp b/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p4.cpp deleted file mode 100644 index 9b3088f20e94..000000000000 --- a/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p4.cpp +++ /dev/null @@ -1,44 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s - -template<class T> struct A { A(); }; -template<class T> int &f(T); -template<class T> float &f(T*); -template<class T> double &f(const T*); - -template<class T> void g(T); // expected-note{{candidate}} -template<class T> void g(T&); // expected-note{{candidate}} - -template<class T> int &h(const T&); -template<class T> float &h(A<T>&); - -void m() { - const int *p; - double &dr1 = f(p); - float x; - g(x); // expected-error{{ambiguous}} - A<int> z; - float &fr1 = h(z); - const A<int> z2; - int &ir1 = h(z2); -} - - -namespace core_26909 { - template<typename T> struct A {}; - template<typename T, typename U> void f(T&, U); // expected-note {{candidate}} - template<typename T, typename U> void f(T&&, A<U>); // expected-note {{candidate}} expected-warning 0-1{{extension}} - template<typename T, typename U> void g(const T&, U); // expected-note {{candidate}} - template<typename T, typename U> void g(T&, A<U>); // expected-note {{candidate}} - - void h(int a, const char b, A<int> c) { - f(a, c); // expected-error{{ambiguous}} - g(b, c); // expected-error{{ambiguous}} - } -} - -namespace PR22435 { - template<typename T, typename U> void foo(void (*)(T), const U &); // expected-note {{candidate}} - template<typename T, typename U> bool foo(void (*)(T &), U &); // expected-note {{candidate}} - void bar(const int x) { bool b = foo<char>(0, x); } // expected-error {{ambiguous}} -} diff --git a/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p5.cpp b/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p5.cpp deleted file mode 100644 index 5f2dbb6018ce..000000000000 --- a/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p5.cpp +++ /dev/null @@ -1,13 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -// expected-no-diagnostics -template<class T> int &f(T); -template<class T> float &f(T*, int=1); - -template<class T> int &g(T); -template<class T> float &g(T*, ...); - -int main() { - int* ip; - float &fr1 = f(ip); - float &fr2 = g(ip); -} diff --git a/test/CXX/temp/temp.decls/temp.fct/temp.over.link/p4-neg.cpp b/test/CXX/temp/temp.decls/temp.fct/temp.over.link/p4-neg.cpp deleted file mode 100644 index e9a3eaa79d67..000000000000 --- a/test/CXX/temp/temp.decls/temp.fct/temp.over.link/p4-neg.cpp +++ /dev/null @@ -1,27 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s - -template<typename T> void f0(T) { } // expected-note{{previous}} -template<class U> void f0(U) { } // expected-error{{redefinition}} - -template<int I> void f0() { } // expected-note{{previous}} -template<int> void f0() { } // expected-error{{redefinition}} - -typedef int INT; - -template<template<class T, T Value1, INT> class X> - void f0() { } // expected-note{{previous}} -template<template<typename T, T Value1, int> class> - void f0() { } // expected-error{{redefinition}} - -template<typename T> -struct MetaFun; - -template<typename T> - typename MetaFun<T*>::type f0(const T&) { while (1) {} } // expected-note{{previous}} -template<class U> - typename MetaFun<U*>::type f0(const U&) { while (1) {} } // expected-error{{redefinition}} - -// FIXME: We need canonicalization of expressions for this to work -// template<int> struct A { }; -// template<int I> void f0(A<I>) { } // Xpected-note{{previous}} -// template<int J> void f0(A<J>) { } // Xpected-error{{redefinition}} diff --git a/test/CXX/temp/temp.decls/temp.fct/temp.over.link/p4.cpp b/test/CXX/temp/temp.decls/temp.fct/temp.over.link/p4.cpp deleted file mode 100644 index d24a3fb71d5d..000000000000 --- a/test/CXX/temp/temp.decls/temp.fct/temp.over.link/p4.cpp +++ /dev/null @@ -1,14 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -// expected-no-diagnostics - -// All of these function templates are distinct. -template<typename T> void f0(T) { } -template<typename T, typename U> void f0(T) { } -template<typename T, typename U> void f0(U) { } -void f0(); -template<typename T> void f0(T*); -void f0(int); -template<int I> void f0(); -template<typename T> void f0(); - - diff --git a/test/CXX/temp/temp.decls/temp.fct/temp.over.link/p6.cpp b/test/CXX/temp/temp.decls/temp.fct/temp.over.link/p6.cpp deleted file mode 100644 index a668adafcaf5..000000000000 --- a/test/CXX/temp/temp.decls/temp.fct/temp.over.link/p6.cpp +++ /dev/null @@ -1,16 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s - -template<int N, int M> -struct A0 { - void g0(); -}; - -template<int X, int Y> void f0(A0<X, Y>) { } // expected-note{{previous}} -template<int N, int M> void f0(A0<M, N>) { } -template<int V1, int V2> void f0(A0<V1, V2>) { } // expected-error{{redefinition}} - -template<int X, int Y> void f1(A0<0, (X + Y)>) { } // expected-note{{previous}} -template<int X, int Y> void f1(A0<0, (X - Y)>) { } -template<int A, int B> void f1(A0<0, (A + B)>) { } // expected-error{{redefinition}} - -template<int X, int Y> void A0<X, Y>::g0() { } diff --git a/test/CXX/temp/temp.decls/temp.friend/p1.cpp b/test/CXX/temp/temp.decls/temp.friend/p1.cpp deleted file mode 100644 index 849728a448bd..000000000000 --- a/test/CXX/temp/temp.decls/temp.friend/p1.cpp +++ /dev/null @@ -1,389 +0,0 @@ -// RUN: %clang_cc1 -verify -emit-llvm-only %s - -namespace test0 { -template <typename T> struct Num { - T value_; - -public: - Num(T value) : value_(value) {} - T get() const { return value_; } - - template <typename U> struct Rep { - U count_; - Rep(U count) : count_(count) {} - - friend Num operator*(const Num &a, const Rep &n) { - Num x = 0; - for (U count = n.count_; count; --count) - x += a; - return x; - } - }; - - friend Num operator+(const Num &a, const Num &b) { - return a.value_ + b.value_; - } - - Num& operator+=(const Num& b) { - value_ += b.value_; - return *this; - } - - class Representation {}; - friend class Representation; -}; - -class A { - template <typename T> friend bool iszero(const A &a) throw(); -}; - -template <class T> class B_iterator; -template <class T> class B { - friend class B_iterator<T>; -}; - -int calc1() { - Num<int> left = -1; - Num<int> right = 1; - Num<int> result = left + right; - return result.get(); -} - -int calc2() { - Num<int> x = 3; - Num<int>::Rep<char> n = (char) 10; - Num<int> result = x * n; - return result.get(); -} -} - -// Reduced from GNU <locale> -namespace test1 { - class A { - bool b; // expected-note {{declared private here}} - template <typename T> friend bool has(const A&); - }; - template <typename T> bool has(const A &x) { - return x.b; - } - template <typename T> bool hasnot(const A &x) { - return x.b; // expected-error {{'b' is a private member of 'test1::A'}} - } -} - -namespace test2 { - class A { - bool b; // expected-note {{declared private here}} - template <typename T> friend class HasChecker; - }; - template <typename T> class HasChecker { - bool check(A *a) { - return a->b; - } - }; - template <typename T> class HasNotChecker { - bool check(A *a) { - return a->b; // expected-error {{'b' is a private member of 'test2::A'}} - } - }; -} - -namespace test3 { - class Bool; - template <class T> class User; - template <class T> T transform(class Bool, T); - - class Bool { - friend class User<bool>; - friend bool transform<>(Bool, bool); - - bool value; // expected-note 2 {{declared private here}} - }; - - template <class T> class User { - static T compute(Bool b) { - return b.value; // expected-error {{'value' is a private member of 'test3::Bool'}} - } - }; - - template <class T> T transform(Bool b, T value) { - if (b.value) // expected-error {{'value' is a private member of 'test3::Bool'}} - return value; - return value + 1; - } - - template bool transform(Bool, bool); - template int transform(Bool, int); // expected-note {{requested here}} - - template class User<bool>; - template class User<int>; // expected-note {{requested here}} -} - -namespace test4 { - template <class T> class A { - template <class T0> friend class B; - bool foo(const A<T> *) const; - }; - - template <class T> class B { - bool bar(const A<T> *a, const A<T> *b) { - return a->foo(b); - } - }; - - template class B<int>; -} - -namespace test5 { - template <class T, class U=int> class A {}; - template <class T> class B { - template <class X, class Y> friend class A; - }; - template class B<int>; - template class A<int>; -} - -namespace Dependent { - template<typename T, typename Traits> class X; - template<typename T, typename Traits> - X<T, Traits> operator+(const X<T, Traits>&, const T*); - - template<typename T, typename Traits> class X { - typedef typename Traits::value_type value_type; - friend X operator+<>(const X&, const value_type*); - }; -} - -namespace test7 { - template <class T> class A { // expected-note {{declared here}} - friend class B; - int x; // expected-note {{declared private here}} - }; - - class B { - int foo(A<int> &a) { - return a.x; - } - }; - - class C { - int foo(A<int> &a) { - return a.x; // expected-error {{'x' is a private member of 'test7::A<int>'}} - } - }; - - // This shouldn't crash. - template <class T> class D { - friend class A; // expected-error {{template 'A' cannot be referenced with a class specifier}} - }; - template class D<int>; -} - -namespace test8 { - template <class N> class A { - static int x; - template <class T> friend void foo(); - }; - template class A<int>; - - template <class T> void foo() { - A<int>::x = 0; - } - template void foo<int>(); -} - -namespace test9 { - template <class T> class A { - class B; class C; - - int foo(B *b) { - return b->x; - } - - int foo(C *c) { - return c->x; // expected-error {{'x' is a private member}} - } - - class B { - int x; - friend int A::foo(B*); - }; - - class C { - int x; // expected-note {{declared private here}} - }; - }; - - template class A<int>; // expected-note {{in instantiation}} -} - -namespace test10 { - template <class T> class A; - template <class T> A<T> bar(const T*, const A<T>&); - template <class T> class A { - private: - void foo(); // expected-note {{declared private here}} - friend A bar<>(const T*, const A<T>&); - }; - - template <class T> A<T> bar(const T *l, const A<T> &r) { - A<T> l1; - l1.foo(); - - A<char> l2; - l2.foo(); // expected-error {{'foo' is a private member of 'test10::A<char>'}} - - return l1; - } - - template A<int> bar<int>(const int *, const A<int> &); // expected-note {{in instantiation}} -} - -// PR6752: this shouldn't crash. -namespace test11 { - struct Foo { - template<class A> - struct IteratorImpl { - template<class T> friend class IteratorImpl; - }; - }; - - template struct Foo::IteratorImpl<int>; - template struct Foo::IteratorImpl<long>; -} - -// PR6827 -namespace test12 { - template <typename T> class Foo; - template <typename T> Foo<T> foo(T* t){ return Foo<T>(t, true); } - - template <typename T> class Foo { - public: - Foo(T*); - friend Foo<T> foo<T>(T*); - private: - Foo(T*, bool); // expected-note {{declared private here}} - }; - - // Should work. - int globalInt; - Foo<int> f = foo(&globalInt); - - // Shouldn't work. - long globalLong; - template <> Foo<long> foo(long *t) { - Foo<int> s(&globalInt, false); // expected-error {{calling a private constructor}} - return Foo<long>(t, true); - } -} - -// PR6514 -namespace test13 { - template <int N, template <int> class Temp> - class Role : public Temp<N> { - friend class Temp<N>; - int x; - }; - - template <int N> class Foo { - void foo(Role<N, test13::Foo> &role) { - (void) role.x; - } - }; - - template class Foo<0>; -} - -namespace test14 { - template <class T> class B; - template <class T> class A { - friend void B<T>::foo(); - static void foo(); // expected-note {{declared private here}} - }; - - template <class T> class B { - public: - void foo() { return A<long>::foo(); } // expected-error {{'foo' is a private member of 'test14::A<long>'}} - }; - - template class B<int>; // expected-note {{in instantiation}} -} - -namespace test15 { - template <class T> class B; - template <class T> class A { - friend void B<T>::foo(); - - // This shouldn't be misrecognized as a templated-scoped reference. - template <class U> friend void B<T>::bar(U); - - static void foo(); // expected-note {{declared private here}} - }; - - template <class T> class B { - public: - void foo() { return A<long>::foo(); } // expected-error {{'foo' is a private member of 'test15::A<long>'}} - }; - - template <> class B<float> { - public: - void foo() { return A<float>::foo(); } - template <class U> void bar(U u) { - (void) A<float>::foo(); - } - }; - - template class B<int>; // expected-note {{in instantiation}} -} - -namespace PR10913 { - template<class T> class X; - - template<class T> void f(X<T> *x) { - x->member = 0; - } - - template<class U, class T> void f2(X<T> *x) { - x->member = 0; // expected-error{{'member' is a protected member of 'PR10913::X<int>'}} - } - - template<class T> class X { - friend void f<T>(X<T> *x); - friend void f2<T>(X<int> *x); - - protected: - int member; // expected-note{{declared protected here}} - }; - - template void f(X<int> *); - template void f2<int>(X<int> *); - template void f2<float>(X<int> *); // expected-note{{in instantiation of function template specialization 'PR10913::f2<float, int>' requested here}} -} - -namespace test16 { -template <class T> struct foo {}; // expected-note{{candidate ignored: not a function template}} -template <class T> class A { - friend void foo<T>(); // expected-error{{no candidate function template was found for dependent friend function template specialization}} -}; -} - -namespace test17 { -namespace ns { -template <class T> void foo() {} // expected-note{{candidate ignored: not a member of the enclosing namespace; did you mean to explicitly qualify the specialization?}} -} -using ns::foo; -template <class T> struct A { - friend void foo<T>() {} // expected-error{{no candidate function template was found for dependent friend function template specialization}} -}; -} - -namespace test18 { -namespace ns1 { template <class T> struct foo {}; } // expected-note{{candidate ignored: not a function template}} -namespace ns2 { void foo() {} } // expected-note{{candidate ignored: not a function template}} -using ns1::foo; -using ns2::foo; - -template <class T> class A { - friend void foo<T>() {} // expected-error{{no candidate function template was found for dependent friend function template specialization}} -}; -} diff --git a/test/CXX/temp/temp.decls/temp.friend/p3.cpp b/test/CXX/temp/temp.decls/temp.friend/p3.cpp deleted file mode 100644 index 0b2a25e9876b..000000000000 --- a/test/CXX/temp/temp.decls/temp.friend/p3.cpp +++ /dev/null @@ -1,12 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s - -template <class T> class A { - typedef int Member; -}; - -class B { - template <class T> friend class A; - template <class T> friend class Undeclared; - - template <class T> friend typename A<T>::Member; // expected-error {{friend type templates must use an elaborated type}} -}; diff --git a/test/CXX/temp/temp.decls/temp.friend/p4.cpp b/test/CXX/temp/temp.decls/temp.friend/p4.cpp deleted file mode 100644 index 8571a141201b..000000000000 --- a/test/CXX/temp/temp.decls/temp.friend/p4.cpp +++ /dev/null @@ -1,45 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s - -template<typename T> -struct X1 { - friend void f6(int) { } // expected-error{{redefinition of}} \ - // expected-note{{previous definition}} -}; - -X1<int> x1a; -X1<float> x1b; // expected-note {{in instantiation of}} - -template<typename T> -struct X2 { - operator int(); - - friend void f(int x) { } // expected-error{{redefinition}} \ - // expected-note{{previous definition}} -}; - -int array0[sizeof(X2<int>)]; -int array1[sizeof(X2<float>)]; // expected-note{{instantiation of}} - -void g() { - X2<int> xi; - f(xi); - X2<float> xf; - f(xf); -} - -template<typename T> -struct X3 { - operator int(); - - friend void h(int x); -}; - -int array2[sizeof(X3<int>)]; -int array3[sizeof(X3<float>)]; - -void i() { - X3<int> xi; - h(xi); - X3<float> xf; - h(xf); -} diff --git a/test/CXX/temp/temp.decls/temp.friend/p5.cpp b/test/CXX/temp/temp.decls/temp.friend/p5.cpp deleted file mode 100644 index c4f9d63b7c66..000000000000 --- a/test/CXX/temp/temp.decls/temp.friend/p5.cpp +++ /dev/null @@ -1,104 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s - -namespace test0 { - template <class T> class A { - class Member {}; - }; - - class B { - template <class T> friend class A<T>::Member; // expected-warning {{not supported}} - int n; - }; - - A<int> a; - B b; -} - -// rdar://problem/8204127 -namespace test1 { - template <class T> struct A; - - class C { - static void foo(); - template <class T> friend void A<T>::f(); // expected-warning {{not supported}} - }; - - template <class T> struct A { - void f() { C::foo(); } - }; - - template <class T> struct A<T*> { - void f() { C::foo(); } - }; - - template <> struct A<char> { - void f() { C::foo(); } - }; -} - -// FIXME: these should fail! -namespace test2 { - template <class T> struct A; - - class C { - static void foo(); - template <class T> friend void A<T>::g(); // expected-warning {{not supported}} - }; - - template <class T> struct A { - void f() { C::foo(); } - }; - - template <class T> struct A<T*> { - void f() { C::foo(); } - }; - - template <> struct A<char> { - void f() { C::foo(); } - }; -} - -// Tests 3, 4 and 5 were all noted in <rdar://problem/8540527>. -namespace test3 { - template <class T> struct A { - struct Inner { - static int foo(); - }; - }; - - template <class U> class C { - int i; - template <class T> friend struct A<T>::Inner; // expected-warning {{not supported}} - }; - - template <class T> int A<T>::Inner::foo() { - C<int> c; - c.i = 0; - return 0; - } - - int test = A<int>::Inner::foo(); -} - -namespace test4 { - template <class T> struct X { - template <class U> void operator+=(U); - - template <class V> - template <class U> - friend void X<V>::operator+=(U); // expected-warning {{not supported}} - }; - - void test() { - X<int>() += 1.0; - } -} - -namespace test5 { - template<template <class> class T> struct A { - template<template <class> class U> friend void A<U>::foo(); // expected-warning {{not supported}} - }; - - template <class> struct B {}; - template class A<B>; -} diff --git a/test/CXX/temp/temp.decls/temp.friend/p8.cpp b/test/CXX/temp/temp.decls/temp.friend/p8.cpp deleted file mode 100644 index d0221a3668d7..000000000000 --- a/test/CXX/temp/temp.decls/temp.friend/p8.cpp +++ /dev/null @@ -1,6 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -template<class T> class A { }; - -class X { - template<class T> friend class A<T*>; // expected-error{{partial specialization cannot be declared as a friend}} -}; diff --git a/test/CXX/temp/temp.decls/temp.mem/p1.cpp b/test/CXX/temp/temp.decls/temp.mem/p1.cpp deleted file mode 100644 index b48e145e1468..000000000000 --- a/test/CXX/temp/temp.decls/temp.mem/p1.cpp +++ /dev/null @@ -1,37 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -// expected-no-diagnostics - -template <class T> struct A { - static T cond; - - template <class U> struct B { - static T twice(U value) { - return (cond ? value + value : value); - } - }; -}; -extern template bool A<bool>::cond; - -int foo() { - A<bool>::cond = true; - return A<bool>::B<int>::twice(4); -} - -namespace PR6376 { - template<typename T> - struct X { - template<typename Y> - struct Y1 { }; // - }; - - template<> - struct X<float> { - template<typename Y> - struct Y1 { }; - }; - - template<typename T, typename U> - struct Z : public X<T>::template Y1<U> { }; - - Z<float, int> z0; -} diff --git a/test/CXX/temp/temp.decls/temp.mem/p2.cpp b/test/CXX/temp/temp.decls/temp.mem/p2.cpp deleted file mode 100644 index feeb362e34b4..000000000000 --- a/test/CXX/temp/temp.decls/temp.mem/p2.cpp +++ /dev/null @@ -1,14 +0,0 @@ -// RUN: %clang_cc1 -std=c++14 -fsyntax-only -verify %s - -template <typename> -void quux(); - -void fun() { - struct foo { - template <typename> struct bar {}; // expected-error{{templates cannot be declared inside of a local class}} - template <typename> void baz() {} // expected-error{{templates cannot be declared inside of a local class}} - template <typename> void qux(); // expected-error{{templates cannot be declared inside of a local class}} - template <typename> using corge = int; // expected-error{{templates cannot be declared inside of a local class}} - template <typename T> static T grault; // expected-error{{static data member}} expected-error{{templates cannot be declared inside of a local class}} - }; -} diff --git a/test/CXX/temp/temp.decls/temp.mem/p3.cpp b/test/CXX/temp/temp.decls/temp.mem/p3.cpp deleted file mode 100644 index 7e13f2a58ba0..000000000000 --- a/test/CXX/temp/temp.decls/temp.mem/p3.cpp +++ /dev/null @@ -1,6 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s - -template <class T> struct AA { - template <class C> virtual void g(C); // expected-error{{'virtual' cannot be specified on member function templates}} - virtual void f(); -}; diff --git a/test/CXX/temp/temp.decls/temp.mem/p5.cpp b/test/CXX/temp/temp.decls/temp.mem/p5.cpp deleted file mode 100644 index a41ea6b5e109..000000000000 --- a/test/CXX/temp/temp.decls/temp.mem/p5.cpp +++ /dev/null @@ -1,92 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -struct A { - template <class T> operator T*(); -}; - -template <class T> A::operator T*() { return 0; } -template <> A::operator char*(){ return 0; } // specialization -template A::operator void*(); // explicit instantiation - -int main() { - A a; - int *ip; - ip = a.operator int*(); -} - -// PR5742 -namespace PR5742 { - template <class T> struct A { }; - template <class T> struct B { }; - - struct S { - template <class T> operator T(); - } s; - - void f() { - s.operator A<A<int> >(); - s.operator A<B<int> >(); - s.operator A<B<A<int> > >(); - } -} - -// PR5762 -class Foo { - public: - template <typename T> operator T(); - - template <typename T> - T As() { - return this->operator T(); - } - - template <typename T> - T As2() { - return operator T(); - } - - int AsInt() { - return this->operator int(); - } -}; - -template float Foo::As(); -template double Foo::As2(); - -// Partial ordering with conversion function templates. -struct X0 { - template<typename T> operator T*() { - T x = 1; // expected-note{{variable 'x' declared const here}} - x = 17; // expected-error{{cannot assign to variable 'x' with const-qualified type 'const int'}} - } - - template<typename T> operator T*() const; // expected-note{{explicit instantiation refers here}} - - template<typename T> operator const T*() const { - T x = T(); - return x; // expected-error{{cannot initialize return object of type 'const char *' with an lvalue of type 'char'}} \ - // expected-error{{cannot initialize return object of type 'const int *' with an lvalue of type 'int'}} - } -}; - -template X0::operator const char*() const; // expected-note{{'X0::operator const char *<char>' requested here}} -template X0::operator const int*(); // expected-note{{'X0::operator const int *<const int>' requested here}} -template X0::operator float*() const; // expected-error{{explicit instantiation of undefined function template}} - -void test_X0(X0 x0, const X0 &x0c) { - x0.operator const int*(); // expected-note{{in instantiation of function template specialization}} - x0.operator float *(); - x0c.operator const char*(); -} - -namespace PR14211 { -template <class U> struct X { - void foo(U){} - template <class T> void foo(T){} - - template <class T> void bar(T){} - void bar(U){} -}; - -template void X<int>::foo(int); -template void X<int>::bar(int); -} diff --git a/test/CXX/temp/temp.decls/temp.variadic/deduction.cpp b/test/CXX/temp/temp.decls/temp.variadic/deduction.cpp deleted file mode 100644 index 2e24fc00dc1a..000000000000 --- a/test/CXX/temp/temp.decls/temp.variadic/deduction.cpp +++ /dev/null @@ -1,51 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s -// expected-no-diagnostics - -namespace DeductionForInstantiation { - template<unsigned I, typename ...Types> - struct X { }; - - template<typename ...Types> - void f0(X<sizeof...(Types), Types&...>) { } - - // No explicitly-specified arguments - template void f0(X<0>); - template void f0(X<1, int&>); - template void f0(X<2, int&, short&>); - - // One explicitly-specified argument - template void f0<float>(X<1, float&>); - template void f0<double>(X<1, double&>); - - // Two explicitly-specialized arguments - template void f0<char, unsigned char>(X<2, char&, unsigned char&>); - template void f0<signed char, char>(X<2, signed char&, char&>); - - // FIXME: Extension of explicitly-specified arguments - // template void f0<short, int>(X<3, short&, int&, long&>); -} - -namespace DeductionWithConversion { - template<char...> struct char_values { - static const unsigned value = 0; - }; - - template<int C1, char C3> - struct char_values<C1, 12, C3> { - static const unsigned value = 1; - }; - - int check0[char_values<1, 12, 3>::value == 1? 1 : -1]; - - template<int...> struct int_values { - static const unsigned value = 0; - }; - - template<unsigned char C1, unsigned char C3> - struct int_values<C1, 12, C3> { - static const unsigned value = 1; - }; - - int check1[int_values<256, 12, 3>::value == 0? 1 : -1]; - int check2[int_values<3, 12, 3>::value == 1? 1 : -1]; -} diff --git a/test/CXX/temp/temp.decls/temp.variadic/example-bind.cpp b/test/CXX/temp/temp.decls/temp.variadic/example-bind.cpp deleted file mode 100644 index 83e03bcc0ddb..000000000000 --- a/test/CXX/temp/temp.decls/temp.variadic/example-bind.cpp +++ /dev/null @@ -1,353 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s -// expected-no-diagnostics - -// Example bind implementation from the variadic templates proposal, -// ISO C++ committee document number N2080. - -// Helper type traits -template<typename T> -struct add_reference { - typedef T &type; -}; - -template<typename T> -struct add_reference<T&> { - typedef T &type; -}; - -template<typename T> -struct add_const_reference { - typedef T const &type; -}; - -template<typename T> -struct add_const_reference<T&> { - typedef T &type; -}; - -template<typename T, typename U> -struct is_same { - static const bool value = false; -}; - -template<typename T> -struct is_same<T, T> { - static const bool value = true; -}; - -template<typename T> -class reference_wrapper { - T *ptr; - -public: - reference_wrapper(T& t) : ptr(&t) { } - operator T&() const { return *ptr; } -}; - -template<typename T> reference_wrapper<T> ref(T& t) { - return reference_wrapper<T>(t); -} -template<typename T> reference_wrapper<const T> cref(const T& t) { - return reference_wrapper<const T>(t); -} - -template<typename... Values> class tuple; - -// Basis case: zero-length tuple -template<> class tuple<> { }; - -template<typename Head, typename... Tail> -class tuple<Head, Tail...> : private tuple<Tail...> { - typedef tuple<Tail...> inherited; - -public: - tuple() { } - // implicit copy-constructor is okay - - // Construct tuple from separate arguments. - tuple(typename add_const_reference<Head>::type v, - typename add_const_reference<Tail>::type... vtail) - : m_head(v), inherited(vtail...) { } - - // Construct tuple from another tuple. - template<typename... VValues> tuple(const tuple<VValues...>& other) - : m_head(other.head()), inherited(other.tail()) { } - - template<typename... VValues> tuple& - operator=(const tuple<VValues...>& other) { - m_head = other.head(); - tail() = other.tail(); - return *this; - } - - typename add_reference<Head>::type head() { return m_head; } - typename add_reference<const Head>::type head() const { return m_head; } - inherited& tail() { return *this; } - const inherited& tail() const { return *this; } - -protected: - Head m_head; -}; - -// Creation functions -template<typename T> -struct make_tuple_result { - typedef T type; -}; - -template<typename T> -struct make_tuple_result<reference_wrapper<T> > { - typedef T& type; -}; - -template<typename... Values> -tuple<typename make_tuple_result<Values>::type...> -make_tuple(const Values&... values) { - return tuple<typename make_tuple_result<Values>::type...>(values...); -} - -template<typename... Values> -tuple<Values&...> tie(Values&... values) { - return tuple<Values&...>(values...); -} - -// Helper classes -template<typename Tuple> struct tuple_size; - -template<typename... Values> struct tuple_size<tuple<Values...> > { - static const int value = sizeof...(Values); -}; - -template<int I, typename Tuple> struct tuple_element; - -template<int I, typename Head, typename... Tail> -struct tuple_element<I, tuple<Head, Tail...> > { - typedef typename tuple_element<I-1, tuple<Tail...> >::type type; -}; - -template<typename Head, typename... Tail> -struct tuple_element<0, tuple<Head, Tail...> > { - typedef Head type; -}; - -// Element access -template<int I, typename Tuple> class get_impl; -template<int I, typename Head, typename... Values> -class get_impl<I, tuple<Head, Values...> > { - typedef typename tuple_element<I-1, tuple<Values...> >::type Element; - typedef typename add_reference<Element>::type RJ; - typedef typename add_const_reference<Element>::type PJ; - typedef get_impl<I-1, tuple<Values...> > Next; -public: - static RJ get(tuple<Head, Values...>& t) { return Next::get(t.tail()); } - static PJ get(const tuple<Head, Values...>& t) { return Next::get(t.tail()); } -}; - -template<typename Head, typename... Values> -class get_impl<0, tuple<Head, Values...> > { - typedef typename add_reference<Head>::type RJ; - typedef typename add_const_reference<Head>::type PJ; -public: - static RJ get(tuple<Head, Values...>& t) { return t.head(); } - static PJ get(const tuple<Head, Values...>& t) { return t.head(); } -}; - -template<int I, typename... Values> typename add_reference< -typename tuple_element<I, tuple<Values...> >::type >::type -get(tuple<Values...>& t) { - return get_impl<I, tuple<Values...> >::get(t); -} - -template<int I, typename... Values> typename add_const_reference< -typename tuple_element<I, tuple<Values...> >::type >::type -get(const tuple<Values...>& t) { - return get_impl<I, tuple<Values...> >::get(t); -} - -// Relational operators -inline bool operator==(const tuple<>&, const tuple<>&) { return true; } - -template<typename T, typename... TTail, typename U, typename... UTail> -bool operator==(const tuple<T, TTail...>& t, const tuple<U, UTail...>& u) { - return t.head() == u.head() && t.tail() == u.tail(); -} - -template<typename... TValues, typename... UValues> -bool operator!=(const tuple<TValues...>& t, const tuple<UValues...>& u) { - return !(t == u); -} - -inline bool operator<(const tuple<>&, const tuple<>&) { return false; } - -template<typename T, typename... TTail, typename U, typename... UTail> -bool operator<(const tuple<T, TTail...>& t, const tuple<U, UTail...>& u) { - return (t.head() < u.head() || (!(t.head() < u.head()) && t.tail() < u.tail())); -} - -template<typename... TValues, typename... UValues> -bool operator>(const tuple<TValues...>& t, const tuple<UValues...>& u) { - return u < t; -} - -template<typename... TValues, typename... UValues> -bool operator<=(const tuple<TValues...>& t, const tuple<UValues...>& u) { - return !(u < t); -} - -template<typename... TValues, typename... UValues> -bool operator>=(const tuple<TValues...>& t, const tuple<UValues...>& u) { - return !(t < u); -} - -// make_indices helper -template<int...> struct int_tuple {}; -// make_indexes impl is a helper for make_indexes -template<int I, typename IntTuple, typename... Types> struct make_indexes_impl; - -template<int I, int... Indexes, typename T, typename... Types> -struct make_indexes_impl<I, int_tuple<Indexes...>, T, Types...> { - typedef typename make_indexes_impl<I+1, int_tuple<Indexes..., I>, Types...>::type type; -}; - -template<int I, int... Indexes> -struct make_indexes_impl<I, int_tuple<Indexes...> > { - typedef int_tuple<Indexes...> type; -}; - -template<typename... Types> -struct make_indexes : make_indexes_impl<0, int_tuple<>, Types...> { -}; - -// Bind -template<typename T> struct is_bind_expression { - static const bool value = false; -}; - -template<typename T> struct is_placeholder { - static const int value = 0; -}; - - -template<typename F, typename... BoundArgs> class bound_functor { - typedef typename make_indexes<BoundArgs...>::type indexes; -public: - typedef typename F::result_type result_type; - explicit bound_functor(const F& f, const BoundArgs&... bound_args) - : f(f), bound_args(bound_args...) { } template<typename... Args> - typename F::result_type operator()(Args&... args); -private: F f; - tuple<BoundArgs...> bound_args; -}; - -template<typename F, typename... BoundArgs> -inline bound_functor<F, BoundArgs...> bind(const F& f, const BoundArgs&... bound_args) { - return bound_functor<F, BoundArgs...>(f, bound_args...); -} - -template<typename F, typename ...BoundArgs> -struct is_bind_expression<bound_functor<F, BoundArgs...> > { - static const bool value = true; -}; - -// enable_if helper -template<bool Cond, typename T = void> -struct enable_if; - -template<typename T> -struct enable_if<true, T> { - typedef T type; -}; - -template<typename T> -struct enable_if<false, T> { }; - -// safe_tuple_element helper -template<int I, typename Tuple, typename = void> -struct safe_tuple_element { }; - -template<int I, typename... Values> -struct safe_tuple_element<I, tuple<Values...>, - typename enable_if<(I >= 0 && I < tuple_size<tuple<Values...> >::value)>::type> { - typedef typename tuple_element<I, tuple<Values...> >::type type; -}; - -// mu -template<typename Bound, typename... Args> -inline typename safe_tuple_element<is_placeholder<Bound>::value -1, - tuple<Args...> >::type -mu(Bound& bound_arg, const tuple<Args&...>& args) { - return get<is_placeholder<Bound>::value-1>(args); -} - -template<typename T, typename... Args> -inline T& mu(reference_wrapper<T>& bound_arg, const tuple<Args&...>&) { - return bound_arg.get(); -} - -template<typename F, int... Indexes, typename... Args> -inline typename F::result_type -unwrap_and_forward(F& f, int_tuple<Indexes...>, const tuple<Args&...>& args) { - return f(get<Indexes>(args)...); -} - -template<typename Bound, typename... Args> -inline typename enable_if<is_bind_expression<Bound>::value, - typename Bound::result_type>::type -mu(Bound& bound_arg, const tuple<Args&...>& args) { - typedef typename make_indexes<Args...>::type Indexes; - return unwrap_and_forward(bound_arg, Indexes(), args); -} - -template<typename T> -struct is_reference_wrapper { - static const bool value = false; -}; - -template<typename T> -struct is_reference_wrapper<reference_wrapper<T>> { - static const bool value = true; -}; - -template<typename Bound, typename... Args> -inline typename enable_if<(!is_bind_expression<Bound>::value - && !is_placeholder<Bound>::value - && !is_reference_wrapper<Bound>::value), - Bound&>::type -mu(Bound& bound_arg, const tuple<Args&...>&) { - return bound_arg; -} - -template<typename F, typename... BoundArgs, int... Indexes, typename... Args> -typename F::result_type apply_functor(F& f, tuple<BoundArgs...>& bound_args, - int_tuple<Indexes...>, - const tuple<Args&...>& args) { - return f(mu(get<Indexes>(bound_args), args)...); -} - -template<typename F, typename... BoundArgs> -template<typename... Args> -typename F::result_type bound_functor<F, BoundArgs...>::operator()(Args&... args) { - return apply_functor(f, bound_args, indexes(), tie(args...)); -} - -template<int N> struct placeholder { }; -template<int N> -struct is_placeholder<placeholder<N>> { - static const int value = N; -}; - -template<typename T> -struct plus { - typedef T result_type; - - T operator()(T x, T y) { return x + y; } -}; - -placeholder<1> _1; - -// Test bind -void test_bind() { - int x = 17; - int y = 25; - bind(plus<int>(), x, _1)(y); -} diff --git a/test/CXX/temp/temp.decls/temp.variadic/example-function.cpp b/test/CXX/temp/temp.decls/temp.variadic/example-function.cpp deleted file mode 100644 index 4cbacf830266..000000000000 --- a/test/CXX/temp/temp.decls/temp.variadic/example-function.cpp +++ /dev/null @@ -1,87 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s -// expected-no-diagnostics - -// Example function implementation from the variadic templates proposal, -// ISO C++ committee document number N2080. - -template<typename Signature> class function; - -template<typename R, typename... Args> class invoker_base { -public: - virtual ~invoker_base() { } - virtual R invoke(Args...) = 0; - virtual invoker_base* clone() = 0; -}; - -template<typename F, typename R, typename... Args> -class functor_invoker : public invoker_base<R, Args...> { -public: - explicit functor_invoker(const F& f) : f(f) { } - R invoke(Args... args) { return f(args...); } - functor_invoker* clone() { return new functor_invoker(f); } - -private: - F f; -}; - -template<typename R, typename... Args> -class function<R (Args...)> { -public: - typedef R result_type; - function() : invoker (0) { } - function(const function& other) : invoker(0) { - if (other.invoker) - invoker = other.invoker->clone(); - } - - template<typename F> function(const F& f) : invoker(0) { - invoker = new functor_invoker<F, R, Args...>(f); - } - - ~function() { - if (invoker) - delete invoker; - } - - function& operator=(const function& other) { - function(other).swap(*this); - return *this; - } - - template<typename F> - function& operator=(const F& f) { - function(f).swap(*this); - return *this; - } - - void swap(function& other) { - invoker_base<R, Args...>* tmp = invoker; - invoker = other.invoker; - other.invoker = tmp; - } - - result_type operator()(Args... args) const { - return invoker->invoke(args...); - } - -private: - invoker_base<R, Args...>* invoker; -}; - -template<typename T> -struct add { - T operator()(T x, T y) { return x + y; } -}; - -int add_ints(int x, int y) { return x + y; } - -void test_function() { - function<int(int, int)> f2a; - function<int(int, int)> f2b = add<int>(); - function<int(int, int)> f2c = add<float>(); - function<int(int, int)> f2d(f2b); - function<int(int, int)> f2e = &add_ints; - f2c = f2d; - f2d = &add_ints; - f2c(1.0, 3); -} diff --git a/test/CXX/temp/temp.decls/temp.variadic/example-tuple.cpp b/test/CXX/temp/temp.decls/temp.variadic/example-tuple.cpp deleted file mode 100644 index f5800471ac2d..000000000000 --- a/test/CXX/temp/temp.decls/temp.variadic/example-tuple.cpp +++ /dev/null @@ -1,261 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s -// expected-no-diagnostics - -// Example tuple implementation from the variadic templates proposal, -// ISO C++ committee document number N2080. - -// Helper type traits -template<typename T> -struct add_reference { - typedef T &type; -}; - -template<typename T> -struct add_reference<T&> { - typedef T &type; -}; - -template<typename T> -struct add_const_reference { - typedef T const &type; -}; - -template<typename T> -struct add_const_reference<T&> { - typedef T &type; -}; - -template<typename T, typename U> -struct is_same { - static const bool value = false; -}; - -template<typename T> -struct is_same<T, T> { - static const bool value = true; -}; - -template<typename T> -class reference_wrapper { - T *ptr; - -public: - reference_wrapper(T& t) : ptr(&t) { } - operator T&() const { return *ptr; } -}; - -template<typename T> reference_wrapper<T> ref(T& t) { - return reference_wrapper<T>(t); -} -template<typename T> reference_wrapper<const T> cref(const T& t) { - return reference_wrapper<const T>(t); -} - -template<typename... Values> class tuple; - -// Basis case: zero-length tuple -template<> class tuple<> { }; - -template<typename Head, typename... Tail> -class tuple<Head, Tail...> : private tuple<Tail...> { - typedef tuple<Tail...> inherited; - -public: - tuple() { } - // implicit copy-constructor is okay - - // Construct tuple from separate arguments. - tuple(typename add_const_reference<Head>::type v, - typename add_const_reference<Tail>::type... vtail) - : m_head(v), inherited(vtail...) { } - - // Construct tuple from another tuple. - template<typename... VValues> tuple(const tuple<VValues...>& other) - : m_head(other.head()), inherited(other.tail()) { } - - template<typename... VValues> tuple& - operator=(const tuple<VValues...>& other) { - m_head = other.head(); - tail() = other.tail(); - return *this; - } - - typename add_reference<Head>::type head() { return m_head; } - typename add_reference<const Head>::type head() const { return m_head; } - inherited& tail() { return *this; } - const inherited& tail() const { return *this; } - -protected: - Head m_head; -}; - -void test_tuple() { - tuple<> t0a; - tuple<> t0b(t0a); - t0a = t0b; - - tuple<int> t1a; - tuple<int> t1b(17); - tuple<int> t1c(t1b); - t1a = t1b; - - tuple<float> t1d(3.14159); - tuple<float> t1e(t1d); - t1d = t1e; - - int i; - float f; - double d; - tuple<int*, float*, double*> t3a(&i, &f, &d); -} - -// Creation functions -template<typename T> -struct make_tuple_result { - typedef T type; -}; - -template<typename T> -struct make_tuple_result<reference_wrapper<T> > { - typedef T& type; -}; - -template<typename... Values> -tuple<typename make_tuple_result<Values>::type...> -make_tuple(const Values&... values) { - return tuple<typename make_tuple_result<Values>::type...>(values...); -} - -template<typename... Values> -tuple<Values&...> tie(Values&... values) { - return tuple<Values&...>(values...); -} - -template<typename T> const T *addr(const T& ref) { return &ref; } -void test_creation_functions() { - int i; - float f; - double d; - const tuple<int, float&, const double&> *t3p = addr(make_tuple(i, ref(f), cref(d))); - const tuple<int&, float&, double&> *t3q = addr(tie(i, f, d)); -} - -// Helper classes -template<typename Tuple> struct tuple_size; - -template<typename... Values> struct tuple_size<tuple<Values...> > { - static const int value = sizeof...(Values); -}; - -int check_tuple_size_0[tuple_size<tuple<> >::value == 0? 1 : -1]; -int check_tuple_size_1[tuple_size<tuple<int>>::value == 1? 1 : -1]; -int check_tuple_size_2[tuple_size<tuple<float, double>>::value == 2? 1 : -1]; -int check_tuple_size_3[tuple_size<tuple<char, unsigned char, signed char>>::value == 3? 1 : -1]; - -template<int I, typename Tuple> struct tuple_element; - -template<int I, typename Head, typename... Tail> -struct tuple_element<I, tuple<Head, Tail...> > { - typedef typename tuple_element<I-1, tuple<Tail...> >::type type; -}; - -template<typename Head, typename... Tail> -struct tuple_element<0, tuple<Head, Tail...> > { - typedef Head type; -}; - -int check_tuple_element_0[is_same<tuple_element<0, tuple<int&, float, double>>::type, - int&>::value? 1 : -1]; - -int check_tuple_element_1[is_same<tuple_element<1, tuple<int&, float, double>>::type, - float>::value? 1 : -1]; - -int check_tuple_element_2[is_same<tuple_element<2, tuple<int&, float, double>>::type, - double>::value? 1 : -1]; - -// Element access -template<int I, typename Tuple> class get_impl; -template<int I, typename Head, typename... Values> -class get_impl<I, tuple<Head, Values...> > { - typedef typename tuple_element<I-1, tuple<Values...> >::type Element; - typedef typename add_reference<Element>::type RJ; - typedef typename add_const_reference<Element>::type PJ; - typedef get_impl<I-1, tuple<Values...> > Next; -public: - static RJ get(tuple<Head, Values...>& t) { return Next::get(t.tail()); } - static PJ get(const tuple<Head, Values...>& t) { return Next::get(t.tail()); } -}; - -template<typename Head, typename... Values> -class get_impl<0, tuple<Head, Values...> > { - typedef typename add_reference<Head>::type RJ; - typedef typename add_const_reference<Head>::type PJ; -public: - static RJ get(tuple<Head, Values...>& t) { return t.head(); } - static PJ get(const tuple<Head, Values...>& t) { return t.head(); } -}; - -template<int I, typename... Values> typename add_reference< -typename tuple_element<I, tuple<Values...> >::type >::type -get(tuple<Values...>& t) { - return get_impl<I, tuple<Values...> >::get(t); -} - -template<int I, typename... Values> typename add_const_reference< -typename tuple_element<I, tuple<Values...> >::type >::type -get(const tuple<Values...>& t) { - return get_impl<I, tuple<Values...> >::get(t); -} - -void test_element_access(tuple<int*, float*, double*&> t3) { - int i; - float f; - double d; - get<0>(t3) = &i; - get<1>(t3) = &f; - get<2>(t3) = &d; -} - -// Relational operators -inline bool operator==(const tuple<>&, const tuple<>&) { return true; } - -template<typename T, typename... TTail, typename U, typename... UTail> -bool operator==(const tuple<T, TTail...>& t, const tuple<U, UTail...>& u) { - return t.head() == u.head() && t.tail() == u.tail(); -} - -template<typename... TValues, typename... UValues> -bool operator!=(const tuple<TValues...>& t, const tuple<UValues...>& u) { - return !(t == u); -} - -inline bool operator<(const tuple<>&, const tuple<>&) { return false; } - -template<typename T, typename... TTail, typename U, typename... UTail> -bool operator<(const tuple<T, TTail...>& t, const tuple<U, UTail...>& u) { - return (t.head() < u.head() || (!(t.head() < u.head()) && t.tail() < u.tail())); -} - -template<typename... TValues, typename... UValues> -bool operator>(const tuple<TValues...>& t, const tuple<UValues...>& u) { - return u < t; -} - -template<typename... TValues, typename... UValues> -bool operator<=(const tuple<TValues...>& t, const tuple<UValues...>& u) { - return !(u < t); -} - -template<typename... TValues, typename... UValues> -bool operator>=(const tuple<TValues...>& t, const tuple<UValues...>& u) { - return !(t < u); -} - -void test_relational_operators(tuple<int*, float*, double*> t3) { - (void)(t3 == t3); - (void)(t3 != t3); - (void)(t3 < t3); - (void)(t3 <= t3); - (void)(t3 >= t3); - (void)(t3 > t3); -}; diff --git a/test/CXX/temp/temp.decls/temp.variadic/ext-blocks.cpp b/test/CXX/temp/temp.decls/temp.variadic/ext-blocks.cpp deleted file mode 100644 index 6d9d8c50af68..000000000000 --- a/test/CXX/temp/temp.decls/temp.variadic/ext-blocks.cpp +++ /dev/null @@ -1,46 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -fblocks -fsyntax-only -verify %s - -// Tests the use of blocks with variadic templates. -template<typename ...Args> -int f0(Args ...args) { - return ^ { - return sizeof...(Args); - }() + ^ { - return sizeof...(args); - }(); -} - -template<typename ...Args> -int f1(Args ...args) { - return ^ { - return f0(args...); - }(); -} - -template int f0(int, float, double); -template int f1(const char*, int, float, double); - -template<typename ...Args> -int f2(Args ...args) { - return ^(Args ...block_args) { - return f1(block_args...); - }(args + 0 ...); -} - -template int f2(const char*, int, float, double); - -template<typename ...Args> -int f3(Args ...args) { - return ^(Args *...block_args) { - return f1(block_args...); - }(&args...); -} - -template int f3(const char*, int, float, double); - -template<typename ...Args> -int PR9953(Args ...args) { - return ^(Args *...block_args) { - return f1(block_args); // expected-error{{expression contains unexpanded parameter pack 'block_args'}} - }(&args...); -} diff --git a/test/CXX/temp/temp.decls/temp.variadic/fixed-expansion.cpp b/test/CXX/temp/temp.decls/temp.variadic/fixed-expansion.cpp deleted file mode 100644 index a990c82564aa..000000000000 --- a/test/CXX/temp/temp.decls/temp.variadic/fixed-expansion.cpp +++ /dev/null @@ -1,136 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s - -template<typename T, typename U> struct pair { }; -template<typename ...Types> struct tuple { }; - -template<typename T, typename U> -struct is_same { - static const bool value = false; -}; - -template<typename T> -struct is_same<T, T> { - static const bool value = true; -}; - -namespace ExpandIntoFixed { - template<typename T, - typename U, - typename V = pair<T, U>, - typename W = V*> - class X0 { }; - - template<typename ...Ts> - class X1 { - public: - typedef X0<Ts...> type; - }; - - static_assert(is_same<X1<int, int>::type, - X0<int, int, pair<int, int>, pair<int, int>*>>::value, - "fails with two default arguments"); - - static_assert(is_same<X1<int, int, float>::type, - X0<int, int, float, float*>>::value, - "fails with one default argument"); - - static_assert(is_same<X1<int, int, float, double>::type, - X0<int, int, float, double>>::value, - "fails with no default arguments"); -} - -namespace ExpandIntoFixedShifted { - template<typename T, - typename U, - typename V = pair<T, U>, - typename W = V*> - class X0 { }; - - template<typename ...Ts> - class X1 { - public: - typedef X0<char, Ts...> type; - }; - - static_assert(is_same<X1<int>::type, - X0<char, int, pair<char, int>, pair<char, int>*>>::value, - "fails with two default arguments"); - - static_assert(is_same<X1<int, float>::type, - X0<char, int, float, float*>>::value, - "fails with one default argument"); - - static_assert(is_same<X1<int, float, double>::type, - X0<char, int, float, double>>::value, - "fails with no default arguments"); -} - -namespace Deduction { - template <typename X, typename Y = double> struct Foo {}; - template <typename ...Args> tuple<Args...> &foo(Foo<Args...>); - - void call_foo(Foo<int, float> foo_if, Foo<int> foo_i) { - tuple<int, float> &t1 = foo(foo_if); - tuple<int, double> &t2 = foo(foo_i); - } -} - -namespace PR9021a { - template<typename, typename> - struct A { }; - - template<typename ...T> - struct B { - A<T...> a1; - }; - - void test() { - B<int, int> c; - } -} - -namespace PR9021b { - template<class, class> - struct t2 - { - - }; - - template<template<class...> class M> - struct m - { - template<class... B> - using inner = M<B...>; - }; - - m<t2> sta2; -} - -namespace PartialSpecialization { - template<typename T, typename U, typename V = U> - struct X0; // expected-note 2{{template is declared here}} - - template<typename ...Ts> - struct X0<Ts...> { // expected-error {{class template partial specialization is not more specialized than the primary template}} - }; - - X0<int> x0i; // expected-error{{too few template arguments for class template 'X0'}} - X0<int, float> x0if; - X0<int, float, double> x0ifd; -} - -namespace FixedAliasTemplate { - template<typename,typename,typename> struct S {}; - template<typename T, typename U> using U = S<T, int, U>; // expected-note 2{{template parameter is declared here}} - template<typename...Ts> U<Ts...> &f(U<Ts...>, Ts...); // expected-error 2{{pack expansion used as argument for non-pack parameter of alias template}} - S<int, int, double> &s1 = f({}, 0, 0.0); // expected-error {{no matching function}} -} - -namespace PR18401 { - template<typename... Args> struct foo { }; - template<typename T, typename... Args> using bar = foo<T, Args...>; // expected-note 2{{template parameter is declared here}} expected-note {{'bar' declared here}} - template<typename T, typename... Args> using baz = bar<Args..., T>; // expected-error {{pack expansion used as argument for non-pack parameter of alias template}} - // FIXME: We should still record the alias template, but mark it as invalid. - template<typename...T> void f(baz<T...>); // expected-error {{no template named 'baz'; did you mean 'bar'}} expected-error {{pack expansion used as argument for non-pack}} - void g() { f(foo<int, char, double>()); } // expected-error {{no matching function}} -} diff --git a/test/CXX/temp/temp.decls/temp.variadic/injected-class-name.cpp b/test/CXX/temp/temp.decls/temp.variadic/injected-class-name.cpp deleted file mode 100644 index c09c0b243a92..000000000000 --- a/test/CXX/temp/temp.decls/temp.variadic/injected-class-name.cpp +++ /dev/null @@ -1,76 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s -// expected-no-diagnostics - -// Check for declaration matching with out-of-line declarations and -// variadic templates, which involves proper computation of the -// injected-class-name. -template<typename T, typename ...Types> -struct X0 { - typedef T type; - - void f0(T); - type f1(T); -}; - -template<typename T, typename ...Types> -void X0<T, Types...>::f0(T) { } - -template<typename T, typename ...Types> -typename X0<T, Types...>::type X0<T, Types...>::f1(T) { } - -template<typename T, typename ...Types> -struct X0<T, T, Types...> { - typedef T* result; - result f3(); - - template<typename... InnerTypes> - struct Inner; -}; - -template<typename T, typename ...Types> -typename X0<T, T, Types...>::result X0<T, T, Types...>::f3() { return 0; } - -template<typename T, typename ...Types> -template<typename ...InnerTypes> -struct X0<T, T, Types...>::Inner { - template<typename ...ReallyInner> void f4(); -}; - -template<typename T, typename ...Types> -template<typename ...InnerTypes> -template<typename ...ReallyInner> -void X0<T, T, Types...>::Inner<InnerTypes...>::f4() { } - -namespace rdar8848837 { - // Out-of-line definitions that cause rebuilding in the current - // instantiation. - template<typename F> struct X; - - template<typename R, typename ...ArgTypes> - struct X<R(ArgTypes...)> { - X<R(ArgTypes...)> f(); - }; - - template<typename R, typename ...ArgTypes> - X<R(ArgTypes...)> X<R(ArgTypes...)>::f() { return *this; } - - - X<int(float, double)> xif; - - template<unsigned> struct unsigned_c { }; - template<typename ...ArgTypes> int g(ArgTypes...); - - template<typename F> struct X1; - - template<typename R, typename ...ArgTypes> - struct X1<R(ArgTypes...)> { - unsigned_c<sizeof(1 + g(ArgTypes()...))> f(); - }; - - template<typename R, typename ...ArgTypes> - unsigned_c<sizeof(1 + g(ArgTypes()...))> X1<R(ArgTypes...)>::f() { - return unsigned_c<sizeof(int)>(); - } - - X1<int(float, double)> xif2; -} diff --git a/test/CXX/temp/temp.decls/temp.variadic/metafunctions.cpp b/test/CXX/temp/temp.decls/temp.variadic/metafunctions.cpp deleted file mode 100644 index f1231f61111e..000000000000 --- a/test/CXX/temp/temp.decls/temp.variadic/metafunctions.cpp +++ /dev/null @@ -1,274 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s - -// This is a collection of various template metafunctions involving -// variadic templates, which are meant to exercise common use cases. -template<typename T, typename U> -struct is_same { - static const bool value = false; -}; - -template<typename T> -struct is_same<T, T> { - static const bool value = true; -}; - -template<typename...> struct tuple { }; -template<int ...> struct int_tuple { }; -template<typename T, typename U> struct pair { }; - -namespace Count { - template<typename Head, typename ...Tail> - struct count { - static const unsigned value = 1 + count<Tail...>::value; - }; - - template<typename T> - struct count<T> { - static const unsigned value = 1; - }; - - int check1[count<int>::value == 1? 1 : -1]; - int check2[count<float, double>::value == 2? 1 : -1]; - int check3[count<char, signed char, unsigned char>::value == 3? 1 : -1]; -} - -namespace CountWithPackExpansion { - template<typename ...> struct count; - - template<typename Head, typename ...Tail> - struct count<Head, Tail...> { - static const unsigned value = 1 + count<Tail...>::value; - }; - - template<> - struct count<> { - static const unsigned value = 0; - }; - - int check0[count<>::value == 0? 1 : -1]; - int check1[count<int>::value == 1? 1 : -1]; - int check2[count<float, double>::value == 2? 1 : -1]; - int check3[count<char, signed char, unsigned char>::value == 3? 1 : -1]; -} - -namespace Replace { - // Simple metafunction that replaces the template arguments of - // template template parameters with 'int'. - template<typename T> - struct EverythingToInt; - - template<template<typename ...> class TT, typename T1, typename T2> - struct EverythingToInt<TT<T1, T2> > { - typedef TT<int, int> type; - }; - - int check0[is_same<EverythingToInt<tuple<double, float>>::type, - tuple<int, int>>::value? 1 : -1]; -} - -namespace Math { - template<int ...Values> - struct double_values { - typedef int_tuple<Values*2 ...> type; - }; - - int check0[is_same<double_values<1, 2, -3>::type, - int_tuple<2, 4, -6>>::value? 1 : -1]; - - template<int ...Values> - struct square { - typedef int_tuple<(Values*Values)...> type; - }; - - int check1[is_same<square<1, 2, -3>::type, - int_tuple<1, 4, 9>>::value? 1 : -1]; - - template<typename IntTuple> struct square_tuple; - - template<int ...Values> - struct square_tuple<int_tuple<Values...>> { - typedef int_tuple<(Values*Values)...> type; - }; - - int check2[is_same<square_tuple<int_tuple<1, 2, -3> >::type, - int_tuple<1, 4, 9>>::value? 1 : -1]; - - template<int ...Values> struct sum; - - template<int First, int ...Rest> - struct sum<First, Rest...> { - static const int value = First + sum<Rest...>::value; - }; - - template<> - struct sum<> { - static const int value = 0; - }; - - int check3[sum<1, 2, 3, 4, 5>::value == 15? 1 : -1]; - - template<int ... Values> - struct lazy_sum { - int operator()() { - return sum<Values...>::value; - } - }; - - void f() { - lazy_sum<1, 2, 3, 4, 5>()(); - } -} - -namespace ListMath { - template<typename T, T ... V> struct add; - - template<typename T, T i, T ... V> - struct add<T, i, V...> { - static const T value = i + add<T, V...>::value; - }; - - template<typename T> - struct add<T> { - static const T value = T(); - }; - - template<typename T, T ... V> - struct List { - struct sum { - static const T value = add<T, V...>::value; - }; - }; - - template<int ... V> - struct ListI : public List<int, V...> { - }; - - int check0[ListI<1, 2, 3>::sum::value == 6? 1 : -1]; -} - -namespace Indices { - template<unsigned I, unsigned N, typename IntTuple> - struct build_indices_impl; - - template<unsigned I, unsigned N, int ...Indices> - struct build_indices_impl<I, N, int_tuple<Indices...> > - : build_indices_impl<I+1, N, int_tuple<Indices..., I> > { - }; - - template<unsigned N, int ...Indices> - struct build_indices_impl<N, N, int_tuple<Indices...> > { - typedef int_tuple<Indices...> type; - }; - - template<unsigned N> - struct build_indices : build_indices_impl<0, N, int_tuple<> > { }; - - int check0[is_same<build_indices<5>::type, - int_tuple<0, 1, 2, 3, 4>>::value? 1 : -1]; -} - -namespace TemplateTemplateApply { - template<typename T, template<class> class ...Meta> - struct apply_each { - typedef tuple<typename Meta<T>::type...> type; - }; - - template<typename T> - struct add_reference { - typedef T& type; - }; - - template<typename T> - struct add_pointer { - typedef T* type; - }; - - template<typename T> - struct add_const { - typedef const T type; - }; - - int check0[is_same<apply_each<int, - add_reference, add_pointer, add_const>::type, - tuple<int&, int*, int const>>::value? 1 : -1]; - - template<typename T, template<class> class ...Meta> - struct apply_each_indirect { - typedef typename apply_each<T, Meta...>::type type; - }; - - int check1[is_same<apply_each_indirect<int, add_reference, add_pointer, - add_const>::type, - tuple<int&, int*, int const>>::value? 1 : -1]; - - template<typename T, typename ...Meta> - struct apply_each_nested { - typedef typename apply_each<T, Meta::template apply...>::type type; - }; - - struct add_reference_meta { - template<typename T> - struct apply { - typedef T& type; - }; - }; - - struct add_pointer_meta { - template<typename T> - struct apply { - typedef T* type; - }; - }; - - struct add_const_meta { - template<typename T> - struct apply { - typedef const T type; - }; - }; - - int check2[is_same<apply_each_nested<int, add_reference_meta, - add_pointer_meta, add_const_meta>::type, - tuple<int&, int*, int const>>::value? 1 : -1]; - -} - -namespace FunctionTypes { - template<typename FunctionType> - struct Arity; - - template<typename R, typename ...Types> - struct Arity<R(Types...)> { - static const unsigned value = sizeof...(Types); - }; - - template<typename R, typename ...Types> - struct Arity<R(Types......)> { // expected-warning {{varargs}} expected-note {{pack}} expected-note {{insert ','}} - static const unsigned value = sizeof...(Types); - }; - - template<typename R, typename T1, typename T2, typename T3, typename T4> - struct Arity<R(T1, T2, T3, T4)>; // expected-note{{template is declared here}} - - int check0[Arity<int()>::value == 0? 1 : -1]; - int check1[Arity<int(float, double)>::value == 2? 1 : -1]; - int check2[Arity<int(float...)>::value == 1? 1 : -1]; - int check3[Arity<int(float, double, long double...)>::value == 3? 1 : -1]; - Arity<int(float, double, long double, char)> check4; // expected-error{{implicit instantiation of undefined template 'FunctionTypes::Arity<int (float, double, long double, char)>'}} -} - -namespace SuperReplace { - template<typename T> - struct replace_with_int { - typedef int type; - }; - - template<template<typename ...> class TT, typename ...Types> - struct replace_with_int<TT<Types...>> { - typedef TT<typename replace_with_int<Types>::type...> type; - }; - - int check0[is_same<replace_with_int<pair<tuple<float, double, short>, - pair<char, unsigned char>>>::type, - pair<tuple<int, int, int>, pair<int, int>>>::value? 1 : -1]; -} diff --git a/test/CXX/temp/temp.decls/temp.variadic/multi-level-substitution.cpp b/test/CXX/temp/temp.decls/temp.variadic/multi-level-substitution.cpp deleted file mode 100644 index 82114cfa9dea..000000000000 --- a/test/CXX/temp/temp.decls/temp.variadic/multi-level-substitution.cpp +++ /dev/null @@ -1,318 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s - -template<typename T, T ...Values> struct value_tuple {}; -template<typename...> struct tuple { }; -template<typename T, typename U> struct pair { }; - -template<typename T, T Value> struct value_c; - -template<typename T, typename U> -struct is_same { - static const bool value = false; -}; - -template<typename T> -struct is_same<T, T> { - static const bool value = true; -}; - -template<typename T> -struct X0 { - template<T ...Values> - void f(value_tuple<T, Values...> * = 0); -}; - -void test_X0() { - X0<int>().f<1, 2, 3, 4, 5>(); -} - -namespace PacksAtDifferentLevels { - - template<typename ...Types> - struct X { - template<typename> struct Inner { - static const unsigned value = 1; - }; - - template<typename ...YTypes> - struct Inner<tuple<pair<Types, YTypes>...> > { - static const unsigned value = sizeof...(Types) - sizeof...(YTypes); - }; - }; - - int check0[X<short, int, long>::Inner<tuple<pair<short, unsigned short>, - pair<int, unsigned int>, - pair<long, unsigned long>> - >::value == 0? 1 : -1]; - - int check1[X<short, int>::Inner<tuple<pair<short, unsigned short>, - pair<int, unsigned int>, - pair<long, unsigned long>> - >::value == 1? 1 : -1]; - - template<unsigned ...Values> struct unsigned_tuple { }; - template<typename ...Types> - struct X1 { - template<typename, typename> struct Inner { - static const unsigned value = 0; - }; - - template<typename ...YTypes> - struct Inner<tuple<pair<Types, YTypes>...>, - unsigned_tuple<sizeof(Types) + sizeof(YTypes)...>> { - static const unsigned value = 1; - }; - }; - - int check2[X1<short, int, long>::Inner<tuple<pair<short, unsigned short>, - pair<int, unsigned int>, - pair<long, unsigned long>>, - unsigned_tuple<sizeof(short) + sizeof(unsigned short), - sizeof(int) + sizeof(unsigned int), - sizeof(long) + sizeof(unsigned long)> - >::value == 1? 1 : -1]; - int check3[X1<short, int>::Inner<tuple<pair<short, unsigned short>, - pair<int, unsigned int>, - pair<long, unsigned long>>, - unsigned_tuple<sizeof(short) + sizeof(unsigned short), - sizeof(int) + sizeof(unsigned int), - sizeof(long) + sizeof(unsigned long)> - >::value == 0? 1 : -1]; - - template<typename ...Types> - struct X2 { - template<typename> struct Inner { - static const unsigned value = 1; - }; - - template<typename R, typename ...YTypes> - struct Inner<R(pair<Types, YTypes>...)> { - static const unsigned value = sizeof...(Types) - sizeof...(YTypes); - }; - }; - - int check4[X2<short, int, long>::Inner<int(pair<short, unsigned short>, - pair<int, unsigned int>, - pair<long, unsigned long>) - >::value == 0? 1 : -1]; - - int check5[X2<short, int>::Inner<int(pair<short, unsigned short>, - pair<int, unsigned int>, - pair<long, unsigned long>) - >::value == 1? 1 : -1]; - - template<typename T, typename U> - struct some_function_object { - template<typename> - struct result_of; - }; - - template<template<class> class...> struct metafun_tuple { }; - - template<typename ...Types1> - struct X3 { - template<typename, typename> struct Inner { - static const unsigned value = 0; - }; - - template<typename ...Types2> - struct Inner<tuple<pair<Types1, Types2>...>, - metafun_tuple<some_function_object<Types1, Types2>::template result_of...> > { - static const unsigned value = 1; - }; - }; - - int check6[X3<short, int, long>::Inner<tuple<pair<short, unsigned short>, - pair<int, unsigned int>, - pair<long, unsigned long>>, - metafun_tuple< - some_function_object<short, unsigned short>::result_of, - some_function_object<int, unsigned int>::result_of, - some_function_object<long, unsigned long>::result_of> - >::value == 1? 1 : -1]; - int check7[X3<short, int>::Inner<tuple<pair<short, unsigned short>, - pair<int, unsigned int>, - pair<long, unsigned long>>, - metafun_tuple< - some_function_object<short, unsigned short>::result_of, - some_function_object<int, unsigned int>::result_of, - some_function_object<long, unsigned long>::result_of> - >::value == 0? 1 : -1]; - - template<unsigned I, unsigned J> struct unsigned_pair { }; - - template<unsigned ...Values1> - struct X4 { - template<typename> struct Inner { - static const unsigned value = 0; - }; - - template<unsigned ...Values2> - struct Inner<tuple<unsigned_pair<Values1, Values2>...>> { - static const unsigned value = 1; - }; - }; - - int check8[X4<1, 3, 5>::Inner<tuple<unsigned_pair<1, 2>, - unsigned_pair<3, 4>, - unsigned_pair<5, 6>> - >::value == 1? 1 : -1]; - int check9[X4<1, 3>::Inner<tuple<unsigned_pair<1, 2>, - unsigned_pair<3, 4>, - unsigned_pair<5, 6>> - >::value == 0? 1 : -1]; - - template<class> struct add_reference; - template<class> struct add_pointer; - template<class> struct add_const; - - template<template<class> class ...Templates> - struct X5 { - template<typename> struct Inner { - static const unsigned value = 0; - }; - - template<typename ...Types> - struct Inner<tuple<Templates<Types>...>> { - static const unsigned value = 1; - }; - }; - - int check10[X5<add_reference, add_pointer, add_const> - ::Inner<tuple<add_reference<int>, - add_pointer<float>, - add_const<double>>>::value == 1? 1 : -1]; - int check11[X5<add_reference, add_pointer> - ::Inner<tuple<add_reference<int>, - add_pointer<float>, - add_const<double>>>::value == 0? 1 : -1]; - - namespace PR13811 { - constexpr int g(int n, int m) { return n * 10 + m; } - - template<typename...A> - struct X6 { - template<typename...B> - constexpr auto f1(A ...a) const -> decltype(g(A(a + B())...)) { return g(A(a + B())...); } - - template<typename...B> - constexpr auto f2(A ...a, B ...b) const -> decltype(g((&a)[b] ...)) { return g((&a)[b] ...); } // expected-note {{past-the-end}} - - template<typename...B> struct Inner { - template<typename...C> - constexpr auto f(A ...a, B ...b, C ...c) const -> decltype(g(a+b+c...)) { return g(a+b+c...); } - }; - }; - struct A { constexpr operator int() const { return 2; } }; - struct B { constexpr operator int() const { return 1; } }; - - static_assert(X6<unsigned char, int>().f1<A, B>(255, 1) == 12, ""); - static_assert(X6<int, int>().f2(3, 4, 0, 0) == 34, ""); - static_assert(X6<int, int>().f2(3, 4, 0, 1) == 34, ""); // expected-error {{constant expression}} expected-note {{in call}} - static_assert(X6<int, int>::Inner<int, int>().f(1, 2, 3, 4, 5, 6) == 102, ""); - } -} - -namespace ExpandingNonTypeTemplateParameters { - template<typename ...Types> - struct tuple_of_values { - template<Types ...Values> // expected-error{{a non-type template parameter cannot have type 'float'}} \ - // expected-note{{template parameter is declared here}} - struct apply { // expected-note 2{{template is declared here}} - typedef tuple<value_c<Types, Values>...> type; - }; - }; - - int i; - float f; - int check_tuple_of_values_1[ - is_same<tuple_of_values<int&, float&, char, int>::apply<i, f, 'a', 17> - ::type, - tuple<value_c<int&, i>, value_c<float&, f>, value_c<char, 'a'>, - value_c<int, 17>> - >::value? 1 : -1]; - - tuple_of_values<int, float> tv1; // expected-note{{in instantiation of template class 'ExpandingNonTypeTemplateParameters::tuple_of_values<int, float>' requested here}} - - tuple_of_values<int&, float&>::apply<i, i>::type tv2; // expected-error{{non-type template parameter of reference type 'float &' cannot bind to template argument of type 'int'}} - - tuple_of_values<int&, float&>::apply<i>::type tv3; // expected-error{{too few template arguments for class template 'apply'}} - - tuple_of_values<int&, float&>::apply<i, f, i>::type tv4; // expected-error{{too many template arguments for class template 'apply'}} -} - -namespace ExpandingFunctionParameters { - template<typename ...T> - struct X0 { - typedef int type; - }; - - template<typename ...T> - struct X1 { - template<typename ... U> - typename X0<T(T, U...)...>::type f(U...); - }; - - void test() { - X1<float> x1; - x1.f(17, 3.14159); - } -} - -namespace PR10230 { - template<typename> - struct s - { - template<typename... Args> - auto f() -> int(&)[sizeof...(Args)]; - }; - - void main() - { - int (&ir1)[1] = s<int>().f<int>(); - int (&ir3)[3] = s<int>().f<int, float, double>(); - } -} - -namespace PR13386 { - template<typename...> struct tuple {}; - template<typename...T> - struct S { - template<typename...U> - void f(T &&...t, U &&...u) {} // expected-note {{candidate}} - template<typename...U> - void g(U &&...u, T &&...t) {} // expected-note {{candidate}} - template<typename...U> - void h(tuple<T, U> &&...) {} // expected-note 2{{candidate}} - - template<typename...U> - struct X { - template<typename...V> - void x(tuple<T, U, V> &&...); // expected-error {{different lengths}} - }; - }; - - void test() { - S<>().f(); - S<>().f(0); - S<int>().f(0); - S<int>().f(0, 1); - S<int, int>().f(0); // expected-error {{no matching member function for call}} - - S<>().g(); - S<>().g(0); - S<int>().g(0); - S<int>().g(0, 1); // expected-error {{no matching member function for call}} - S<int>().g<int>(0, 1); - S<int, int>().g(0, 1); - - S<>().h(); - S<>().h(0); // expected-error {{no matching member function for call}} - S<int>().h({}); // expected-error {{no matching member function for call}} - S<int>().h<int>({}); - S<int>().h(tuple<int,int>{}); - S<int, int>().h(tuple<int,int>{}, tuple<int,int>{}); - - S<int, int>::X<char>(); // expected-note {{here}} - } -} diff --git a/test/CXX/temp/temp.decls/temp.variadic/p1.cpp b/test/CXX/temp/temp.decls/temp.variadic/p1.cpp deleted file mode 100644 index daff9d189690..000000000000 --- a/test/CXX/temp/temp.decls/temp.variadic/p1.cpp +++ /dev/null @@ -1,9 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s - -template<class ...Types> struct Tuple; - -Tuple<> *t0; -Tuple<int> *t1; -Tuple<int, char> *t2a; -Tuple<int, float> *t2b = t2a; // expected-error{{cannot initialize a variable of type 'Tuple<int, float> *' with an lvalue of type 'Tuple<int, char> *'}} -Tuple<int, float, double> *t3; diff --git a/test/CXX/temp/temp.decls/temp.variadic/p2.cpp b/test/CXX/temp/temp.decls/temp.variadic/p2.cpp deleted file mode 100644 index e7a62366a9be..000000000000 --- a/test/CXX/temp/temp.decls/temp.variadic/p2.cpp +++ /dev/null @@ -1,22 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s - -template<class ... Types> void f(Types ... args); - -void test() { - f(); - f(1); - f(2, 1.0); -} - -// Test simple recursive variadic function template -template<typename Head, typename ...Tail> -void recurse_until_fail(const Head &, const Tail &...tail) { // expected-note{{candidate function template not viable: requires at least 1 argument, but 0 were provided}} - recurse_until_fail(tail...); // expected-error{{no matching function for call to 'recurse_until_fail'}} \ - // expected-note{{in instantiation of function template specialization 'recurse_until_fail<char [7]>' requested here}} \ - // expected-note{{in instantiation of function template specialization 'recurse_until_fail<double, char [7]>' requested here}} -} - -void test_recurse_until_fail() { - recurse_until_fail(1, 3.14159, "string"); // expected-note{{in instantiation of function template specialization 'recurse_until_fail<int, double, char [7]>' requested here}} - -} diff --git a/test/CXX/temp/temp.decls/temp.variadic/p4.cpp b/test/CXX/temp/temp.decls/temp.variadic/p4.cpp deleted file mode 100644 index 1681325f2e6c..000000000000 --- a/test/CXX/temp/temp.decls/temp.variadic/p4.cpp +++ /dev/null @@ -1,291 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -fsyntax-only -fexceptions -fcxx-exceptions -verify %s -// RUN: %clang_cc1 -std=c++2a -fsyntax-only -fexceptions -fcxx-exceptions -verify %s - -template<typename... Types> struct tuple; -template<int I> struct int_c; - -template<typename T> -struct identity { - typedef T type; -}; - -template<typename T, typename U> -struct is_same { - static const bool value = false; -}; - -template<typename T> -struct is_same<T, T> { - static const bool value = true; -}; - -// FIXME: Several more bullets to go - -// In a function parameter pack, the pattern is the parameter-declaration -// without the ellipsis. -namespace PR11850 { - template<typename ...T> struct S { - int f(T...a, int b) { return b; } - }; - S<> s; - S<int*, char, const double&> t; - int k = s.f(0); - int l = t.f(&k, 'x', 5.9, 4); - - template<typename ...As> struct A { - template<typename ...Bs> struct B { - template<typename ...Cs> struct C { - C(As..., Bs..., int &k, Cs...); - }; - }; - }; - A<>::B<>::C<> c000(k); - A<int>::B<>::C<int> c101(1, k, 3); - A<>::B<int>::C<int> c011(1, k, 3); - A<int>::B<int>::C<> c110(1, 2, k); - A<int, int>::B<int, int>::C<int, int> c222(1, 2, 3, 4, k, 5, 6); - A<int, int, int>::B<>::C<> c300(1, 2, 3, k); - - int &f(); - char &f(void*); - template<typename ...A> struct U { - template<typename ...B> struct V { - auto g(A...a, B...b) -> decltype(f(a...)); - }; - }; - U<>::V<int*> v0; - U<int*>::V<> v1; - int &v0f = v0.g(0); - char &v1f = v1.g(0); -} -namespace PR12096 { - void Foo(int) {} - void Foo(int, int) = delete; - template<typename ...Args> struct Var { - Var(const Args &...args, int *) { Foo(args...); } - }; - Var<int> var(1, 0); -} - -// In an initializer-list (8.5); the pattern is an initializer-clause. -// Note: this also covers expression-lists, since expression-list is -// just defined as initializer-list. -void five_args(int, int, int, int, int); // expected-note{{candidate function not viable: requires 5 arguments, but 6 were provided}} - -template<int ...Values> -void initializer_list_expansion() { - int values[5] = { Values... }; // expected-error{{excess elements in array initializer}} - five_args(Values...); // expected-error{{no matching function for call to 'five_args'}} -} - -template void initializer_list_expansion<1, 2, 3, 4, 5>(); -template void initializer_list_expansion<1, 2, 3, 4, 5, 6>(); // expected-note{{in instantiation of function template specialization 'initializer_list_expansion<1, 2, 3, 4, 5, 6>' requested here}} - -namespace PR8977 { - struct A { }; - template<typename T, typename... Args> void f(Args... args) { - // An empty expression-list performs value initialization. - constexpr T t(args...); - }; - - template void f<A>(); -} - -// In a base-specifier-list (Clause 10); the pattern is a base-specifier. -template<typename ...Mixins> -struct HasMixins : public Mixins... { - HasMixins(); - HasMixins(const HasMixins&); - HasMixins(int i); -}; - -struct A { }; // expected-note{{candidate constructor (the implicit copy constructor) not viable: no known conversion from 'int' to 'const A' for 1st argument}} \ -// expected-note{{candidate constructor (the implicit move constructor) not viable: no known conversion from 'int' to 'A' for 1st argument}} \ -// expected-note{{candidate constructor (the implicit default constructor) not viable: requires 0 arguments, but 1 was provided}} -struct B { }; -struct C { }; -struct D { }; - -A *checkA = new HasMixins<A, B, C, D>; -B *checkB = new HasMixins<A, B, C, D>; -D *checkD = new HasMixins<A, B, C, D>; -C *checkC = new HasMixins<A, B, D>; // expected-error{{cannot initialize a variable of type 'C *' with an rvalue of type 'HasMixins<A, B, D> *'}} -HasMixins<> *checkNone = new HasMixins<>; - -template<typename Mixins> -struct BrokenMixins : public Mixins... { }; // expected-error{{pack expansion does not contain any unexpanded parameter packs}} - -// In a mem-initializer-list (12.6.2); the pattern is a mem-initializer. -template<typename ...Mixins> -HasMixins<Mixins...>::HasMixins(): Mixins()... { } - -template<typename ...Mixins> -HasMixins<Mixins...>::HasMixins(const HasMixins &other): Mixins(other)... { } - -template<typename ...Mixins> -HasMixins<Mixins...>::HasMixins(int i): Mixins(i)... { } // expected-error{{no matching constructor for initialization of 'A'}} - -void test_has_mixins() { - HasMixins<A, B> ab; - HasMixins<A, B> ab2 = ab; - HasMixins<A, B> ab3(17); // expected-note{{in instantiation of member function 'HasMixins<A, B>::HasMixins' requested here}} -} - -template<typename T> -struct X { - T member; - - X() : member()... { } // expected-error{{pack expansion for initialization of member 'member'}} -}; - -// There was a bug in the delayed parsing code for the -// following case. -template<typename ...T> -struct DelayedParseTest : T... -{ - int a; - DelayedParseTest(T... i) : T{i}..., a{10} {} -}; - - -// In a template-argument-list (14.3); the pattern is a template-argument. -template<typename ...Types> -struct tuple_of_refs { - typedef tuple<Types& ...> types; -}; - -tuple<int&, float&> *t_int_ref_float_ref; -tuple_of_refs<int&, float&>::types *t_int_ref_float_ref_2 = t_int_ref_float_ref; - -template<typename ...Types> -struct extract_nested_types { - typedef tuple<typename Types::type...> types; -}; - -tuple<int, float> *t_int_float; -extract_nested_types<identity<int>, identity<float> >::types *t_int_float_2 - = t_int_float; - -template<int ...N> -struct tuple_of_ints { - typedef tuple<int_c<N>...> type; -}; - -int check_temp_arg_1[is_same<tuple_of_ints<1, 2, 3, 4, 5>::type, - tuple<int_c<1>, int_c<2>, int_c<3>, int_c<4>, - int_c<5>>>::value? 1 : -1]; - -#if __cplusplus < 201703L -// In a dynamic-exception-specification (15.4); the pattern is a type-id. -template<typename ...Types> -struct f_with_except { - virtual void f() throw(Types...); // expected-note{{overridden virtual function is here}} -}; - -struct check_f_with_except_1 : f_with_except<int, float> { - virtual void f() throw(int, float); -}; - -struct check_f_with_except_2 : f_with_except<int, float> { - virtual void f() throw(int); -}; - -struct check_f_with_except_3 : f_with_except<int, float> { - virtual void f() throw(int, float, double); // expected-error{{exception specification of overriding function is more lax than base version}} -}; -#endif - -namespace PackExpansionWithinLambda { - void swallow(...); - template<typename ...T, typename ...U> void f(U ...u) { - swallow([=] { - // C++17 [temp.variadic]p4: - // Pack expansions can occur in the following contexts: - - // - in a function parameter pack - void g(T...); - -#if __cplusplus >= 201703L - struct A : T... { - // - in a using-declaration - using T::x...; - using typename T::U...; - }; -#endif - - // - in a template parameter pack that is a pack expansion - // FIXME: We do not support any way to reach this case yet. - - // - in an initializer-list - int arr[] = {T().x...}; - - // - in a base-specifier-list - struct B : T... { - // - in a mem-initializer-list - B() : T{0}... {} - }; - - // - in a template-argument-list - f<T...>(); - - // - in an attribute-list - // FIXME: We do not support any such attributes yet. - - // - in an alignment-specifier - alignas(T...) int y; - - // - in a capture-list - [](T ...t) { [t...]{}(); } (T()...); - - // - in a sizeof... expression - const int k1 = sizeof...(T); - -#if __cplusplus >= 201703L - // - in a fold-expression - const int k2 = ((sizeof(T)/sizeof(T)) + ...); - - static_assert(k1 == k2); -#endif - - // Trigger clang to look in here for unexpanded packs. - U u; - } ...); - } - - template<typename ...T> void nested() { - swallow([=] { - [](T ...t) { [t]{}(); } (T()...); // expected-error {{unexpanded parameter pack 't'}} - }...); // expected-error {{does not contain any unexpanded}} - } - - template <typename ...T> void g() { - // Check that we do detect the above cases when the pack is not expanded. - swallow([=] { void h(T); }); // expected-error {{unexpanded parameter pack 'T'}} - swallow([=] { struct A : T {}; }); // expected-error {{unexpanded parameter pack 'T'}} -#if __cplusplus >= 201703L - swallow([=] { struct A : T... { using T::x; }; }); // expected-error {{unexpanded parameter pack 'T'}} - swallow([=] { struct A : T... { using typename T::U; }; }); // expected-error {{unexpanded parameter pack 'T'}} -#endif - - swallow([=] { int arr[] = {T().x}; }); // expected-error {{unexpanded parameter pack 'T'}} - swallow([=] { struct B : T... { B() : T{0} {} }; }); // expected-error {{unexpanded parameter pack 'T'}} - swallow([=] { f<T>(); }); // expected-error {{unexpanded parameter pack 'T'}} - swallow([=] { alignas(T) int y; }); // expected-error {{unexpanded parameter pack 'T'}} - swallow([=] { [](T ...t) { - [t]{}(); // expected-error {{unexpanded parameter pack 't'}} - } (T()...); }); - } - - struct T { int x; using U = int; }; - void g() { f<T>(1, 2, 3); } - - template<typename ...T, typename ...U> void pack_in_lambda(U ...u) { // expected-note {{here}} - // FIXME: Move this test into 'f' above once we support this syntax. - []<T *...v, template<T *> typename ...U>(U<v> ...uv) {}; // expected-error {{expected body of lambda}} expected-error {{does not refer to a value}} - } - - template<typename ...T> void pack_expand_attr() { - // FIXME: Move this test into 'f' above once we support this. - [[gnu::aligned(alignof(T))...]] int x; // expected-error {{cannot be used as an attribute pack}} expected-error {{unexpanded}} - } -} diff --git a/test/CXX/temp/temp.decls/temp.variadic/p5.cpp b/test/CXX/temp/temp.decls/temp.variadic/p5.cpp deleted file mode 100644 index 206e9f73e9f0..000000000000 --- a/test/CXX/temp/temp.decls/temp.variadic/p5.cpp +++ /dev/null @@ -1,471 +0,0 @@ -// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -std=c++11 -fblocks -fms-extensions -fsyntax-only -verify %s - -template<typename T, typename U> struct pair; -template<typename ...> struct tuple; - -// A parameter pack whose name appears within the pattern of a pack -// expansion is expanded by that pack expansion. An appearance of the -// name of a parameter pack is only expanded by the innermost -// enclosing pack expansion. The pattern of a pack expansion shall -// name one or more parameter packs that are not expanded by a nested -// pack expansion. -template<typename... Types> -struct Expansion { - typedef pair<Types..., int> expand_with_pacs; // okay - typedef pair<Types, int...> expand_no_packs; // expected-error{{pack expansion does not contain any unexpanded parameter packs}} - typedef pair<pair<Types..., int>..., int> expand_with_expanded_nested; // expected-error{{pack expansion does not contain any unexpanded parameter packs}} -}; - -// All of the parameter packs expanded by a pack expansion shall have -// the same number of arguments specified. -template<typename ...Types> -struct ExpansionLengthMismatch { - template<typename ...OtherTypes> - struct Inner { - typedef tuple<pair<Types, OtherTypes>...> type; // expected-error{{pack expansion contains parameter packs 'Types' and 'OtherTypes' that have different lengths (3 vs. 2)}} - }; -}; - -ExpansionLengthMismatch<int, long>::Inner<unsigned int, unsigned long>::type - *il_pairs; -tuple<pair<int, unsigned int>, pair<long, unsigned long> >*il_pairs_2 = il_pairs; - -ExpansionLengthMismatch<short, int, long>::Inner<unsigned int, unsigned long>::type // expected-note{{in instantiation of template class 'ExpansionLengthMismatch<short, int, long>::Inner<unsigned int, unsigned long>' requested here}} - *il_pairs_bad; - - -// An appearance of a name of a parameter pack that is not expanded is -// ill-formed. - -// Test for unexpanded parameter packs in each of the type nodes. -template<typename T, int N, typename ... Types> -struct TestPPName - : public Types, public T // expected-error{{base type contains unexpanded parameter pack 'Types'}} -{ - // BuiltinType is uninteresting - // FIXME: ComplexType is uninteresting? - // PointerType - typedef Types *types_pointer; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} - - // BlockPointerType - typedef Types (^block_pointer_1)(int); // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} - typedef int (^block_pointer_2)(Types); // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} - - // LValueReferenceType - typedef Types &lvalue_ref; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} - - // RValueReferenceType - typedef Types &&rvalue_ref; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} - - // MemberPointerType - typedef Types TestPPName::* member_pointer_1; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} - typedef int Types::*member_pointer_2; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} - - // ConstantArrayType - typedef Types constant_array[17]; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} - - // IncompleteArrayType - typedef Types incomplete_array[]; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} - - // VariableArrayType - void f(int i) { - Types variable_array[i]; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} - } - - // DependentSizedArrayType - typedef Types dependent_sized_array[N]; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} - - // DependentSizedExtVectorType - typedef Types dependent_sized_ext_vector __attribute__((ext_vector_type(N))); // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} - - // VectorType is uninteresting - - // ExtVectorType - typedef Types ext_vector __attribute__((ext_vector_type(4))); // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} - - // FunctionProtoType - typedef Types (function_type_1)(int); // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} - typedef int (function_type_2)(Types); // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} - - // FunctionNoProtoType is uninteresting - // UnresolvedUsingType is uninteresting - // ParenType is uninteresting - // TypedefType is uninteresting - - // TypeOfExprType - typedef __typeof__((static_cast<Types>(0))) typeof_expr; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} - - // TypeOfType - typedef __typeof__(Types) typeof_type; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} - - // DecltypeType - typedef decltype((static_cast<Types>(0))) typeof_expr; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} - - // RecordType is uninteresting - // EnumType is uninteresting - // ElaboratedType is uninteresting - - // TemplateTypeParmType - typedef Types template_type_parm; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} - - // SubstTemplateTypeParmType is uninteresting - - // TemplateSpecializationType - typedef pair<Types, int> template_specialization; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} - - // InjectedClassName is uninteresting. - - // DependentNameType - typedef typename Types::type dependent_name; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} - - // DependentTemplateSpecializationType - typedef typename Types::template apply<int> dependent_name_1; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} - typedef typename T::template apply<Types> dependent_name_2; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} - - // ObjCObjectType is uninteresting - // ObjCInterfaceType is uninteresting - // ObjCObjectPointerType is uninteresting -}; - -// FIXME: Test for unexpanded parameter packs in each of the expression nodes. -template<int ...Values> -void test_unexpanded_in_exprs() { - // PredefinedExpr is uninteresting - // DeclRefExpr - Values; // expected-error{{expression contains unexpanded parameter pack 'Values'}} - // IntegerLiteral is uninteresting - // FloatingLiteral is uninteresting - // ImaginaryLiteral is uninteresting - // StringLiteral is uninteresting - // CharacterLiteral is uninteresting - (Values); // expected-error{{expression contains unexpanded parameter pack 'Values'}} - // UnaryOperator - -Values; // expected-error{{expression contains unexpanded parameter pack 'Values'}} - // OffsetOfExpr - struct OffsetMe { - int array[17]; - }; - __builtin_offsetof(OffsetMe, array[Values]); // expected-error{{expression contains unexpanded parameter pack 'Values'}} - // FIXME: continue this... -} - -template<typename ... Types> -void TestPPNameFunc(int i) { - f(static_cast<Types>(i)); // expected-error{{expression contains unexpanded parameter pack 'Types'}} -} - -template<typename T, template<class> class ...Meta> -struct TestUnexpandedTTP { - typedef tuple<typename Meta<T>::type> type; // expected-error{{declaration type contains unexpanded parameter pack 'Meta'}} -}; - -// Test for unexpanded parameter packs in declarations. -template<typename T, typename... Types> -// FIXME: this should test that the diagnostic reads "type contains..." -struct alignas(Types) TestUnexpandedDecls : T{ // expected-error{{expression contains unexpanded parameter pack 'Types'}} - void member_function(Types); // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} - void member_function () throw(Types); // expected-error{{exception type contains unexpanded parameter pack 'Types'}} - void member_function2() noexcept(Types()); // expected-error{{expression contains unexpanded parameter pack 'Types'}} - operator Types() const; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} - Types data_member; // expected-error{{data member type contains unexpanded parameter pack 'Types'}} - static Types static_data_member; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} - unsigned bit_field : static_cast<Types>(0); // expected-error{{bit-field size contains unexpanded parameter pack 'Types'}} - static_assert(static_cast<Types>(0), "Boom"); // expected-error{{static assertion contains unexpanded parameter pack 'Types'}} - - enum E0 : Types { // expected-error{{fixed underlying type contains unexpanded parameter pack 'Types'}} - EnumValue = static_cast<Types>(0) // expected-error{{enumerator value contains unexpanded parameter pack 'Types'}} - }; - - using typename Types::type; // expected-error{{using declaration contains unexpanded parameter pack 'Types'}} - using Types::value; // expected-error{{using declaration contains unexpanded parameter pack 'Types'}} - using T::operator Types; // expected-error{{using declaration contains unexpanded parameter pack 'Types'}} - - friend class Types::foo; // expected-error{{friend declaration contains unexpanded parameter pack 'Types'}} - friend void friend_func(Types); // expected-error{{friend declaration contains unexpanded parameter pack 'Types'}} - friend void Types::other_friend_func(int); // expected-error{{friend declaration contains unexpanded parameter pack 'Types'}} - - void test_initializers() { - T copy_init = static_cast<Types>(0); // expected-error{{initializer contains unexpanded parameter pack 'Types'}} - T direct_init(0, static_cast<Types>(0)); // expected-error{{initializer contains unexpanded parameter pack 'Types'}} - T list_init = { static_cast<Types>(0) }; // expected-error{{initializer contains unexpanded parameter pack 'Types'}} - } - - T in_class_member_init = static_cast<Types>(0); // expected-error{{initializer contains unexpanded parameter pack 'Types'}} - TestUnexpandedDecls() : - Types(static_cast<Types>(0)), // expected-error{{initializer contains unexpanded parameter pack 'Types'}} - Types(static_cast<Types>(0))..., - in_class_member_init(static_cast<Types>(0)) {} // expected-error{{initializer contains unexpanded parameter pack 'Types'}} - - void default_function_args(T = static_cast<Types>(0)); // expected-error{{default argument contains unexpanded parameter pack 'Types'}} - - template<typename = Types*> // expected-error{{default argument contains unexpanded parameter pack 'Types'}} - struct default_template_args_1; - template<int = static_cast<Types>(0)> // expected-error{{default argument contains unexpanded parameter pack 'Types'}} - struct default_template_args_2; - template<template<typename> class = Types::template apply> // expected-error{{default argument contains unexpanded parameter pack 'Types'}} - struct default_template_args_3; - - template<Types value> // expected-error{{non-type template parameter type contains unexpanded parameter pack 'Types'}} - struct non_type_template_param_type; - - void decls_in_stmts() { - Types t; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} - for (Types *t = 0; ; ) { } // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} - for (; Types *t = 0; ) { } // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} - T a[] = { T(), T(), T() }; - for (Types t : a) { } // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} - switch(Types *t = 0) { } // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} - while(Types *t = 0) { } // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} - if (Types *t = 0) { } // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} - try { - } catch (Types*) { // expected-error{{exception type contains unexpanded parameter pack 'Types'}} - } - } -}; - -// FIXME: Test for unexpanded parameter packs in each of the statements. -struct X { - void f(int, int); - template<typename ...Types> - void f(Types...); -}; - -namespace std { - class type_info; -} - -typedef struct _GUID { - unsigned long Data1; - unsigned short Data2; - unsigned short Data3; - unsigned char Data4[ 8 ]; -} GUID; - -template<typename T, typename ...Types> -void test_unexpanded_exprs(Types ...values) { - // CXXOperatorCallExpr - (void)(values + 0); // expected-error{{expression contains unexpanded parameter pack 'values'}} - (void)(0 + values); // expected-error{{expression contains unexpanded parameter pack 'values'}} - - // CXXMemberCallExpr - values.f(); // expected-error{{expression contains unexpanded parameter pack 'values'}} - X x; - x.f(values); // expected-error{{expression contains unexpanded parameter pack 'values'}} - x.Types::f(); // expected-error{{expression contains unexpanded parameter pack 'Types'}} - x.f<Types>(); // expected-error{{expression contains unexpanded parameter pack 'Types'}} - - // CXXStaticCastExpr - (void)static_cast<Types&>(values); // expected-error{{expression contains unexpanded parameter packs 'Types' and 'values'}} - - // CXXDynamicCastExpr - (void)dynamic_cast<Types&>(values); // expected-error{{expression contains unexpanded parameter packs 'Types' and 'values'}} - - // CXXReinterpretCastExpr - (void)reinterpret_cast<Types&>(values); // expected-error{{expression contains unexpanded parameter packs 'Types' and 'values'}} - - // CXXConstCastExpr - (void)const_cast<Types&>(values); // expected-error{{expression contains unexpanded parameter packs 'Types' and 'values'}} - - // CXXTypeidExpr - (void)typeid(Types); // expected-error{{expression contains unexpanded parameter pack 'Types'}} - (void)typeid(values); // expected-error{{expression contains unexpanded parameter pack 'values'}} - - // CXXUuidofExpr - (void)__uuidof(Types); // expected-error{{expression contains unexpanded parameter pack 'Types'}} - (void)__uuidof(values); // expected-error{{expression contains unexpanded parameter pack 'values'}} - - // CXXThisExpr is uninteresting - - // CXXThrowExpr - throw Types(); // expected-error{{expression contains unexpanded parameter pack 'Types'}} - throw values; // expected-error{{expression contains unexpanded parameter pack 'values'}} - - // CXXDefaultArgExpr is uninteresting - - // CXXBindTemporaryExpr is uninteresting - - // CXXConstructExpr is uninteresting - - // CXXFunctionalCastExpr - (void)Types(); // expected-error{{expression contains unexpanded parameter pack 'Types'}} - - // CXXTemporaryObjectExpr - (void)X(values); // expected-error{{expression contains unexpanded parameter pack 'values'}} - - // CXXScalarValueInitExpr is uninteresting - - // CXXNewExpr - (void)new Types; // expected-error{{expression contains unexpanded parameter pack 'Types'}} - (void)new X(values); // expected-error{{expression contains unexpanded parameter pack 'values'}} - (void)new (values) X(values); // expected-error{{expression contains unexpanded parameter pack 'values'}} - (void)new X [values]; // expected-error{{expression contains unexpanded parameter pack 'values'}} - - // CXXDeleteExpr - delete values; // expected-error{{expression contains unexpanded parameter pack 'values'}} - delete [] values; // expected-error{{expression contains unexpanded parameter pack 'values'}} - - // CXXPseudoDestructorExpr - T t; - values.~T(); // expected-error{{expression contains unexpanded parameter pack 'values'}} - t.~Types(); // expected-error{{expression contains unexpanded parameter pack 'Types'}} - t.Types::~T(); // expected-error{{expression contains unexpanded parameter pack 'Types'}} - - // Unary TypeTraitExpr - __is_pod(Types); // expected-error{{expression contains unexpanded parameter pack 'Types'}} - - // Binary TypeTraitExpr - __is_base_of(Types, T); // expected-error{{expression contains unexpanded parameter pack 'Types'}} - __is_base_of(T, Types); // expected-error{{expression contains unexpanded parameter pack 'Types'}} - - // UnresolvedLookupExpr - test_unexpanded_exprs(values); // expected-error{{expression contains unexpanded parameter pack 'values'}} - test_unexpanded_exprs<Types>(); // expected-error{{expression contains unexpanded parameter pack 'Types'}} - - // DependentScopeDeclRefExpr - Types::test_unexpanded_exprs(); // expected-error{{expression contains unexpanded parameter pack 'Types'}} - T::template test_unexpanded_exprs<Types>(); // expected-error{{expression contains unexpanded parameter pack 'Types'}} - - // CXXUnresolvedConstructExpr - Types(5); // expected-error{{expression contains unexpanded parameter pack 'Types'}} - - // CXXDependentScopeMemberExpr - values.foo(); // expected-error{{expression contains unexpanded parameter pack 'values'}} - t.foo(values); // expected-error{{expression contains unexpanded parameter pack 'values'}} - - // FIXME: There's an evil ambiguity here, because we don't know if - // Types refers to the template type parameter pack in scope or a - // non-pack member. - // t.Types::foo(); - - t.template foo<Types>(); // expected-error{{expression contains unexpanded parameter pack 'Types'}} - - // UnresolvedMemberExpr - x.f<Types>(); // expected-error{{expression contains unexpanded parameter pack 'Types'}} - x.f(values); // expected-error{{expression contains unexpanded parameter pack 'values'}} - - // CXXNoexceptExpr - noexcept(values); // expected-error{{expression contains unexpanded parameter pack 'values'}} - - // PackExpansionExpr is uninteresting - // SizeOfPackExpr is uninteresting - - // FIXME: Objective-C expressions will need to go elsewhere - - for (auto t : values) { } // expected-error{{expression contains unexpanded parameter pack 'values'}} - - switch (values) { } // expected-error{{expression contains unexpanded parameter pack 'values'}} - switch (0) { case 0: case values: ; } // expected-error{{expression contains unexpanded parameter pack 'values'}} - - do { } while (values); // expected-error{{expression contains unexpanded parameter pack 'values'}} - -test: - goto *values; // expected-error{{expression contains unexpanded parameter pack 'values'}} - - void f(int arg = values); // expected-error{{default argument contains unexpanded parameter pack 'values'}} -} - -// Test unexpanded parameter packs in partial specializations. -template<typename ...Types> -struct TestUnexpandedDecls<int, Types>; // expected-error{{partial specialization contains unexpanded parameter pack 'Types'}} - -// Test for diagnostics in the presence of multiple unexpanded -// parameter packs. -template<typename T, typename U> struct pair; - -template<typename ...OuterTypes> -struct MemberTemplatePPNames { - template<typename ...InnerTypes> - struct Inner { - typedef pair<OuterTypes, InnerTypes>* types; // expected-error{{declaration type contains unexpanded parameter packs 'OuterTypes' and 'InnerTypes'}} - - template<typename ...VeryInnerTypes> - struct VeryInner { - typedef pair<pair<VeryInnerTypes, OuterTypes>, pair<InnerTypes, OuterTypes> > types; // expected-error{{declaration type contains unexpanded parameter packs 'VeryInnerTypes', 'OuterTypes', ...}} - }; - }; -}; - -// Example from working paper -namespace WorkingPaperExample { - template<typename...> struct Tuple {}; - template<typename T1, typename T2> struct Pair {}; - - template<class ... Args1> struct zip { - template<class ... Args2> struct with { - typedef Tuple<Pair<Args1, Args2> ... > type; // expected-error{{pack expansion contains parameter packs 'Args1' and 'Args2' that have different lengths (1 vs. 2)}} - }; - }; - - typedef zip<short, int>::with<unsigned short, unsigned>::type T1; // T1 is Tuple<Pair<short, unsigned short>, Pair<int, unsigned>> - typedef Tuple<Pair<short, unsigned short>, Pair<int, unsigned>> T1; - - typedef zip<short>::with<unsigned short, unsigned>::type T2; // expected-note{{in instantiation of template class}} - - template<class ... Args> void f(Args...); - template<class ... Args> void h(Args...); - - template<class ... Args> - void g(Args ... args) { - f(const_cast<const Args*>(&args)...); // OK: "Args" and "args" are expanded within f - f(5 ...); // expected-error{{pack expansion does not contain any unexpanded parameter packs}} - f(args); // expected-error{{expression contains unexpanded parameter pack 'args'}} - f(h(args ...) + args ...); - } -} - -namespace PR16303 { - template<int> struct A { A(int); }; - template<int...N> struct B { - template<int...M> struct C : A<N>... { - C() : A<N>(M)... {} // expected-error{{pack expansion contains parameter packs 'N' and 'M' that have different lengths (2 vs. 3)}} expected-error{{pack expansion contains parameter packs 'N' and 'M' that have different lengths (4 vs. 3)}} - }; - }; - B<1,2>::C<4,5,6> c1; // expected-note{{in instantiation of}} - B<1,2,3,4>::C<4,5,6> c2; // expected-note{{in instantiation of}} -} - -namespace PR21289 { - template<int> using T = int; - template<typename> struct S { static const int value = 0; }; - template<typename> const int vt = 0; // expected-warning {{extension}} - int f(...); - template<int ...Ns> void g() { - f(T<Ns>()...); - f(S<T<Ns>>::value...); - f(vt<T<Ns>>...); - } - template void g<>(); - template void g<1, 2, 3>(); -} - -template <class... Ts> -int var_expr(Ts... ts); - -template <class... Ts> -auto a_function(Ts... ts) -> decltype(var_expr(ts...)); - -template <class T> -using partial = decltype(a_function<int, T>); - -int use_partial() { partial<char> n; } - -namespace PR26017 { -template <class T> -struct Foo {}; -template <class... Ts> -using FooAlias = Foo<void(Ts...)>; - -template <class... Ts> -using FooAliasAlias = FooAlias<Ts..., Ts...>; - -template <class... Ts> -void bar(const FooAlias<Ts...> &) {} - -int fn() { - FooAlias<> a; - bar(a); - - FooAlias<int> b; - bar(b); -} -} diff --git a/test/CXX/temp/temp.decls/temp.variadic/p5.mm b/test/CXX/temp/temp.decls/temp.variadic/p5.mm deleted file mode 100644 index d0598263e50b..000000000000 --- a/test/CXX/temp/temp.decls/temp.variadic/p5.mm +++ /dev/null @@ -1,9 +0,0 @@ -// RUN: %clang_cc1 -fobjc-exceptions -fexceptions -std=c++11 -fblocks -fsyntax-only -verify %s - -template<typename...Types> -void f(Types ...values) { - for (id x in values) { } // expected-error {{expression contains unexpanded parameter pack 'values'}} - @synchronized(values) { // expected-error {{expression contains unexpanded parameter pack 'values'}} - @throw values; // expected-error {{expression contains unexpanded parameter pack 'values'}} - } -} diff --git a/test/CXX/temp/temp.decls/temp.variadic/parameter-matching.cpp b/test/CXX/temp/temp.decls/temp.variadic/parameter-matching.cpp deleted file mode 100644 index 79340c3741a8..000000000000 --- a/test/CXX/temp/temp.decls/temp.variadic/parameter-matching.cpp +++ /dev/null @@ -1,43 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s - -// Check for template type parameter pack (mis-)matches with template -// type parameters. -template<typename ...T> struct X0t; -template<typename ...T> struct X0t; - -template<typename ...T> struct X1t; // expected-note{{previous template type parameter pack declared here}} -template<typename T> struct X1t; // expected-error{{template type parameter conflicts with previous template type parameter pack}} - -template<typename T> struct X2t; // expected-note{{previous template type parameter declared here}} -template<typename ...T> struct X2t; // expected-error{{template type parameter pack conflicts with previous template type parameter}} - -template<template<typename ...T> class> struct X0t_intt; -template<template<typename ...T> class> struct X0t_intt; - -template<template<typename ...T> class> struct X1t_intt; // expected-note{{previous template type parameter pack declared here}} -template<template<typename T> class> struct X1t_intt; // expected-error{{template type parameter conflicts with previous template type parameter pack}} - -template<template<typename T> class> struct X2t_intt; // expected-note{{previous template type parameter declared here}} -template<template<typename ...T> class> struct X2t_intt; // expected-error{{template type parameter pack conflicts with previous template type parameter}} - -template<int ...Values> struct X1nt; // expected-note{{previous non-type template parameter pack declared here}} -template<int Values> struct X1nt; // expected-error{{non-type template parameter conflicts with previous non-type template parameter pack}} - -template<template<class T> class> class X1tt; // expected-note{{previous template template parameter declared here}} -template<template<class T> class...> class X1tt; // expected-error{{template template parameter pack conflicts with previous template template parameter}} - -// Check for matching with out-of-line definitions -namespace rdar8859985 { - template<typename ...> struct tuple { }; - template<int ...> struct int_tuple { }; - - template<typename T> - struct X { - template<typename ...Args1, int ...Indices1> - X(tuple<Args1...>, int_tuple<Indices1...>); - }; - - template<typename T> - template<typename ...Args1, int ...Indices1> - X<T>::X(tuple<Args1...>, int_tuple<Indices1...>) {} -} diff --git a/test/CXX/temp/temp.decls/temp.variadic/partial-ordering.cpp b/test/CXX/temp/temp.decls/temp.variadic/partial-ordering.cpp deleted file mode 100644 index 36535e3f90ed..000000000000 --- a/test/CXX/temp/temp.decls/temp.variadic/partial-ordering.cpp +++ /dev/null @@ -1,62 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s -// expected-no-diagnostics - -// Various tests related to partial ordering of variadic templates. -template<typename ...Types> struct tuple; - -template<typename Tuple> -struct X1 { - static const unsigned value = 0; -}; - -template<typename Head, typename ...Tail> -struct X1<tuple<Head, Tail...> > { - static const unsigned value = 1; -}; - -template<typename Head, typename ...Tail> -struct X1<tuple<Head, Tail&...> > { - static const unsigned value = 2; -}; - -template<typename Head, typename ...Tail> -struct X1<tuple<Head&, Tail&...> > { - static const unsigned value = 3; -}; - -int check0[X1<tuple<>>::value == 0? 1 : -1]; -int check1[X1<tuple<int>>::value == 2? 1 : -1]; -int check2[X1<tuple<int, int>>::value == 1? 1 : -1]; -int check3[X1<tuple<int, int&>>::value == 2? 1 : -1]; -int check4[X1<tuple<int&, int&>>::value == 3? 1 : -1]; - -// Partial ordering of function templates. -template<typename T1, typename T2, typename ...Rest> -int &f0(T1, T2, Rest...); - -template<typename T1, typename T2> -float &f0(T1, T2); - -void test_f0() { - int &ir1 = f0(1, 2.0, 'a'); - float &fr1 = f0(1, 2.0); -} - -template<typename T1, typename T2, typename ...Rest> -int &f1(T1, T2, Rest...); - -template<typename T1, typename T2> -float &f1(T1, T2, ...); - -void test_f1() { - int &ir1 = f1(1, 2.0, 'a'); -} - -template<typename T1, typename T2, typename ...Rest> -int &f2(T1, T2, Rest...); - -float &f2(...); - -void test_f2() { - int &ir1 = f2(1, 2.0, 'a'); -} diff --git a/test/CXX/temp/temp.decls/temp.variadic/sizeofpack.cpp b/test/CXX/temp/temp.decls/temp.variadic/sizeofpack.cpp deleted file mode 100644 index 87c22a0d7e94..000000000000 --- a/test/CXX/temp/temp.decls/temp.variadic/sizeofpack.cpp +++ /dev/null @@ -1,203 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s -// expected-no-diagnostics - -namespace pr12262 { - -template<typename T, typename... Ts> -void abc1(int (*xxx)[sizeof ... (Ts) + 1]); - -void qq1 () { - abc1<int>(0); - abc1<int,double>(0); -} - - -template <unsigned N> class array {}; - - -template<typename T, typename... Types> -array<sizeof...(Types)> make_array1(Types&&... args); - -void qq2 () { - array<1> arr = make_array1<int>(1); - array<3> arr2 = make_array1<int>(1,array<5>(),0.1); -} - - -template<typename T, typename... Types> -int make_array(array<sizeof...(Types)>&, Types... args); - -void qq3 () { - array<1> a1; - int aa1 = make_array<int>(a1,1); - array<2> a2; - int aa2 = make_array<int>(a2, 0L, "abc"); -} - - -template<typename ... Ts> -struct AAA { - template<typename T, typename... Types> - static array<sizeof...(Types)> make_array(Types ... args); -}; - -void qq4 () { - array<2> arr2 = AAA<int, int>::make_array<int>(1,2); -} - -} - - -namespace pr12439 { - -template<class... Members> -struct X { - template<int Idx> - using get_t = decltype(sizeof...(Members)); - - template<int i> - get_t<i> get(); -}; - -template<class... Members> -template<int i> -typename X<Members...>::template get_t<i> X<Members...>::get() -{ - return 0; -} - -} - - -namespace pr13272 { - -template<bool B, class T = void> -struct enable_if { }; - -template<class T> struct enable_if<true, T> { - typedef T type; -}; - -class Exception {}; - -template<class Ex, typename... Args> -void cxx_throw(typename enable_if<(sizeof...(Args) > 0), const char *>::type fmt, Args&&... args) { - return; -} - -void test() { - cxx_throw<Exception>("Youpi",1); -} - -} - - -namespace pr13817 { - -template <unsigned> -struct zod; - -template <> -struct zod<1> {}; - -template <typename T, typename ... Ts> -zod<sizeof...(Ts)> make_zod(Ts ...) { - return zod<sizeof...(Ts)>(); -} - -int main(int argc, char *argv[]) -{ - make_zod<int>(1); - return 0; -} - -} - - -namespace pr14273 { - -template<typename T, int i> -struct myType -{ }; - -template<typename T, typename... Args> -struct Counter -{ - static const int count = 1 + Counter<Args...>::count; -}; - -template<typename T> -struct Counter<T> -{ - static const int count = 1; -}; - -template<typename Arg, typename... Args> -myType<Arg, sizeof...(Args)>* make_array_with_type(const Args&... args) -{ - return 0; -} - -void func(void) -{ - make_array_with_type<char>(1,2,3); -} - -} - - -namespace pr15112 -{ - template<bool, typename _Tp = void> - struct enable_if - { }; - template<typename _Tp> - struct enable_if<true,_Tp> - { typedef _Tp type; }; - - typedef __typeof__(sizeof(int)) size_t; - - template <size_t n, typename T, typename... Args> - struct is_array_of { static const bool value = true; }; - - struct cpu { using value_type = void; }; - - template <size_t Order, typename T> - struct coords_alias { typedef T type; }; - - template <size_t Order, typename MemoryTag> - using coords = typename coords_alias<Order, MemoryTag>::type; - - template <typename MemTag, typename... Args> - typename enable_if<is_array_of<sizeof...(Args), size_t, Args...>::value, - coords<sizeof...(Args), MemTag>>::type - mkcoords(Args... args); - - auto c1 = mkcoords<cpu>(0ul, 0ul, 0ul); -} - - -namespace pr12699 { - -template<bool B> -struct bool_constant -{ - static const bool value = B; -}; - -template<typename... A> -struct F -{ - template<typename... B> - using SameSize = bool_constant<sizeof...(A) == sizeof...(B)>; - - template<typename... B, typename = SameSize<B...>> - F(B...) { } -}; - -void func() -{ - F<int> f1(3); -} - -} diff --git a/test/CXX/temp/temp.deduct.guide/p1.cpp b/test/CXX/temp/temp.deduct.guide/p1.cpp deleted file mode 100644 index 8bb9da8a9723..000000000000 --- a/test/CXX/temp/temp.deduct.guide/p1.cpp +++ /dev/null @@ -1,108 +0,0 @@ -// RUN: %clang_cc1 -std=c++1z -fcxx-exceptions -verify %s -// RUN: %clang_cc1 -std=c++1z -fcxx-exceptions -verify %s -DCLASS - -#ifdef CLASS -struct Outer { -#endif - -template<typename> struct A {}; - -// Valid forms. -A(int(&)[1]) -> A<int>; -explicit A(int(&)[2]) -> A<int>; - -// Declarator pieces are not OK. -*A(int(&)[3]) -> A<int>; // expected-error {{cannot specify any part of a return type in the declaration of a deduction guide}} -&A(int(&)[4]) -> A<int>; // expected-error {{cannot specify any part of a return type in the declaration of a deduction guide}} -A(int(&)[5])[3] -> A<int>; -#ifdef CLASS // FIXME: These diagnostics are both pretty bad. -// expected-error@-2 {{function cannot return array type}} expected-error@-2 {{';'}} -#else -// expected-error@-4 {{expected function body after function declarator}} -#endif - -(A[3])(int(&)[5][1]) -> A<int>; // expected-error {{'<deduction guide for A>' cannot be the name of a variable}} -#ifndef CLASS -// expected-error@-2 {{declared as array of functions}} -#endif -(*A)(int(&)[5][2]) -> A<int>; // expected-error {{'<deduction guide for A>' cannot be the name of a variable}} -(&A)(int(&)[5][3]) -> A<int>; // expected-error {{'<deduction guide for A>' cannot be the name of a variable}} -(*A(int))(int(&)[5][4]) -> A<int>; // expected-error {{cannot specify any part of a return type in the declaration of a deduction guide}} - -// (Pending DR) attributes and parens around the declarator-id are OK. -[[deprecated]] A(int(&)[6]) [[]] -> A<int> [[]]; -A [[]] (int(&)[7]) -> A<int>; -(A)(int(&)[8]) -> A<int>; - -// ... but the trailing-return-type is part of the function-declarator as normal -(A(int(&)[9])) -> A<int>; -#ifdef CLASS // FIXME: These diagnostics are both pretty bad. -// expected-error@-2 {{deduction guide declaration without trailing return type}} expected-error@-2 {{';'}} -#else -// expected-error@-4 {{expected function body after function declarator}} -#endif -(A(int(&)[10]) -> A<int>); // expected-error {{trailing return type may not be nested within parentheses}} - -// A trailing-return-type is mandatory. -A(int(&)[11]); // expected-error {{deduction guide declaration without trailing return type}} - -// No type specifier is permitted; we don't even parse such cases as a deduction-guide. -int A(int) -> A<int>; // expected-error {{function with trailing return type must specify return type 'auto', not 'int'}} -template<typename T> struct B {}; // expected-note {{here}} -auto B(int) -> B<int>; // expected-error {{redefinition of 'B' as different kind of symbol}} - -// No storage class specifier, function specifier, ... -friend A(int(&)[20]) -> A<int>; -#ifdef CLASS -// expected-error@-2 {{cannot declare a deduction guide as a friend}} -#else -// expected-error@-4 {{'friend' used outside of class}} -#endif -typedef A(int(&)[21]) -> A<int>; // expected-error {{deduction guide cannot be declared 'typedef'}} -constexpr A(int(&)[22]) -> A<int>; // expected-error {{deduction guide cannot be declared 'constexpr'}} -inline A(int(&)[23]) -> A<int>; // expected-error {{deduction guide cannot be declared 'inline'}} -static A(int(&)[24]) -> A<int>; // expected-error {{deduction guide cannot be declared 'static'}} -thread_local A(int(&)[25]) -> A<int>; // expected-error {{'thread_local' is only allowed on variable declarations}} -extern A(int(&)[26]) -> A<int>; -#ifdef CLASS -// expected-error@-2 {{storage class specified for a member}} -#else -// expected-error@-4 {{deduction guide cannot be declared 'extern'}} -#endif -mutable A(int(&)[27]) -> A<int>; // expected-error-re {{{{'mutable' cannot be applied to|illegal storage class on}} function}} -virtual A(int(&)[28]) -> A<int>; // expected-error {{'virtual' can only appear on non-static member functions}} -const A(int(&)[28]) -> A<int>; // expected-error {{deduction guide cannot be declared 'const'}} - -const volatile static constexpr inline A(int(&)[29]) -> A<int>; // expected-error {{deduction guide cannot be declared 'static inline constexpr const volatile'}} - -A(int(&)[30]) const -> A<int>; // expected-error {{deduction guide cannot have 'const' qualifier}} - -// No definition is allowed. -A(int(&)[40]) -> A<int> {} // expected-error {{deduction guide cannot have a function definition}} -A(int(&)[41]) -> A<int> = default; // expected-error {{deduction guide cannot have a function definition}} expected-error {{only special member functions may be defaulted}} -A(int(&)[42]) -> A<int> = delete; // expected-error {{deduction guide cannot have a function definition}} -A(int(&)[43]) -> A<int> try {} catch (...) {} // expected-error {{deduction guide cannot have a function definition}} - -#ifdef CLASS -}; -#endif - -namespace ExplicitInst { - // Explicit instantiation / specialization is not permitted. - template<typename T> struct B {}; - template<typename T> B(T) -> B<T>; - template<> B(int) -> B<int>; // expected-error {{deduction guide cannot be explicitly specialized}} - extern template B(float) -> B<float>; // expected-error {{deduction guide cannot be explicitly instantiated}} - template B(char) -> B<char>; // expected-error {{deduction guide cannot be explicitly instantiated}} - - // An attempt at partial specialization doesn't even parse as a deduction-guide. - template<typename T> B<T*>(T*) -> B<T*>; // expected-error 1+{{}} expected-note 0+{{}} - - struct X { - template<typename T> struct C {}; - template<typename T> C(T) -> C<T>; - template<> C(int) -> C<int>; // expected-error {{deduction guide cannot be explicitly specialized}} - extern template C(float) -> C<float>; // expected-error {{expected member name or ';'}} - template C(char) -> C<char>; // expected-error {{expected '<' after 'template'}} - }; -} diff --git a/test/CXX/temp/temp.deduct.guide/p2.cpp b/test/CXX/temp/temp.deduct.guide/p2.cpp deleted file mode 100644 index 3549755ff0f2..000000000000 --- a/test/CXX/temp/temp.deduct.guide/p2.cpp +++ /dev/null @@ -1,15 +0,0 @@ -// RUN: %clang_cc1 -std=c++1z -verify %s -// expected-no-diagnostics - -namespace std_example { - template<typename T, typename U = int> struct S { - T data; - }; - template<typename U> S(U) -> S<typename U::type>; - - struct A { - using type = short; - operator type(); - }; - S x{A()}; -} diff --git a/test/CXX/temp/temp.deduct.guide/p3.cpp b/test/CXX/temp/temp.deduct.guide/p3.cpp deleted file mode 100644 index 07d1be0593f4..000000000000 --- a/test/CXX/temp/temp.deduct.guide/p3.cpp +++ /dev/null @@ -1,72 +0,0 @@ -// RUN: %clang_cc1 -std=c++1z %s -verify - -// The same restrictions apply to the parameter-declaration-clause of a -// deduction guide as in a function declaration. -template<typename T> struct A {}; -A(void) -> A<int>; // ok -A(void, int) -> A<int>; // expected-error {{'void' must be the first and only parameter if specified}} - -// We interpret this as also extending to the validity of redeclarations. It's -// a bit of a stretch (OK, a lot of a stretch) but it gives desirable answers. -A() -> A<int>; // ok, redeclaration - -A() -> A<int>; // expected-note {{previous}} -A() -> A<float>; // FIXME: "functions" is a poor term. expected-error {{functions that differ only in their return type cannot be overloaded}} - -template<typename T> A(T) -> A<typename T::foo>; -template<typename T> A(T) -> A<typename T::bar>; // ok, can overload on return type (SFINAE applies) - -A(long) -> A<int>; -template<typename T = int> A(long) -> A<char>; // ok, non-template beats template as usual - -// (Pending DR) The template-name shall name a class template. -template<typename T> using B = A<T>; // expected-note {{template}} -B() -> B<int>; // expected-error {{cannot specify deduction guide for alias template 'B'}} -// FIXME: expected-error@-1 {{declarator requires an identifier}} -template<typename T> int C; -C() -> int; // expected-error {{requires a type specifier}} -template<typename T> void D(); -D() -> int; // expected-error {{requires a type specifier}} -template<template<typename> typename TT> struct E { // expected-note 2{{template}} - // FIXME: Should only diagnose this once! - TT(int) -> TT<int>; // expected-error 2{{cannot specify deduction guide for template template parameter 'TT'}} expected-error {{requires an identifier}} -}; - -A(int) -> int; // expected-error {{deduced type 'int' of deduction guide is not a specialization of template 'A'}} -template<typename T> A(T) -> B<T>; // expected-error {{deduced type 'B<T>' (aka 'A<type-parameter-0-0>') of deduction guide is not written as a specialization of template 'A'}} -template<typename T> A(T*) -> const A<T>; // expected-error {{deduced type 'const A<T>' of deduction guide is not a specialization of template 'A'}} - -// A deduction-guide shall be declared in the same scope as the corresponding -// class template. -namespace WrongScope { - namespace { - template<typename T> struct AnonNS1 {}; // expected-note {{here}} - AnonNS1(float) -> AnonNS1<float>; // ok - } - AnonNS1(int) -> AnonNS1<int>; // expected-error {{deduction guide must be declared in the same scope as template 'WrongScope::}} - template<typename T> struct AnonNS2 {}; // expected-note {{here}} - namespace { - AnonNS1(char) -> AnonNS1<char>; // ok - AnonNS2(int) -> AnonNS2<int>; // expected-error {{deduction guide must be declared in the same scope as template 'WrongScope::AnonNS2'}} - } - namespace N { - template<typename T> struct NamedNS1 {}; // expected-note {{here}} - template<typename T> struct NamedNS2 {}; // expected-note {{here}} - } - using N::NamedNS1; - NamedNS1(int) -> NamedNS1<int>; // expected-error {{deduction guide must be declared in the same scope as template}} - using namespace N; - NamedNS2(int) -> NamedNS2<int>; // expected-error {{deduction guide must be declared in the same scope as template}} - struct ClassMemberA { - template<typename T> struct X {}; // expected-note {{here}} - }; - struct ClassMemberB : ClassMemberA { - X(int) -> X<int>; // expected-error {{deduction guide must be declared in the same scope as template 'WrongScope::ClassMemberA::X'}} - }; - template<typename T> struct Local {}; - void f() { - Local(int) -> Local<int>; // expected-error {{expected}} - using WrongScope::Local; - Local(int) -> Local<int>; // expected-error {{expected}} - } -} diff --git a/test/CXX/temp/temp.fct.spec/temp.arg.explicit/p1.cpp b/test/CXX/temp/temp.fct.spec/temp.arg.explicit/p1.cpp deleted file mode 100644 index 0aef6adad13f..000000000000 --- a/test/CXX/temp/temp.fct.spec/temp.arg.explicit/p1.cpp +++ /dev/null @@ -1,12 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only %s - -template<typename T> struct A { }; - -template<typename T> T make(); -template<typename T> T make2(const T&); - -void test_make() { - int& ir0 = make<int&>(); - A<int> a0 = make< A<int> >(); - A<int> a1 = make2< A<int> >(A<int>()); -} diff --git a/test/CXX/temp/temp.fct.spec/temp.arg.explicit/p3-0x.cpp b/test/CXX/temp/temp.fct.spec/temp.arg.explicit/p3-0x.cpp deleted file mode 100644 index dcf5a08d9062..000000000000 --- a/test/CXX/temp/temp.fct.spec/temp.arg.explicit/p3-0x.cpp +++ /dev/null @@ -1,49 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s -// expected-no-diagnostics - -namespace ParameterPacksWithFunctions { - template<typename ...> struct count; - - template<typename Head, typename ...Tail> - struct count<Head, Tail...> { - static const unsigned value = 1 + count<Tail...>::value; - }; - - template<> - struct count<> { - static const unsigned value = 0; - }; - - template<unsigned> struct unsigned_c { }; - - template<typename ... Types> - unsigned_c<count<Types...>::value> f(); - - void test_f() { - unsigned_c<0> uc0a = f(); // okay, deduced to an empty pack - unsigned_c<0> uc0b = f<>(); - unsigned_c<1> uc1 = f<int>(); - unsigned_c<2> uc2 = f<float, double>(); - } -} - -namespace rdar12176336 { - typedef void (*vararg_func)(...); - - struct method { - vararg_func implementation; - - method(vararg_func implementation) : implementation(implementation) {} - - template<typename TReturnType, typename... TArguments, typename TFunctionType = TReturnType (*)(TArguments...)> - auto getImplementation() const -> TFunctionType - { - return reinterpret_cast<TFunctionType>(implementation); - } - }; - - void f() { - method m(nullptr); - auto imp = m.getImplementation<int, int, int>(); - } -} diff --git a/test/CXX/temp/temp.fct.spec/temp.arg.explicit/p3-nodeduct.cpp b/test/CXX/temp/temp.fct.spec/temp.arg.explicit/p3-nodeduct.cpp deleted file mode 100644 index de3b44f1b513..000000000000 --- a/test/CXX/temp/temp.fct.spec/temp.arg.explicit/p3-nodeduct.cpp +++ /dev/null @@ -1,36 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s - -// PR5811 -template <class F> void Call(F f) { f(1); } -template <typename T> void f(T); -void a() { Call(f<int>); } - -// Check the conversion of a template-id to a pointer -template<typename T, T* Address> struct Constant { }; -Constant<void(int), &f<int> > constant0; - -template<typename T, T* Address> void constant_func(); -void test_constant_func() { - constant_func<void(int), &f<int> >(); -} - - -// Check typeof() on a template-id referring to a single function -template<typename T, typename U> -struct is_same { - static const bool value = false; -}; - -template<typename T> -struct is_same<T, T> { - static const bool value = true; -}; - -int typeof0[is_same<__typeof__(f<int>), void (int)>::value? 1 : -1]; -int typeof1[is_same<__typeof__(&f<int>), void (*)(int)>::value? 1 : -1]; - -template <typename T> void g(T); // expected-note{{possible target for call}} -template <typename T> void g(T, T); // expected-note{{possible target for call}} - -int typeof2[is_same<__typeof__(g<float>), void (int)>::value? 1 : -1]; // \ - // expected-error{{reference to overloaded function could not be resolved; did you mean to call it?}} diff --git a/test/CXX/temp/temp.fct.spec/temp.arg.explicit/p3.cpp b/test/CXX/temp/temp.fct.spec/temp.arg.explicit/p3.cpp deleted file mode 100644 index bfe08a67a416..000000000000 --- a/test/CXX/temp/temp.fct.spec/temp.arg.explicit/p3.cpp +++ /dev/null @@ -1,78 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s - -template<class X, class Y, class Z> X f(Y,Z); // expected-note {{candidate template ignored: couldn't infer template argument 'X'}} - -void g() { - f<int,char*,double>("aa",3.0); -#if __cplusplus <= 199711L // C++03 or earlier modes - // expected-warning@-2{{conversion from string literal to 'char *' is deprecated}} -#else - // expected-warning@-4{{ISO C++11 does not allow conversion from string literal to 'char *'}} -#endif - - f<int,char*>("aa",3.0); // Z is deduced to be double -#if __cplusplus <= 199711L - // expected-warning@-2{{conversion from string literal to 'char *' is deprecated}} -#else - // expected-warning@-4{{ISO C++11 does not allow conversion from string literal to 'char *'}} -#endif - - f<int>("aa",3.0); // Y is deduced to be char*, and - // Z is deduced to be double - f("aa",3.0); // expected-error{{no matching}} -} - -// PR5910 -namespace PR5910 { - template <typename T> - void Func() {} - - template <typename R> - void Foo(R (*fp)()); - - void Test() { - Foo(Func<int>); - } -} - -// PR5949 -namespace PR5949 { - struct Bar; - - template <class Container> - void quuz(const Container &cont) { - } - - template<typename T> - int Foo(Bar *b, void (*Baz)(const T &t), T * = 0) { - return 0; - } - - template<typename T> - int Quux(Bar *b, T * = 0) - { - return Foo<T>(b, quuz); - } -} - -// PR7641 -namespace PR7641 { - namespace N2 - { - template<class> - int f0(int); - } - namespace N - { - using N2::f0; - } - - template<class R,class B1> - int - f1(R(a)(B1)); - - void f2() - { f1(N::f0<int>); } -} diff --git a/test/CXX/temp/temp.fct.spec/temp.arg.explicit/p9-0x.cpp b/test/CXX/temp/temp.fct.spec/temp.arg.explicit/p9-0x.cpp deleted file mode 100644 index a9bda621e98f..000000000000 --- a/test/CXX/temp/temp.fct.spec/temp.arg.explicit/p9-0x.cpp +++ /dev/null @@ -1,69 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s -// expected-no-diagnostics - -// Metafunction to extract the Nth type from a set of types. -template<unsigned N, typename ...Types> struct get_nth_type; - -template<unsigned N, typename Head, typename ...Tail> -struct get_nth_type<N, Head, Tail...> : get_nth_type<N-1, Tail...> { }; - -template<typename Head, typename ...Tail> -struct get_nth_type<0, Head, Tail...> { - typedef Head type; -}; - -// Placeholder type when get_nth_type fails. -struct no_type {}; - -template<unsigned N> -struct get_nth_type<N> { - typedef no_type type; -}; - -template<typename ...Args> -typename get_nth_type<0, Args...>::type first_arg(Args...); - -template<typename ...Args> -typename get_nth_type<1, Args...>::type second_arg(Args...); - -// Test explicit specification of function template arguments. -void test_explicit_spec_simple() { - int *ip1 = first_arg<int *>(0); - int *ip2 = first_arg<int *, float*>(0, 0); - float *fp1 = first_arg<float *, double*, int*>(0, 0, 0); -} - -// Template argument deduction can extend the sequence of template -// arguments corresponding to a template parameter pack, even when the -// sequence contains explicitly specified template arguments. -void test_explicit_spec_extension(double *dp) { - int *ip1 = first_arg<int *>(0, 0); - int *ip2 = first_arg<int *, float*>(0, 0, 0, 0); - float *fp1 = first_arg<float *, double*, int*>(0, 0, 0); - int *i1 = second_arg<float *>(0, (int*)0, 0); - double *dp1 = first_arg<>(dp); -} - -template<typename ...Types> -struct tuple { }; - -template<typename ...Types> -void accept_tuple(tuple<Types...>); - -void test_explicit_spec_extension_targs(tuple<int, float, double> t3) { - accept_tuple(t3); - accept_tuple<int, float, double>(t3); - accept_tuple<int>(t3); - accept_tuple<int, float>(t3); -} - -template<typename R, typename ...ParmTypes> -void accept_function_ptr(R(*)(ParmTypes...)); - -void test_explicit_spec_extension_funcparms(int (*f3)(int, float, double)) { - accept_function_ptr(f3); - accept_function_ptr<int>(f3); - accept_function_ptr<int, int>(f3); - accept_function_ptr<int, int, float>(f3); - accept_function_ptr<int, int, float, double>(f3); -} diff --git a/test/CXX/temp/temp.fct.spec/temp.deduct/cwg1170.cpp b/test/CXX/temp/temp.fct.spec/temp.deduct/cwg1170.cpp deleted file mode 100644 index 47184ec03455..000000000000 --- a/test/CXX/temp/temp.fct.spec/temp.deduct/cwg1170.cpp +++ /dev/null @@ -1,42 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s -// expected-no-diagnostics - -#if !__has_feature(cxx_access_control_sfinae) -# error No support for access control as part of SFINAE? -#endif - -typedef char yes_type; -typedef char (&no_type)[2]; - -template<unsigned N> struct unsigned_c { }; - -template<typename T> -class has_copy_constructor { - static T t; - - template<typename U> static yes_type check(unsigned_c<sizeof(U(t))> * = 0); - template<typename U> static no_type check(...); - -public: - static const bool value = (sizeof(check<T>(0)) == sizeof(yes_type)); -}; - -struct HasCopy { }; - -struct HasNonConstCopy { - HasNonConstCopy(HasNonConstCopy&); -}; - -struct HasDeletedCopy { - HasDeletedCopy(const HasDeletedCopy&) = delete; -}; - -struct HasPrivateCopy { -private: - HasPrivateCopy(const HasPrivateCopy&); -}; - -int check0[has_copy_constructor<HasCopy>::value? 1 : -1]; -int check1[has_copy_constructor<HasNonConstCopy>::value? 1 : -1]; -int check2[has_copy_constructor<HasDeletedCopy>::value? -1 : 1]; -int check3[has_copy_constructor<HasPrivateCopy>::value? -1 : 1]; diff --git a/test/CXX/temp/temp.fct.spec/temp.deduct/p7.cpp b/test/CXX/temp/temp.fct.spec/temp.deduct/p7.cpp deleted file mode 100644 index bc074ba25e8e..000000000000 --- a/test/CXX/temp/temp.fct.spec/temp.deduct/p7.cpp +++ /dev/null @@ -1,22 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -verify %s - -struct Q { typedef int type; }; - -// "The substitution occurs in all types and expressions that are used in [...] -// template parameter declarations." In particular, we must substitute into the -// type of a parameter pack that is not a pack expansion, even if we know the -// corresponding argument pack is empty. -template<typename T, typename T::type...> void a(T); -int &a(...); -int &a_disabled = a(0); -int &a_enabled = a(Q()); // expected-error {{cannot bind to a temporary of type 'void'}} - -template<typename T, template<typename T::type> class ...X> void b(T); -int &b(...); -int &b_disabled = b(0); -int &b_enabled = b(Q()); // expected-error {{cannot bind to a temporary of type 'void'}} - -template<typename T, template<typename T::type...> class ...X> void c(T); -int &c(...); -int &c_disabled = c(0); -int &c_enabled = c(Q()); // expected-error {{cannot bind to a temporary of type 'void'}} diff --git a/test/CXX/temp/temp.fct.spec/temp.deduct/p9.cpp b/test/CXX/temp/temp.fct.spec/temp.deduct/p9.cpp deleted file mode 100644 index f7103a33cc72..000000000000 --- a/test/CXX/temp/temp.fct.spec/temp.deduct/p9.cpp +++ /dev/null @@ -1,42 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s - -template <int> int f(int); // expected-note {{candidate function}} -#if __cplusplus <= 199711L -// expected-note@-2 {{candidate function}} -#endif - -template <signed char> int f(int); // expected-note {{candidate function}} -#if __cplusplus <= 199711L -// expected-note@-2 {{candidate function}} -#endif - -int i1 = f<1>(0); // expected-error{{call to 'f' is ambiguous}} -int i2 = f<1000>(0); -#if __cplusplus <= 199711L -// expected-error@-2{{call to 'f' is ambiguous}} -#endif - -namespace PR6707 { - template<typename T, T Value> - struct X { }; - - template<typename T, T Value> - void f(X<T, Value>); - - void g(X<int, 10> x) { - f(x); - } - - static const unsigned char ten = 10; - template<typename T, T Value, typename U> - void f2(X<T, Value>, X<U, Value>); - // expected-note@-1 {{candidate template ignored: deduced values of conflicting types for parameter 'Value' (10 of type 'int' vs. 10 of type 'char')}} - // expected-note@-2 {{candidate template ignored: deduced values of conflicting types for parameter 'Value' (10 of type 'char' vs. 10 of type 'int')}} - - void g2() { - f2(X<int, 10>(), X<char, ten>()); // expected-error {{no matching}} - f2(X<char, 10>(), X<int, ten>()); // expected-error {{no matching}} - } -} diff --git a/test/CXX/temp/temp.fct.spec/temp.deduct/sfinae-1.cpp b/test/CXX/temp/temp.fct.spec/temp.deduct/sfinae-1.cpp deleted file mode 100644 index 1907bd77998f..000000000000 --- a/test/CXX/temp/temp.fct.spec/temp.deduct/sfinae-1.cpp +++ /dev/null @@ -1,43 +0,0 @@ -// RUN: %clang_cc1 -verify %s -// expected-no-diagnostics - -typedef char one_byte; -struct two_bytes { char data[2]; }; - -template<typename T> one_byte __is_class_check(int T::*); -template<typename T> two_bytes __is_class_check(...); - -template<typename T> struct is_class { - static const bool value = sizeof(__is_class_check<T>(0)) == 1; -}; - -struct X { }; - -int array0[is_class<X>::value? 1 : -1]; -int array1[is_class<int>::value? -1 : 1]; -int array2[is_class<char[3]>::value? -1 : 1]; - -namespace instantiation_order1 { - template<typename T> - struct it_is_a_trap { - typedef typename T::trap type; - }; - - template<bool, typename T = void> - struct enable_if { - typedef T type; - }; - - template<typename T> - struct enable_if<false, T> { }; - - template<typename T> - typename enable_if<sizeof(T) == 17>::type - f(const T&, typename it_is_a_trap<T>::type* = 0); - - void f(...); - - void test_f() { - f('a'); - } -} diff --git a/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/basic.cpp b/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/basic.cpp deleted file mode 100644 index 33efac02482d..000000000000 --- a/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/basic.cpp +++ /dev/null @@ -1,47 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s - -template<typename T> struct A { }; - -template<typename T> A<T> f0(T*); - -void test_f0(int *ip, float const *cfp) { - A<int> a0 = f0(ip); - A<const float> a1 = f0(cfp); -} - -template<typename T> void f1(T*, int); - -void test_f1(int *ip, float fv) { - f1(ip, fv); -} - -template<typename T> void f2(T*, T*); // expected-note {{candidate template ignored: could not match 'T *' against 'ConvToIntPtr'}} \ -// expected-note{{candidate template ignored: deduced conflicting types for parameter 'T' ('int' vs. 'float')}} - -struct ConvToIntPtr { - operator int*() const; -}; - -void test_f2(int *ip, float *fp) { - f2(ip, ConvToIntPtr()); // expected-error{{no matching function}} - f2(ip, ip); // okay - f2(ip, fp); // expected-error{{no matching function}} -} - -namespace test3 { - template<typename T> - struct bar { }; - - template<typename T> - struct foo { - operator bar<T>(); - }; - - template<typename T> - void func(bar<T>) { // expected-note {{candidate template ignored: could not match 'bar' against 'foo'}} - } - - void test() { - func(foo<int>()); // expected-error {{no matching function}} - } -} diff --git a/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p1-0x.cpp b/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p1-0x.cpp deleted file mode 100644 index 081bba2b8dff..000000000000 --- a/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p1-0x.cpp +++ /dev/null @@ -1,92 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s - -// Metafunction to extract the Nth type from a set of types. -template<unsigned N, typename ...Types> struct get_nth_type; - -template<unsigned N, typename Head, typename ...Tail> -struct get_nth_type<N, Head, Tail...> : get_nth_type<N-1, Tail...> { }; - -template<typename Head, typename ...Tail> -struct get_nth_type<0, Head, Tail...> { - typedef Head type; -}; - -// Placeholder type when get_nth_type fails. -struct no_type {}; - -template<unsigned N> -struct get_nth_type<N> { - typedef no_type type; -}; - -template<typename T, typename U> struct pair { }; -template<typename T, typename U> pair<T, U> make_pair(T, U); - -// For a function parameter pack that occurs at the end of the -// parameter-declaration-list, the type A of each remaining argument -// of the call is compared with the type P of the declarator-id of the -// function parameter pack. -template<typename ...Args> -typename get_nth_type<0, Args...>::type first_arg(Args...); - -template<typename ...Args> -typename get_nth_type<1, Args...>::type second_arg(Args...); - -void test_simple_deduction(int *ip, float *fp, double *dp) { - int *ip1 = first_arg(ip); - int *ip2 = first_arg(ip, fp); - int *ip3 = first_arg(ip, fp, dp); - no_type nt1 = first_arg(); -} - -template<typename ...Args> -typename get_nth_type<0, Args...>::type first_arg_ref(Args&...); - -template<typename ...Args> -typename get_nth_type<1, Args...>::type second_arg_ref(Args&...); - -void test_simple_ref_deduction(int *ip, float *fp, double *dp) { - int *ip1 = first_arg_ref(ip); - int *ip2 = first_arg_ref(ip, fp); - int *ip3 = first_arg_ref(ip, fp, dp); - no_type nt1 = first_arg_ref(); -} - - -// FIXME: Use the template parameter names in this diagnostic. -template<typename ...Args1, typename ...Args2> -typename get_nth_type<0, Args1...>::type first_arg_pair(pair<Args1, Args2>...); // expected-note{{candidate template ignored: could not match 'pair<type-parameter-0-0, type-parameter-0-1>' against 'int'}} - -template<typename ...Args1, typename ...Args2> -typename get_nth_type<1, Args1...>::type second_arg_pair(pair<Args1, Args2>...); - -void test_pair_deduction(int *ip, float *fp, double *dp) { - int *ip1 = first_arg_pair(make_pair(ip, 17)); - int *ip2 = first_arg_pair(make_pair(ip, 17), make_pair(fp, 17)); - int *ip3 = first_arg_pair(make_pair(ip, 17), make_pair(fp, 17), - make_pair(dp, 17)); - float *fp1 = second_arg_pair(make_pair(ip, 17), make_pair(fp, 17)); - float *fp2 = second_arg_pair(make_pair(ip, 17), make_pair(fp, 17), - make_pair(dp, 17)); - no_type nt1 = first_arg_pair(); - no_type nt2 = second_arg_pair(); - no_type nt3 = second_arg_pair(make_pair(ip, 17)); - - - first_arg_pair(make_pair(ip, 17), 16); // expected-error{{no matching function for call to 'first_arg_pair'}} -} - -// A function parameter pack not at the end of the parameter list is never -// deduced. We interpret this as meaning the types within it are never -// deduced, and thus must match explicitly-specified values. -template<typename ...Types> struct tuple { }; - -template<typename ...Types> -void pack_not_at_end(tuple<Types...>, Types... values, int); // expected-note {{<int *, double *> vs. <>}} - -void test_pack_not_at_end(tuple<int*, double*> t2) { - pack_not_at_end(t2, 0, 0, 0); // expected-error {{no match}} - // FIXME: Should the "original argument type must match deduced parameter - // type" rule apply here? - pack_not_at_end<int*, double*>(t2, 0, 0, 0); // ok -} diff --git a/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p2.cpp b/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p2.cpp deleted file mode 100644 index 4be81d882588..000000000000 --- a/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p2.cpp +++ /dev/null @@ -1,32 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -// expected-no-diagnostics -template<typename T> struct A { }; - -// bullet 1 -template<typename T> A<T> f0(T* ptr); - -void test_f0_bullet1() { - int arr0[6]; - A<int> a0 = f0(arr0); - const int arr1[] = { 1, 2, 3, 4, 5 }; - A<const int> a1 = f0(arr1); -} - -// bullet 2 -int g0(int, int); -float g1(float); - -void test_f0_bullet2() { - A<int(int, int)> a0 = f0(g0); - A<float(float)> a1 = f0(g1); -} - -// bullet 3 -struct X { }; -const X get_X(); - -template<typename T> A<T> f1(T); - -void test_f1_bullet3() { - A<X> a0 = f1(get_X()); -} diff --git a/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p3-0x.cpp b/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p3-0x.cpp deleted file mode 100644 index ebff0a1df4e7..000000000000 --- a/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p3-0x.cpp +++ /dev/null @@ -1,93 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s -// RUN: %clang_cc1 -std=c++1z -fsyntax-only -verify %s - -// A forwarding reference is an rvalue reference to a cv-unqualified template -// parameter that does not represent a template parameter of a class template. -#if __cplusplus > 201402L -namespace ClassTemplateParamNotForwardingRef { - // This is not a forwarding reference. - template<typename T> struct A { // expected-note {{candidate}} - A(T&&); // expected-note {{no known conversion from 'int' to 'int &&'}} - }; - int n; - A a = n; // expected-error {{no viable constructor or deduction guide}} - - A b = 0; - A<int> *pb = &b; - - // This is a forwarding reference. - template<typename T> A(T&&) -> A<T>; - A c = n; - A<int&> *pc = &c; - - A d = 0; - A<int> *pd = &d; - - template<typename T = void> struct B { - // This is a forwarding reference. - template<typename U> B(U &&); - }; - B e = n; - B<void> *pe = &e; -} -#endif - -// If P is a forwarding reference and the argument is an lvalue, the type -// "lvalue reference to A" is used in place of A for type deduction. -template<typename T> struct X { }; - -template<typename T> X<T> f0(T&&); - -struct Y { }; - -template<typename T> T prvalue(); -template<typename T> T&& xvalue(); -template<typename T> T& lvalue(); - -void test_f0() { - X<int> xi0 = f0(prvalue<int>()); - X<int> xi1 = f0(xvalue<int>()); - X<int&> xi2 = f0(lvalue<int>()); - X<Y> xy0 = f0(prvalue<Y>()); - X<Y> xy1 = f0(xvalue<Y>()); - X<Y&> xy2 = f0(lvalue<Y>()); -} - -template<typename T> X<T> f1(const T&&); // expected-note{{candidate function [with T = int] not viable: no known conversion from 'int' to 'const int &&' for 1st argument}} \ -// expected-note{{candidate function [with T = Y] not viable: no known conversion from 'Y' to 'const Y &&' for 1st argument}} - -void test_f1() { - X<int> xi0 = f1(prvalue<int>()); - X<int> xi1 = f1(xvalue<int>()); - f1(lvalue<int>()); // expected-error{{no matching function for call to 'f1'}} - X<Y> xy0 = f1(prvalue<Y>()); - X<Y> xy1 = f1(xvalue<Y>()); - f1(lvalue<Y>()); // expected-error{{no matching function for call to 'f1'}} -} - -namespace std_example { - template <class T> int f(T&&); - template <class T> int g(const T&&); // expected-note{{candidate function [with T = int] not viable: no known conversion from 'int' to 'const int &&' for 1st argument}} - - int i; - int n1 = f(i); - int n2 = f(0); - int n3 = g(i); // expected-error{{no matching function for call to 'g'}} - -#if __cplusplus > 201402L - template<class T> struct A { // expected-note {{candidate}} - template<class U> - A(T &&, U &&, int *); // expected-note {{[with T = int, U = int] not viable: no known conversion from 'int' to 'int &&'}} - A(T &&, int *); // expected-note {{requires 2}} - }; - template<class T> A(T &&, int *) -> A<T>; // expected-note {{requires 2}} - - int *ip; - A a{i, 0, ip}; // expected-error {{no viable constructor or deduction guide}} - A a0{0, 0, ip}; - A a2{i, ip}; - - A<int> &a0r = a0; - A<int&> &a2r = a2; -#endif -} 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 deleted file mode 100644 index ff8178f94769..000000000000 --- a/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p3.cpp +++ /dev/null @@ -1,175 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s - -template<typename T> struct A { }; - -// Top-level cv-qualifiers of P's type are ignored for type deduction. -template<typename T> A<T> f0(const T); - -void test_f0(int i, const int ci) { - A<int> a0 = f0(i); - A<int> a1 = f0(ci); -} - -// If P is a reference type, the type referred to by P is used for type -// deduction. -template<typename T> A<T> f1(T&); - -void test_f1(int i, const int ci, volatile int vi) { - A<int> a0 = f1(i); - A<const int> a1 = f1(ci); - A<volatile int> a2 = f1(vi); -} - -template<typename T, unsigned N> struct B { }; -template<typename T, unsigned N> B<T, N> g0(T (&array)[N]); -template<typename T, unsigned N> B<T, N> g0b(const T (&array)[N]); - -void test_g0() { - int array0[5]; - B<int, 5> b0 = g0(array0); - const int array1[] = { 1, 2, 3}; - B<const int, 3> b1 = g0(array1); - B<int, 3> b2 = g0b(array1); -} - -template<typename T> B<T, 0> g1(const A<T>&); - -void test_g1(A<float> af) { - B<float, 0> b0 = g1(af); - B<int, 0> b1 = g1(A<int>()); -} - -// - If the original P is a reference type, the deduced A (i.e., the type -// referred to by the reference) can be more cv-qualified than the -// transformed A. -template<typename T> A<T> f2(const T&); - -void test_f2(int i, const int ci, volatile int vi) { - A<int> a0 = f2(i); - A<int> a1 = f2(ci); - A<volatile int> a2 = f2(vi); -} - -// PR5913 -template <typename T, int N> -void Foo(const T (&a)[N]) { - T x; - x = 0; -} - -const int a[1] = { 0 }; - -void Test() { - Foo(a); -} - -// - The transformed A can be another pointer or pointer to member type that -// can be converted to the deduced A via a qualification conversion (4.4). -template<typename T> A<T> f3(T * * const * const); - -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 -// to by the deduced A. -template<typename T, int I> struct C { }; - -struct D : public C<int, 1> { }; -struct E : public D { }; -struct F : A<float> { }; -struct G : A<float>, C<int, 1> { }; - -template<typename T, int I> - C<T, I> *f4a(const C<T, I>&); -template<typename T, int I> - C<T, I> *f4b(C<T, I>); -template<typename T, int I> - C<T, I> *f4c(C<T, I>*); -int *f4c(...); - -void test_f4(D d, E e, F f, G g) { - C<int, 1> *ci1a = f4a(d); - C<int, 1> *ci2a = f4a(e); - C<int, 1> *ci1b = f4b(d); - C<int, 1> *ci2b = f4b(e); - C<int, 1> *ci1c = f4c(&d); - C<int, 1> *ci2c = f4c(&e); - C<int, 1> *ci3c = f4c(&g); - int *ip1 = f4c(&f); -} - -// PR8462 -namespace N { - struct T0; - struct T1; - - template<typename X, typename Y> struct B {}; - - struct J : B<T0,T0> {}; - struct K : B<T1,T1> {}; - - struct D : J, K {}; - - template<typename X, typename Y> void F(B<Y,X>); - - void test() - { - D d; - N::F<T0>(d); // Fails - N::F<T1>(d); // OK - } -} - -namespace PR9233 { - template<typename T> void f(const T **q); // expected-note{{candidate template ignored: deduced type 'const int **' of 1st parameter does not match adjusted type 'int **' of argument [with T = int]}} - - void g(int **p) { - f(p); // expected-error{{no matching function for call to 'f'}} - } - -} - -namespace PR27155 { - -struct B {}; - -template<class T, int i> struct D : T {}; -template<class T> void Foo(D<T, 1>); - -int fn() { - D<D<B, 1>, 0> f; - Foo(f); -} - -} - -namespace PR28195 { - -template<int N> struct B {}; -struct D : B<0>, B<1> {}; - -template<int N> int callee(B<N>); // expected-note{{failed template argument deduction}} - -int caller() { - callee(D()); // expected-error{{no matching function}} -} - -} diff --git a/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p4.cpp b/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p4.cpp deleted file mode 100644 index 357ea664037d..000000000000 --- a/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p4.cpp +++ /dev/null @@ -1,57 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++1z %s - -namespace PR8598 { - template<class T> struct identity { typedef T type; }; - - template<class T, class C> - void f(T C::*, typename identity<T>::type*){} - - struct X { void f() {}; }; - - void g() { (f)(&X::f, 0); } -} - -namespace PR12132 { - template<typename S> void fun(const int* const S::* member) {} - struct A { int* x; }; - void foo() { - fun(&A::x); - } -} - -#if __cplusplus > 201402L -namespace noexcept_conversion { - template<typename R> void foo(R()); - template<typename R> void bar(R()) = delete; - template<typename R> void bar(R() noexcept) {} - void f() throw() { - foo(&f); - bar(&f); - } - // There is no corresponding rule for references. - // We consider this to be a defect, and allow deduction to succeed in this - // case. FIXME: Check this should be accepted once the DR is resolved. - template<typename R> void baz(R(&)()); - void g() { - baz(f); - } - - // But there is one for member pointers. - template<typename R, typename C, typename ...A> void quux(R (C::*)(A...)); - struct Q { void f(int, char) noexcept { quux(&Q::f); } }; - - void g1() noexcept; - void g2(); - template <class T> int h(T *, T *); // expected-note {{deduced conflicting types for parameter 'T' ('void () noexcept' vs. 'void ()')}} - int x = h(g1, g2); // expected-error {{no matching function}} - - // We consider it a defect that deduction does not support the following. - // FIXME: Check that the defect is resolved as we expect. - template<bool B> int i(void () noexcept(B)); - int i1 = i(g1); - int i2 = i(g2); -} -#else -// expected-no-diagnostics -#endif diff --git a/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p6.cpp b/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p6.cpp deleted file mode 100644 index 8b18189bb3da..000000000000 --- a/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p6.cpp +++ /dev/null @@ -1,128 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s - -namespace test0 { - template<class T> void apply(T x, void (*f)(T)) { f(x); } // expected-note 2 {{candidate template ignored: deduced conflicting types for parameter 'T'}}\ - // expected-note {{no overload of 'temp2' matching 'void (*)(int)'}} - - template<class A> void temp(A); - void test0() { - // okay: deduce T=int from first argument, A=int during overload - apply(0, &temp); - apply(0, &temp<>); - - // okay: deduce T=int from first and second arguments - apply(0, &temp<int>); - - // deduction failure: T=int from first, T=long from second - apply(0, &temp<long>); // expected-error {{no matching function for call to 'apply'}} - } - - void over(int); - int over(long); - - void test1() { - // okay: deductions match - apply(0, &over); - - // deduction failure: deduced T=long from first argument, T=int from second - apply(0L, &over); // expected-error {{no matching function for call to 'apply'}} - } - - void over(short); - - void test2() { - // deduce T=int from first arg, second arg is undeduced context, - // pick correct overload of 'over' during overload resolution for 'apply' - apply(0, &over); - } - - template<class A, class B> B temp2(A); - void test3() { - // deduce T=int from first arg, A=int B=void during overload resolution - apply(0, &temp2); - apply(0, &temp2<>); - apply(0, &temp2<int>); - - // overload failure - apply(0, &temp2<long>); // expected-error {{no matching function for call to 'apply'}} - } -} - -namespace test1 { - template<class T> void invoke(void (*f)(T)) { f(T()); } // expected-note 6 {{couldn't infer template argument}} \ - // expected-note {{candidate template ignored: couldn't infer template argument 'T'}} - - template<class T> void temp(T); - void test0() { - // deduction failure: overload has template => undeduced context - invoke(&temp); // expected-error {{no matching function for call to 'invoke'}} - invoke(&temp<>); // expected-error {{no matching function for call to 'invoke'}} - - // okay: full template-id - invoke(&temp<int>); - } - - void over(int); - int over(long); - - void test1() { - // okay: only one overload matches - invoke(&over); - } - - void over(short); - - void test2() { - // deduction failure: overload has multiple matches => undeduced context - invoke(&over); // expected-error {{no matching function for call to 'invoke'}} - } - - template<class A, class B> B temp2(A); - void test3() { - // deduction failure: overload has template => undeduced context - // (even though partial application temp2<int> could in theory - // let us infer T=int) - invoke(&temp2); // expected-error {{no matching function for call to 'invoke'}} - invoke(&temp2<>); // expected-error {{no matching function for call to 'invoke'}} - invoke(&temp2<int>); // expected-error {{no matching function for call to 'invoke'}} - - // okay: full template-id - invoke(&temp2<int, void>); - - // overload failure - invoke(&temp2<int, int>); // expected-error {{no matching function for call to 'invoke'}} - } -} - -namespace rdar8360106 { - template<typename R, typename T> void f0(R (*)(T), T); - template<typename R, typename T> void f1(R (&)(T) , T); // expected-note{{candidate template ignored: couldn't infer template argument 'R'}} - template<typename R, typename T> void f2(R (* const&)(T), T); // expected-note{{candidate template ignored: couldn't infer template argument 'R'}} - - int g(int); - int g(int, int); - - void h() { - f0(g, 1); - f0(&g, 1); - f1(g, 1); - f1(&g, 1); // expected-error{{no matching function for call to 'f1'}} - f2(g, 1); // expected-error{{no matching function for call to 'f2'}} - f2(&g, 1); - } -} - -namespace PR11713 { - template<typename T> - int f(int, int, int); - - template<typename T> - float f(float, float); - - template<typename R, typename B1, typename B2, typename A1, typename A2> - R& g(R (*)(B1, B2), A1, A2); - - void h() { - float &fr = g(f<int>, 1, 2); - } -} diff --git a/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.conv/p2.cpp b/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.conv/p2.cpp deleted file mode 100644 index badd5a8c6a2c..000000000000 --- a/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.conv/p2.cpp +++ /dev/null @@ -1,37 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -// expected-no-diagnostics - -// FIXME: [temp.deduct.conv]p2 bullets 1 and 2 can't actually happen without -// references? -// struct ConvertibleToArray { -// // template<typename T, unsigned N> -// // operator T(()[]) const; - -// private: -// typedef int array[17]; - -// operator array() const; -// }; - -// void test_array(ConvertibleToArray cta) { -// int *ip = cta; -// ip = cta; -// const float *cfp = cta; -// } - -// bullet 2 -// struct ConvertibleToFunction { -// template<typename T, typename A1, typename A2> -// operator T(A1, A2) const () { }; -// }; - -// bullet 3 -struct ConvertibleToCVQuals { - template<typename T> - operator T* const() const; -}; - -void test_cvqual_conv(ConvertibleToCVQuals ctcv) { - int *ip = ctcv; - const int *icp = ctcv; -} diff --git a/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.conv/p3.cpp b/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.conv/p3.cpp deleted file mode 100644 index a5916ba65377..000000000000 --- a/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.conv/p3.cpp +++ /dev/null @@ -1,31 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -// expected-no-diagnostics -struct AnyPtr { - template<typename T> - operator T*() const; -}; - -// If A is a cv-qualified type, the top level cv-qualifiers of A's type -// are ignored for type deduction. -void test_cvquals(AnyPtr ap) { - int* const ip = ap; - const float * const volatile fp = ap; -} - -// If A is a reference type, the type referred to by A is used for -// type deduction. -void test_ref_arg(AnyPtr ap) { - const int* const &ip = ap; - double * const &dp = ap; -} - -struct AnyRef { - template<typename T> - operator T&() const; -}; - -void test_ref_param(AnyRef ar) { - int &ir = ar; - const float &fr = ar; - int i = ar; -} diff --git a/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.conv/p4.cpp b/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.conv/p4.cpp deleted file mode 100644 index 085976b08133..000000000000 --- a/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.conv/p4.cpp +++ /dev/null @@ -1,149 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only %s -verify -// RUN: %clang_cc1 -std=c++11 -fsyntax-only %s -verify -// RUN: %clang_cc1 -std=c++17 -fsyntax-only %s -verify - -struct AnyT { - template<typename T> - operator T(); -}; - -void test_cvqual_ref(AnyT any) { - const int &cir = any; -} - -struct AnyThreeLevelPtr { - template<typename T> - operator T***() const { - T x = 0; // expected-note 2{{declared const here}} - x = 0; // expected-error 2{{const-qualified type}} - T ***p; - return p; - } -}; - -struct X { }; - -void test_deduce_with_qual(AnyThreeLevelPtr a3) { - int * const * const * const ip1 = a3; - // FIXME: This is wrong; we are supposed to deduce 'T = int' here. - const int * const * const * const ip2 = a3; // expected-note {{instantiation of}} - // This one is correct, though. - const double * * * ip3 = a3; // expected-note {{instantiation of}} -} - -struct AnyPtrMem { - template<typename Class, typename T> - operator T Class::*() const - { - // This is correct: we don't need a qualification conversion here, so we - // deduce 'T = const float'. - T x = 0; // expected-note {{declared const here}} - x = 0; // expected-error {{const-qualified type}} - return 0; - } -}; - -void test_deduce_ptrmem_with_qual(AnyPtrMem apm) { - const float X::* pm = apm; // expected-note {{instantiation of}} -} - -struct TwoLevelPtrMem { - template<typename Class1, typename Class2, typename T> - operator T Class1::*Class2::*() const - { - T x = 0; // expected-note 2{{declared const here}} - x = 0; // expected-error 2{{const-qualified type}} - return 0; - } -}; - -void test_deduce_two_level_ptrmem_with_qual(TwoLevelPtrMem apm) { - // FIXME: This is wrong: we should deduce T = 'float' - const float X::* const X::* pm2 = apm; // expected-note {{instantiation of}} - // This is correct: we don't need a qualification conversion, so we directly - // deduce T = 'const double' - const double X::* X::* pm1 = apm; // expected-note {{instantiation of}} -} - -namespace non_ptr_ref_cv_qual { - template<typename Expected> - struct ConvToT { - template<typename T> operator T() { - using Check = T; - using Check = Expected; - } - }; - const int test_conv_to_t_1 = ConvToT<int>(); - // We intentionally deviate from [temp.deduct.conv]p4 here, and also remove - // the top-level cv-quaifiers from A *after* removing the reference type, if - // P is not also a reference type. This matches what other compilers are - // doing, and is necessary to support real-world code. - const int &test_conv_to_t_2 = ConvToT<int>(); - - // Example code that would be broken by the standard's rule. - struct Dest {}; - Dest d1a((ConvToT<Dest>())); - Dest d1b = ConvToT<Dest>(); - Dest &d2 = (d1a = ConvToT<Dest>()); - - template<typename Expected> - struct ConvToTRef { - template<typename T> operator T&() { - using Check = T; - using Check = Expected; - } - }; - const int test_conv_to_t_ref_1 = ConvToTRef<int>(); - const int &test_conv_to_t_ref_2 = ConvToTRef<const int>(); - - Dest d3a((ConvToTRef<const Dest>())); // initialize the copy ctor parameter with 'const Dest&' - Dest d3b = ConvToTRef<Dest>(); // convert to non-const T via [over.match.copy]/1.2 - Dest &d4 = (d3a = ConvToTRef<const Dest>()); - - template<typename Expected> - struct ConvToConstT { - template<typename T> operator const T() { - using Check = T; - using Check = Expected; - } - }; - const int test_conv_to_const_t_1 = ConvToConstT<int>(); - const int &test_conv_to_const_t_2 = ConvToConstT<int>(); - - template<typename Expected> - struct ConvToConstTRef { - template<typename T> operator const T&() { - using Check = T; - using Check = Expected; - } - }; - const int test_conv_to_const_t_ref_1 = ConvToConstTRef<int>(); - const int &test_conv_to_const_t_ref_2 = ConvToConstTRef<int>(); - - template <typename T, int N> using Arr = T[N]; - struct ConvToArr { - template <int N> - operator Arr<int, N> &() { - static_assert(N == 3, ""); - } - }; - int (&test_conv_to_arr_1)[3] = ConvToArr(); // ok - const int (&test_conv_to_arr_2)[3] = ConvToArr(); // ok, with qualification conversion - -#if __cplusplus >= 201702L - template<bool Noexcept, typename T, typename ...U> using Function = T(U...) noexcept(Noexcept); - template<bool Noexcept> struct ConvToFunction { - template <typename T, typename ...U> operator Function<Noexcept, T, U...>&(); // expected-note {{candidate}} - }; - void (&fn1)(int) noexcept(false) = ConvToFunction<false>(); - void (&fn2)(int) noexcept(true) = ConvToFunction<false>(); // expected-error {{no viable}} - void (&fn3)(int) noexcept(false) = ConvToFunction<true>(); - void (&fn4)(int) noexcept(true) = ConvToFunction<true>(); - - struct ConvToFunctionDeducingNoexcept { - template <bool Noexcept, typename T, typename ...U> operator Function<Noexcept, T, U...>&(); - }; - void (&fn5)(int) noexcept(false) = ConvToFunctionDeducingNoexcept(); - void (&fn6)(int) noexcept(true) = ConvToFunctionDeducingNoexcept(); -#endif -} diff --git a/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.conv/p5.cpp b/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.conv/p5.cpp deleted file mode 100644 index 8821d538dcbe..000000000000 --- a/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.conv/p5.cpp +++ /dev/null @@ -1,61 +0,0 @@ -// RUN: %clang_cc1 -std=c++1z -verify %s - -template<typename T, bool B> using Fn = T () noexcept(B); - -// - If the original A is a function pointer type, A can be "pointer to -// function" even if the deduced A is "pointer to noexcept function". -struct A { - template<typename T> operator Fn<T, false>*(); // expected-note {{candidate}} -}; -struct B { - template<typename T> operator Fn<T, true>*(); -}; -void (*p1)() = A(); -void (*p2)() = B(); -void (*p3)() noexcept = A(); // expected-error {{no viable conversion}} -void (*p4)() noexcept = B(); - -// - If the original A is a pointer to member function type, A can be "pointer -// to member of type function" even if the deduced A is "pointer to member of -// type noexcept function". -struct C { - template<typename T> operator Fn<T, false> A::*(); // expected-note {{candidate}} -}; -struct D { - template<typename T> operator Fn<T, true> A::*(); -}; -void (A::*q1)() = C(); -void (A::*q2)() = D(); -void (A::*q3)() noexcept = C(); // expected-error {{no viable conversion}} -void (A::*q4)() noexcept = D(); - -// There is no corresponding rule for references. -// FIXME: This seems like a defect. -// FIXME: We don't actually implement the final check for equal types at all! -// Instead, we handle the matching via [over.ics.user]p3: -// "If the user-defined conversion is specified by a specialization of a -// conversion function template, the second standard conversion sequence -// shall have exact match rank." -// Note that this *does* allow discarding noexcept, since that conversion has -// Exact Match rank. -struct E { - template<typename T> operator Fn<T, false>&(); // expected-note {{candidate}} -}; -struct F { - template<typename T> operator Fn<T, true>&(); -}; -void (&r1)() = E(); -void (&r2)() = F(); -void (&r3)() noexcept = E(); // expected-error {{no viable conversion}} -void (&r4)() noexcept = F(); - -// FIXME: We reject this for entirely the wrong reason. We incorrectly succeed -// in deducing T = void, U = G::B, and only fail due to [over.ics.user]p3. -struct G { - template<typename, typename> struct A {}; - template<typename U> struct A<U, int> : A<U, void> {}; - struct B { typedef int type; }; - - template<typename T, typename U = B> operator A<T, typename U::type> *(); // expected-note {{candidate function [with T = void, U = G::B]}} -}; -G::A<void, void> *g = G(); // expected-error {{no viable conversion}} diff --git a/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.funcaddr/p1.cpp b/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.funcaddr/p1.cpp deleted file mode 100644 index 99a265af394c..000000000000 --- a/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.funcaddr/p1.cpp +++ /dev/null @@ -1,22 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only %s - -template<typename T> - T f0(T, int); - -void test_f0() { - int (*f0a)(int, int) = f0; - int (*f0b)(int, int) = &f0; - float (*f0c)(float, int) = &f0; -} - -template<typename T> T f1(T, int); -template<typename T> T f1(T); - -void test_f1() { - float (*f1a)(float, int) = f1; - float (*f1b)(float, int) = &f1; - float (*f1c)(float) = f1; - float (*f1d)(float) = (f1); - float (*f1e)(float) = &f1; - float (*f1f)(float) = (&f1); -} diff --git a/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.partial/p11.cpp b/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.partial/p11.cpp deleted file mode 100644 index 01155e136aad..000000000000 --- a/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.partial/p11.cpp +++ /dev/null @@ -1,47 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s - -template <class T> T* f(int); // #1 -template <class T, class U> T& f(U); // #2 - -void g() { - int *ip = f<int>(1); // calls #1 -} - -template<typename T> -struct identity { - typedef T type; -}; - -template <class T> - T* f2(int, typename identity<T>::type = 0); -template <class T, class U> - T& f2(U, typename identity<T>::type = 0); - -void g2() { - int* ip = f2<int>(1); -} - -template<class T, class U> struct A { }; - -template<class T, class U> inline int *f3( U, A<U,T>* p = 0 ); // #1 expected-note{{candidate function [with T = int, U = int]}} -template< class U> inline float *f3( U, A<U,U>* p = 0 ); // #2 expected-note{{candidate function [with U = int]}} - -void g3() { - float *fp = f3<int>( 42, (A<int,int>*)0 ); // Ok, picks #2. - f3<int>( 42 ); // expected-error{{call to 'f3' is ambiguous}} - -} - -namespace PR9006 { - struct X { - template <class Get> - int &f(char const* name, Get fget, char const* docstr = 0); - - template <class Get, class Set> - float &f(char const* name, Get fget, Set fset, char const* docstr = 0); - }; - - void test(X x) { - int &ir = x.f("blah", 0, "blah"); - } -} diff --git a/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.partial/p12.cpp b/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.partial/p12.cpp deleted file mode 100644 index ec7e8970b1b5..000000000000 --- a/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.partial/p12.cpp +++ /dev/null @@ -1,28 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s -// expected-no-diagnostics - -// Note: Partial ordering of function templates containing template -// parameter packs is independent of the number of deduced arguments -// for those template parameter packs. -template<class ...> struct Tuple { }; -template<class ... Types> int &g(Tuple<Types ...>); // #1 -template<class T1, class ... Types> float &g(Tuple<T1, Types ...>); // #2 -template<class T1, class ... Types> double &g(Tuple<T1, Types& ...>); // #3 - -void test_g() { - int &ir1 = g(Tuple<>()); - float &fr1 = g(Tuple<int, float>()); - double &dr1 = g(Tuple<int, float&>()); - double &dr2 = g(Tuple<int>()); -} - -template<class ... Types> int &h(int (*)(Types ...)); // #1 -template<class T1, class ... Types> float &h(int (*)(T1, Types ...)); // #2 -template<class T1, class ... Types> double &h(int (*)(T1, Types& ...)); // #3 - -void test_h() { - int &ir1 = h((int(*)())0); - float &fr1 = h((int(*)(int, float))0); - double &dr1 = h((int(*)(int, float&))0); - double &dr2 = h((int(*)(int))0); -} diff --git a/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.partial/p9-0x.cpp b/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.partial/p9-0x.cpp deleted file mode 100644 index cc129c0a9b2e..000000000000 --- a/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.partial/p9-0x.cpp +++ /dev/null @@ -1,11 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s -// expected-no-diagnostics - -template<typename T> int &f0(T&); -template<typename T> float &f0(T&&); - -// Core issue 1164 -void test_f0(int i) { - int &ir0 = f0(i); - float &fr0 = f0(5); -} diff --git a/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.type/p1.cpp b/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.type/p1.cpp deleted file mode 100644 index 33d8182ab14e..000000000000 --- a/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.type/p1.cpp +++ /dev/null @@ -1,10 +0,0 @@ -// RUN: %clang_cc1 -verify %s - -// an attempt is made to find template argument values that will make P, after -// substitution of the deduced values, compatible with A - -namespace cv_mismatch { - template<typename> struct X {}; - template<typename T> void f(X<const T>); // expected-note {{cannot deduce a type for 'T' that would make 'const T' equal 'volatile int'}} - void g() { f(X<volatile int>()); } // expected-error {{no matching}} -} diff --git a/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.type/p10-0x.cpp b/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.type/p10-0x.cpp deleted file mode 100644 index b38ade39edf2..000000000000 --- a/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.type/p10-0x.cpp +++ /dev/null @@ -1,5 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s -// expected-no-diagnostics -template<typename T> void f(T&&); -template<> void f(int&) { } -void (*fp)(int&) = &f; diff --git a/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.type/p17.cpp b/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.type/p17.cpp deleted file mode 100644 index bf5f96225dad..000000000000 --- a/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.type/p17.cpp +++ /dev/null @@ -1,31 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s - -template<int i> class A { }; -template<short s> void f(A<s>); // expected-note{{candidate template ignored: substitution failure}} - -void k1() { - A<1> a; - f(a); // expected-error{{no matching function for call}} - f<1>(a); -} -template<const short cs> class B { }; -template<short s> void g(B<s>); -void k2() { - B<1> b; - g(b); // OK: cv-qualifiers are ignored on template parameter types -} - -template<short s> void h(int (&)[s]); // expected-note{{candidate function template not viable: requires 1 argument, but 2 were provided}} -void k3() { - int array[5]; - h(array); - h<5>(array); -} - -template<short s> void h(int (&)[s], A<s>); // expected-note{{candidate template ignored: substitution failure}} -void k4() { - A<5> a; - int array[5]; - h(array, a); // expected-error{{no matching function for call}} - h<5>(array, a); -} diff --git a/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.type/p2-0x.cpp b/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.type/p2-0x.cpp deleted file mode 100644 index e3a9f5798dbf..000000000000 --- a/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.type/p2-0x.cpp +++ /dev/null @@ -1,24 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s -// expected-no-diagnostics - -// If type deduction cannot be done for any P/A pair, or if for any -// pair the deduction leads to more than one possible set of deduced -// values, or if different pairs yield different deduced values, or if -// any template argument remains neither deduced nor explicitly -// specified, template argument deduction fails. - -template<typename ...> struct tuple; - -template<typename T, typename U> -struct same_tuple { - static const bool value = false; -}; - -template<typename ...Types1> -struct same_tuple<tuple<Types1...>, tuple<Types1...> > { - static const bool value = true; -}; - -int same_tuple_check1[same_tuple<tuple<int, float>, tuple<int, double>>::value? -1 : 1]; -int same_tuple_check2[same_tuple<tuple<float, double>, tuple<float, double>>::value? 1 : -1]; - diff --git a/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.type/p21.cpp b/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.type/p21.cpp deleted file mode 100644 index 20e6ea2d7127..000000000000 --- a/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.type/p21.cpp +++ /dev/null @@ -1,32 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s -// expected-no-diagnostics - -// Note: Template argument deduction involving parameter packs -// (14.5.3) can deduce zero or more arguments for each parameter pack. - -template<class> struct X { - static const unsigned value = 0; -}; - -template<class R, class ... ArgTypes> struct X<R(int, ArgTypes ...)> { - static const unsigned value = 1; -}; - -template<class ... Types> struct Y { - static const unsigned value = 0; -}; - -template<class T, class ... Types> struct Y<T, Types& ...> { - static const unsigned value = 1; -}; - -template<class ... Types> int f(void (*)(Types ...)); -void g(int, float); - -int check0[X<int>::value == 0? 1 : -1]; // uses primary template -int check1[X<int(int, float, double)>::value == 1? 1 : -1]; // uses partial specialization -int check2[X<int(float, int)>::value == 0? 1 : -1]; // uses primary template -int check3[Y<>::value == 0? 1 : -1]; // uses primary template -int check4[Y<int&, float&, double&>::value == 1? 1 : -1]; // uses partial specialization -int check5[Y<int, float, double>::value == 0? 1 : -1]; // uses primary template -int fv = f(g); // okay diff --git a/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.type/p22.cpp b/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.type/p22.cpp deleted file mode 100644 index 09b1648e68e7..000000000000 --- a/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.type/p22.cpp +++ /dev/null @@ -1,15 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s -// expected-no-diagnostics - -// If the original function parameter associated with A is a function -// parameter pack and the function parameter associated with P is not -// a function parameter pack, then template argument deduction fails. -template<class ... Args> int& f(Args ... args); -template<class T1, class ... Args> float& f(T1 a1, Args ... args); -template<class T1, class T2> double& f(T1 a1, T2 a2); - -void test_f() { - int &ir1 = f(); - float &fr1 = f(1, 2, 3); - double &dr1 = f(1, 2); -} diff --git a/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.type/p5-0x.cpp b/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.type/p5-0x.cpp deleted file mode 100644 index 697412995b33..000000000000 --- a/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.type/p5-0x.cpp +++ /dev/null @@ -1,37 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s - -// FIXME: More bullets to go! - -template<typename T, typename U> -struct has_nondeduced_pack_test { - static const bool value = false; -}; - -template<typename R, typename FirstType, typename ...Types> -struct has_nondeduced_pack_test<R(FirstType, Types..., int), - R(FirstType, Types...)> { - static const bool value = true; -}; - -// - A function parameter pack that does not occur at the end of the -// parameter-declaration-clause. -// -// We interpret [temp.deduct.call]p1's -// -// "When a function parameter pack appears in a non-deduced context -// (12.9.2.5), the type of that pack is never deduced." -// -// as applying in all deduction contexts, not just [temp.deduct.call], -// so we do *not* deduce Types from the second argument here. (More -// precisely, we deduce it as <> when processing the first argument, -// and then fail because 'int' doesn't match 'double, int'.) -int check_nondeduced_pack_test0[ - has_nondeduced_pack_test<int(float, double, int), - int(float, double)>::value? -1 : 1]; - -template<typename ...T> void has_non_trailing_pack(T ..., int); -void (*ptr_has_non_trailing_pack)(char, int) = has_non_trailing_pack<char>; - -template<typename ...T, typename U> void has_non_trailing_pack_and_more(T ..., U); // expected-note {{failed}} -void (*ptr_has_non_trailing_pack_and_more_1)(float, double, int) = &has_non_trailing_pack_and_more<float, double>; -void (*ptr_has_non_trailing_pack_and_more_2)(float, double, int) = &has_non_trailing_pack_and_more<float>; // expected-error {{does not match}} diff --git a/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.type/p8-0x.cpp b/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.type/p8-0x.cpp deleted file mode 100644 index 6ef8e2fd5ecd..000000000000 --- a/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.type/p8-0x.cpp +++ /dev/null @@ -1,48 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s -// expected-no-diagnostics - -// Deductions specific to C++0x. - -template<typename T> -struct member_pointer_kind { - static const unsigned value = 0; -}; - -template<class C, typename R, typename ...Args> -struct member_pointer_kind<R (C::*)(Args...)> { - static const unsigned value = 1; -}; - -template<class C, typename R, typename ...Args> -struct member_pointer_kind<R (C::*)(Args...) &> { - static const unsigned value = 2; -}; - -template<class C, typename R, typename ...Args> -struct member_pointer_kind<R (C::*)(Args...) &&> { - static const unsigned value = 3; -}; - -template<class C, typename R, typename ...Args> -struct member_pointer_kind<R (C::*)(Args...) const> { - static const unsigned value = 4; -}; - -template<class C, typename R, typename ...Args> -struct member_pointer_kind<R (C::*)(Args...) const &> { - static const unsigned value = 5; -}; - -template<class C, typename R, typename ...Args> -struct member_pointer_kind<R (C::*)(Args...) const &&> { - static const unsigned value = 6; -}; - -struct X { }; - -static_assert(member_pointer_kind<int (X::*)(int)>::value == 1, ""); -static_assert(member_pointer_kind<int (X::*)(int) &>::value == 2, ""); -static_assert(member_pointer_kind<int (X::*)(int) &&>::value == 3, ""); -static_assert(member_pointer_kind<int (X::*)(int) const>::value == 4, ""); -static_assert(member_pointer_kind<int (X::*)(int) const&>::value == 5, ""); -static_assert(member_pointer_kind<int (X::*)(int) const&&>::value == 6, ""); diff --git a/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.type/p9-0x.cpp b/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.type/p9-0x.cpp deleted file mode 100644 index fccac8f1e5a4..000000000000 --- a/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.type/p9-0x.cpp +++ /dev/null @@ -1,106 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s - -template<typename ...Types> struct tuple; -template<unsigned> struct unsigned_c; - -template<typename T, typename U> -struct is_same { - static const bool value = false; -}; - -template<typename T> -struct is_same<T, T> { - static const bool value = true; -}; - -namespace PackExpansionNotAtEnd { - template<typename T, typename U> - struct tuple_same_with_int { - static const bool value = false; - }; - - template<typename ...Types> - struct tuple_same_with_int<tuple<Types...>, tuple<Types..., int>> { - static const bool value = true; - }; - - int tuple_same_with_int_1[tuple_same_with_int<tuple<int, float, double>, - tuple<int, float, double, int> - >::value? 1 : -1]; - - template<typename ... Types> struct UselessPartialSpec; - - template<typename ... Types, // expected-note{{non-deducible template parameter 'Types'}} - typename Tail> // expected-note{{non-deducible template parameter 'Tail'}} - struct UselessPartialSpec<Types..., Tail>; // expected-error{{class template partial specialization contains template parameters that cannot be deduced; this partial specialization will never be used}} -} - -// When a pack expansion occurs within a template argument list, the entire -// list is a non-deduced context. For the corresponding case in a function -// parameter list, only that parameter is non-deduced. -// -// FIXME: It's not clear that this difference is intended, but the wording is -// explicit. -namespace PackExpansionNotAtEndFunctionVersusTemplate { - template<typename ...T> struct X {}; - template<typename ...T, typename U> void f1(void(T..., U)); - // expected-note@+1 {{couldn't infer template argument 'U'}} - template<typename ...T, typename U> void f2(X<T..., U>); // FIXME: ill-formed, U is not deducible - - void g(int, int, int); - X<int, int, int> h; - void test() { - // This is deducible: the T... parameter is a non-deduced context, but - // that's OK because we don't need to deduce it. - f1<int, int>(g); - // This is not deducible: the T... parameter renders the entire - // template-argument-list a non-deduced context, so U is not deducible. - f2<int, int>(h); // expected-error {{no matching function}} - } - - template<typename T> struct Y; - template<typename ...T, // expected-note {{non-deducible template parameter 'T'}} - typename U> - struct Y<void(T..., U)> {}; // expected-error {{cannot be deduced}} - template<typename ...T, // expected-note {{non-deducible template parameter 'T'}} - typename U> // expected-note {{non-deducible template parameter 'U'}} - struct Y<X<T..., U>>; // expected-error {{cannot be deduced}} - // FIXME: T is not deducible here, due to [temp.deduct.call]p1: - // "When a function parameter pack appears in a non-deduced context, - // the type of that pack is never deduced." - template<typename ...T, - typename U> - struct Y<void(T..., U, T...)> {}; -} - -namespace DeduceNonTypeTemplateArgsInArray { - template<typename ...ArrayTypes> - struct split_arrays; - - template<typename ...ElementTypes, unsigned ...Bounds> - struct split_arrays<ElementTypes[Bounds]...> { - typedef tuple<ElementTypes...> element_types; - - // FIXME: Would like to have unsigned_tuple<Bounds...> here. - typedef tuple<unsigned_c<Bounds>...> bounds_types; - }; - - int check1[is_same<split_arrays<int[1], float[2], double[3]>::element_types, - tuple<int, float, double>>::value? 1 : -1]; - int check2[is_same<split_arrays<int[1], float[2], double[3]>::bounds_types, - tuple<unsigned_c<1>, unsigned_c<2>, unsigned_c<3>> - >::value? 1 : -1]; -} - -namespace DeduceWithDefaultArgs { - template<template<typename...> class Container> void f(Container<int>); // expected-note {{deduced type 'X<[...], (default) int>' of 1st parameter does not match adjusted type 'X<[...], double>' of argument [with Container = X]}} - template<typename, typename = int> struct X {}; - void g() { - // OK, use default argument for the second template parameter. - f(X<int>{}); - f(X<int, int>{}); - - // Not OK. - f(X<int, double>{}); // expected-error {{no matching function for call to 'f'}} - } -} diff --git a/test/CXX/temp/temp.names/p2.cpp b/test/CXX/temp/temp.names/p2.cpp deleted file mode 100644 index 532dd84ecb43..000000000000 --- a/test/CXX/temp/temp.names/p2.cpp +++ /dev/null @@ -1,14 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -// expected-no-diagnostics - -// Ensure that when enforcing access control an unqualified template name with -// explicit template arguments, we don't lose the context of the name lookup -// because of the required early lookup to determine if it names a template. -namespace PR7163 { - template <typename R, typename P> void h(R (*func)(P)) {} - class C { - template <typename T> static void g(T*) {}; - public: - void f() { h(g<int>); } - }; -} diff --git a/test/CXX/temp/temp.names/p3-0x.cpp b/test/CXX/temp/temp.names/p3-0x.cpp deleted file mode 100644 index 85dc75e30199..000000000000 --- a/test/CXX/temp/temp.names/p3-0x.cpp +++ /dev/null @@ -1,12 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 %s -verify - -template<int i> class X { /* ... */ }; -X< 1>2 > x1; // expected-error{{expected unqualified-id}} -X<(1>2)> x2; // OK -template<class T> class Y { /* ... */ }; -Y<X<1>> x3; // OK, same as Y<X<1> > x3; -Y<X<6>>1>> x4; // expected-error{{expected unqualified-id}} -Y<X<(6>>1)>> x5; - -int a, b; -Y<decltype(a < b)> x6; diff --git a/test/CXX/temp/temp.names/p4.cpp b/test/CXX/temp/temp.names/p4.cpp deleted file mode 100644 index 64ca80517b8c..000000000000 --- a/test/CXX/temp/temp.names/p4.cpp +++ /dev/null @@ -1,16 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -// expected-no-diagnostics - -struct meta { - template<typename U> - struct apply { - typedef U* type; - }; -}; - -template<typename T, typename U> -void f(typename T::template apply<U>::type); - -void test_f(int *ip) { - f<meta, int>(ip); -} diff --git a/test/CXX/temp/temp.param/p1.cpp b/test/CXX/temp/temp.param/p1.cpp deleted file mode 100644 index e9a978961769..000000000000 --- a/test/CXX/temp/temp.param/p1.cpp +++ /dev/null @@ -1,12 +0,0 @@ -// Suppress 'no run line' failure. -// RUN: %clang_cc1 -fsyntax-only -verify %s - -template<template<> class C> class D; // expected-error{{template template parameter must have its own template parameters}} - - -struct A {}; -template<class M, - class T = A, // expected-note{{previous default template argument defined here}} - class C> // expected-error{{template parameter missing a default argument}} -class X0 {}; // expected-note{{template is declared here}} -X0<int> x0; // expected-error{{too few template arguments for class template 'X0'}} diff --git a/test/CXX/temp/temp.param/p10-0x.cpp b/test/CXX/temp/temp.param/p10-0x.cpp deleted file mode 100644 index 21a96bf613e6..000000000000 --- a/test/CXX/temp/temp.param/p10-0x.cpp +++ /dev/null @@ -1,14 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s -// expected-no-diagnostics - -template<typename> struct Y1; -template<typename, int> struct Y2; - -template<class T1, class T2 = int> using B2 = T1; -template<class T1 = int, class T2> using B2 = T1; - -template<template<class> class F, template<class> class G = Y1> using B2t = F<G<int>>; -template<template<class> class F = Y2, template<class> class G> using B2t = F<G<int>>; - -template<int N, int M = 5> using B2n = Y2<int, N + M>; -template<int N = 5, int M> using B2n = Y2<int, N + M>; diff --git a/test/CXX/temp/temp.param/p10.cpp b/test/CXX/temp/temp.param/p10.cpp deleted file mode 100644 index 4feea828466e..000000000000 --- a/test/CXX/temp/temp.param/p10.cpp +++ /dev/null @@ -1,13 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -// expected-no-diagnostics -template<typename> struct Y1; -template<typename, int> struct Y2; - -template<class T1, class T2 = int> class B2; -template<class T1 = int, class T2> class B2; - -template<template<class, int> class, template<class> class = Y1> class B2t; -template<template<class, int> class = Y2, template<class> class> class B2t; - -template<int N, int M = 5> class B2n; -template<int N = 5, int M> class B2n; diff --git a/test/CXX/temp/temp.param/p11-0x.cpp b/test/CXX/temp/temp.param/p11-0x.cpp deleted file mode 100644 index d2276a3bced3..000000000000 --- a/test/CXX/temp/temp.param/p11-0x.cpp +++ /dev/null @@ -1,81 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s - -// If a template-parameter of a class template or alias template has a default -// template-argument, each subsequent template-parameter shall either have a -// default template-argument supplied or be a template parameter pack. -template<typename> struct vector; - -template<typename T = int, typename> struct X3t; // expected-error{{template parameter missing a default argument}} expected-note{{previous default template argument defined here}} -template<typename T = int, typename> using A3t = int; // expected-error{{template parameter missing a default argument}} expected-note{{previous default template argument defined here}} -template<int V = 0, int> struct X3nt; // expected-error{{template parameter missing a default argument}} expected-note{{previous default template argument defined here}} -template<int V = 0, int> using A3nt = int; // expected-error{{template parameter missing a default argument}} expected-note{{previous default template argument defined here}} -template<template<class> class M = vector, template<class> class> struct X3tt; // expected-error{{template parameter missing a default argument}} expected-note{{previous default template argument defined here}} -template<template<class> class M = vector, template<class> class> using A3tt = int; // expected-error{{template parameter missing a default argument}} expected-note{{previous default template argument defined here}} - -template<typename T = int, typename ...Types> struct X2t; -template<typename T = int, typename ...Types> using A2t = X2t<T, Types...>; -template<int V = 0, int ...Values> struct X2nt; -template<int V = 0, int ...Values> using A2nt = X2nt<V, Values...>; -template<template<class> class M = vector, template<class> class... Metas> - struct X2tt; -template<template<class> class M = vector, template<class> class... Metas> - using A2tt = X2tt<M, Metas...>; - -// If a template-parameter of a primary class template or alias template is a -// template parameter pack, it shall be the last template-parameter. -template<typename ...Types, // expected-error{{template parameter pack must be the last template parameter}} - int After, int After2> -struct X0t; -X0t<int> pr9789(); -template<typename ...Types, // expected-error{{template parameter pack must be the last template parameter}} - int After> -using A0t = int; - -template<int ...Values, // expected-error{{template parameter pack must be the last template parameter}} - int After> -struct X0nt; -template<int ...Values, // expected-error{{template parameter pack must be the last template parameter}} - int After> -using A0nt = int; - -template<template<typename> class ...Templates, // expected-error{{template parameter pack must be the last template parameter}} - int After> -struct X0tt; -template<template<typename> class ...Templates, // expected-error{{template parameter pack must be the last template parameter}} - int After> -using A0tt = int; - -// [ Note: These are not requirements for function templates or class -// template partial specializations because template arguments can be -// deduced (14.8.2). -- end note] -template<typename... Types> struct X1t; -template<typename ...Types, typename T> struct X1t<T, Types...> { }; - -template<int... Values> struct X1nt; -template<int ...Values, int V> struct X1nt<V, Values...> { }; - -template<template<int> class... Meta> struct X1tt; -template<template<int> class... Meta, template<int> class M> - struct X1tt<M, Meta...> { }; - -template<typename ...Types, typename T> -void f1t(X1t<T, Types...>); - -template<int ...Values, int V> -void f1nt(X1nt<V, Values...>); - -template<template<int> class... Meta, template<int> class M> -void f1tt(X1tt<M, Meta...>); - -namespace DefaultTemplateArgsInFunction { - template<typename T = int, typename U> T &f0(U) { T *x = 0; return *x; } - - void test_f0() { - int &ir0 = f0(3.14159); - int &ir1 = f0<int>(3.14159); - float &fr0 = f0<float>(3.14159); - } - - template<> int &f0(int*); - template int &f0(double&); -} diff --git a/test/CXX/temp/temp.param/p11.cpp b/test/CXX/temp/temp.param/p11.cpp deleted file mode 100644 index 5af0c4e91b56..000000000000 --- a/test/CXX/temp/temp.param/p11.cpp +++ /dev/null @@ -1,15 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -template<typename> struct Y1; -template<typename, int> struct Y2; - -template<class T1 = int, // expected-note{{previous default template argument defined here}} - class T2> // expected-error{{template parameter missing a default argument}} - class B1; - -template<template<class> class = Y1, // expected-note{{previous default template argument defined here}} - template<class> class> // expected-error{{template parameter missing a default argument}} - class B1t; - -template<int N = 5, // expected-note{{previous default template argument defined here}} - int M> // expected-error{{template parameter missing a default argument}} - class B1n; diff --git a/test/CXX/temp/temp.param/p12.cpp b/test/CXX/temp/temp.param/p12.cpp deleted file mode 100644 index 7be38790905f..000000000000 --- a/test/CXX/temp/temp.param/p12.cpp +++ /dev/null @@ -1,39 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -template<typename> struct Y1; // expected-note{{too few template parameters in template template argument}} -template<typename, int> struct Y2; - -// C++ [temp.param]p12: -template<class T1, - class T2 = int> // expected-note{{previous default template argument defined here}} - class B3; -template<class T1, typename T2> class B3; -template<class T1, - typename T2 = float> // expected-error{{template parameter redefines default argument}} - class B3; - -template<template<class, int> class, - template<class> class = Y1> // expected-note{{previous default template argument defined here}} - class B3t; - -template<template<class, int> class, template<class> class> class B3t; - -template<template<class, int> class, - template<class> class = Y1> // expected-error{{template parameter redefines default argument}} - class B3t; - -template<int N, - int M = 5> // expected-note{{previous default template argument defined here}} - class B3n; - -template<int N, int M> class B3n; - -template<int N, - int M = 7> // expected-error{{template parameter redefines default argument}} - class B3n; - -// Check validity of default arguments -template<template<class, int> class // expected-note{{previous template template parameter is here}} - = Y1> // expected-error{{template template argument has different template parameters than its corresponding template template parameter}} - class C1 {}; - -C1<> c1; // expected-note{{while checking a default template argument}} diff --git a/test/CXX/temp/temp.param/p13.cpp b/test/CXX/temp/temp.param/p13.cpp deleted file mode 100644 index 257b36f4f96f..000000000000 --- a/test/CXX/temp/temp.param/p13.cpp +++ /dev/null @@ -1,15 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -// expected-no-diagnostics - -// The scope of atemplate-parameterextends from its point of -// declaration until the end of its template. In particular, a -// template-parameter can be used in the declaration of subsequent -// template-parameters and their default arguments. - -template<class T, T* p, class U = T> class X { /* ... */ }; -// FIXME: template<class T> void f(T* p = new T); - -// Check for bogus template parameter shadow warning. -template<template<class T> class, - template<class T> class> - class B1noshadow; diff --git a/test/CXX/temp/temp.param/p15-cxx0x.cpp b/test/CXX/temp/temp.param/p15-cxx0x.cpp deleted file mode 100644 index 667152da1cbc..000000000000 --- a/test/CXX/temp/temp.param/p15-cxx0x.cpp +++ /dev/null @@ -1,178 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s -template<typename T> struct X; // expected-note {{'X' is incomplete}} -template<int I> struct Y; - -X<X<int>> *x1; - -Y<(1 >> 2)> *y1; -Y<1 >> 2> *y2; // FIXME: expected-error{{expected unqualified-id}} - -X<X<X<X<X<int>>>>> *x2; - -template<> struct X<int> { }; -typedef X<int> X_int; -struct Z : X_int { }; - -void f(const X<int> x) { - (void)reinterpret_cast<X<int>>(x); // expected-error{{reinterpret_cast from}} - (void)reinterpret_cast<X<X<X<int>>>>(x); // expected-error{{reinterpret_cast from}} - - X<X<int>> *x1; -} - -template<typename T = void> struct X1 { }; -X1<X1<>> x1a; - - -namespace ParameterPackExpansions { - -// A template parameter pack that [contains an unexpanded parameter pack] is a -// pack expansion. - -template<typename...Ts> struct Outer { - // From [temp.variadic]p4: - // In a template parameter pack that is a pack expansion, the pattern is - // [...the template-parameter...] without the ellipsis. - // Therefore the resulting sequence of parameters is not a parameter pack, - // so is not required to be the last template parameter. - template<Ts ...As, template<Ts> class ...Bs, typename ...Cs> struct Inner { - struct Check : Bs<As>... { - Check(Cs...); - }; - }; -}; - -template<int> struct TemplateInt {}; -template<char> struct TemplateChar {}; -template<int*> struct TemplateIntPtr {}; -int x; - -Outer<int, char, int*>:: -Inner<12345, 'x', &x, - TemplateInt, TemplateChar, TemplateIntPtr, - int*>:: -Check check(&x); - - -template<typename...Ts> struct types; - -enum place { _ }; -template<place...> struct places {}; - -template<typename P1, typename P2> struct append_places; -template<place...X1, place...X2> -struct append_places<places<X1...>, places<X2...>> { - typedef places<X1...,X2...> type; -}; - -template<unsigned N> -struct make_places : append_places<typename make_places<N/2>::type, - typename make_places<N-N/2>::type> {}; -template<> struct make_places<0> { typedef places<> type; }; -template<> struct make_places<1> { typedef places<_> type; }; - -template<typename T> struct wrap { - template<place> struct inner { typedef T type; }; -}; - -template<typename T> struct takedrop_impl; -template<place...X> struct takedrop_impl<places<X...>> { - template<template<decltype(X)> class ...Take, - template<place > class ...Drop> - struct inner { // expected-note 2{{declared}} - typedef types<typename Take<_>::type...> take; - typedef types<typename Drop<_>::type...> drop; - }; -}; - -template<unsigned N, typename...Ts> struct take { - using type = typename takedrop_impl<typename make_places<N>::type>:: - template inner<wrap<Ts>::template inner...>::take; // expected-error {{too few template arguments}} -}; -template<unsigned N, typename...Ts> struct drop { - using type = typename takedrop_impl<typename make_places<N>::type>:: - template inner<wrap<Ts>::template inner...>::drop; // expected-error {{too few template arguments}} -}; - -using T1 = take<3, int, char, double, long>::type; // expected-note {{previous}} -// FIXME: Desguar the types on the RHS in this diagnostic. -// desired-error {{'types<void, void, void, void>' vs 'types<int, char, double, (no argument)>'}} -using T1 = types<void, void, void, void>; // expected-error {{'types<void, void, void, void>' vs 'types<typename inner<_>::type, typename inner<_>::type, typename inner<_>::type, (no argument)>'}} -using D1 = drop<3, int, char, double, long>::type; -using D1 = types<long>; - -using T2 = take<4, int, char, double, long>::type; // expected-note {{previous}} -// FIXME: Desguar the types on the RHS in this diagnostic. -// desired-error {{'types<void, void, void, void>' vs 'types<int, char, double, long>'}} -using T2 = types<void, void, void, void>; // expected-error {{'types<void, void, void, void>' vs 'types<typename inner<_>::type, typename inner<_>::type, typename inner<_>::type, typename inner<_>::type>'}} -using T2 = types<int, char, double, long>; -using D2 = drop<4, int, char, double, long>::type; -using D2 = types<>; - -using T3 = take<5, int, char, double, long>::type; // expected-note {{in instantiation of}} -using D3 = drop<5, int, char, double, long>::type; // expected-note {{in instantiation of}} - - -// FIXME: We should accept this code. A parameter pack within a default argument -// in a template template parameter pack is expanded, because the pack is -// implicitly a pack expansion. -template<typename ...Default> struct DefArg { - template<template<typename T = Default> class ...Classes> struct Inner { // expected-error {{default argument contains unexpanded parameter pack}} expected-note {{here}} - Inner(Classes<>...); // expected-error {{too few}} - }; -}; -template<typename T> struct vector {}; -template<typename T> struct list {}; -vector<int> vi; -list<char> lc; -DefArg<int, char>::Inner<vector, list> defarg(vi, lc); - - -// FIXME: -// A template parameter pack that is a pack expansion shall not expand a -// parameter pack declared in the same template-parameter-list. -template<typename...Ts, Ts...Vs> void error(); // desired-error - -// This case should not produce an error, because in A's instantiation, Cs is -// not a parameter pack. -template<typename...Ts> void consume(Ts...); -template<typename...Ts> struct A { - template<template<typename, Ts = 0> class ...Cs, Cs<Ts> ...Vs> struct B { // ok - B() { - consume([]{ - int arr[Vs]; // expected-error {{negative size}} - }...); - } - }; -}; -template<typename, int> using Int = int; -template<typename, short> using Char = char; -A<int, short>::B<Int, Char, -1, 'x'> b; // expected-note {{here}} - -} - -namespace PR9023 { - template<typename ...T> struct A { - template<template<T> class ...> struct B { - }; - }; - - template<int> struct C { }; - template<long> struct D { }; - - int main() { - A<int, long>::B<C, D> e; - } -} - -namespace std_examples { - template <class... Types> class Tuple; - template <class T, int... Dims> struct multi_array; - template <class... T> struct value_holder { - template<T... Values> struct apply { }; - }; - template <class... T, T... Values> struct static_array; // expected-error {{must be the last}} - - int n; - value_holder<int, char, int*>::apply<12345, 'x', &n> test; -} diff --git a/test/CXX/temp/temp.param/p15.cpp b/test/CXX/temp/temp.param/p15.cpp deleted file mode 100644 index ee572e986b93..000000000000 --- a/test/CXX/temp/temp.param/p15.cpp +++ /dev/null @@ -1,12 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -std=c++98 -verify %s -template<typename T> struct X; -template<int I> struct Y; - -X<X<int> > *x1; -X<X<int>> *x2; // expected-error{{a space is required between consecutive right angle brackets (use '> >')}} - -X<X<X<X<int>> // expected-error{{a space is required between consecutive right angle brackets (use '> >')}} - >> *x3; // expected-error{{a space is required between consecutive right angle brackets (use '> >')}} - -Y<(1 >> 2)> *y1; -Y<1 >> 2> *y2; // expected-warning{{use of right-shift operator ('>>') in template argument will require parentheses in C++11}} diff --git a/test/CXX/temp/temp.param/p2.cpp b/test/CXX/temp/temp.param/p2.cpp deleted file mode 100644 index c70b1d354f7c..000000000000 --- a/test/CXX/temp/temp.param/p2.cpp +++ /dev/null @@ -1,51 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s -DCPP11 -// RUN: %clang_cc1 -std=c++17 -fsyntax-only -verify %s -DCPP17 - -// There is no semantic difference between class and typename in a -// template-parameter. typename followed by an unqualified-id names a -// template type parameter. -template<class T> struct X; -template<typename T> struct X; - -// typename followed by a qualified-id denotes the type in a non-type -// parameter-declaration. -template<typename T, typename T::type Value> struct Y0; -template<typename T, typename X<T>::type Value> struct Y1; -template<typename T typename U> struct Y2; // expected-error{{expected ',' or '>'}} -template<typename T U> struct Y3; // expected-error{{expected a qualified name after 'typename'}} expected-error{{expected ',' or '>'}} -template<typedef T typename U> struct Y4; // expected-error{{expected template parameter}} expected-note {{did you mean to use 'typename'?}} expected-error{{expected ',' or '>'}} - -// A storage class shall not be specified in a template-parameter declaration. -template<static int Value> struct Z; //expected-error{{invalid declaration specifier}} -template<typedef int Value> struct Z0; //expected-error{{invalid declaration specifier}} -template<extern inline int Value> struct Z1; //expected-error2{{invalid declaration specifier}} -template<virtual int Value> struct Z2; //expected-error{{invalid declaration specifier}} -template<explicit int Value> struct Z3; //expected-error{{invalid declaration specifier}} -template<inline int Value> struct Z4; //expected-error{{invalid declaration specifier}} -template<extern int> struct Z5; //expected-error{{invalid declaration specifier}} -template<static int> struct Z6; //expected-error{{invalid declaration specifier}} -template<explicit int Value> struct Z7; //expected-error{{invalid declaration specifier}} -template<mutable int> struct Z8; //expected-error{{invalid declaration specifier}} - -template<const int> struct Z9; // OK -template<volatile int> struct Z10; // OK - - - -#ifdef CPP11 -template<thread_local int> struct Z11; //expected-error{{invalid declaration specifier}} -template<constexpr int> struct Z12; //expected-error{{invalid declaration specifier}} - -#endif - -#ifdef CPP17 -template<auto> struct Z13; // OK -#endif - -// Make sure that we properly disambiguate non-type template parameters that -// start with 'class'. -class X1 { }; -template<class X1 *xptr> struct X2 { }; - -// FIXME: add the example from p2 diff --git a/test/CXX/temp/temp.param/p3.cpp b/test/CXX/temp/temp.param/p3.cpp deleted file mode 100644 index f709630504cd..000000000000 --- a/test/CXX/temp/temp.param/p3.cpp +++ /dev/null @@ -1,46 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s - -// A type-parameter defines its identifier to be a type-name (if -// declared with class or typename) or template-name (if declared with -// template) in the scope of the template declaration. -template<typename T> struct X0 { - T* value; -}; - -template<template<class T> class Y> struct X1 { - Y<int> value; -}; - -// [Note: because of the name lookup rules, a template-parameter that -// could be interpreted as either a non-type template-parameter or a -// type-parameter (because its identifier is the name of an already -// existing class) is taken as a type-parameter. For example, -class T { /* ... */ }; // expected-note{{candidate constructor (the implicit copy constructor) not viable}} -#if __cplusplus >= 201103L // C++11 or later -// expected-note@-2 {{candidate constructor (the implicit move constructor) not viable}} -#endif - -int i; - -template<class T, T i> struct X2 { - void f(T t) - { - T t1 = i; // template-parameters T and i - ::T t2 = ::i; // global namespace members T and i \ - // expected-error{{no viable conversion}} - } -}; - -namespace PR6831 { - namespace NA { struct S; } - namespace NB { struct S; } - - using namespace NA; - using namespace NB; - - template <typename S> void foo(); - template <int S> void bar(); - template <template<typename> class S> void baz(); -} diff --git a/test/CXX/temp/temp.param/p4.cpp b/test/CXX/temp/temp.param/p4.cpp deleted file mode 100644 index 809fb20b4a3a..000000000000 --- a/test/CXX/temp/temp.param/p4.cpp +++ /dev/null @@ -1,21 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -class X; - -// C++ [temp.param]p4 -typedef int INT; -enum E { enum1, enum2 }; -template<int N> struct A1; -template<INT N, INT M> struct A2; -template<enum E x, E y> struct A3; -template<int &X> struct A4; -template<int *Ptr> struct A5; -template<int (&f)(int, int)> struct A6; -template<int (*fp)(float, double)> struct A7; -template<int X::*pm> struct A8; -template<float (X::*pmf)(float, int)> struct A9; -template<typename T, T x> struct A10; - -template<float f> struct A11; // expected-error{{a non-type template parameter cannot have type 'float'}} - -template<void *Ptr> struct A12; -template<int (*IncompleteArrayPtr)[]> struct A13; diff --git a/test/CXX/temp/temp.param/p5.cpp b/test/CXX/temp/temp.param/p5.cpp deleted file mode 100644 index 4cb2d4343a33..000000000000 --- a/test/CXX/temp/temp.param/p5.cpp +++ /dev/null @@ -1,13 +0,0 @@ -// RUN: %clang_cc1 -verify %s -std=c++14 - -template<const int I> struct S { // expected-error {{reference member 'r' binds to a temporary object}} - decltype(I) n; - int &&r = I; // expected-note {{default member initializer}} -}; -S<5> s; // expected-note {{implicit default constructor}} - -template<typename T, T v> struct U { // expected-error {{reference member 'r' binds to a temporary object}} - decltype(v) n; - int &&r = v; // expected-note {{default member initializer}} -}; -U<const int, 6> u; // expected-note {{implicit default constructor}} diff --git a/test/CXX/temp/temp.param/p7.cpp b/test/CXX/temp/temp.param/p7.cpp deleted file mode 100644 index 13f0367764aa..000000000000 --- a/test/CXX/temp/temp.param/p7.cpp +++ /dev/null @@ -1,15 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s - -// A non-type template-parameter shall not be declared to have -// floating point, class, or void type. -struct A; - -template<double d> class X; // expected-error{{cannot have type}} -template<double* pd> class Y; //OK -template<double& rd> class Z; //OK - -template<A a> class X0; // expected-error{{cannot have type}} - -typedef void VOID; -template<VOID a> class X01; // expected-error{{cannot have type}} - diff --git a/test/CXX/temp/temp.param/p8.cpp b/test/CXX/temp/temp.param/p8.cpp deleted file mode 100644 index 592e41ec408e..000000000000 --- a/test/CXX/temp/temp.param/p8.cpp +++ /dev/null @@ -1,7 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -// expected-no-diagnostics -template<int X[10]> struct A; -template<int *X> struct A; -template<int f(float, double)> struct B; -typedef float FLOAT; -template<int (*f)(FLOAT, double)> struct B; diff --git a/test/CXX/temp/temp.param/p9-0x.cpp b/test/CXX/temp/temp.param/p9-0x.cpp deleted file mode 100644 index 29a7549a8f1a..000000000000 --- a/test/CXX/temp/temp.param/p9-0x.cpp +++ /dev/null @@ -1,61 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s - -// A default template-argument may be specified for any kind of -// template-parameter that is not a template parameter pack. -template<typename ...Types = int> // expected-error{{template parameter pack cannot have a default argument}} -struct X0; - -template<int ...Values = 0> // expected-error{{template parameter pack cannot have a default argument}} -struct X1; - -template<typename T> struct vector; - -template<template<class> class ...Templates = vector> // expected-error{{template parameter pack cannot have a default argument}} -struct X2; - -struct X3 { - template<typename T = int> // expected-error{{default template argument not permitted on a friend template}} - friend void f0(X3); - - template<typename T = int> - friend void f1(X3) { - } -}; - -namespace PR8748 { - // Testcase 1 - struct A0 { template<typename U> struct B; }; - template<typename U = int> struct A0::B { }; - - // Testcase 2 - template<typename T> struct A1 { template<typename U> struct B; }; - template<typename T> template<typename U = int> struct A1<T>::B { }; // expected-error{{cannot add a default template argument to the definition of a member of a class template}} - - // Testcase 3 - template<typename T> - struct X2 { - void f0(); - template<typename U> void f1(); - }; - - template<typename T = int> void X2<T>::f0() { } // expected-error{{cannot add a default template argument to the definition of a member of a class template}} - template<typename T> template<typename U = int> void X2<T>::f1() { } // expected-error{{cannot add a default template argument to the definition of a member of a class template}} - - namespace Inner { - template<typename T> struct X3; - template<typename T> void f2(); - } - - // Okay; not class members. - template<typename T = int> struct Inner::X3 { }; - template<typename T = int> void Inner::f2() {} -} - -namespace PR10069 { - template<typename T, T a, T b=0, T c=1> - T f(T x); - - void g() { - f<unsigned int, 0>(0); - } -} diff --git a/test/CXX/temp/temp.param/p9.cpp b/test/CXX/temp/temp.param/p9.cpp deleted file mode 100644 index b2318c275e44..000000000000 --- a/test/CXX/temp/temp.param/p9.cpp +++ /dev/null @@ -1,23 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -std=c++98 -verify %s - -// A default template-argument shall not be specified in a function -// template declaration or a function template definition -template<typename T = int> // expected-warning{{default template arguments for a function template are a C++11 extension}} - void foo0(T); -template<typename T = int> // expected-warning{{default template arguments for a function template are a C++11 extension}} - void foo1(T) { } - -// [...] nor in the template-parameter-list of the definition of a -// member of a class template. -template<int N> -struct X0 { - void f(); -}; - -template<int N = 0> // expected-error{{cannot add a default template argument}} -void X0<N>::f() { } - -class X1 { - template<template<int> class TT = X0> // expected-error{{not permitted on a friend template}} - friend void f2(); -}; diff --git a/test/CXX/temp/temp.res/p3.cpp b/test/CXX/temp/temp.res/p3.cpp deleted file mode 100644 index 8984ce349496..000000000000 --- a/test/CXX/temp/temp.res/p3.cpp +++ /dev/null @@ -1,38 +0,0 @@ -// RUN: %clang_cc1 -verify %s -std=c++11 - -template<typename T> struct A { - template<typename U> struct B; - template<typename U> using C = U; // expected-note {{here}} -}; - -struct X { - template<typename T> X(T); - struct Y { - template<typename T> Y(T); - }; -}; - -template<typename T> A // expected-error {{missing 'typename' prior to dependent type template name 'A<T>::B'}} - <T>::B<T> f1(); -template<typename T> A<T>::C<T> f2(); // expected-error {{missing 'typename' prior to dependent type template name 'A<T>::C'}} - -// FIXME: Should these cases really be valid? There doesn't appear to be a rule prohibiting them... -template<typename T> A<T>::C<X>::X(T) {} -template<typename T> A<T>::C<X>::X::Y::Y(T) {} - -// FIXME: This is ill-formed -template<typename T> int A<T>::B<T>::*f3() {} -template<typename T> int A<T>::C<X>::*f4() {} - -// FIXME: This is valid -template<typename T> int A<T>::template C<int>::*f5() {} // expected-error {{has no members}} - -template<typename T> template<typename U> struct A<T>::B { - friend A<T>::C<T> f6(); // ok, same as 'friend T f6();' - - // FIXME: Error recovery here is awful; we decide that the template-id names - // a type, and then complain about the rest of the tokens, and then complain - // that we didn't get a function declaration. - friend A<U>::C<T> f7(); // expected-error {{use 'template' keyword to treat 'C' as a dependent template name}} expected-error 3{{}} - friend A<U>::template C<T> f8(); // expected-error 4{{}} -}; diff --git a/test/CXX/temp/temp.res/temp.dep.res/temp.point/p1.cpp b/test/CXX/temp/temp.res/temp.dep.res/temp.point/p1.cpp deleted file mode 100644 index 75580d245cfc..000000000000 --- a/test/CXX/temp/temp.res/temp.dep.res/temp.point/p1.cpp +++ /dev/null @@ -1,32 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -// XFAIL: * - -// Note: we fail this test because we perform template instantiation -// at the end of the translation unit, so argument-dependent lookup -// finds functions that occur after the point of instantiation. Note -// that GCC fails this test; EDG passes the test in strict mode, but -// not in relaxed mode. -namespace N { - struct A { }; - struct B : public A { }; - - int& f0(A&); -} - -template<typename T, typename Result> -struct X0 { - void test_f0(T t) { - Result r = f0(t); - }; -}; - -void test_f0() { - X0<N::A, int&> xA; - xA.test_f0(N::A()); - X0<N::B, int&> xB; - xB.test_f0(N::B()); -} - -namespace N { - char& f0(B&); -} diff --git a/test/CXX/temp/temp.res/temp.dep/p3.cpp b/test/CXX/temp/temp.res/temp.dep/p3.cpp deleted file mode 100644 index 583fb4b3cc05..000000000000 --- a/test/CXX/temp/temp.res/temp.dep/p3.cpp +++ /dev/null @@ -1,89 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -struct A0 { - struct K { }; -}; - -template <typename T> struct B0: A0 { - static void f() { - K k; - } -}; - -namespace E1 { - typedef double A; - - template<class T> class B { - typedef int A; - }; - - template<class T> - struct X : B<T> { - A* blarg(double *dp) { - return dp; - } - }; -} - -namespace E2 { - struct A { - struct B; - int *a; - int Y; - }; - - int a; - template<class T> struct Y : T { - struct B { /* ... */ }; - B b; - void f(int i) { a = i; } - Y* p; - }; - - Y<A> ya; -} - -namespace PR14402 { - template<typename T> - struct A { - typedef int n; - int f(); - - struct B {}; - struct C : B { - // OK, can't be sure whether we derive from A yet. - using A::n; - int g() { return f(); } - }; - - struct D { - using A::n; // expected-error {{using declaration refers into 'A<T>::', which is not a base class of 'D'}} - int g() { return f(); } // expected-error {{call to non-static member function 'f' of 'A' from nested type 'D'}} - }; - - struct E { char &f(); }; - struct F : E { - // FIXME: Reject this prior to instantiation; f() is known to return int. - char &g() { return f(); } - // expected-error@-1 {{'PR14402::A<int>::f' is not a member of class 'PR14402::A<int>::F'}} - // expected-error@-2 {{non-const lvalue reference to type 'char' cannot bind to a temporary of type 'int'}} - }; - }; - - template<> struct A<int>::B : A<int> {}; - A<int>::C::n n = A<int>::C().g(); - - // 'not a member' - char &r = A<int>::F().g(); // expected-note {{in instantiation of}} - template<> struct A<char>::E : A<char> {}; - // 'cannot bind to a temporary' - char &s = A<char>::F().g(); // expected-note {{in instantiation of}} - - struct X; - struct X { void f(); }; - struct X; - template<typename T> struct Y : X { - void g() { - X::f(); - } - }; -} diff --git a/test/CXX/temp/temp.res/temp.dep/temp.dep.constexpr/p2-0x.cpp b/test/CXX/temp/temp.res/temp.dep/temp.dep.constexpr/p2-0x.cpp deleted file mode 100644 index 8f2a599ab28a..000000000000 --- a/test/CXX/temp/temp.res/temp.dep/temp.dep.constexpr/p2-0x.cpp +++ /dev/null @@ -1,28 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -verify %s -// expected-no-diagnostics - -template<int n> struct S; - -template<int n> struct T { - T() { - // An identifier is value-dependent if it is: - // - a name declared with a dependent type - S<n> s; - S<s> check1; // ok, s is value-dependent - // - the name of a non-type template parameter - typename S<n>::T check2; // ok, n is value-dependent - // - a constant with literal type and is initialized with an expression - // that is value-dependent. - const int k = n; - typename S<k>::T check3a; // ok, u is value-dependent - - constexpr const int *p = &k; - typename S<*p>::T check3b; // ok, p is value-dependent - - // (missing from the standard) - // - a reference and is initialized with an expression that is - // value-dependent. - const int &i = k; - typename S<i>::T check4; // ok, i is value-dependent - } -}; diff --git a/test/CXX/temp/temp.res/temp.dep/temp.dep.constexpr/p2.cpp b/test/CXX/temp/temp.res/temp.dep/temp.dep.constexpr/p2.cpp deleted file mode 100644 index 68a41c7184c0..000000000000 --- a/test/CXX/temp/temp.res/temp.dep/temp.dep.constexpr/p2.cpp +++ /dev/null @@ -1,21 +0,0 @@ -// RUN: %clang_cc1 -std=c++98 -verify %s - -template<int n> struct S; - -template<int n> struct T { - T() { - // An identifier is value-dependent if it is: - // - a name declared with a dependent type - S<n> s; - S<s> check1; // ok, s is value-dependent - // - the name of a non-type template parameter - typename S<n>::T check2; // ok, n is value-dependent - // - a constant with literal type and is initialized with an expression - // that is value-dependent. - const int k = n; - typename S<k>::T check3; // ok, u is value-dependent - - const int &i = k; - typename S<i>::T check4; // expected-error {{not an integral constant expression}} expected-error {{qualified name}} - } -}; diff --git a/test/CXX/temp/temp.res/temp.dep/temp.dep.type/p1.cpp b/test/CXX/temp/temp.res/temp.dep/temp.dep.type/p1.cpp deleted file mode 100644 index 81b070f040ee..000000000000 --- a/test/CXX/temp/temp.res/temp.dep/temp.dep.type/p1.cpp +++ /dev/null @@ -1,30 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s - -// Examples from CWG1056. -namespace Example1 { - template<class T> struct A; - template<class T> using B = A<T>; - - template<class T> struct A { - struct C {}; - B<T>::C bc; // ok, B<T> is the current instantiation. - }; - - template<class T> struct A<A<T>> { - struct C {}; - B<B<T>>::C bc; // ok, B<B<T>> is the current instantiation. - }; - - template<class T> struct A<A<A<T>>> { - struct C {}; - B<B<T>>::C bc; // expected-error {{missing 'typename'}} - }; -} - -namespace Example2 { - template<class T> struct A { - void g(); - }; - template<class T> using B = A<T>; - template<class T> void B<T>::g() {} // ok. -} diff --git a/test/CXX/temp/temp.res/temp.local/p1.cpp b/test/CXX/temp/temp.res/temp.local/p1.cpp deleted file mode 100644 index faa85cb5fce3..000000000000 --- a/test/CXX/temp/temp.res/temp.local/p1.cpp +++ /dev/null @@ -1,76 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++1z %s - -// C++1z [temp.local]p1: -// Like normal (non-template) classes, class templates have an -// injected-class-name (Clause 9). The injected-class-name can -// be used as a template-name or a type-name. - -template<typename> char id; - -template<typename> struct TempType {}; -template<template<typename> class> struct TempTemp {}; - -template<typename> void use(int&); // expected-note {{invalid explicitly-specified argument}} expected-note {{no known conversion}} -template<template<typename> class> void use(float&); // expected-note 2{{no known conversion}} -template<int> void use(char&); // expected-note 2{{invalid explicitly-specified argument}} - -template<typename T> struct A { - template<typename> struct C {}; - struct B : C<T> { - // When it is used with a template-argument-list, - A<int> *aint; - typename B::template C<int> *cint; - - // as a template-argument for a template template-parameter, - TempTemp<A> a_as_temp; - TempTemp<B::template C> c_as_temp; - - // or as the final identifier in the elaborated-type-specifier of a friend - // class template declaration, - template<typename U> friend struct A; - // it refers to the class template itself. - - // Otherwise, it is equivalent to the template-name followed by the - // template-parameters of the class template enclosed in <>. - A *aT; - typename B::C *cT; - TempType<A> a_as_type; - TempType<typename B::C> c_as_type; - friend struct A; - friend struct B::C; - - void f(T &t) { - use<A>(t); // expected-error {{no matching function}} - if constexpr (&id<T> != &id<int>) - use<B::template C>(t); // expected-error {{no matching function}} - } - }; -}; - -template struct A<int>; -template struct A<float>; -template struct A<char>; // expected-note {{instantiation of}} - -template <typename T> struct X0 { - X0(); - ~X0(); - X0 f(const X0&); -}; - -// Test non-type template parameters. -template <int N1, const int& N2, const int* N3> struct X1 { - X1(); - ~X1(); - X1 f(const X1& x1a) { X1 x1b(x1a); return x1b; } -}; - -// When it is used with a template-argument-list, it refers to the specified -// class template specialization, which could be the current specialization -// or another specialization. -// FIXME: Test this clause. - -int i = 42; -void test() { - X0<int> x0; (void)x0; - X1<42, i, &i> x1; (void)x1; -} diff --git a/test/CXX/temp/temp.res/temp.local/p3.cpp b/test/CXX/temp/temp.res/temp.local/p3.cpp deleted file mode 100644 index 63c40fb57690..000000000000 --- a/test/CXX/temp/temp.res/temp.local/p3.cpp +++ /dev/null @@ -1,31 +0,0 @@ -// RUN: %clang_cc1 -verify %s - -template <class T> struct Base { // expected-note 4 {{member found by ambiguous name lookup}} - static void f(); -}; - -struct X0 { }; - -template <class T> struct Derived: Base<int>, Base<char> { - typename Derived::Base b; // expected-error{{member 'Base' found in multiple base classes of different types}} - typename Derived::Base<double> d; // OK - - void g(X0 *t) { - t->Derived::Base<T>::f(); - t->Base<T>::f(); - t->Base::f(); // expected-error{{member 'Base' found in multiple base classes of different types}} \ - // expected-error{{no member named 'f' in 'X0'}} - } -}; - -namespace PR6717 { - template <typename T> - class WebVector { - } // expected-error {{expected ';' after class}} - - 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{{undeclared identifier 'T'}} -} diff --git a/test/CXX/temp/temp.res/temp.local/p6.cpp b/test/CXX/temp/temp.res/temp.local/p6.cpp deleted file mode 100644 index e2aa0ff34429..000000000000 --- a/test/CXX/temp/temp.res/temp.local/p6.cpp +++ /dev/null @@ -1,150 +0,0 @@ -// RUN: %clang_cc1 -verify %s -fcxx-exceptions -std=c++1y - -namespace N {} - -template<typename T, // expected-note {{declared here}} - typename T> struct X {}; // expected-error {{declaration of 'T' shadows template parameter}} - -template<typename T> struct Y { // expected-note 18{{declared here}} - template<typename T> struct A {}; // expected-error {{declaration of 'T' shadows template parameter}} - - struct B { - template<typename> struct T {}; // expected-error {{declaration of 'T' shadows template parameter}} - }; - struct C { - template<typename> void T(); // expected-error {{declaration of 'T' shadows template parameter}} - }; - struct D { - struct T {}; // expected-error {{declaration of 'T' shadows template parameter}} - }; - struct E { - typedef int T; // expected-error {{declaration of 'T' shadows template parameter}} - }; - struct F { - using T = int; // expected-error {{declaration of 'T' shadows template parameter}} - }; - struct G { - int T; // expected-error {{declaration of 'T' shadows template parameter}} - }; - struct H { - static int T; // expected-error {{declaration of 'T' shadows template parameter}} - }; - struct I { - void T(); // expected-error {{declaration of 'T' shadows template parameter}} - }; - struct J { - enum T { e }; // expected-error {{declaration of 'T' shadows template parameter}} - }; - struct K { - enum E { T }; // expected-error {{declaration of 'T' shadows template parameter}} - }; - - void a() { - extern int T; // expected-error {{declaration of 'T' shadows template parameter}} - } - void b() { - int T; // expected-error {{declaration of 'T' shadows template parameter}} - } - void c() { - try {} - catch (int T) {} // expected-error {{declaration of 'T' shadows template parameter}} - } - void d() { - void T(); // expected-error {{declaration of 'T' shadows template parameter}} - } - void e() { - namespace T = N; // expected-error {{declaration of 'T' shadows template parameter}} - } - - // FIXME: These diagnostics are poorly worded. Lookup for the elaborated type - // specifier finds the template parameter in this case, which is ill-formed - // because it's not a struct. - void f() { - struct T *p; // expected-error {{declaration of 'T' shadows template parameter}} - } - friend struct T; // expected-error {{declaration of 'T' shadows template parameter}} -}; - -template<int T> struct Z { // expected-note 16{{declared here}} - template<typename T> struct A {}; // expected-error {{declaration of 'T' shadows template parameter}} - - struct B { - template<typename> struct T {}; // expected-error {{declaration of 'T' shadows template parameter}} - }; - struct C { - template<typename> void T(); // expected-error {{declaration of 'T' shadows template parameter}} - }; - struct D { - struct T {}; // expected-error {{declaration of 'T' shadows template parameter}} - }; - struct E { - typedef int T; // expected-error {{declaration of 'T' shadows template parameter}} - }; - struct F { - using T = int; // expected-error {{declaration of 'T' shadows template parameter}} - }; - struct G { - int T; // expected-error {{declaration of 'T' shadows template parameter}} - }; - struct H { - static int T; // expected-error {{declaration of 'T' shadows template parameter}} - }; - struct I { - void T(); // expected-error {{declaration of 'T' shadows template parameter}} - }; - struct J { - enum T { e }; // expected-error {{declaration of 'T' shadows template parameter}} - }; - struct K { - enum E { T }; // expected-error {{declaration of 'T' shadows template parameter}} - }; - - void a() { - extern int T; // expected-error {{declaration of 'T' shadows template parameter}} - } - void b() { - int T; // expected-error {{declaration of 'T' shadows template parameter}} - } - void c() { - try {} - catch (int T) {} // expected-error {{declaration of 'T' shadows template parameter}} - } - void d() { - void T(); // expected-error {{declaration of 'T' shadows template parameter}} - } - void e() { - namespace T = N; // expected-error {{declaration of 'T' shadows template parameter}} - } - - // These cases are valid when 'T' is a non-type template parameter, as T - // names an injected struct ::T, which doesn't shadow the template parameter. - void f() { - struct T *p; - } - friend struct T; -}; - -template<typename T> // expected-note {{declared here}} -void f(int T) {} // expected-error {{declaration of 'T' shadows template parameter}} - -// FIXME: These are ill-formed: a template-parameter shall not have the same name as the template name. -namespace A { - template<typename T> struct T {}; // expected-error{{declaration of 'T' shadows template parameter}} - // expected-note@-1{{template parameter is declared here}} -} -namespace B { - template<typename T> void T() {} -} -namespace C { - template<typename T> int T; -} - -namespace PR28023 { -template<int V> // expected-note{{template parameter is declared here}} -struct A { - struct B { - template <int> friend struct V; // expected-error{{declaration of 'V' shadows template parameter}} - }; -}; -A<0>::B a; -} diff --git a/test/CXX/temp/temp.res/temp.local/p7.cpp b/test/CXX/temp/temp.res/temp.local/p7.cpp deleted file mode 100644 index 3fa9c9952609..000000000000 --- a/test/CXX/temp/temp.res/temp.local/p7.cpp +++ /dev/null @@ -1,11 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -// expected-no-diagnostics - -template<class T> struct A { - int B; - int f(); -}; - -template<class B> int A<B>::f() { - return B; -} diff --git a/test/CXX/temp/temp.res/temp.local/p8.cpp b/test/CXX/temp/temp.res/temp.local/p8.cpp deleted file mode 100644 index fecfed06f109..000000000000 --- a/test/CXX/temp/temp.res/temp.local/p8.cpp +++ /dev/null @@ -1,54 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -// expected-no-diagnostics - -namespace N { - enum { C }; - template<class T> class B { - void f(T); - }; -} - -template<class C> void N::B<C>::f(C) { - C b; -} - -namespace N { - enum { D }; - namespace M { - enum { C , D }; - template<typename C> class X { - template<typename U> void f(C, U); - - template<typename D> void g(C, D) { - C c; - D d; - } - }; - - struct Y { - template<typename U> void f(U); - }; - } - - struct Y { - template<typename D> void f(D); - }; -} - -template<typename C> -template<typename D> -void N::M::X<C>::f(C, D) { - C c; - D d; -} - -template<typename C> -void N::M::Y::f(C) { - C c; -} - -template<typename D> -void N::Y::f(D) { - D d; -} - diff --git a/test/CXX/temp/temp.res/temp.local/p9.cpp b/test/CXX/temp/temp.res/temp.local/p9.cpp deleted file mode 100644 index 9ca8d8877d7d..000000000000 --- a/test/CXX/temp/temp.res/temp.local/p9.cpp +++ /dev/null @@ -1,15 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -struct A { - struct B { void f(); }; - int a; - int Y; -}; - -template<class B, class a> struct X : A { - B b; // A's B - a c; // expected-error{{unknown type name 'a'}} - - void g() { - b.g(); // expected-error{{no member named 'g' in 'A::B'}} - } -}; diff --git a/test/CXX/temp/temp.spec/cxx1y-variable-template-no-body.cpp b/test/CXX/temp/temp.spec/cxx1y-variable-template-no-body.cpp deleted file mode 100644 index 741ebc5de41f..000000000000 --- a/test/CXX/temp/temp.spec/cxx1y-variable-template-no-body.cpp +++ /dev/null @@ -1,35 +0,0 @@ -// RUN: %clang_cc1 --std=c++1y -fsyntax-only -verify %s -// RUN: cp %s %t -// RUN: not %clang_cc1 --std=c++1y -x c++ -fixit %t -DFIXING -// RUN: %clang_cc1 --std=c++1y -x c++ %t -DFIXING - -template<typename T> -T pi = T(3.1415926535897932385); // expected-note {{template is declared here}} - -template int pi<int>; - -#ifndef FIXING -template float pi<>; // expected-error {{too few template arguments for variable template 'pi'}} -template double pi_var0; // expected-error {{explicit instantiation of 'pi_var0' does not refer to a function template, variable template, member function, member class, or static data member}} -#endif - -// Should recover as if definition -template double pi_var = 5; // expected-error {{variable cannot be defined in an explicit instantiation; if this declaration is meant to be a variable definition, remove the 'template' keyword}} -#ifndef FIXING -template<typename T> -T pi0 = T(3.1415926535897932385); // expected-note {{previous definition is here}} - -template int pi0 = 10; // expected-error {{variable cannot be defined in an explicit instantiation; if this declaration is meant to be a variable definition, remove the 'template' keyword}} \ - expected-error{{redefinition of 'pi0' as different kind of symbol}} -#endif - -template<typename T> -T pi1 = T(3.1415926535897932385); // expected-note 0-2 {{here}} - -// Should recover as if specialization -template float pi1<float> = 1.0; // expected-error {{explicit template instantiation cannot have a definition; if this definition is meant to be an explicit specialization, add '<>' after the 'template' keyword}} -namespace expected_global { -#ifndef FIXING - template int pi1<int> = 10; // expected-error {{explicit template instantiation cannot have a definition; if this definition is meant to be an explicit specialization, add '<>' after the 'template' keyword}} expected-error {{must occur at global scope}} -#endif -} diff --git a/test/CXX/temp/temp.spec/no-body.cpp b/test/CXX/temp/temp.spec/no-body.cpp deleted file mode 100644 index 6d1b82fe1898..000000000000 --- a/test/CXX/temp/temp.spec/no-body.cpp +++ /dev/null @@ -1,90 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s -// RUN: cp %s %t -// RUN: not %clang_cc1 -x c++ -fixit %t -DFIXING -// RUN: %clang_cc1 -x c++ %t -DFIXING - -template<typename T> void f(T) { } -#if __cplusplus >= 201103L - // expected-note@-2 {{explicit instantiation refers here}} -#endif - -template<typename T> void g(T) { } -#if __cplusplus >= 201103L - // expected-note@-2 {{explicit instantiation refers here}} -#endif - -template<typename T> struct x { }; -#if __cplusplus >= 201103L - // expected-note@-2 {{explicit instantiation refers here}} -#endif - -template<typename T> struct y { }; // expected-note {{declared here}} - -namespace good { // Only good in C++98/03 -#ifndef FIXING - template void f<int>(int); -#if __cplusplus >= 201103L - // expected-error@-2 {{explicit instantiation of 'f' must occur at global scope}} -#endif - - template void g(int); -#if __cplusplus >= 201103L - // expected-error@-2 {{explicit instantiation of 'g' must occur at global scope}} -#endif - - template struct x<int>; -#if __cplusplus >= 201103L - // expected-error@-2 {{explicit instantiation of 'x' must occur at global scope}} -#endif -#endif -} - -namespace unsupported { -#ifndef FIXING - template struct y; // expected-error {{template 'y' cannot be referenced with a struct specifier}} -#endif -} - -template<typename T> void f0(T) { } -template<typename T> void g0(T) { } -template<typename T> struct x0 { }; // expected-note {{explicitly specialized declaration is here}} -template<typename T> struct y0 { }; - -// Should recover as if definition -namespace noargs_body { -#ifndef FIXING - template void g0(int) { } // expected-error {{function cannot be defined in an explicit instantiation; if this declaration is meant to be a function definition, remove the 'template' keyword}} -#endif - template struct y0 { }; // expected-error {{class cannot be defined in an explicit instantiation; if this declaration is meant to be a class definition, remove the 'template' keyword}} -} - -// Explicit specializations expected in global scope -namespace exp_spec { -#ifndef FIXING - template<> void f0<int>(int) { } // expected-error {{no function template matches function template specialization 'f0'}} - template<> struct x0<int> { }; // expected-error {{class template specialization of 'x0' must occur at global scope}} -#endif -} - -template<typename T> void f1(T) { } -template<typename T> struct x1 { }; // expected-note {{explicitly specialized declaration is here}} - -// Should recover as if specializations, -// thus also complain about not being in global scope. -namespace args_bad { -#ifndef FIXING - template void f1<int>(int) { } // expected-error {{explicit template instantiation cannot have a definition; if this definition is meant to be an explicit specialization, add '<>' after the 'template' keyword}} \ - expected-error {{no function template matches function template specialization 'f1'}} - template struct x1<int> { }; // expected-error {{explicit template instantiation cannot have a definition; if this definition is meant to be an explicit specialization, add '<>' after the 'template' keyword}} \ - expected-error {{class template specialization of 'x1' must occur at global scope}} -#endif -} - -template<typename T> void f2(T) { } -template<typename T> struct x2 { }; - -// Should recover as if specializations -template void f2<int>(int) { } // expected-error {{explicit template instantiation cannot have a definition; if this definition is meant to be an explicit specialization, add '<>' after the 'template' keyword}} -template struct x2<int> { }; // expected-error {{explicit template instantiation cannot have a definition; if this definition is meant to be an explicit specialization, add '<>' after the 'template' keyword}} diff --git a/test/CXX/temp/temp.spec/p5.cpp b/test/CXX/temp/temp.spec/p5.cpp deleted file mode 100644 index ba92d41e3e8e..000000000000 --- a/test/CXX/temp/temp.spec/p5.cpp +++ /dev/null @@ -1,47 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s - -template<typename T> inline void f(T) { } -template void f(int); // expected-note{{previous explicit instantiation}} -template void f(int); // expected-error{{duplicate explicit instantiation}} - -template<typename T> -struct X0 { - union Inner { }; - - void f(T) { } - - static T value; -}; - -template<typename T> -T X0<T>::value = 3.14; // expected-warning{{implicit conversion from 'double' to 'int' changes value from 3.14 to 3}} - -template struct X0<int>; // expected-note{{previous explicit instantiation}} \ - expected-note{{requested here}} -template struct X0<int>; // expected-error{{duplicate explicit instantiation}} - -template void X0<float>::f(float); // expected-note{{previous explicit instantiation}} -template void X0<float>::f(float); // expected-error{{duplicate explicit instantiation}} - -template union X0<float>::Inner; // expected-note{{previous explicit instantiation}} -template union X0<float>::Inner; // expected-error{{duplicate explicit instantiation}} - -template float X0<float>::value; // expected-note{{previous explicit instantiation}} -template float X0<float>::value; // expected-error{{duplicate explicit instantiation}} - -// Make sure that we don't get tricked by redeclarations of nested classes. -namespace NestedClassRedecls { - template<typename T> - struct X { - struct Nested; - friend struct Nested; - - struct Nested { - Nested() {} - } nested; - }; - - X<int> xi; - - template struct X<int>; -} diff --git a/test/CXX/temp/temp.spec/temp.expl.spec/examples.cpp b/test/CXX/temp/temp.spec/temp.expl.spec/examples.cpp deleted file mode 100644 index ec2e380864bf..000000000000 --- a/test/CXX/temp/temp.spec/temp.expl.spec/examples.cpp +++ /dev/null @@ -1,334 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s - -namespace PR5907 { - template<typename T> struct identity { typedef T type; }; - struct A { A(); }; - identity<A>::type::A() { } - - struct B { void f(); }; - template<typename T> struct C { typedef B type; }; - - void C<int>::type::f() { } -} - -namespace PR9421 { - namespace N { template<typename T> struct S { void f(); }; } - typedef N::S<int> T; - namespace N { template<> void T::f() {} } -} - -namespace PR8277 { - template< typename S > - struct C - { - template< int > - void F( void ) - { - } - }; - - template< typename S > - struct D - { - typedef C< int > A; - }; - - typedef D< int >::A A; - - template<> - template<> - void A::F< 0 >( void ) - { - } -} - -namespace PR8277b { - template<typename S> struct C { - void f(); - }; - template<typename S> struct D { - typedef C<int> A; - }; - template<> void D<int>::A::f() { - } -} - -namespace PR8708 { - template<typename T> struct A { - template<typename U> struct B { - // #2 - void f(); - }; - }; - - // #A specialize the member template for - // implicit instantiation of A<int>, - // leaving the member template "unspecialized" - // (14.7.3/16). Specialization uses the syntax - // for explicit specialization (14.7.3/14) - template<> template<typename U> - struct A<int>::B { - // #1 - void g(); - }; - - // #1 define its function g. There is an enclosing - // class template, so we write template<> for each - // specialized template (14.7.3/15). - template<> template<typename U> - void A<int>::B<U>::g() { } - - // #2 define the unspecialized member template's - // f - template<typename T> template<typename U> - void A<T>::B<U>::f() { } - - - // specialize the member template again, now - // specializing the member too. This specializes - // #A - template<> template<> - struct A<int>::B<int> { - // #3 - void h(); - }; - - // defines #3. There is no enclosing class template, so - // we write no "template<>". - void A<int>::B<int>::h() { } - - void test() { - // calls #1 - A<int>::B<float> a; a.g(); - - // calls #2 - A<float>::B<int> b; b.f(); - - // calls #3 - A<int>::B<int> c; c.h(); - } -} - -namespace PR9482 { - namespace N1 { - template <typename T> struct S { - void foo() {} - }; - } - - namespace N2 { - typedef N1::S<int> X; - } - - namespace N1 { - template<> void N2::X::foo() {} - } -} - -namespace PR9668 { - namespace First - { - template<class T> - class Bar - { - protected: - - static const bool static_bool; - }; - } - - namespace Second - { - class Foo; - } - - typedef First::Bar<Second::Foo> Special; - - namespace - First - { - template<> - const bool Special::static_bool(false); - } -} - -namespace PR9877 { - template<int> - struct X - { - struct Y; - }; - - template<> struct X<0>::Y { static const int Z = 1; }; - template<> struct X<1>::Y { static const int Z = 1; }; - - const int X<0>::Y::Z; - template<> const int X<1>::Y::Z; // expected-error{{extraneous 'template<>' in declaration of variable 'Z'}} -} - -namespace PR9913 { - template<class,class=int>struct S; - template<class X>struct S<X> { - template<class T> class F; - }; - - template<class A> - template<class B> - class S<A>::F{}; -} - -namespace template_class_spec_perClassDecl_nested -{ - template <typename T1> struct A { - template <typename T2> struct B { - template <typename T3> struct C { - static void foo(); - }; - }; - }; - - template <> struct A<int> { - template <typename T2> struct B { - template <typename T3> struct C { - static void foo(); - }; - }; - }; - - template <> template <typename T3> struct A<int>::B<int>::C { - static void foo(); - }; - - template <> template <> struct A<int>::B<int>::C<int> { - static void foo(); - }; - - template <> template<> template <typename T2> struct A<bool>::B<bool>::C { - static void foo(); - }; -} - - -namespace spec_vs_expl_inst { - - // Test all permutations of Specialization, - // explicit instantiation Declaration, and explicit instantiation defInition. - - namespace SDI { // PR11558 - template <typename STRING_TYPE> class BasicStringPiece; - template <> class BasicStringPiece<int> { }; - extern template class BasicStringPiece<int>; - template class BasicStringPiece<int>; - } - - namespace SID { - template <typename STRING_TYPE> class BasicStringPiece; - template <> class BasicStringPiece<int> { }; // expected-note {{previous template specialization is here}} - template class BasicStringPiece<int>; // expected-note {{explicit instantiation definition is here}} expected-warning {{has no effect}} - extern template class BasicStringPiece<int>; // expected-error {{explicit instantiation declaration (with 'extern') follows explicit instantiation definition (without 'extern')}} - } - - namespace ISD { - template <typename STRING_TYPE> class BasicStringPiece; // expected-note {{template is declared here}} - template class BasicStringPiece<int>; // expected-error {{explicit instantiation of undefined template 'spec_vs_expl_inst::ISD::BasicStringPiece<int>'}} - template <> class BasicStringPiece<int> { }; - extern template class BasicStringPiece<int>; - } - - namespace IDS { - template <typename STRING_TYPE> class BasicStringPiece; // expected-note {{template is declared here}} - template class BasicStringPiece<int>; // expected-error {{explicit instantiation of undefined template 'spec_vs_expl_inst::IDS::BasicStringPiece<int>'}} // expected-note {{explicit instantiation definition is here}} - extern template class BasicStringPiece<int>; // expected-error {{explicit instantiation declaration (with 'extern') follows explicit instantiation definition (without 'extern')}} - template <> class BasicStringPiece<int> { }; - } - - namespace DIS { - template <typename STRING_TYPE> class BasicStringPiece; // expected-note {{template is declared here}} - extern template class BasicStringPiece<int>; // expected-error {{explicit instantiation of undefined template 'spec_vs_expl_inst::DIS::BasicStringPiece<int>'}} - template class BasicStringPiece<int>; - template <> class BasicStringPiece<int> { }; - } - - namespace DSI { - template <typename STRING_TYPE> class BasicStringPiece; // expected-note {{template is declared here}} - extern template class BasicStringPiece<int>; // expected-error {{explicit instantiation of undefined template 'spec_vs_expl_inst::DSI::BasicStringPiece<int>'}} - template <> class BasicStringPiece<int> { }; // expected-note {{previous}} - template class BasicStringPiece<int>; // expected-warning {{has no effect}} - } - - // The same again, with a defined template class. - - namespace SDI_WithDefinedTemplate { - template <typename STRING_TYPE> class BasicStringPiece {}; - template <> class BasicStringPiece<int> { }; - extern template class BasicStringPiece<int>; - template class BasicStringPiece<int>; - } - - namespace SID_WithDefinedTemplate { - template <typename STRING_TYPE> class BasicStringPiece {}; - template <> class BasicStringPiece<int> { }; // expected-note {{previous}} - template class BasicStringPiece<int>; // expected-note {{explicit instantiation definition is here}} expected-warning {{has no effect}} - extern template class BasicStringPiece<int>; // expected-error {{explicit instantiation declaration (with 'extern') follows explicit instantiation definition (without 'extern')}} - } - - namespace ISD_WithDefinedTemplate { - template <typename STRING_TYPE> class BasicStringPiece {}; - template class BasicStringPiece<int>; // expected-note {{explicit instantiation first required here}} - template <> class BasicStringPiece<int> { }; // expected-error {{explicit specialization of 'spec_vs_expl_inst::ISD_WithDefinedTemplate::BasicStringPiece<int>' after instantiation}} - extern template class BasicStringPiece<int>; - } - - namespace IDS_WithDefinedTemplate { - template <typename STRING_TYPE> class BasicStringPiece {}; - template class BasicStringPiece<int>; // expected-note {{explicit instantiation definition is here}} expected-note {{previous definition is here}} - extern template class BasicStringPiece<int>; // expected-error {{explicit instantiation declaration (with 'extern') follows explicit instantiation definition (without 'extern')}} - template <> class BasicStringPiece<int> { }; // expected-error {{redefinition of 'BasicStringPiece<int>'}} - } - - namespace DIS_WithDefinedTemplate { - template <typename STRING_TYPE> class BasicStringPiece {}; - extern template class BasicStringPiece<int>; // expected-note {{explicit instantiation first required here}} - template class BasicStringPiece<int>; - template <> class BasicStringPiece<int> { }; // expected-error {{explicit specialization of 'spec_vs_expl_inst::DIS_WithDefinedTemplate::BasicStringPiece<int>' after instantiation}} - } - - namespace DSI_WithDefinedTemplate { - template <typename STRING_TYPE> class BasicStringPiece {}; - extern template class BasicStringPiece<int>; // expected-note {{explicit instantiation first required here}} - template <> class BasicStringPiece<int> { }; // expected-error {{explicit specialization of 'spec_vs_expl_inst::DSI_WithDefinedTemplate::BasicStringPiece<int>' after instantiation}} - template class BasicStringPiece<int>; - } - - // And some more random tests. - - namespace SII_WithDefinedTemplate { - template <typename STRING_TYPE> class BasicStringPiece {}; - template <> class BasicStringPiece<int> { }; // expected-note {{previous}} - template class BasicStringPiece<int>; // expected-note {{previous explicit instantiation is here}} expected-warning {{has no effect}} - template class BasicStringPiece<int>; // expected-error {{duplicate explicit instantiation of 'BasicStringPiece<int>'}} - } - - namespace SIS { - template <typename STRING_TYPE> class BasicStringPiece; - template <> class BasicStringPiece<int> { }; // expected-note {{previous definition is here}} expected-note {{previous}} - template class BasicStringPiece<int>; // expected-warning {{has no effect}} - template <> class BasicStringPiece<int> { }; // expected-error {{redefinition of 'BasicStringPiece<int>'}} - } - - namespace SDS { - template <typename STRING_TYPE> class BasicStringPiece; - template <> class BasicStringPiece<int> { }; // expected-note {{previous definition is here}} - extern template class BasicStringPiece<int>; - template <> class BasicStringPiece<int> { }; // expected-error {{redefinition of 'BasicStringPiece<int>'}} - } - - namespace SDIS { - template <typename STRING_TYPE> class BasicStringPiece; - template <> class BasicStringPiece<int> { }; // expected-note {{previous definition is here}} - extern template class BasicStringPiece<int>; - template class BasicStringPiece<int>; - template <> class BasicStringPiece<int> { }; // expected-error {{redefinition of 'BasicStringPiece<int>'}} - } - -} diff --git a/test/CXX/temp/temp.spec/temp.expl.spec/p1.cpp b/test/CXX/temp/temp.spec/temp.expl.spec/p1.cpp deleted file mode 100644 index 263356e949a3..000000000000 --- a/test/CXX/temp/temp.spec/temp.expl.spec/p1.cpp +++ /dev/null @@ -1,100 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -// expected-no-diagnostics - -// This test creates cases where implicit instantiations of various entities -// would cause a diagnostic, but provides expliict specializations for those -// entities that avoid the diagnostic. The intent is to verify that -// implicit instantiations do not occur (because the explicit specialization -// is used instead). -struct NonDefaultConstructible { - NonDefaultConstructible(int); -}; - - -// C++ [temp.expl.spec]p1: -// An explicit specialization of any of the following: - -// -- function template -template<typename T> void f0(T) { - T t; -} - -template<> void f0(NonDefaultConstructible) { } - -void test_f0(NonDefaultConstructible NDC) { - f0(NDC); -} - -// -- class template -template<typename T> -struct X0 { - static T member; - - void f1(T t) { - t = 17; - } - - struct Inner : public T { }; - - template<typename U> - struct InnerTemplate : public T { }; - - template<typename U> - void ft1(T t, U u); -}; - -template<typename T> -template<typename U> -void X0<T>::ft1(T t, U u) { - t = u; -} - -template<typename T> T X0<T>::member; - -template<> struct X0<void> { }; -X0<void> test_X0; - - -// -- member function of a class template -template<> void X0<void*>::f1(void *) { } - -void test_spec(X0<void*> xvp, void *vp) { - xvp.f1(vp); -} - -// -- static data member of a class template -template<> -NonDefaultConstructible X0<NonDefaultConstructible>::member = 17; - -NonDefaultConstructible &get_static_member() { - return X0<NonDefaultConstructible>::member; -} - -// -- member class of a class template -template<> -struct X0<void*>::Inner { }; - -X0<void*>::Inner inner0; - -// -- member class template of a class template -template<> -template<> -struct X0<void*>::InnerTemplate<int> { }; - -X0<void*>::InnerTemplate<int> inner_template0; - -// -- member function template of a class template -template<> -template<> -void X0<void*>::ft1(void*, const void*) { } - -void test_func_template(X0<void *> xvp, void *vp, const void *cvp) { - xvp.ft1(vp, cvp); -} - -// example from the standard: -template<class T> class stream; -template<> class stream<char> { /* ... */ }; -template<class T> class Array { /* ... */ }; -template<class T> void sort(Array<T>& v) { /* ... */ } -template<> void sort<char*>(Array<char*>&) ; diff --git a/test/CXX/temp/temp.spec/temp.expl.spec/p10.cpp b/test/CXX/temp/temp.spec/temp.expl.spec/p10.cpp deleted file mode 100644 index b81c1e7b2c8f..000000000000 --- a/test/CXX/temp/temp.spec/temp.expl.spec/p10.cpp +++ /dev/null @@ -1,7 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s - -template<class T> class X; -template<> class X<int>; // expected-note{{forward}} -X<int>* p; - -X<int> x; // expected-error{{incomplete type}} diff --git a/test/CXX/temp/temp.spec/temp.expl.spec/p11.cpp b/test/CXX/temp/temp.spec/temp.expl.spec/p11.cpp deleted file mode 100644 index f03811f35e60..000000000000 --- a/test/CXX/temp/temp.spec/temp.expl.spec/p11.cpp +++ /dev/null @@ -1,9 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -// expected-no-diagnostics - -template<class T> class Array { /* ... */ }; -template<class T> void sort(Array<T>& v); - -// explicit specialization for sort(Array<int>&) -// with deduced template-argument of type int -template<> void sort(Array<int>&); diff --git a/test/CXX/temp/temp.spec/temp.expl.spec/p13.cpp b/test/CXX/temp/temp.spec/temp.expl.spec/p13.cpp deleted file mode 100644 index fb6d1bed1f71..000000000000 --- a/test/CXX/temp/temp.spec/temp.expl.spec/p13.cpp +++ /dev/null @@ -1,6 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only %s - -template<typename T> void f(T); - -template<> void f(int) { } -void f(int) { } diff --git a/test/CXX/temp/temp.spec/temp.expl.spec/p14.cpp b/test/CXX/temp/temp.spec/temp.expl.spec/p14.cpp deleted file mode 100644 index aba9d3640801..000000000000 --- a/test/CXX/temp/temp.spec/temp.expl.spec/p14.cpp +++ /dev/null @@ -1,42 +0,0 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm -o - %s | FileCheck %s - -template<class T> void f(T) { /* ... */ } -template<class T> inline void g(T) { /* ... */ } - -// CHECK: define void @_Z1gIiEvT_ -template<> void g<>(int) { /* ... */ } - -template<class T> -struct X { - void f() { } - void g(); - void h(); -}; - -template<class T> -void X<T>::g() { -} - -template<class T> -inline void X<T>::h() { -} - -// CHECK: define void @_ZN1XIiE1fEv -template<> void X<int>::f() { } - -// CHECK: define void @_ZN1XIiE1hEv -template<> void X<int>::h() { } - -// CHECK: define linkonce_odr void @_Z1fIiEvT_ -template<> inline void f<>(int) { /* ... */ } - -// CHECK: define linkonce_odr void @_ZN1XIiE1gEv -template<> inline void X<int>::g() { } - -void test(X<int> xi) { - f(17); - g(17); - xi.f(); - xi.g(); - xi.h(); -} diff --git a/test/CXX/temp/temp.spec/temp.expl.spec/p15.cpp b/test/CXX/temp/temp.spec/temp.expl.spec/p15.cpp deleted file mode 100644 index 72f33df7efa4..000000000000 --- a/test/CXX/temp/temp.spec/temp.expl.spec/p15.cpp +++ /dev/null @@ -1,33 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s - -struct NonDefaultConstructible { - NonDefaultConstructible(const NonDefaultConstructible&); // expected-note{{candidate constructor}} -}; - -template<typename T, typename U> -struct X { - static T member; -}; - -template<typename T, typename U> -T X<T, U>::member; // expected-error{{no matching constructor}} - -// Okay; this is a declaration, not a definition. -template<> -NonDefaultConstructible X<NonDefaultConstructible, long>::member; - -NonDefaultConstructible &test(bool b) { - return b? X<NonDefaultConstructible, int>::member // expected-note{{instantiation}} - : X<NonDefaultConstructible, long>::member; -} - -namespace rdar9422013 { - template<int> - struct X { - struct Inner { - static unsigned array[17]; - }; - }; - - template<> unsigned X<1>::Inner::array[]; // okay -} diff --git a/test/CXX/temp/temp.spec/temp.expl.spec/p16.cpp b/test/CXX/temp/temp.spec/temp.expl.spec/p16.cpp deleted file mode 100644 index c7597e9f817c..000000000000 --- a/test/CXX/temp/temp.spec/temp.expl.spec/p16.cpp +++ /dev/null @@ -1,38 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -template<class T> struct A { - void f(T); - template<class X1> void g1(T, X1); - template<class X2> void g2(T, X2); - void h(T) { } -}; - -// specialization -template<> void A<int>::f(int); - -// out of class member template definition -template<class T> template<class X1> void A<T>::g1(T, X1) { } - -// member template specialization -template<> template<class X1> void A<int>::g1(int, X1); - -// member template specialization -template<> template<> - void A<int>::g1(int, char); // X1 deduced as char - -template<> template<> - void A<int>::g2<char>(int, char); // X2 specified as char - // member specialization even if defined in class definition - -template<> void A<int>::h(int) { } - -namespace PR10024 { - template <typename T> - struct Test{ - template <typename U> - void get(U i) {} - }; - - template <typename T> - template <> - void Test<T>::get<double>(double i) {} // expected-error{{cannot specialize (with 'template<>') a member of an unspecialized template}} -} diff --git a/test/CXX/temp/temp.spec/temp.expl.spec/p17.cpp b/test/CXX/temp/temp.spec/temp.expl.spec/p17.cpp deleted file mode 100644 index 56231e2f725f..000000000000 --- a/test/CXX/temp/temp.spec/temp.expl.spec/p17.cpp +++ /dev/null @@ -1,34 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -template<class T1> -class A { - template<class T2> class B { - void mf(); - }; -}; - -template<> template<> class A<int>::B<double>; -template<> template<> void A<char>::B<char>::mf(); - -template<> void A<char>::B<int>::mf(); // expected-error{{requires 'template<>'}} - -namespace test1 { - template <class> class A { - static int foo; - static int bar; - }; - typedef A<int> AA; - - template <> int AA::foo = 0; - int AA::bar = 1; // expected-error {{template specialization requires 'template<>'}} - int A<float>::bar = 2; // expected-error {{template specialization requires 'template<>'}} - - template <> class A<double> { - public: - static int foo; - static int bar; - }; - - typedef A<double> AB; - template <> int AB::foo = 0; // expected-error{{extraneous 'template<>'}} - int AB::bar = 1; -} diff --git a/test/CXX/temp/temp.spec/temp.expl.spec/p18.cpp b/test/CXX/temp/temp.spec/temp.expl.spec/p18.cpp deleted file mode 100644 index 4d175a886087..000000000000 --- a/test/CXX/temp/temp.spec/temp.expl.spec/p18.cpp +++ /dev/null @@ -1,20 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -template<class T1> class A { - template<class T2> class B { - template<class T3> void mf1(T3); - void mf2(); - }; -}; - -template<> template<class X> -class A<long>::B { }; - -template<> template<> template<class T> - void A<int>::B<double>::mf1(T t) { } - -template<> template<> template<class T> -void A<long>::B<double>::mf1(T t) { } // expected-error{{does not match}} - -// FIXME: This diagnostic could probably be better. -template<class Y> template<> - void A<Y>::B<double>::mf2() { } // expected-error{{does not refer}} diff --git a/test/CXX/temp/temp.spec/temp.expl.spec/p19.cpp b/test/CXX/temp/temp.spec/temp.expl.spec/p19.cpp deleted file mode 100644 index 1c2ea7ebde71..000000000000 --- a/test/CXX/temp/temp.spec/temp.expl.spec/p19.cpp +++ /dev/null @@ -1,30 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s - -template<typename T> -struct X { - template<typename U> struct Inner { }; - - template<typename U> void f(T, U) { } -}; - -template<> template<typename U> -struct X<int>::Inner { - U member; -}; - -template<> template<typename U> -void X<int>::f(int x, U y) { - x = y; // expected-error{{incompatible type}} -} - -void test(X<int> xi, X<long> xl, float *fp) { - X<int>::Inner<float*> xii; - xii.member = fp; - xi.f(17, 25); - xi.f(17, 3.14159); - xi.f(17, fp); // expected-note{{instantiation}} - X<long>::Inner<float*> xli; - - xli.member = fp; // expected-error{{no member}} - xl.f(17, fp); // okay -} diff --git a/test/CXX/temp/temp.spec/temp.expl.spec/p2-0x.cpp b/test/CXX/temp/temp.spec/temp.expl.spec/p2-0x.cpp deleted file mode 100644 index c29646dd9455..000000000000 --- a/test/CXX/temp/temp.spec/temp.expl.spec/p2-0x.cpp +++ /dev/null @@ -1,344 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s -Wno-c++1y-extensions - -// This test creates cases where implicit instantiations of various entities -// would cause a diagnostic, but provides expliict specializations for those -// entities that avoid the diagnostic. The specializations are alternately -// declarations and definitions, and the intent of this test is to verify -// that we allow specializations only in the appropriate namespaces (and -// nowhere else). -struct NonDefaultConstructible { - NonDefaultConstructible(int); -}; - -// C++ [temp.expl.spec]p1: -// An explicit specialization of any of the following: - -// -- function template -namespace N0 { - template<typename T> void f0(T) { - T t; - } - - template<> void f0(NonDefaultConstructible) { } - - void test_f0(NonDefaultConstructible NDC) { - f0(NDC); - } - - template<> void f0(int); - template<> void f0(long); -} - -template<> void N0::f0(int) { } // okay - -namespace N1 { - template<> void N0::f0(long) { } // expected-error{{does not enclose namespace}} -} - -template<> void N0::f0(double) { } - -struct X1 { - template<typename T> void f(T); - - template<> void f(int); // OK (DR727) -}; - -// -- class template -namespace N0 { - -template<typename T> -struct X0 { // expected-note {{here}} - static T member; - - void f1(T t) { - t = 17; - } - - struct Inner : public T { }; // expected-note 2{{here}} - - template<typename U> - struct InnerTemplate : public T { }; // expected-note 1{{explicitly specialized}} \ - // expected-error{{base specifier}} - - template<typename U> - void ft1(T t, U u); -}; - -} - -template<typename T> -template<typename U> -void N0::X0<T>::ft1(T t, U u) { - t = u; -} - -template<typename T> T N0::X0<T>::member; - -template<> struct N0::X0<void> { }; -N0::X0<void> test_X0; - -namespace N1 { - template<> struct N0::X0<const void> { }; // expected-error{{class template specialization of 'X0' not in a namespace enclosing 'N0'}} -} - -namespace N0 { - template<> struct X0<volatile void>; -} - -template<> struct N0::X0<volatile void> { - void f1(void *); -}; - -// -- variable template [C++1y] -namespace N0 { -template<typename T> int v0; // expected-note 4{{explicitly specialized declaration is here}} -template<> extern int v0<char[1]>; -template<> extern int v0<char[2]>; -template<> extern int v0<char[5]>; -template<> extern int v0<char[6]>; -} -using N0::v0; - -template<typename T> int v1; // expected-note 4{{explicitly specialized declaration is here}} -template<> extern int v1<char[3]>; -template<> extern int v1<char[4]>; -template<> extern int v1<char[7]>; -template<> extern int v1<char[8]>; - -template<> int N0::v0<int[1]>; -template<> int v0<int[2]>; -template<> int ::v1<int[3]>; // expected-warning {{extra qualification}} -template<> int v1<int[4]>; - -template<> int N0::v0<char[1]>; -template<> int v0<char[2]>; -template<> int ::v1<char[3]>; // expected-warning {{extra qualification}} -template<> int v1<char[4]>; - -namespace N1 { -template<> int N0::v0<int[5]>; // expected-error {{not in a namespace enclosing 'N0'}} -template<> int v0<int[6]>; // expected-error {{not in a namespace enclosing 'N0'}} -template<> int ::v1<int[7]>; // expected-error {{must occur at global scope}} -template<> int v1<int[8]>; // expected-error {{must occur at global scope}} - -template<> int N0::v0<char[5]>; // expected-error {{not in a namespace enclosing 'N0'}} -template<> int v0<char[6]>; // expected-error {{not in a namespace enclosing 'N0'}} -template<> int ::v1<char[7]>; // expected-error {{must occur at global scope}} -template<> int v1<char[8]>; // expected-error {{must occur at global scope}} -} - -// -- member function of a class template -template<> void N0::X0<void*>::f1(void *) { } - -void test_spec(N0::X0<void*> xvp, void *vp) { - xvp.f1(vp); -} - -namespace N0 { - template<> void X0<volatile void>::f1(void *) { } // expected-error{{no function template matches}} - - template<> void X0<const volatile void*>::f1(const volatile void*); -} - -void test_x0_cvvoid(N0::X0<const volatile void*> x0, const volatile void *cvp) { - x0.f1(cvp); // okay: we've explicitly specialized -} - -// -- static data member of a class template -namespace N0 { - // This actually tests p15; the following is a declaration, not a definition. - template<> - NonDefaultConstructible X0<NonDefaultConstructible>::member; - - template<> long X0<long>::member = 17; - - template<> float X0<float>::member; - - template<> double X0<double>::member; -} - -NonDefaultConstructible &get_static_member() { - return N0::X0<NonDefaultConstructible>::member; -} - -template<> int N0::X0<int>::member; - -template<> float N0::X0<float>::member = 3.14f; - -namespace N1 { - template<> double N0::X0<double>::member = 3.14; // expected-error{{does not enclose namespace}} -} - -// -- member class of a class template -namespace N0 { - - template<> - struct X0<void*>::Inner { }; - - template<> - struct X0<int>::Inner { }; - - template<> - struct X0<unsigned>::Inner; - - template<> - struct X0<float>::Inner; - - template<> - struct X0<double>::Inner; // expected-note{{forward declaration}} -} - -template<> -struct N0::X0<long>::Inner { }; - -template<> -struct N0::X0<float>::Inner { }; - -namespace N1 { - template<> - struct N0::X0<unsigned>::Inner { }; // expected-error{{member class specialization}} - - template<> - struct N0::X0<unsigned long>::Inner { }; // expected-error{{member class specialization}} -}; - -N0::X0<void*>::Inner inner0; -N0::X0<int>::Inner inner1; -N0::X0<long>::Inner inner2; -N0::X0<float>::Inner inner3; -N0::X0<double>::Inner inner4; // expected-error{{incomplete}} - -// -- member class template of a class template -namespace N0 { - template<> - template<> - struct X0<void*>::InnerTemplate<int> { }; - - template<> template<> - struct X0<int>::InnerTemplate<int>; // expected-note{{forward declaration}} - - template<> template<> - struct X0<int>::InnerTemplate<long>; - - template<> template<> - struct X0<int>::InnerTemplate<double>; -} - -template<> template<> -struct N0::X0<int>::InnerTemplate<long> { }; // okay - -template<> template<> -struct N0::X0<int>::InnerTemplate<float> { }; - -namespace N1 { - template<> template<> - struct N0::X0<int>::InnerTemplate<double> { }; // expected-error{{enclosing}} -} - -N0::X0<void*>::InnerTemplate<int> inner_template0; -N0::X0<int>::InnerTemplate<int> inner_template1; // expected-error{{incomplete}} -N0::X0<int>::InnerTemplate<long> inner_template2; -N0::X0<int>::InnerTemplate<unsigned long> inner_template3; // expected-note{{instantiation}} - -// -- member function template of a class template -namespace N0 { - template<> - template<> - void X0<void*>::ft1(void*, const void*) { } - - template<> template<> - void X0<void*>::ft1(void *, int); - - template<> template<> - void X0<void*>::ft1(void *, unsigned); - - template<> template<> - void X0<void*>::ft1(void *, long); -} - -template<> template<> -void N0::X0<void*>::ft1(void *, unsigned) { } // okay - -template<> template<> -void N0::X0<void*>::ft1(void *, float) { } - -namespace N1 { - template<> template<> - void N0::X0<void*>::ft1(void *, long) { } // expected-error{{does not enclose namespace}} -} - - -void test_func_template(N0::X0<void *> xvp, void *vp, const void *cvp, - int i, unsigned u) { - xvp.ft1(vp, cvp); - xvp.ft1(vp, i); - xvp.ft1(vp, u); -} - -namespace has_inline_namespaces { - inline namespace inner { - template<class T> void f(T&); - - template<class T> - struct X0 { - struct MemberClass; - - void mem_func(); - - template<typename U> - struct MemberClassTemplate; - - template<typename U> - void mem_func_template(U&); - - static int value; - }; - } - - struct X1; - struct X2; - - // An explicit specialization whose declarator-id is not qualified - // shall be declared in the nearest enclosing namespace of the - // template, or, if the namespace is inline (7.3.1), any namespace - // from its enclosing namespace set. - template<> void f(X1&); - template<> void f<X2>(X2&); - - template<> struct X0<X1> { }; - - template<> struct X0<X2>::MemberClass { }; - - template<> void X0<X2>::mem_func(); - - template<> template<typename T> struct X0<X2>::MemberClassTemplate { }; - - template<> template<typename T> void X0<X2>::mem_func_template(T&) { } - - template<> int X0<X2>::value = 12; -} - -struct X3; -struct X4; - -template<> void has_inline_namespaces::f(X3&); -template<> void has_inline_namespaces::f<X4>(X4&); - -template<> struct has_inline_namespaces::X0<X3> { }; - -template<> struct has_inline_namespaces::X0<X4>::MemberClass { }; - -template<> void has_inline_namespaces::X0<X4>::mem_func(); - -template<> template<typename T> -struct has_inline_namespaces::X0<X4>::MemberClassTemplate { }; - -template<> template<typename T> -void has_inline_namespaces::X0<X4>::mem_func_template(T&) { } - -template<> int has_inline_namespaces::X0<X4>::value = 13; - -namespace PR12938 { - template<typename> [[noreturn]] void func(); - template<> void func<int>(); -} diff --git a/test/CXX/temp/temp.spec/temp.expl.spec/p2.cpp b/test/CXX/temp/temp.spec/temp.expl.spec/p2.cpp deleted file mode 100644 index 904f950df443..000000000000 --- a/test/CXX/temp/temp.spec/temp.expl.spec/p2.cpp +++ /dev/null @@ -1,256 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s - - -// This test creates cases where implicit instantiations of various entities -// would cause a diagnostic, but provides expliict specializations for those -// entities that avoid the diagnostic. The specializations are alternately -// declarations and definitions, and the intent of this test is to verify -// that we allow specializations only in the appropriate namespaces (and -// nowhere else). -struct NonDefaultConstructible { - NonDefaultConstructible(int); -}; - - -// C++ [temp.expl.spec]p1: -// An explicit specialization of any of the following: - -// -- function template -namespace N0 { - template<typename T> void f0(T) { - T t; - } - - template<> void f0(NonDefaultConstructible) { } - - void test_f0(NonDefaultConstructible NDC) { - f0(NDC); - } - - template<> void f0(int); - template<> void f0(long); -} - -template<> void N0::f0(int) { } // okay - -namespace N1 { - template<> void N0::f0(long) { } // expected-error{{does not enclose namespace}} -} - -template<> void N0::f0(double); - -template<> void N0::f0(double) { } - -struct X1 { - template<typename T> void f(T); - - template<> void f(int); -}; - -// -- class template -namespace N0 { - -template<typename T> -struct X0 { // expected-note {{explicitly specialized declaration is here}} - static T member; - - void f1(T t) { - t = 17; - } - - struct Inner : public T { }; // expected-note 2{{explicitly specialized declaration is here}} - - template<typename U> - struct InnerTemplate : public T { }; // expected-note {{explicitly specialized declaration is here}} - // expected-error@-1 {{base specifier must name a class}} - - template<typename U> - void ft1(T t, U u); -}; - -} - -template<typename T> -template<typename U> -void N0::X0<T>::ft1(T t, U u) { - t = u; -} - -template<typename T> T N0::X0<T>::member; - -template<> struct N0::X0<void> { }; -N0::X0<void> test_X0; - -namespace N1 { - template<> struct N0::X0<const void> { }; // expected-error{{not in a namespace enclosing 'N0'}} -} - -namespace N0 { - template<> struct X0<volatile void>; -} - -template<> struct N0::X0<volatile void> { - void f1(void *); -}; - -// -- member function of a class template -template<> void N0::X0<void*>::f1(void *) { } - -void test_spec(N0::X0<void*> xvp, void *vp) { - xvp.f1(vp); -} - -namespace N0 { - template<> void X0<volatile void>::f1(void *) { } // expected-error{{no function template matches}} - - template<> void X0<const volatile void*>::f1(const volatile void*); -} - -void test_x0_cvvoid(N0::X0<const volatile void*> x0, const volatile void *cvp) { - x0.f1(cvp); // okay: we've explicitly specialized -} - -// -- static data member of a class template -namespace N0 { - // This actually tests p15; the following is a declaration, not a definition. - template<> - NonDefaultConstructible X0<NonDefaultConstructible>::member; - - template<> long X0<long>::member = 17; - - template<> float X0<float>::member; - - template<> double X0<double>::member; -} - -NonDefaultConstructible &get_static_member() { - return N0::X0<NonDefaultConstructible>::member; -} - -template<> int N0::X0<int>::member; - -template<> float N0::X0<float>::member = 3.14f; - -namespace N1 { - template<> double N0::X0<double>::member = 3.14; // expected-error{{does not enclose namespace}} -} - -// -- member class of a class template -namespace N0 { - - template<> - struct X0<void*>::Inner { }; - - template<> - struct X0<int>::Inner { }; - - template<> - struct X0<unsigned>::Inner; - - template<> - struct X0<float>::Inner; - - template<> - struct X0<double>::Inner; // expected-note{{forward declaration}} -} - -template<> -struct N0::X0<long>::Inner { }; - -template<> -struct N0::X0<float>::Inner { }; - -namespace N1 { - template<> - struct N0::X0<unsigned>::Inner { }; // expected-error{{member class specialization}} - - template<> - struct N0::X0<unsigned long>::Inner { }; // expected-error{{member class specialization}} -}; - -N0::X0<void*>::Inner inner0; -N0::X0<int>::Inner inner1; -N0::X0<long>::Inner inner2; -N0::X0<float>::Inner inner3; -N0::X0<double>::Inner inner4; // expected-error{{incomplete}} - -// -- member class template of a class template -namespace N0 { - template<> - template<> - struct X0<void*>::InnerTemplate<int> { }; - - template<> template<> - struct X0<int>::InnerTemplate<int>; // expected-note{{forward declaration}} - - template<> template<> - struct X0<int>::InnerTemplate<long>; - - template<> template<> - struct X0<int>::InnerTemplate<double>; -} - -template<> template<> -struct N0::X0<int>::InnerTemplate<long> { }; // okay - -template<> template<> -struct N0::X0<int>::InnerTemplate<float> { }; - -namespace N1 { - template<> template<> - struct N0::X0<int>::InnerTemplate<double> { }; // expected-error{{enclosing}} -} - -N0::X0<void*>::InnerTemplate<int> inner_template0; -N0::X0<int>::InnerTemplate<int> inner_template1; // expected-error{{incomplete}} -N0::X0<int>::InnerTemplate<long> inner_template2; -N0::X0<int>::InnerTemplate<unsigned long> inner_template3; // expected-note{{instantiation}} - -// -- member function template of a class template -namespace N0 { - template<> - template<> - void X0<void*>::ft1(void*, const void*) { } - - template<> template<> - void X0<void*>::ft1(void *, int); - - template<> template<> - void X0<void*>::ft1(void *, unsigned); - - template<> template<> - void X0<void*>::ft1(void *, long); -} - -template<> template<> -void N0::X0<void*>::ft1(void *, unsigned) { } // okay - -template<> template<> -void N0::X0<void*>::ft1(void *, float) { } - -namespace N1 { - template<> template<> - void N0::X0<void*>::ft1(void *, long) { } // expected-error{{does not enclose namespace}} -} - - -void test_func_template(N0::X0<void *> xvp, void *vp, const void *cvp, - int i, unsigned u) { - xvp.ft1(vp, cvp); - xvp.ft1(vp, i); - xvp.ft1(vp, u); -} - -namespace PR8979 { - template<typename Z> - struct X0 { - template <class T, class U> class Inner; - struct OtherInner; - template<typename T, typename U> void f(Inner<T, U>&); - - typedef Inner<OtherInner, OtherInner> MyInner; - template<> void f(MyInner&); - }; -} diff --git a/test/CXX/temp/temp.spec/temp.expl.spec/p20.cpp b/test/CXX/temp/temp.spec/temp.expl.spec/p20.cpp deleted file mode 100644 index 86cdcf80cbeb..000000000000 --- a/test/CXX/temp/temp.spec/temp.expl.spec/p20.cpp +++ /dev/null @@ -1,14 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -template<typename T> -void f(T); - -template<typename T> -struct A { }; - -struct X { - template<> friend void f<int>(int); // expected-error{{in a friend}} - template<> friend class A<int>; // expected-error{{cannot be a friend}} - - friend void f<float>(float); // okay - friend class A<float>; // okay -}; diff --git a/test/CXX/temp/temp.spec/temp.expl.spec/p21.cpp b/test/CXX/temp/temp.spec/temp.expl.spec/p21.cpp deleted file mode 100644 index ab26f407f3f3..000000000000 --- a/test/CXX/temp/temp.spec/temp.expl.spec/p21.cpp +++ /dev/null @@ -1,30 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s - -template<typename T> -struct X { - void mf1(T); - template<typename U> void mf2(T, U); // expected-note{{previous}} -}; - -template<> -void X<int>::mf1(int i = 17) // expected-error{{default}} -{ -} - -template<> template<> -void X<int>::mf2(int, int = 17) // expected-error{{default}} -{ } - -template<> template<typename U> -void X<int>::mf2(int, U = U()) // expected-error{{default}} -{ -} - -template<> -struct X<float> { - void mf1(float); -}; - -void X<float>::mf1(float = 3.14f) // okay -{ -} diff --git a/test/CXX/temp/temp.spec/temp.expl.spec/p3.cpp b/test/CXX/temp/temp.spec/temp.expl.spec/p3.cpp deleted file mode 100644 index ca55c54a5e92..000000000000 --- a/test/CXX/temp/temp.spec/temp.expl.spec/p3.cpp +++ /dev/null @@ -1,15 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s - -namespace N { - template<class T> class X; // expected-note {{'N::X' declared here}} -} - -template<> class X<int> { /* ... */ }; // expected-error {{no template named 'X'; did you mean 'N::X'?}} - -namespace N { - -template<> class X<char*> { /* ... */ }; // OK: X is a template - -} diff --git a/test/CXX/temp/temp.spec/temp.expl.spec/p4.cpp b/test/CXX/temp/temp.spec/temp.expl.spec/p4.cpp deleted file mode 100644 index ac040ccb3d64..000000000000 --- a/test/CXX/temp/temp.spec/temp.expl.spec/p4.cpp +++ /dev/null @@ -1,70 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s -// RUN: %clang_cc1 -fsyntax-only -verify %s - -struct IntHolder { // expected-note 0-1{{here}} expected-note 2-4{{candidate constructor (the implicit}} - IntHolder(int); // expected-note 2{{candidate constructor}} -}; - -template<typename T, typename U> -struct X { // expected-note{{here}} - void f() { - T t; // expected-error{{no matching}} - } - - void g() { } - - struct Inner { -#if __cplusplus >= 201103L - T value; // expected-note {{has no default constructor}} -#else - // expected-error@-4 {{implicit default}} - T value; // expected-note {{member is declared here}} -#endif - }; - - static T value; -}; - -template<typename T, typename U> -T X<T, U>::value; // expected-error{{no matching constructor}} - -IntHolder &test_X_IntHolderInt(X<IntHolder, int> xih) { - xih.g(); // okay - xih.f(); // expected-note{{instantiation}} - - X<IntHolder, int>::Inner inner; -#if __cplusplus >= 201103L - // expected-error@-2 {{call to implicitly-deleted}} -#else - // expected-note@-4 {{first required here}} -#endif - - return X<IntHolder, int>::value; // expected-note{{instantiation}} -} - -// Explicitly specialize the members of X<IntHolder, long> to not cause -// problems with instantiation. -template<> -void X<IntHolder, long>::f() { } - -template<> -struct X<IntHolder, long>::Inner { - Inner() : value(17) { } - IntHolder value; -}; - -template<> -IntHolder X<IntHolder, long>::value = 17; - -IntHolder &test_X_IntHolderInt(X<IntHolder, long> xih) { - xih.g(); // okay - xih.f(); // okay, uses specialization - - X<IntHolder, long>::Inner inner; // okay, uses specialization - - return X<IntHolder, long>::value; // okay, uses specialization -} - -template<> -X<IntHolder, long>::X() { } // expected-error{{instantiated member}} diff --git a/test/CXX/temp/temp.spec/temp.expl.spec/p5-example.cpp b/test/CXX/temp/temp.spec/temp.expl.spec/p5-example.cpp deleted file mode 100644 index f49190ef5ad8..000000000000 --- a/test/CXX/temp/temp.spec/temp.expl.spec/p5-example.cpp +++ /dev/null @@ -1,34 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -template<class T> struct A { - struct B { }; - template<class U> struct C { }; -}; - template<> struct A<int> { - void f(int); -}; -void h() { - A<int> a; - a.f(16); -} -// A<int>::f must be defined somewhere -// template<> not used for a member of an // explicitly specialized class template -void A<int>::f(int) { /* ... */ } - template<> struct A<char>::B { - void f(); -}; -// template<> also not used when defining a member of // an explicitly specialized member class -void A<char>::B::f() { /* ... */ } - template<> template<class U> struct A<char>::C { - void f(); -}; - -template<> -template<class U> void A<char>::C<U>::f() { /* ... */ } - template<> struct A<short>::B { - void f(); -}; -template<> void A<short>::B::f() { /* ... */ } // expected-error{{no function template matches function template specialization 'f'}} - template<> template<class U> struct A<short>::C { - void f(); -}; -template<class U> void A<short>::C<U>::f() { /* ... */ } // expected-error{{template parameter list matching the non-templated nested type 'A<short>' should be empty ('template<>')}} diff --git a/test/CXX/temp/temp.spec/temp.expl.spec/p5.cpp b/test/CXX/temp/temp.spec/temp.expl.spec/p5.cpp deleted file mode 100644 index 512ea47d5a5f..000000000000 --- a/test/CXX/temp/temp.spec/temp.expl.spec/p5.cpp +++ /dev/null @@ -1,61 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s - -struct IntHolder { - IntHolder(int); -}; - -template<typename T, typename U> -struct X { - void f() { - T t; - } - - void g() { } - - struct Inner { - T value; - }; - - static T value; -}; - -template<typename T, typename U> -T X<T, U>::value; - -// Explicitly specialize the members of X<IntHolder, long> to not cause -// problems with instantiation, but only provide declarations (not definitions). -template<> -void X<IntHolder, long>::f(); - -template<> -struct X<IntHolder, long>::Inner; // expected-note{{forward declaration}} - -template<> -IntHolder X<IntHolder, long>::value; - -IntHolder &test_X_IntHolderInt(X<IntHolder, long> xih) { - xih.g(); // okay - xih.f(); // okay, uses specialization - - X<IntHolder, long>::Inner inner; // expected-error {{incomplete}} - - return X<IntHolder, long>::value; // okay, uses specialization -} - - -template<class T> struct A { - void f(T) { /* ... */ } -}; - -template<> struct A<int> { - void f(int); -}; - -void h() { - A<int> a; - a.f(16); // A<int>::f must be defined somewhere -} - -// explicit specialization syntax not used for a member of -// explicitly specialized class template specialization -void A<int>::f(int) { /* ... */ } diff --git a/test/CXX/temp/temp.spec/temp.expl.spec/p6.cpp b/test/CXX/temp/temp.spec/temp.expl.spec/p6.cpp deleted file mode 100644 index f53947139688..000000000000 --- a/test/CXX/temp/temp.spec/temp.expl.spec/p6.cpp +++ /dev/null @@ -1,63 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s - -template<typename T> -struct X0 { - void f(); - - template<typename U> - void g(U); - - struct Nested { - }; - - static T member; -}; - -int &use_X0_int(X0<int> x0i, // expected-note{{implicit instantiation first required here}} - int i) { - x0i.f(); // expected-note{{implicit instantiation first required here}} - x0i.g(i); // expected-note{{implicit instantiation first required here}} - X0<int>::Nested nested; // expected-note{{implicit instantiation first required here}} - return X0<int>::member; // expected-note{{implicit instantiation first required here}} -} - -template<> -void X0<int>::f() { // expected-error{{after instantiation}} -} - -template<> template<> -void X0<int>::g(int) { // expected-error{{after instantiation}} -} - -template<> -struct X0<int>::Nested { }; // expected-error{{after instantiation}} - -template<> -int X0<int>::member = 17; // expected-error{{after instantiation}} - -template<> -struct X0<int> { }; // expected-error{{after instantiation}} - -// Example from the standard -template<class T> class Array { /* ... */ }; - -template<class T> void sort(Array<T>& v) { /* ... */ } - -struct String {}; - -void f(Array<String>& v) { - - sort(v); // expected-note{{required}} - // use primary template - // sort(Array<T>&), T is String -} - -template<> void sort<String>(Array<String>& v); // // expected-error{{after instantiation}} -template<> void sort<>(Array<char*>& v); // OK: sort<char*> not yet used - -namespace PR6160 { - template<typename T> void f(T); - template<> void f(int); - extern template void f(int); - template<> void f(int) { } -} diff --git a/test/CXX/temp/temp.spec/temp.expl.spec/p9.cpp b/test/CXX/temp/temp.spec/temp.expl.spec/p9.cpp deleted file mode 100644 index 10ec66d53994..000000000000 --- a/test/CXX/temp/temp.spec/temp.expl.spec/p9.cpp +++ /dev/null @@ -1,15 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -// expected-no-diagnostics - -namespace N { - template<class T> class X { /* ... */ }; - template<class T> class Y { /* ... */ }; - template<> class X<int> { /* ... */ }; - template<> class Y<double>; - - const unsigned NumElements = 17; -} - -template<> class N::Y<double> { - int array[NumElements]; -}; diff --git a/test/CXX/temp/temp.spec/temp.explicit/p1-0x.cpp b/test/CXX/temp/temp.spec/temp.explicit/p1-0x.cpp deleted file mode 100644 index 580ef3151e5d..000000000000 --- a/test/CXX/temp/temp.spec/temp.explicit/p1-0x.cpp +++ /dev/null @@ -1,24 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s - -template<typename T> -struct X { - void f() {} -}; - -template inline void X<int>::f(); // expected-error{{explicit instantiation cannot be 'inline'}} - -template<typename T> -struct Y { - constexpr int f() { return 0; } // expected-warning{{C++14}} -}; - -template constexpr int Y<int>::f() const; // expected-error{{explicit instantiation cannot be 'constexpr'}} - -template<typename T> -struct Z { - enum E : T { e1, e2 }; - T t; // expected-note {{refers here}} -}; - -template enum Z<int>::E; // expected-error {{enumerations cannot be explicitly instantiated}} -template int Z<int>::t; // expected-error {{explicit instantiation of 't' does not refer to}} diff --git a/test/CXX/temp/temp.spec/temp.explicit/p1-emit.cpp b/test/CXX/temp/temp.spec/temp.explicit/p1-emit.cpp deleted file mode 100644 index 24f68a094e54..000000000000 --- a/test/CXX/temp/temp.spec/temp.explicit/p1-emit.cpp +++ /dev/null @@ -1,29 +0,0 @@ -// RUN: %clang_cc1 -emit-llvm -triple x86_64-apple-darwin10 -o - %s | FileCheck %s -template<typename T> -struct X { - static T member1; - static T member2; - static T member3; -}; - -template<typename T> -T X<T>::member1; - -template<typename T> -T X<T>::member2 = 17; - -// CHECK: @_ZN1XIiE7member1E = weak_odr global i32 0 -template int X<int>::member1; - -// CHECK: @_ZN1XIiE7member2E = weak_odr global i32 17 -template int X<int>::member2; - -// For implicit instantiation of -long& get(bool Cond1, bool Cond2) { - // CHECK: @_ZN1XIlE7member1E = linkonce_odr global i64 0 - // CHECK: @_ZN1XIlE7member2E = linkonce_odr global i64 17 - // CHECK: @_ZN1XIlE7member3E = external global i64 - return Cond1? X<long>::member1 - : Cond2? X<long>::member2 - : X<long>::member3; -} diff --git a/test/CXX/temp/temp.spec/temp.explicit/p1.cpp b/test/CXX/temp/temp.spec/temp.explicit/p1.cpp deleted file mode 100644 index 5a77d27d5ab6..000000000000 --- a/test/CXX/temp/temp.spec/temp.explicit/p1.cpp +++ /dev/null @@ -1,94 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s - -struct C { }; - -template<typename T> -struct X0 { - T value; // expected-error{{incomplete}} -}; - -// Explicitly instantiate a class template specialization -template struct X0<int>; -template struct X0<void>; // expected-note{{instantiation}} - -// Explicitly instantiate a function template specialization -template<typename T> -void f0(T t) { - ++t; // expected-error{{cannot increment}} -} - -template void f0(int); -template void f0<long>(long); -template void f0<>(unsigned); -template void f0(int C::*); // expected-note{{instantiation}} - -// Explicitly instantiate a member template specialization -template<typename T> -struct X1 { - template<typename U> - struct Inner { - T member1; - U member2; // expected-error{{incomplete}} - }; - - template<typename U> - void f(T& t, U u) { - t = u; // expected-error{{incompatible}} - } -}; - -template struct X1<int>::Inner<float>; -template struct X1<int>::Inner<double>; -template struct X1<int>::Inner<void>; // expected-note{{instantiation}} - -template void X1<int>::f(int&, float); -template void X1<int>::f<long>(int&, long); -template void X1<int>::f<>(int&, double); -template void X1<int>::f<>(int&, int*); // expected-note{{instantiation}} - -// Explicitly instantiate members of a class template -struct Incomplete; // expected-note{{forward declaration}} -struct NonDefaultConstructible { // expected-note{{candidate constructor (the implicit copy constructor) not viable}} -#if __cplusplus >= 201103L // C++11 or later -// expected-note@-2 {{candidate constructor (the implicit move constructor) not viable}} -#endif - NonDefaultConstructible(int); // expected-note{{candidate constructor}} -}; - -template<typename T, typename U> -struct X2 { - void f(T &t, U u) { - t = u; // expected-error{{incompatible}} - } - - struct Inner { - T member1; - U member2; // expected-error{{incomplete}} - }; - - static T static_member1; - static U static_member2; -}; - -template<typename T, typename U> -T X2<T, U>::static_member1 = 17; // expected-error{{cannot initialize}} - -template<typename T, typename U> -U X2<T, U>::static_member2; // expected-error{{no matching}} - -template void X2<int, float>::f(int &, float); -template void X2<int, float>::f(int &, double); // expected-error{{does not refer}} -template void X2<int, int*>::f(int&, int*); // expected-note{{instantiation}} - -template struct X2<int, float>::Inner; -template struct X2<int, Incomplete>::Inner; // expected-note{{instantiation}} - -template int X2<int, float>::static_member1; -template int* X2<int*, float>::static_member1; // expected-note{{instantiation}} -template - NonDefaultConstructible X2<NonDefaultConstructible, int>::static_member1; - -template - NonDefaultConstructible X2<int, NonDefaultConstructible>::static_member2; // expected-note{{instantiation}} diff --git a/test/CXX/temp/temp.spec/temp.explicit/p10.cpp b/test/CXX/temp/temp.spec/temp.explicit/p10.cpp deleted file mode 100644 index 290a874296e1..000000000000 --- a/test/CXX/temp/temp.spec/temp.explicit/p10.cpp +++ /dev/null @@ -1,33 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s - -template<typename T> -struct X0 { - void f(T&); - - struct Inner; - - static T static_var; -}; - -template<typename T> -void X0<T>::f(T& t) { - t = 1; // expected-error{{incompatible type}} -} - -template<typename T> -struct X0<T>::Inner { - T member; -}; - -template<typename T> -T X0<T>::static_var = 1; // expected-error{{cannot initialize}} - -extern template struct X0<void*>; -template struct X0<void*>; // expected-note 2{{instantiation}} - -template struct X0<int>; // expected-note 4{{explicit instantiation definition is here}} - -extern template void X0<int>::f(int&); // expected-error{{follows explicit instantiation definition}} -extern template struct X0<int>::Inner; // expected-error{{follows explicit instantiation definition}} -extern template int X0<int>::static_var; // expected-error{{follows explicit instantiation definition}} -extern template struct X0<int>; // expected-error{{follows explicit instantiation definition}} diff --git a/test/CXX/temp/temp.spec/temp.explicit/p11.cpp b/test/CXX/temp/temp.spec/temp.explicit/p11.cpp deleted file mode 100644 index 5363cbe0aedf..000000000000 --- a/test/CXX/temp/temp.spec/temp.explicit/p11.cpp +++ /dev/null @@ -1,19 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -// expected-no-diagnostics - -class X { - template <typename T> class Y {}; -}; - -class A { - class B {}; - class C {}; -}; - -// C++0x [temp.explicit] 14.7.2/11: -// The usual access checking rules do not apply to names used to specify -// explicit instantiations. -template class X::Y<A::B>; - -// As an extension, this rule is applied to explicit specializations as well. -template <> class X::Y<A::C> {}; diff --git a/test/CXX/temp/temp.spec/temp.explicit/p12.cpp b/test/CXX/temp/temp.spec/temp.explicit/p12.cpp deleted file mode 100644 index 9518a0b077b7..000000000000 --- a/test/CXX/temp/temp.spec/temp.explicit/p12.cpp +++ /dev/null @@ -1,49 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s - -namespace test0 { - char* p = 0; - template<class T> T g(T x = &p) { return x; } - template int g<int>(int); // OK even though &p isn't an int. -} - -// Don't impose access restrictions on explicit instantiations. -namespace test1 { - class A { - class Private {}; - public: - typedef Private Public; - }; - - template <class T> class Temp { - static Temp<A::Public> make() { return Temp<A::Public>(); } - }; - template class Temp<A::Private>; - - // FIXME: this ought to be an error, but it isn't because Sema is - // silently failing to create a declaration for the explicit - // instantiation. - template class Temp<A::Private> Temp<int>::make(); -} - -// Don't impose access restrictions on explicit specializations, -// either. This goes here because it's an extension of the rule for -// explicit instantiations and doesn't have any independent support. -namespace test2 { - class A { - class Private {}; // expected-note {{implicitly declared private here}} - public: - typedef Private Public; - }; - - template <class T> class Temp { - static Temp<A::Public> make(); - }; - template <> class Temp<A::Private> { - public: - Temp(int x) {} - }; - - template <> class Temp<A::Private> Temp<int>::make() { // expected-error {{'Private' is a private member of 'test2::A'}} - return Temp<A::Public>(0); - } -} diff --git a/test/CXX/temp/temp.spec/temp.explicit/p2.cpp b/test/CXX/temp/temp.spec/temp.explicit/p2.cpp deleted file mode 100644 index 027022176f81..000000000000 --- a/test/CXX/temp/temp.spec/temp.explicit/p2.cpp +++ /dev/null @@ -1,56 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -pedantic -Wc++11-compat %s -// RUN: %clang_cc1 -fsyntax-only -verify -pedantic -std=c++98 -Wc++11-compat %s -// RUN: %clang_cc1 -fsyntax-only -verify -pedantic -std=c++11 %s - -// Example from the standard -template<class T> class Array { void mf() { } }; - -template class Array<char>; -template void Array<int>::mf(); -template<class T> void sort(Array<T>& v) { /* ... */ } -template void sort(Array<char>&); -namespace N { - template<class T> void f(T&) { } -} -template void N::f<int>(int&); - - -template<typename T> -struct X0 { - struct Inner {}; - void f() { } - static T value; -}; - -template<typename T> -T X0<T>::value = 17; - -typedef X0<int> XInt; - -template struct XInt::Inner; // expected-warning{{template-id}} -template void XInt::f(); // expected-warning{{template-id}} -template int XInt::value; // expected-warning{{template-id}} - -namespace N { - template<typename T> - struct X1 { // expected-note{{explicit instantiation refers here}} - }; - - template<typename T> - void f1(T) {} // expected-note{{explicit instantiation refers here}} -} -using namespace N; - -template struct X1<int>; -#if __cplusplus <= 199711L -// expected-warning@-2 {{explicit instantiation of 'N::X1' must occur in namespace 'N'}} -#else -// expected-error@-4 {{explicit instantiation of 'N::X1' must occur in namespace 'N'}} -#endif - -template void f1(int); -#if __cplusplus <= 199711L -// expected-warning@-2 {{explicit instantiation of 'N::f1' must occur in namespace 'N'}} -#else -// expected-error@-4 {{explicit instantiation of 'N::f1' must occur in namespace 'N'}} -#endif diff --git a/test/CXX/temp/temp.spec/temp.explicit/p3-0x.cpp b/test/CXX/temp/temp.spec/temp.explicit/p3-0x.cpp deleted file mode 100644 index 146b6b5da80b..000000000000 --- a/test/CXX/temp/temp.spec/temp.explicit/p3-0x.cpp +++ /dev/null @@ -1,66 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -verify %s -// expected-no-diagnostics - -// If the name declared in the explicit instantiation is an -// unqualified name, the explicit instantiation shall appear in the -// namespace where its template is declared or, if that namespace is -// inline (7.3.1), any namespace from its enclosing namespace set. - -namespace has_inline_namespaces { - inline namespace inner { - template<class T> void f(T&) {} - - template<class T> - struct X0 { - struct MemberClass {}; - - void mem_func() {} - - template<typename U> - struct MemberClassTemplate {}; - - template<typename U> - void mem_func_template(U&) {} - - static int value; - }; - } - - template<typename T> int X0<T>::value = 17; - - struct X1 {}; - struct X2 {}; - - template void f(X1&); - template void f<X2>(X2&); - - template struct X0<X1>; - - template struct X0<X2>::MemberClass; - - template void X0<X2>::mem_func(); - - template struct X0<X2>::MemberClassTemplate<X1>; - - template void X0<X2>::mem_func_template(X1&); - - template int X0<X2>::value; -} - -struct X3; -struct X4; - -template void has_inline_namespaces::f(X3&); -template void has_inline_namespaces::f<X4>(X4&); - -template struct has_inline_namespaces::X0<X3>; - -template struct has_inline_namespaces::X0<X4>::MemberClass; - -template void has_inline_namespaces::X0<X4>::mem_func(); - -template -struct has_inline_namespaces::X0<X4>::MemberClassTemplate<X3>; - -template -void has_inline_namespaces::X0<X4>::mem_func_template(X3&); diff --git a/test/CXX/temp/temp.spec/temp.explicit/p3.cpp b/test/CXX/temp/temp.spec/temp.explicit/p3.cpp deleted file mode 100644 index 38ae7688a0b5..000000000000 --- a/test/CXX/temp/temp.spec/temp.explicit/p3.cpp +++ /dev/null @@ -1,81 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -Wc++11-compat %s - -// A declaration of a function template shall be in scope at the point of the -// explicit instantiation of the function template. -template<typename T> void f0(T); -template void f0(int); // okay -template<typename T> void f0(T) { } - -// A definition of the class or class template containing a member function -// template shall be in scope at the point of the explicit instantiation of -// the member function template. -struct X0; // expected-note {{forward declaration}} -template<typename> struct X1; // expected-note 5{{declared here}} - -template void X0::f0<int>(int); // expected-error {{incomplete type}} -template void X1<int>::f0<int>(int); // expected-error {{implicit instantiation of undefined template}} - -// A definition of a class template or class member template shall be in scope -// at the point of the explicit instantiation of the class template or class -// member template. -template struct X1<float>; // expected-error{{explicit instantiation of undefined template}} - -template<typename T> -struct X2 { // expected-note 4{{refers here}} - template<typename U> - struct Inner; // expected-note{{declared here}} - - struct InnerClass; // expected-note{{forward declaration}} -}; - -template struct X2<int>::Inner<float>; // expected-error{{explicit instantiation of undefined template}} - -// A definition of a class template shall be in scope at the point of an -// explicit instantiation of a member function or a static data member of the -// class template. -template void X1<int>::f1(int); // expected-error {{undefined template}} -template void X1<int>::f1<int>(int); // expected-error {{undefined template}} - -template int X1<int>::member; // expected-error {{undefined template}} - -// A definition of a member class of a class template shall be in scope at the -// point of an explicit instantiation of the member class. -template struct X2<float>::InnerClass; // expected-error{{undefined member}} - -// If the declaration of the explicit instantiation names an implicitly-declared -// special member function (Clause 12), the program is ill-formed. -template X2<int>::X2(); // expected-error{{not an instantiation}} -template X2<int>::X2(const X2&); // expected-error{{not an instantiation}} -template X2<int>::~X2(); // expected-error{{not an instantiation}} -template X2<int> &X2<int>::operator=(const X2<int>&); // expected-error{{not an instantiation}} - - -// A definition of a class template is sufficient to explicitly -// instantiate a member of the class template which itself is not yet defined. -namespace PR7979 { - template <typename T> struct S { - void f(); - static void g(); - static int i; - struct S2 { - void h(); - }; - }; - - template void S<int>::f(); - template void S<int>::g(); - template int S<int>::i; - template void S<int>::S2::h(); - - template <typename T> void S<T>::f() {} - template <typename T> void S<T>::g() {} - template <typename T> int S<T>::i; - template <typename T> void S<T>::S2::h() {} -} - -namespace PR11599 { - template <typename STRING_TYPE> class BasicStringPiece; // expected-note {{template is declared here}} - - extern template class BasicStringPiece<int>; // expected-error{{explicit instantiation of undefined template 'PR11599::BasicStringPiece<int>}} - template class BasicStringPiece<int>; -} diff --git a/test/CXX/temp/temp.spec/temp.explicit/p4.cpp b/test/CXX/temp/temp.spec/temp.explicit/p4.cpp deleted file mode 100644 index 0a8a0ce9ff18..000000000000 --- a/test/CXX/temp/temp.spec/temp.explicit/p4.cpp +++ /dev/null @@ -1,49 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s - -template<typename T> void f0(T); // expected-note{{here}} -template void f0(int); // expected-error{{explicit instantiation of undefined function template}} - -template<typename T> -struct X0 { - struct Inner; - - void f1(); // expected-note{{here}} - - static T value; // expected-note{{here}} -}; - -template void X0<int>::f1(); // expected-error{{explicit instantiation of undefined member function}} - -template int X0<int>::value; // expected-error{{explicit instantiation of undefined static data member}} - -template<> void f0(long); // expected-note{{previous template specialization is here}} -template void f0(long); // expected-warning{{explicit instantiation of 'f0<long>' that occurs after an explicit specialization has no effect}} - -template<> void X0<long>::f1(); // expected-note{{previous template specialization is here}} -template void X0<long>::f1(); // expected-warning{{explicit instantiation of 'f1' that occurs after an explicit specialization has no effect}} - -template<> struct X0<long>::Inner; // expected-note{{previous template specialization is here}} -template struct X0<long>::Inner; // expected-warning{{explicit instantiation of 'Inner' that occurs after an explicit specialization has no effect}} - -template<> long X0<long>::value; // expected-note{{previous template specialization is here}} -template long X0<long>::value; // expected-warning{{explicit instantiation of 'value' that occurs after an explicit specialization has no effect}} - -template<> struct X0<double>; // expected-note{{previous template specialization is here}} -template struct X0<double>; // expected-warning{{explicit instantiation of 'X0<double>' that occurs after an explicit specialization has no effect}} - -// PR 6458 -namespace test0 { - template <class T> class foo { - int compare(T x, T y); - }; - - template <> int foo<char>::compare(char x, char y); - template <class T> int foo<T>::compare(T x, T y) { - // invalid at T=char; if we get a diagnostic here, we're - // inappropriately instantiating this template. - void *ptr = x; - } - extern template class foo<char>; // expected-warning 0-1{{extern templates are a C++11 extension}} - template class foo<char>; -} diff --git a/test/CXX/temp/temp.spec/temp.explicit/p5.cpp b/test/CXX/temp/temp.spec/temp.explicit/p5.cpp deleted file mode 100644 index ca1f9a391edd..000000000000 --- a/test/CXX/temp/temp.spec/temp.explicit/p5.cpp +++ /dev/null @@ -1,24 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -Wc++11-compat %s -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 -Wc++11-compat %s -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s - -namespace N { - template<class T> class Y { // expected-note{{explicit instantiation refers here}} - void mf() { } - }; -} - -template class Z<int>; // expected-error{{explicit instantiation of non-template class 'Z'}} - -// FIXME: This example from the standard is wrong; note posted to CWG reflector -// on 10/27/2009 -using N::Y; -template class Y<int>; -#if __cplusplus <= 199711L -// expected-warning@-2 {{explicit instantiation of 'N::Y' must occur in namespace 'N'}} -#else -// expected-error@-4 {{explicit instantiation of 'N::Y' must occur in namespace 'N'}} -#endif - -template class N::Y<char*>; -template void N::Y<double>::mf(); diff --git a/test/CXX/temp/temp.spec/temp.explicit/p6.cpp b/test/CXX/temp/temp.spec/temp.explicit/p6.cpp deleted file mode 100644 index 0f5db2119052..000000000000 --- a/test/CXX/temp/temp.spec/temp.explicit/p6.cpp +++ /dev/null @@ -1,36 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -// expected-no-diagnostics - -template<class T> class Array { /* ... */ }; -template<class T> void sort(Array<T>& v) { } - -// instantiate sort(Array<int>&) - template-argument deduced -template void sort<>(Array<int>&); - -template void sort(Array<long>&); - -template<typename T, typename U> void f0(T, U*) { } - -template void f0<int>(int, float*); -template void f0<>(double, float*); - -template<typename T> struct hash { }; -struct S { - bool operator==(const S&) const { return false; } -}; - -template<typename T> struct Hash_map { - void Method(const T& x) { h(x); } - hash<T> h; -}; - -Hash_map<S> *x; -const Hash_map<S> *foo() { - return x; -} - -template<> struct hash<S> { - int operator()(const S& k) const { - return 0; - } -}; diff --git a/test/CXX/temp/temp.spec/temp.explicit/p7.cpp b/test/CXX/temp/temp.spec/temp.explicit/p7.cpp deleted file mode 100644 index 7398dca7ba1c..000000000000 --- a/test/CXX/temp/temp.spec/temp.explicit/p7.cpp +++ /dev/null @@ -1,36 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s - -template<typename T> -struct X0 { - struct MemberClass { - T member; // expected-error{{with function type}} - }; - - T* f0(T* ptr) { - 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 the function}} - -template class X0<int>; // okay - -template class X0<int(int)>; // expected-note 3{{requested here}} - -// Specialize everything, so that the explicit instantiation does not trigger -// any diagnostics. -template<> -struct X0<int(long)>::MemberClass { }; - -typedef int int_long_func(long); -template<> -int_long_func *X0<int_long_func>::f0(int_long_func *) { return 0; } - -template<> -int_long_func *X0<int(long)>::static_member; - -template class X0<int(long)>; - diff --git a/test/CXX/temp/temp.spec/temp.explicit/p8.cpp b/test/CXX/temp/temp.spec/temp.explicit/p8.cpp deleted file mode 100644 index 550078ab147c..000000000000 --- a/test/CXX/temp/temp.spec/temp.explicit/p8.cpp +++ /dev/null @@ -1,40 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s - -template<typename T> -struct X0 { - struct MemberClass; - - T* f0(T* ptr); - - static T* static_member; -}; - -template class X0<int(int)>; // ok; nothing gets instantiated. - -template<typename T> -struct X0<T>::MemberClass { - T member; -}; - -template<typename T> -T* X0<T>::f0(T* ptr) { - return ptr + 1; -} - -template<typename T> -T* X0<T>::static_member = 0; - -template class X0<int>; // ok - - -template<typename T> -struct X1 { - enum class E { - e = T::error // expected-error 2{{no members}} - }; -}; -template struct X1<int>; // expected-note {{here}} - -extern template struct X1<char>; // ok - -template struct X1<char>; // expected-note {{here}} diff --git a/test/CXX/temp/temp.spec/temp.explicit/p9-linkage.cpp b/test/CXX/temp/temp.spec/temp.explicit/p9-linkage.cpp deleted file mode 100644 index 9bdccc8e7324..000000000000 --- a/test/CXX/temp/temp.spec/temp.explicit/p9-linkage.cpp +++ /dev/null @@ -1,66 +0,0 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin -O1 -disable-llvm-passes -emit-llvm -std=c++11 -o - %s | FileCheck %s - -template<typename T> -struct X0 { - void f(T &t) { - t = 0; - } - - void g(T &t); - - void h(T &t); - - static T static_var; -}; - -template<typename T> -inline void X0<T>::g(T & t) { - t = 0; -} - -template<typename T> -void X0<T>::h(T & t) { - t = 0; -} - -template<typename T> -T X0<T>::static_var = 0; - -extern template struct X0<int*>; - -int *&test(X0<int*> xi, int *ip) { - // CHECK: define available_externally void @_ZN2X0IPiE1fERS0_ - xi.f(ip); - // CHECK: define available_externally void @_ZN2X0IPiE1gERS0_ - xi.g(ip); - // CHECK: declare void @_ZN2X0IPiE1hERS0_ - xi.h(ip); - return X0<int*>::static_var; -} - -template<typename T> -void f0(T& t) { - t = 0; -} - -template<typename T> -inline void f1(T& t) { - t = 0; -} - -extern template void f0<>(int *&); -extern template void f1<>(int *&); - -void test_f0(int *ip, float *fp) { - // CHECK: declare void @_Z2f0IPiEvRT_ - f0(ip); - // CHECK: define linkonce_odr void @_Z2f0IPfEvRT_ - f0(fp); -} - -void test_f1(int *ip, float *fp) { - // CHECK: define available_externally void @_Z2f1IPiEvRT_ - f1(ip); - // CHECK: define linkonce_odr void @_Z2f1IPfEvRT_ - f1(fp); -} diff --git a/test/CXX/temp/temp.spec/temp.explicit/p9.cpp b/test/CXX/temp/temp.spec/temp.explicit/p9.cpp deleted file mode 100644 index 86490175f0c3..000000000000 --- a/test/CXX/temp/temp.spec/temp.explicit/p9.cpp +++ /dev/null @@ -1,59 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s - -template<typename T> -struct X0 { - void f(T &t) { - t = 1; // expected-error{{incompatible type}} - } - - void g(T &t); - - void h(T &t); - - static T static_var; -}; - -template<typename T> -inline void X0<T>::g(T & t) { - t = 1; // expected-error{{incompatible type}} -} - -template<typename T> -void X0<T>::h(T & t) { - t = 1; -} - -template<typename T> -T X0<T>::static_var = 1; - -extern template struct X0<int*>; - -int *&test(X0<int*> xi, int *ip) { - xi.f(ip); // expected-note{{instantiation}} - xi.g(ip); // expected-note{{instantiation}} - xi.h(ip); - return X0<int*>::static_var; -} - -template<typename T> -void f0(T& t) { - t = 1; // expected-error{{incompatible type}} -} - -template<typename T> -inline void f1(T& t) { - t = 1; // expected-error 2{{incompatible type}} -} - -extern template void f0<>(int *&); -extern template void f1<>(int *&); - -void test_f0(int *ip, float *fp) { - f0(ip); - f0(fp); // expected-note{{instantiation}} -} - -void test_f1(int *ip, float *fp) { - f1(ip); // expected-note{{instantiation}} - f1(fp); // expected-note{{instantiation}} -} diff --git a/test/CXX/temp/temp.spec/temp.inst/p1.cpp b/test/CXX/temp/temp.spec/temp.inst/p1.cpp deleted file mode 100644 index 3d2d6d7c3adf..000000000000 --- a/test/CXX/temp/temp.spec/temp.inst/p1.cpp +++ /dev/null @@ -1,113 +0,0 @@ -// RUN: %clang_cc1 -std=c++11 -verify %s - -// The implicit specialization of a class template specialuzation causes the -// implicit instantiation of the declarations, but not the definitions or -// default arguments, of: - -// FIXME: Many omitted cases - -// - scoped member enumerations -namespace ScopedEnum { - template<typename T> struct ScopedEnum1 { - enum class E { - e = T::error // expected-error {{'double' cannot be used prior to '::'}} - }; - }; - ScopedEnum1<int> se1; // ok - - template<typename T> struct ScopedEnum2 { - enum class E : T { // expected-error {{non-integral type 'void *' is an invalid underlying type}} - e = 0 - }; - }; - ScopedEnum2<void*> se2; // expected-note {{here}} - - template<typename T> struct UnscopedEnum3 { - enum class E : T { - e = 4 - }; - int arr[(int)E::e]; - }; - UnscopedEnum3<int> ue3; // ok - - ScopedEnum1<double>::E e1; // ok - ScopedEnum1<double>::E e2 = decltype(e2)::e; // expected-note {{in instantiation of enumeration 'ScopedEnum::ScopedEnum1<double>::E' requested here}} - - // DR1484 specifies that enumerations cannot be separately instantiated, - // they will be instantiated with the rest of the template declaration. - template<typename T> - int f() { - enum class E { - e = T::error // expected-error {{has no members}} - }; - return (int)E(); - } - int test1 = f<int>(); // expected-note {{here}} - - template<typename T> - int g() { - enum class E { - e = T::error // expected-error {{has no members}} - }; - return E::e; - } - int test2 = g<int>(); // expected-note {{here}} -} - -// - static data members -namespace StaticDataMembers { - template<typename T> - struct A { - static const int n = T::error; // expected-error {{has no members}} - static inline int m = T::error; // expected-warning {{extension}} - }; - A<int> ai; // expected-note {{here}} -} - -// And it cases the implicit instantiations of the definitions of: - -// - unscoped member enumerations -namespace UnscopedEnum { - template<typename T> struct UnscopedEnum1 { - enum E { - e = T::error // expected-error {{'int' cannot be used prior to '::'}} - }; - }; - UnscopedEnum1<int> ue1; // expected-note {{here}} - - template<typename T> struct UnscopedEnum2 { - enum E : T { // expected-error {{non-integral type 'void *' is an invalid underlying type}} - e = 0 - }; - }; - UnscopedEnum2<void*> ue2; // expected-note {{here}} - - template<typename T> struct UnscopedEnum3 { - enum E : T { - e = 4 - }; - int arr[E::e]; - }; - UnscopedEnum3<int> ue3; // ok - - template<typename T> - int f() { - enum E { - e = T::error // expected-error {{has no members}} - }; - return (int)E(); - } - int test1 = f<int>(); // expected-note {{here}} - - template<typename T> - int g() { - enum E { - e = T::error // expected-error {{has no members}} - }; - return E::e; - } - int test2 = g<int>(); // expected-note {{here}} -} - -// FIXME: -//- - member anonymous unions diff --git a/test/CXX/temp/temp.spec/temp.inst/p11.cpp b/test/CXX/temp/temp.spec/temp.inst/p11.cpp deleted file mode 100644 index 818407102cfd..000000000000 --- a/test/CXX/temp/temp.spec/temp.inst/p11.cpp +++ /dev/null @@ -1,15 +0,0 @@ -// RUN: %clang_cc1 -verify -emit-llvm-only %s - -// rdar://problem/7838962 -namespace test0 { - template<typename T> unsigned f0() { - return T::MaxSize; // expected-error {{'int' cannot be used prior to '::'}} - }; - template<typename T> struct A { - void Allocate(unsigned Alignment - = f0<T>()) // expected-note {{in instantiation}} - {} - }; - void f1(A<int> x) { x.Allocate(); } - -} diff --git a/test/CXX/temp/temp.spec/temp.inst/p7.cpp b/test/CXX/temp/temp.spec/temp.inst/p7.cpp deleted file mode 100644 index 5145dafdc5b4..000000000000 --- a/test/CXX/temp/temp.spec/temp.inst/p7.cpp +++ /dev/null @@ -1,12 +0,0 @@ -// RUN: %clang_cc1 -verify -std=c++17 %s - -template<typename T> constexpr int f() { return T::value; } // expected-error {{'::'}} -template<bool B, typename T> void g(decltype(B ? f<T>() : 0)); -template<bool B, typename T> void g(...); -template<bool B, typename T> void h(decltype(int{B ? f<T>() : 0})); // expected-note {{instantiation of}} -template<bool B, typename T> void h(...); -void x() { - g<false, int>(0); // ok - g<true, int>(0); // ok - h<false, int>(0); // expected-note {{while substituting}} -} diff --git a/test/CXX/temp/temp.type/p1-0x.cpp b/test/CXX/temp/temp.type/p1-0x.cpp deleted file mode 100644 index 35d00c2fab20..000000000000 --- a/test/CXX/temp/temp.type/p1-0x.cpp +++ /dev/null @@ -1,23 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s - -namespace Old { - template<template<class> class TT> struct X { }; - template<class> struct Y { }; - template<class T> using Z = Y<T>; - X<Y> y; - X<Z> z; - - using SameType = decltype(y); // expected-note {{here}} - using SameType = decltype(z); // expected-error {{different types}} -} - -namespace New { - template<class T> struct X { }; - template<class> struct Y { }; - template<class T> using Z = Y<T>; - X<Y<int>> y; - X<Z<int>> z; - - using SameType = decltype(y); - using SameType = decltype(z); // ok -} |