diff options
Diffstat (limited to 'test/Misc/diag-template-diffing.cpp')
-rw-r--r-- | test/Misc/diag-template-diffing.cpp | 258 |
1 files changed, 234 insertions, 24 deletions
diff --git a/test/Misc/diag-template-diffing.cpp b/test/Misc/diag-template-diffing.cpp index 2c044f8..add96ef 100644 --- a/test/Misc/diag-template-diffing.cpp +++ b/test/Misc/diag-template-diffing.cpp @@ -645,41 +645,41 @@ void Play1() { } // CHECK-ELIDE-NOTREE: no viable overloaded '=' -// CHECK-ELIDE-NOTREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from 'Foo1<1>' to 'Foo1<2>' for 1st argument +// CHECK-ELIDE-NOTREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from 'Foo1<1>' to 'const Foo1<2>' for 1st argument // CHECK-ELIDE-NOTREE: candidate function (the implicit move assignment operator) not viable: no known conversion from 'Foo1<1>' to 'Foo1<2>' for 1st argument // CHECK-ELIDE-NOTREE: no viable overloaded '=' -// CHECK-ELIDE-NOTREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from 'Foo1<2>' to 'Foo1<1>' for 1st argument +// CHECK-ELIDE-NOTREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from 'Foo1<2>' to 'const Foo1<1>' for 1st argument // CHECK-ELIDE-NOTREE: candidate function (the implicit move assignment operator) not viable: no known conversion from 'Foo1<2>' to 'Foo1<1>' for 1st argument // CHECK-NOELIDE-NOTREE: no viable overloaded '=' -// CHECK-NOELIDE-NOTREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from 'Foo1<1>' to 'Foo1<2>' for 1st argument +// CHECK-NOELIDE-NOTREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from 'Foo1<1>' to 'const Foo1<2>' for 1st argument // CHECK-NOELIDE-NOTREE: candidate function (the implicit move assignment operator) not viable: no known conversion from 'Foo1<1>' to 'Foo1<2>' for 1st argument // CHECK-NOELIDE-NOTREE: no viable overloaded '=' -// CHECK-NOELIDE-NOTREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from 'Foo1<2>' to 'Foo1<1>' for 1st argument +// CHECK-NOELIDE-NOTREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from 'Foo1<2>' to 'const Foo1<1>' for 1st argument // CHECK-NOELIDE-NOTREE: candidate function (the implicit move assignment operator) not viable: no known conversion from 'Foo1<2>' to 'Foo1<1>' for 1st argument // CHECK-ELIDE-TREE: no viable overloaded '=' // CHECK-ELIDE-TREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument -// CHECK-ELIDE-TREE: Foo1< +// CHECK-ELIDE-TREE: [(no qualifiers) != const] Foo1< // CHECK-ELIDE-TREE: [1 != 2]> // CHECK-ELIDE-TREE: candidate function (the implicit move assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument // CHECK-ELIDE-TREE: Foo1< // CHECK-ELIDE-TREE: [1 != 2]> // CHECK-ELIDE-TREE: no viable overloaded '=' // CHECK-ELIDE-TREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument -// CHECK-ELIDE-TREE: Foo1< +// CHECK-ELIDE-TREE: [(no qualifiers) != const] Foo1< // CHECK-ELIDE-TREE: [2 != 1]> // CHECK-ELIDE-TREE: candidate function (the implicit move assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument // CHECK-ELIDE-TREE: Foo1< // CHECK-ELIDE-TREE: [2 != 1]> // CHECK-NOELIDE-TREE: no viable overloaded '=' // CHECK-NOELIDE-TREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument -// CHECK-NOELIDE-TREE: Foo1< +// CHECK-NOELIDE-TREE: [(no qualifiers) != const] Foo1< // CHECK-NOELIDE-TREE: [1 != 2]> // CHECK-NOELIDE-TREE: candidate function (the implicit move assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument // CHECK-NOELIDE-TREE: Foo1< // CHECK-NOELIDE-TREE: [1 != 2]> // CHECK-NOELIDE-TREE: no viable overloaded '=' // CHECK-NOELIDE-TREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument -// CHECK-NOELIDE-TREE: Foo1< +// CHECK-NOELIDE-TREE: [(no qualifiers) != const] Foo1< // CHECK-NOELIDE-TREE: [2 != 1]> // CHECK-NOELIDE-TREE: candidate function (the implicit move assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument // CHECK-NOELIDE-TREE: Foo1< @@ -694,41 +694,41 @@ void Play2() { F3 = F2; } // CHECK-ELIDE-NOTREE: no viable overloaded '=' -// CHECK-ELIDE-NOTREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from 'Foo2<1>' to 'Foo2<2>' for 1st argument +// CHECK-ELIDE-NOTREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from 'Foo2<1>' to 'const Foo2<2>' for 1st argument // CHECK-ELIDE-NOTREE: candidate function (the implicit move assignment operator) not viable: no known conversion from 'Foo2<1>' to 'Foo2<2>' for 1st argument // CHECK-ELIDE-NOTREE: no viable overloaded '=' -// CHECK-ELIDE-NOTREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from 'Foo2<(default) 2>' to 'Foo2<1>' for 1st argument +// CHECK-ELIDE-NOTREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from 'Foo2<(default) 2>' to 'const Foo2<1>' for 1st argument // CHECK-ELIDE-NOTREE: candidate function (the implicit move assignment operator) not viable: no known conversion from 'Foo2<(default) 2>' to 'Foo2<1>' for 1st argument // CHECK-NOELIDE-NOTREE: no viable overloaded '=' -// CHECK-NOELIDE-NOTREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from 'Foo2<1>' to 'Foo2<2>' for 1st argument +// CHECK-NOELIDE-NOTREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from 'Foo2<1>' to 'const Foo2<2>' for 1st argument // CHECK-NOELIDE-NOTREE: candidate function (the implicit move assignment operator) not viable: no known conversion from 'Foo2<1>' to 'Foo2<2>' for 1st argument // CHECK-NOELIDE-NOTREE: no viable overloaded '=' -// CHECK-NOELIDE-NOTREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from 'Foo2<(default) 2>' to 'Foo2<1>' for 1st argument +// CHECK-NOELIDE-NOTREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from 'Foo2<(default) 2>' to 'const Foo2<1>' for 1st argument // CHECK-NOELIDE-NOTREE: candidate function (the implicit move assignment operator) not viable: no known conversion from 'Foo2<(default) 2>' to 'Foo2<1>' for 1st argument // CHECK-ELIDE-TREE: no viable overloaded '=' // CHECK-ELIDE-TREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument -// CHECK-ELIDE-TREE: Foo2< +// CHECK-ELIDE-TREE: [(no qualifiers) != const] Foo2< // CHECK-ELIDE-TREE: [1 != 2]> // CHECK-ELIDE-TREE: candidate function (the implicit move assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument // CHECK-ELIDE-TREE: Foo2< // CHECK-ELIDE-TREE: [1 != 2]> // CHECK-ELIDE-TREE: no viable overloaded '=' // CHECK-ELIDE-TREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument -// CHECK-ELIDE-TREE: Foo2< +// CHECK-ELIDE-TREE: [(no qualifiers) != const] Foo2< // CHECK-ELIDE-TREE: [(default) 2 != 1]> // CHECK-ELIDE-TREE: candidate function (the implicit move assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument // CHECK-ELIDE-TREE: Foo2< // CHECK-ELIDE-TREE: [(default) 2 != 1]> // CHECK-NOELIDE-TREE: no viable overloaded '=' // CHECK-NOELIDE-TREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument -// CHECK-NOELIDE-TREE: Foo2< +// CHECK-NOELIDE-TREE: [(no qualifiers) != const] Foo2< // CHECK-NOELIDE-TREE: [1 != 2]> // CHECK-NOELIDE-TREE: candidate function (the implicit move assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument // CHECK-NOELIDE-TREE: Foo2< // CHECK-NOELIDE-TREE: [1 != 2]> // CHECK-NOELIDE-TREE: no viable overloaded '=' // CHECK-NOELIDE-TREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument -// CHECK-NOELIDE-TREE: Foo2< +// CHECK-NOELIDE-TREE: [(no qualifiers) != const] Foo2< // CHECK-NOELIDE-TREE: [(default) 2 != 1]> // CHECK-NOELIDE-TREE: candidate function (the implicit move assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument // CHECK-NOELIDE-TREE: Foo2< @@ -743,20 +743,20 @@ void Play3() { F3 = F2; } // CHECK-ELIDE-NOTREE: no viable overloaded '=' -// CHECK-ELIDE-NOTREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from 'Foo3<1, (no argument)>' to 'Foo3<2, 1>' for 1st argument +// CHECK-ELIDE-NOTREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from 'Foo3<1, (no argument)>' to 'const Foo3<2, 1>' for 1st argument // CHECK-ELIDE-NOTREE: candidate function (the implicit move assignment operator) not viable: no known conversion from 'Foo3<1, (no argument)>' to 'Foo3<2, 1>' for 1st argument // CHECK-ELIDE-NOTREE: no viable overloaded '=' -// CHECK-ELIDE-NOTREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from 'Foo3<2, 1>' to 'Foo3<1, (no argument)>' for 1st argument +// CHECK-ELIDE-NOTREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from 'Foo3<2, 1>' to 'const Foo3<1, (no argument)>' for 1st argument // CHECK-ELIDE-NOTREE: candidate function (the implicit move assignment operator) not viable: no known conversion from 'Foo3<2, 1>' to 'Foo3<1, (no argument)>' for 1st argument // CHECK-NOELIDE-NOTREE: no viable overloaded '=' -// CHECK-NOELIDE-NOTREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from 'Foo3<1, (no argument)>' to 'Foo3<2, 1>' for 1st argument +// CHECK-NOELIDE-NOTREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from 'Foo3<1, (no argument)>' to 'const Foo3<2, 1>' for 1st argument // CHECK-NOELIDE-NOTREE: candidate function (the implicit move assignment operator) not viable: no known conversion from 'Foo3<1, (no argument)>' to 'Foo3<2, 1>' for 1st argument // CHECK-NOELIDE-NOTREE: no viable overloaded '=' -// CHECK-NOELIDE-NOTREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from 'Foo3<2, 1>' to 'Foo3<1, (no argument)>' for 1st argument +// CHECK-NOELIDE-NOTREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from 'Foo3<2, 1>' to 'const Foo3<1, (no argument)>' for 1st argument // CHECK-NOELIDE-NOTREE: candidate function (the implicit move assignment operator) not viable: no known conversion from 'Foo3<2, 1>' to 'Foo3<1, (no argument)>' for 1st argument // CHECK-ELIDE-TREE: no viable overloaded '=' // CHECK-ELIDE-TREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument -// CHECK-ELIDE-TREE: Foo3< +// CHECK-ELIDE-TREE: [(no qualifiers) != const] Foo3< // CHECK-ELIDE-TREE: [1 != 2], // CHECK-ELIDE-TREE: [(no argument) != 1]> // CHECK-ELIDE-TREE: candidate function (the implicit move assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument @@ -765,7 +765,7 @@ void Play3() { // CHECK-ELIDE-TREE: [(no argument) != 1]> // CHECK-ELIDE-TREE: no viable overloaded '=' // CHECK-ELIDE-TREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument -// CHECK-ELIDE-TREE: Foo3< +// CHECK-ELIDE-TREE: [(no qualifiers) != const] Foo3< // CHECK-ELIDE-TREE: [2 != 1], // CHECK-ELIDE-TREE: [1 != (no argument)]> // CHECK-ELIDE-TREE: candidate function (the implicit move assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument @@ -774,7 +774,7 @@ void Play3() { // CHECK-ELIDE-TREE: [1 != (no argument)]> // CHECK-NOELIDE-TREE: no viable overloaded '=' // CHECK-NOELIDE-TREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument -// CHECK-NOELIDE-TREE: Foo3< +// CHECK-NOELIDE-TREE: [(no qualifiers) != const] Foo3< // CHECK-NOELIDE-TREE: [1 != 2], // CHECK-NOELIDE-TREE: [(no argument) != 1]> // CHECK-NOELIDE-TREE: candidate function (the implicit move assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument @@ -783,7 +783,7 @@ void Play3() { // CHECK-NOELIDE-TREE: [(no argument) != 1]> // CHECK-NOELIDE-TREE: no viable overloaded '=' // CHECK-NOELIDE-TREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument -// CHECK-NOELIDE-TREE: Foo3< +// CHECK-NOELIDE-TREE: [(no qualifiers) != const] Foo3< // CHECK-NOELIDE-TREE: [2 != 1], // CHECK-NOELIDE-TREE: [1 != (no argument)]> // CHECK-NOELIDE-TREE: candidate function (the implicit move assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument @@ -792,8 +792,218 @@ void Play3() { // CHECK-NOELIDE-TREE: [1 != (no argument)]> } +namespace PR14342 { + template<typename T, short a> struct X {}; + X<int, (signed char)-1> x = X<long, -1>(); + X<int, 3UL> y = X<int, 2>(); + // CHECK-ELIDE-NOTREE: error: no viable conversion from 'X<long, [...]>' to 'X<int, [...]>' + // CHECK-ELIDE-NOTREE: error: no viable conversion from 'X<[...], 2>' to 'X<[...], 3>' +} + +namespace PR14489 { + // The important thing here is that the diagnostic diffs a template specialization + // with no arguments against itself. (We might need a different test if this + // diagnostic changes). + template<class ...V> + struct VariableList { + void ConnectAllToAll(VariableList<>& params = VariableList<>()) { + } + }; + // CHECK-ELIDE-NOTREE: non-const lvalue reference to type 'VariableList<>' cannot bind to a temporary of type 'VariableList<>' +} + +namespace rdar12456626 { + struct IntWrapper { + typedef int type; + }; + + template<typename T, typename T::type V> + struct X { }; + + struct A { + virtual X<IntWrapper, 1> foo(); + }; + + struct B : A { + // CHECK-ELIDE-NOTREE: virtual function 'foo' has a different return type + virtual X<IntWrapper, 2> foo(); + }; +} + +namespace PR15023 { + // Don't crash when non-QualTypes are passed to a diff modifier. + template <typename... Args> + void func(void (*func)(Args...), Args...) { } + + void bar(int, int &) { + } + + void foo(int x) { + func(bar, 1, x) + } + // CHECK-ELIDE-NOTREE: no matching function for call to 'func' + // CHECK-ELIDE-NOTREE: candidate template ignored: deduced conflicting types for parameter 'Args' (<int, int &> vs. <int, int>) +} + +namespace rdar12931988 { + namespace A { + template<typename T> struct X { }; + } + + namespace B { + template<typename T> struct X { }; + } + + void foo(A::X<int> &ax, B::X<int> bx) { + // CHECK-ELIDE-NOTREE: no viable overloaded '=' + // CHECK-ELIDE-NOTREE: no known conversion from 'B::X<int>' to 'const rdar12931988::A::X<int>' + ax = bx; + } + + template<template<typename> class> class Y {}; + + void bar(Y<A::X> ya, Y<B::X> yb) { + // CHECK-ELIDE-NOTREE: no viable overloaded '=' + // CHECK-ELIDE-NOTREE: no known conversion from 'Y<template rdar12931988::B::X>' to 'Y<template rdar12931988::A::X>' + ya = yb; + } +} + +namespace ValueDecl { + int int1, int2, default_int; + template <const int& T = default_int> + struct S {}; + + typedef S<int1> T1; + typedef S<int2> T2; + typedef S<> TD; + + void test() { + T1 t1; + T2 t2; + TD td; + + t1 = t2; + // CHECK-ELIDE-NOTREE: no viable overloaded '=' + // CHECK-ELIDE-NOTREE: no known conversion from 'S<int2>' to 'S<int1>' + + t2 = t1; + // CHECK-ELIDE-NOTREE: no viable overloaded '=' + // CHECK-ELIDE-NOTREE: no known conversion from 'S<int1>' to 'S<int2>' + + td = t1; + // TODO: Find out why (default) isn't printed on second template. + // CHECK-ELIDE-NOTREE: no viable overloaded '=' + // CHECK-ELIDE-NOTREE: no known conversion from 'S<int1>' to 'S<default_int>' + + t2 = td; + // CHECK-ELIDE-NOTREE: no viable overloaded '=' + // CHECK-ELIDE-NOTREE: no known conversion from 'S<(default) default_int>' to 'S<int2>' + + } +} + +namespace DependentDefault { + template <typename> struct Trait { + enum { V = 40 }; + typedef int Ty; + static int I; + }; + int other; + + template <typename T, int = Trait<T>::V > struct A {}; + template <typename T, typename = Trait<T>::Ty > struct B {}; + template <typename T, int& = Trait<T>::I > struct C {}; + + void test() { + + A<int> a1; + A<char> a2; + A<int, 10> a3; + a1 = a2; + // CHECK-ELIDE-NOTREE: no viable overloaded '=' + // CHECK-ELIDE-NOTREE: no known conversion from 'A<char, [...]>' to 'A<int, [...]>' + a3 = a1; + // CHECK-ELIDE-NOTREE: no viable overloaded '=' + // CHECK-ELIDE-NOTREE: no known conversion from 'A<[...], (default) 40>' to 'A<[...], 10>' + a2 = a3; + // CHECK-ELIDE-NOTREE: no viable overloaded '=' + // CHECK-ELIDE-NOTREE: no known conversion from 'A<int, 10>' to 'A<char, 40>' + + B<int> b1; + B<char> b2; + B<int, char> b3; + b1 = b2; + // CHECK-ELIDE-NOTREE: no viable overloaded '=' + // CHECK-ELIDE-NOTREE: no known conversion from 'B<char, (default) Trait<T>::Ty>' to 'B<int, int>' + b3 = b1; + // CHECK-ELIDE-NOTREE: no viable overloaded '=' + // CHECK-ELIDE-NOTREE: no known conversion from 'B<[...], (default) Trait<T>::Ty>' to 'B<[...], char>' + b2 = b3; + // CHECK-ELIDE-NOTREE: no viable overloaded '=' + // CHECK-ELIDE-NOTREE: no known conversion from 'B<int, char>' to 'B<char, int>' + + C<int> c1; + C<char> c2; + C<int, other> c3; + c1 = c2; + // CHECK-ELIDE-NOTREE: no viable overloaded '=' + // CHECK-ELIDE-NOTREE: no known conversion from 'C<char, (default) I>' to 'C<int, I>' + c3 = c1; + // CHECK-ELIDE-NOTREE: no viable overloaded '=' + // CHECK-ELIDE-NOTREE: no known conversion from 'C<[...], (default) I>' to 'C<[...], other>' + c2 = c3; + // CHECK-ELIDE-NOTREE: no viable overloaded '=' + // CHECK-ELIDE-NOTREE: no known conversion from 'C<int, other>' to 'C<char, I>' + } +} + +namespace VariadicDefault { + int i1, i2, i3; + template <int = 5, int...> struct A {}; + template <int& = i1, int& ...> struct B {}; + template <typename = void, typename...> struct C {}; + + void test() { + A<> a1; + A<5, 6, 7> a2; + A<1, 2> a3; + a2 = a1; + // CHECK-ELIDE-NOTREE: no viable overloaded '=' + // CHECK-ELIDE-NOTREE: no known conversion from 'A<[...], (no argument), (no argument)>' to 'A<[...], 6, 7>' + a3 = a1; + // CHECK-ELIDE-NOTREE: no viable overloaded '=' + // CHECK-ELIDE-NOTREE: no known conversion from 'A<(default) 5, (no argument)>' to 'A<1, 2>' + + B<> b1; + B<i1, i2, i3> b2; + B<i2, i3> b3; + b2 = b1; + // CHECK-ELIDE-NOTREE: no viable overloaded '=' + // CHECK-ELIDE-NOTREE: no known conversion from 'B<[...], (no argument), (no argument)>' to 'B<[...], i2, i3>' + b3 = b1; + // CHECK-ELIDE-NOTREE: no viable overloaded '=' + // CHECK-ELIDE-NOTREE: no known conversion from 'B<(default) i1, (no argument)>' to 'B<i2, i3>' + + B<i1, i2, i3> b4 = b1; + // CHECK-ELIDE-NOTREE: no viable conversion from 'B<[...], (no argument), (no argument)>' to 'B<[...], i2, i3>' + B<i2, i3> b5 = b1; + // CHECK-ELIDE-NOTREE: no viable conversion from 'B<(default) i1, (no argument)>' to 'B<i2, i3>' + + C<> c1; + C<void, void> c2; + C<char, char> c3; + c2 = c1; + // CHECK-ELIDE-NOTREE: no viable overloaded '=' + // CHECK-ELIDE-NOTREE: no known conversion from 'C<[...], (no argument)>' to 'C<[...], void>' + c3 = c1; + // CHECK-ELIDE-NOTREE: no viable overloaded '=' + // CHECK-ELIDE-NOTREE: no known conversion from 'C<(default) void, (no argument)>' to 'C<char, char>' + } +} // CHECK-ELIDE-NOTREE: {{[0-9]*}} errors generated. // CHECK-NOELIDE-NOTREE: {{[0-9]*}} errors generated. // CHECK-ELIDE-TREE: {{[0-9]*}} errors generated. // CHECK-NOELIDE-TREE: {{[0-9]*}} errors generated. + |