diff options
author | Daniel Jasper <djasper@google.com> | 2016-12-19 10:09:25 +0000 |
---|---|---|
committer | Daniel Jasper <djasper@google.com> | 2016-12-19 10:09:25 +0000 |
commit | 9949ead55ad85698096af2fda29e8c6bb00a09b9 (patch) | |
tree | cb7551d743a7326e28591672cc19f3c5ff0a2004 /clang/test | |
parent | 03b8be575e36f847387e314cfab75c2ae54e831f (diff) | |
download | bcm5719-llvm-9949ead55ad85698096af2fda29e8c6bb00a09b9.tar.gz bcm5719-llvm-9949ead55ad85698096af2fda29e8c6bb00a09b9.zip |
Revert "[c++1z] P0195R2: Support pack-expansion of using-declarations."
This reverts commit r290080 as it leads to many Clang crashes, e.g.:
http://lab.llvm.org:8011/builders/clang-cmake-aarch64-quick/builds/1814
llvm-svn: 290092
Diffstat (limited to 'clang/test')
-rw-r--r-- | clang/test/PCH/cxx1z-using-declaration.cpp | 35 | ||||
-rw-r--r-- | clang/test/Parser/cxx1z-using-declaration.cpp | 9 | ||||
-rw-r--r-- | clang/test/SemaTemplate/cxx1z-using-declaration.cpp | 230 |
3 files changed, 2 insertions, 272 deletions
diff --git a/clang/test/PCH/cxx1z-using-declaration.cpp b/clang/test/PCH/cxx1z-using-declaration.cpp deleted file mode 100644 index a185ff17404..00000000000 --- a/clang/test/PCH/cxx1z-using-declaration.cpp +++ /dev/null @@ -1,35 +0,0 @@ -// No PCH: -// RUN: %clang_cc1 -pedantic -std=c++1z -include %s -verify %s -// -// With PCH: -// RUN: %clang_cc1 -pedantic -std=c++1z -emit-pch %s -o %t -// RUN: %clang_cc1 -pedantic -std=c++1z -include-pch %t -verify %s - -#ifndef HEADER -#define HEADER - -template<typename ...T> struct A : T... { - using T::f ...; - template<typename ...U> void g(U ...u) { f(u...); } -}; - -struct X { void f(); }; -struct Y { void f(int); }; -struct Z { void f(int, int); }; - -inline A<X, Y, Z> a; - -#else - -void test() { - a.g(); - a.g(0); - a.g(0, 0); - // expected-error@13 {{no match}} - // expected-note@16 {{candidate}} - // expected-note@17 {{candidate}} - // expected-note@18 {{candidate}} - a.g(0, 0, 0); // expected-note {{instantiation of}} -} - -#endif diff --git a/clang/test/Parser/cxx1z-using-declaration.cpp b/clang/test/Parser/cxx1z-using-declaration.cpp index 0be81677d9f..dab1ca82c2a 100644 --- a/clang/test/Parser/cxx1z-using-declaration.cpp +++ b/clang/test/Parser/cxx1z-using-declaration.cpp @@ -10,10 +10,10 @@ namespace B { } struct X { - int x1, x2, y, z; // expected-note 2{{conflicting}} + int x1, x2, y, z; // expected-note {{conflicting}} }; struct Y { - int x1, x2, y, z; // expected-note 2{{target}} + int x1, x2, y, z; // expected-note {{target}} }; struct Z : X, Y { using X::x1, @@ -28,8 +28,3 @@ int X::*px1 = &Z::x1; int X::*px2 = &Z::x2; int Y::*py = &Z::y; int X::*pz = &Z::z; - -template<typename ...T> struct Q : T... { - using T::z...; // expected-error {{conflicts}} -}; -Q<X,Y> q; // expected-note {{instantiation of}} diff --git a/clang/test/SemaTemplate/cxx1z-using-declaration.cpp b/clang/test/SemaTemplate/cxx1z-using-declaration.cpp deleted file mode 100644 index 7bef36db1f4..00000000000 --- a/clang/test/SemaTemplate/cxx1z-using-declaration.cpp +++ /dev/null @@ -1,230 +0,0 @@ -// RUN: %clang_cc1 -std=c++1z -verify %s - -// Test that we cope with failure to expand a pack. -template<typename ...T> struct Unexpanded : T... { - using T::f; // expected-error {{unexpanded}} - using typename T::type; // expected-error {{unexpanded}} - template<typename ...U> void g(U ...u) { f(u...); } // expected-error {{undeclared identifier 'f'}} - void h() { - Unexpanded<type...> *p; // expected-error {{undeclared identifier 'type'}} - } -}; -void test_Unexpanded() { - struct A { void f(); }; // expected-note {{must qualify}} - struct B { void f(int); }; // expected-note {{must qualify}} - Unexpanded<A, B>().g(0); // expected-note {{instantiation of}} -} - -// Test using non-type members from pack of base classes. -template<typename ...T> struct A : T... { // expected-note 2{{candidate}} - using T::T ...; // expected-note 6{{inherited here}} - using T::operator() ...; - using T::operator T* ...; - using T::h ...; - - void f(int n) { h(n); } // expected-error {{ambiguous}} - void f(int n, int m) { h(n, m); } // expected-error {{member using declaration 'h' instantiates to an empty pack}} - void g(int n) { (*this)(n); } // expected-error {{ambiguous}} - void g(int n, int m) { (*this)(n, m); } // expected-error {{does not provide a call operator}} -}; - -namespace test_A { - struct X { // expected-note 2{{candidate}} - X(); - X(int); // expected-note {{candidate}} - void operator()(int); // expected-note 2{{candidate}} - operator X *(); - void h(int); // expected-note {{candidate}} - }; - struct Y { - Y(); - Y(int, int); - void operator()(int, int); - operator Y *(); - void h(int, int); // expected-note {{not viable}} - }; - struct Z { // expected-note 2{{candidate}} - Z(); - Z(int); // expected-note {{candidate}} - void operator()(int); // expected-note 2{{candidate}} - operator Z *(); - void h(int); // expected-note {{candidate}} - }; - - void f() { - A<> a; - a.f(0, 0); // expected-note {{instantiation of}} - a.g(0, 0); // expected-note {{instantiation of}} - - A<X, Y> axy(0); - A<X, Y>(0, 0); - axy.f(0); - axy.f(0, 0); - axy.g(0); - axy.g(0, 0); - axy(0); - axy(0, 0); - - A<X, Y, Z>(0); // expected-error {{ambiguous}} - A<X, Y, Z> axyz(0, 0); - axyz.f(0); // expected-note {{instantiation of}} - axyz.f(0, 0); - axyz.g(0); // expected-note {{instantiation of}} - axyz.g(0, 0); - axyz(0); // expected-error {{ambiguous}} - axyz(0, 0); - - X *x; - x = a; // expected-error {{incompatible}} - x = axy; - x = axyz; - x = a.operator X*(); // expected-error {{no member}} - x = axy.operator X*(); - x = axyz.operator X*(); - - Z *z; - z = axyz; - z = axyz.operator Z*(); - } -} - -// Test using pack of non-type members from single base class. -template<typename X, typename Y, typename ...T> struct B : X, Y { - using X::operator T* ...; -}; - -namespace test_B { - struct X { operator int*(); operator float*(); operator char*(); }; // expected-note {{candidate}} - struct Y { operator int*(); operator float*(); operator char*(); }; // expected-note {{candidate}} - B<X, Y, int, float> bif; - int *pi = bif; - float *pf = bif; - char *pc = bif; // expected-error {{ambiguous}} -} - -// Test using type member from pack of base classes. -template<typename ...T> struct C : T... { - using typename T::type ...; // expected-error {{target of using declaration conflicts}} - void f() { type value; } // expected-error {{member using declaration 'type' instantiates to an empty pack}} -}; - -namespace test_C { - struct X { typedef int type; }; - struct Y { typedef int type; }; // expected-note {{conflicting}} - struct Z { typedef float type; }; // expected-note {{target}} - - void f() { - C<> c; - c.f(); // expected-note {{instantiation of}} - - C<X, Y> cxy; - cxy.f(); - - C<X, Y, Z> cxyz; // expected-note {{instantiation of}} - cxyz.f(); - } -} - -// Test using pack of non-types at block scope. -template<typename ...T> int fn1() { - using T::e ...; // expected-error 2{{class member}} expected-note 2{{instead}} - // expected-error@-1 2{{produces multiple values}} - return e; // expected-error {{using declaration 'e' instantiates to an empty pack}} -} - -namespace test_fn1 { - struct X { static int e; }; - struct Y { typedef int e; }; - inline namespace P { enum E { e }; } - inline namespace Q { enum F { e }; } - void f() { - fn1<>(); // expected-note {{instantiation of}} - fn1<X>(); // expected-note {{instantiation of}} - fn1<Y>(); // expected-note {{instantiation of}} - fn1<E>(); - fn1<E, F>(); // expected-note {{instantiation of}} - fn1<E, X>(); // expected-note {{instantiation of}} - } -} - -// Test using pack of types at block scope. -template<typename ...T> void fn2() { - // This cannot ever be valid: in order for T::type to be a type, T must be a - // class, and a class member cannot be named by a block-scope using declaration. - using typename T::type ...; // expected-error {{class member}} - type x; // expected-error {{unknown type name 'type'}} -} - -// Test partial substitution into class-scope pack. -template<typename ...T> auto lambda1() { - return [](auto x) { - struct A : T::template X<decltype(x)>... { // expected-note 1+{{instantiation of}} - using T::template X<decltype(x)>::f ...; - using typename T::template X<decltype(x)>::type ...; - void g(int n) { f(n); } // expected-error {{empty pack}} expected-error {{expected 2, have 1}} expected-error {{ambiguous}} - void h() { type value; } // expected-error {{empty pack}} - }; - return A(); - }; -} - -namespace test_lambda1 { - struct A { - template<typename> struct X { - void f(int); // expected-note {{candidate}} - using type = int; - }; - }; - struct B { - template<typename> struct X { - void f(int, int); // expected-note {{declared here}} expected-note {{not viable}} - using type = int; - }; - }; - struct C { - template<typename> struct X { - void f(int); // expected-note {{candidate}} - void f(int, int); // expected-note {{not viable}} - using type = int; - }; - }; - - void f() { - lambda1<>() // expected-note 2{{instantiation of}} - (0) - // FIXME: This is poor error recovery - .g(0); // expected-error {{no member named 'g'}} - lambda1<A>() - (0) - .g(0); - lambda1<B>() - (0) // expected-note {{instantiation of}} - .g(0); - lambda1<A, B, C>() - (0) // expected-note {{instantiation of}} - .g(0); - } -} - -namespace p0195r2_example { - template<typename ...Ts> - struct Overloader : Ts... { - using Ts::operator() ...; - }; - - template<typename ...Ts> - constexpr auto make_overloader(Ts &&...ts) { - return Overloader<Ts...>{static_cast<Ts&&>(ts)...}; - } - - void test() { - auto o = make_overloader( - [&](int &r) -> int & { return r; }, // expected-note {{candidate function}} - [&](float &r) -> float & { return r; } // expected-note {{candidate function}} - ); - int a; float f; double d; - int &ra = o(a); - float &rf = o(f); - double &rd = o(d); // expected-error {{no matching function}} - } -} |