diff options
Diffstat (limited to 'clang/test')
| -rw-r--r-- | clang/test/CXX/drs/dr13xx.cpp | 78 | ||||
| -rw-r--r-- | clang/test/Misc/diag-template-diffing.cpp | 6 | ||||
| -rw-r--r-- | clang/test/SemaCXX/attr-mode-tmpl.cpp | 2 | ||||
| -rw-r--r-- | clang/test/SemaCXX/attr-noreturn.cpp | 10 | ||||
| -rw-r--r-- | clang/test/SemaCXX/overload-call.cpp | 2 | ||||
| -rw-r--r-- | clang/test/SemaCXX/overload-member-call.cpp | 2 | ||||
| -rw-r--r-- | clang/test/SemaTemplate/deduction.cpp | 4 | ||||
| -rw-r--r-- | clang/test/SemaTemplate/temp_arg_nontype.cpp | 8 |
8 files changed, 99 insertions, 13 deletions
diff --git a/clang/test/CXX/drs/dr13xx.cpp b/clang/test/CXX/drs/dr13xx.cpp index 2c861ff5aeb..28e667f77f8 100644 --- a/clang/test/CXX/drs/dr13xx.cpp +++ b/clang/test/CXX/drs/dr13xx.cpp @@ -218,6 +218,84 @@ namespace dr1388 { // dr1388: 4.0 } } +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() { diff --git a/clang/test/Misc/diag-template-diffing.cpp b/clang/test/Misc/diag-template-diffing.cpp index 78083989928..9006fc6f9ac 100644 --- a/clang/test/Misc/diag-template-diffing.cpp +++ b/clang/test/Misc/diag-template-diffing.cpp @@ -1265,7 +1265,7 @@ void test() { foo<BoolT<true>>(X); } // CHECK-ELIDE-NOTREE: no matching function for call to 'foo' -// CHECK-ELIDE-NOTREE: candidate function [with T = BoolArgumentBitExtended::BoolT<true>] not viable: no known conversion from 'BoolT<false>' to 'BoolT<true>' for 1st argument +// CHECK-ELIDE-NOTREE: candidate function not viable: no known conversion from 'BoolT<false>' to 'BoolT<true>' for 1st argument } namespace DifferentIntegralTypes { @@ -1401,7 +1401,7 @@ void run() { f(1, integral_constant<bool, true>{}); } // CHECK-ELIDE-NOTREE: error: no matching function for call to 'f' -// CHECK-ELIDE-NOTREE: note: candidate function [with T = int] not viable: no known conversion from 'integral_constant<[...], true>' to 'integral_constant<[...], false>' for 2nd argument +// CHECK-ELIDE-NOTREE: note: candidate function not viable: no known conversion from 'integral_constant<[...], true>' to 'integral_constant<[...], false>' for 2nd argument } namespace ZeroArgs { @@ -1454,7 +1454,7 @@ void run() { D<X::X1>(VectorType<X::X2>()); } // CHECK-ELIDE-NOTREE: error: no matching function for call to 'D' -// CHECK-ELIDE-NOTREE: note: candidate function [with x = TypeAlias::X::X1] not viable: no known conversion from 'VectorType<X::X2>' to 'const VectorType<(TypeAlias::X)0>' for 1st argument +// CHECK-ELIDE-NOTREE: note: candidate function not viable: no known conversion from 'VectorType<X::X2>' to 'const VectorType<(TypeAlias::X)0>' for 1st argument } namespace TypeAlias2 { diff --git a/clang/test/SemaCXX/attr-mode-tmpl.cpp b/clang/test/SemaCXX/attr-mode-tmpl.cpp index 4e1489a8a5b..d83bb398905 100644 --- a/clang/test/SemaCXX/attr-mode-tmpl.cpp +++ b/clang/test/SemaCXX/attr-mode-tmpl.cpp @@ -45,7 +45,7 @@ void CheckMachineMode() { // Check attributes on function parameters. template <class T1, class T2> -void CheckParameters(T1 __attribute__((mode(SI))) paramSI, // expected-note2{{ignored: substitution failure}} +void CheckParameters(T1 __attribute__((mode(SI))) paramSI, // expected-note{{ignored: substitution failure}} expected-note-re{{not viable: no known conversion from '{{.*}}' (vector of 4 '{{.*}}' values) to 'EnumType' for 2nd argument}} T1 __attribute__((mode(V4DI))) paramV4DI, // expected-warning{{deprecated}} T2 __attribute__((mode(SF))) paramSF, T2 __attribute__((mode(V4DF))) paramV4DF) { // expected-warning{{deprecated}} diff --git a/clang/test/SemaCXX/attr-noreturn.cpp b/clang/test/SemaCXX/attr-noreturn.cpp index a8e71db7370..6edc86c43a7 100644 --- a/clang/test/SemaCXX/attr-noreturn.cpp +++ b/clang/test/SemaCXX/attr-noreturn.cpp @@ -244,11 +244,11 @@ namespace PR15291 { template <typename T> void qux(T) {} - // expected-note@+5 {{candidate function [with T = void (*)(int) __attribute__((noreturn))] not viable: no overload of 'baz' matching 'void (*)(int) __attribute__((noreturn))' for 1st argument}} - // expected-note@+4 {{candidate function [with T = void (*)(int) __attribute__((noreturn))] not viable: no overload of 'qux' matching 'void (*)(int) __attribute__((noreturn))' for 1st argument}} - // expected-note@+3 {{candidate function [with T = void (*)(int) __attribute__((noreturn))] not viable: no overload of 'bar' matching 'void (*)(int) __attribute__((noreturn))' for 1st argument}} - // expected-note@+2 {{candidate function [with T = void (*)(int)] not viable: no overload of 'bar' matching 'void (*)(int)' for 1st argument}} - // expected-note@+1 {{candidate function [with T = void (int)] not viable: no overload of 'bar' matching 'void (*)(int)' for 1st argument}} + // expected-note@+5 {{candidate function not viable: no overload of 'baz' matching 'void (*)(int) __attribute__((noreturn))' for 1st argument}} + // expected-note@+4 {{candidate function not viable: no overload of 'qux' matching 'void (*)(int) __attribute__((noreturn))' for 1st argument}} + // expected-note@+3 {{candidate function not viable: no overload of 'bar' matching 'void (*)(int) __attribute__((noreturn))' for 1st argument}} + // expected-note@+2 {{candidate function not viable: no overload of 'bar' matching 'void (*)(int)' for 1st argument}} + // expected-note@+1 {{candidate function not viable: no overload of 'bar' matching 'void (*)(int)' for 1st argument}} template <typename T> void accept_T(T) {} // expected-note@+1 {{candidate function not viable: no overload of 'bar' matching 'void (*)(int)' for 1st argument}} diff --git a/clang/test/SemaCXX/overload-call.cpp b/clang/test/SemaCXX/overload-call.cpp index 3a01bf24b31..0e3a9ee50bb 100644 --- a/clang/test/SemaCXX/overload-call.cpp +++ b/clang/test/SemaCXX/overload-call.cpp @@ -338,7 +338,7 @@ namespace PR5756 { // Tests the exact text used to note the candidates namespace test1 { - template <class T> void foo(T t, unsigned N); // expected-note {{candidate function [with T = int] not viable: no known conversion from 'const char [6]' to 'unsigned int' for 2nd argument}} + template <class T> void foo(T t, unsigned N); // expected-note {{candidate function not viable: no known conversion from 'const char [6]' to 'unsigned int' for 2nd argument}} void foo(int n, char N); // expected-note {{candidate function not viable: no known conversion from 'const char [6]' to 'char' for 2nd argument}} void foo(int n, const char *s, int t); // expected-note {{candidate function not viable: requires 3 arguments, but 2 were provided}} void foo(int n, const char *s, int t, ...); // expected-note {{candidate function not viable: requires at least 3 arguments, but 2 were provided}} diff --git a/clang/test/SemaCXX/overload-member-call.cpp b/clang/test/SemaCXX/overload-member-call.cpp index e0f34d937f6..6e64b25d6b5 100644 --- a/clang/test/SemaCXX/overload-member-call.cpp +++ b/clang/test/SemaCXX/overload-member-call.cpp @@ -70,7 +70,7 @@ void test_X2(X2 *x2p, const X2 *cx2p) { // Tests the exact text used to note the candidates namespace test1 { class A { - template <class T> void foo(T t, unsigned N); // expected-note {{candidate function [with T = int] not viable: no known conversion from 'const char [6]' to 'unsigned int' for 2nd argument}} + template <class T> void foo(T t, unsigned N); // expected-note {{candidate function not viable: no known conversion from 'const char [6]' to 'unsigned int' for 2nd argument}} void foo(int n, char N); // expected-note {{candidate function not viable: no known conversion from 'const char [6]' to 'char' for 2nd argument}} void foo(int n, const char *s, int t); // expected-note {{candidate function not viable: requires 3 arguments, but 2 were provided}} void foo(int n, const char *s, int t, ...); // expected-note {{candidate function not viable: requires at least 3 arguments, but 2 were provided}} diff --git a/clang/test/SemaTemplate/deduction.cpp b/clang/test/SemaTemplate/deduction.cpp index 499b376855e..0c0e7d599cc 100644 --- a/clang/test/SemaTemplate/deduction.cpp +++ b/clang/test/SemaTemplate/deduction.cpp @@ -361,6 +361,10 @@ namespace deduction_after_explicit_pack { g<int, float&, double&>(a, b, c, &c); // ok } + template<class... ExtraArgs> + int test(ExtraArgs..., unsigned vla_size, const char *input); + int n = test(0, ""); + template <typename... T> void i(T..., int, T..., ...); // expected-note 5{{deduced conflicting}} void j() { i(0); diff --git a/clang/test/SemaTemplate/temp_arg_nontype.cpp b/clang/test/SemaTemplate/temp_arg_nontype.cpp index 93f11b5657d..27a0a03f84f 100644 --- a/clang/test/SemaTemplate/temp_arg_nontype.cpp +++ b/clang/test/SemaTemplate/temp_arg_nontype.cpp @@ -173,12 +173,16 @@ namespace pr6249 { } namespace PR6723 { - template<unsigned char C> void f(int (&a)[C]); // expected-note {{candidate template ignored}} \ - // expected-note{{substitution failure [with C = '\x00']}} + template<unsigned char C> void f(int (&a)[C]); // expected-note 3{{candidate template ignored: substitution failure [with C = '\x00']}} + // expected-note@-1 {{not viable: no known conversion from 'int [512]' to 'int (&)[0]'}} void g() { int arr512[512]; f(arr512); // expected-error{{no matching function for call}} f<512>(arr512); // expected-error{{no matching function for call}} + + int arr0[0]; + f(arr0); // expected-error{{no matching function for call}} + f<0>(arr0); // expected-error{{no matching function for call}} } } |

