Commit 3784b33c by Jason Merrill Committed by Jason Merrill

re PR c++/20669 (Template candidates not listed in error message.)

	PR c++/20669
	* call.c (add_template_candidate_real): If deduction fails, still
	add the template as a non-viable candidate.
	(equal_functions): Handle template candidates.
	(print_z_candidate): Likewise.
	(print_z_candidates): Likewise.
	(build_new_function_call): Likewise.

From-SVN: r159335
parent d451d5b2
2010-05-12 Jason Merrill <jason@redhat.com> 2010-05-12 Jason Merrill <jason@redhat.com>
PR c++/20669
* call.c (add_template_candidate_real): If deduction fails, still
add the template as a non-viable candidate.
(equal_functions): Handle template candidates.
(print_z_candidate): Likewise.
(print_z_candidates): Likewise.
(build_new_function_call): Likewise.
* cp-tree.h (LOOKUP_LIST_ONLY): New. * cp-tree.h (LOOKUP_LIST_ONLY): New.
* call.c (add_candidates): Enforce it. * call.c (add_candidates): Enforce it.
(build_new_method_call): Try non-list ctor if no viable list ctor. (build_new_method_call): Try non-list ctor if no viable list ctor.
......
...@@ -2508,11 +2508,11 @@ add_template_candidate_real (struct z_candidate **candidates, tree tmpl, ...@@ -2508,11 +2508,11 @@ add_template_candidate_real (struct z_candidate **candidates, tree tmpl,
return_type, strict, flags); return_type, strict, flags);
if (i != 0) if (i != 0)
return NULL; goto fail;
fn = instantiate_template (tmpl, targs, tf_none); fn = instantiate_template (tmpl, targs, tf_none);
if (fn == error_mark_node) if (fn == error_mark_node)
return NULL; goto fail;
/* In [class.copy]: /* In [class.copy]:
...@@ -2541,7 +2541,7 @@ add_template_candidate_real (struct z_candidate **candidates, tree tmpl, ...@@ -2541,7 +2541,7 @@ add_template_candidate_real (struct z_candidate **candidates, tree tmpl,
tree arg_types = FUNCTION_FIRST_USER_PARMTYPE (fn); tree arg_types = FUNCTION_FIRST_USER_PARMTYPE (fn);
if (arg_types && same_type_p (TYPE_MAIN_VARIANT (TREE_VALUE (arg_types)), if (arg_types && same_type_p (TYPE_MAIN_VARIANT (TREE_VALUE (arg_types)),
ctype)) ctype))
return NULL; goto fail;
} }
if (obj != NULL_TREE) if (obj != NULL_TREE)
...@@ -2575,6 +2575,9 @@ add_template_candidate_real (struct z_candidate **candidates, tree tmpl, ...@@ -2575,6 +2575,9 @@ add_template_candidate_real (struct z_candidate **candidates, tree tmpl,
cand->template_decl = DECL_TEMPLATE_INFO (fn); cand->template_decl = DECL_TEMPLATE_INFO (fn);
return cand; return cand;
fail:
return add_candidate (candidates, tmpl, first_arg, arglist, nargs, NULL,
access_path, conversion_path, 0);
} }
...@@ -2607,10 +2610,10 @@ add_template_conv_candidate (struct z_candidate **candidates, tree tmpl, ...@@ -2607,10 +2610,10 @@ add_template_conv_candidate (struct z_candidate **candidates, tree tmpl,
} }
/* The CANDS are the set of candidates that were considered for /* The CANDS are the set of candidates that were considered for
overload resolution. Return the set of viable candidates. If none overload resolution. Return the set of viable candidates, or CANDS
of the candidates were viable, set *ANY_VIABLE_P to true. STRICT_P if none are viable. If any of the candidates were viable, set
is true if a candidate should be considered viable only if it is *ANY_VIABLE_P to true. STRICT_P is true if a candidate should be
strictly viable. */ considered viable only if it is strictly viable. */
static struct z_candidate* static struct z_candidate*
splice_viable (struct z_candidate *cands, splice_viable (struct z_candidate *cands,
...@@ -2675,6 +2678,10 @@ build_this (tree obj) ...@@ -2675,6 +2678,10 @@ build_this (tree obj)
static inline int static inline int
equal_functions (tree fn1, tree fn2) equal_functions (tree fn1, tree fn2)
{ {
if (TREE_CODE (fn1) != TREE_CODE (fn2))
return 0;
if (TREE_CODE (fn1) == TEMPLATE_DECL)
return fn1 == fn2;
if (DECL_LOCAL_FUNCTION_P (fn1) || DECL_LOCAL_FUNCTION_P (fn2) if (DECL_LOCAL_FUNCTION_P (fn1) || DECL_LOCAL_FUNCTION_P (fn2)
|| DECL_EXTERN_C_FUNCTION_P (fn1)) || DECL_EXTERN_C_FUNCTION_P (fn1))
return decls_match (fn1, fn2); return decls_match (fn1, fn2);
...@@ -2710,7 +2717,7 @@ print_z_candidate (const char *msgstr, struct z_candidate *candidate) ...@@ -2710,7 +2717,7 @@ print_z_candidate (const char *msgstr, struct z_candidate *candidate)
inform (input_location, "%s %T <conversion>", msgstr, candidate->fn); inform (input_location, "%s %T <conversion>", msgstr, candidate->fn);
else if (candidate->viable == -1) else if (candidate->viable == -1)
inform (input_location, "%s %+#D <near match>", msgstr, candidate->fn); inform (input_location, "%s %+#D <near match>", msgstr, candidate->fn);
else if (DECL_DELETED_FN (candidate->fn)) else if (DECL_DELETED_FN (STRIP_TEMPLATE (candidate->fn)))
inform (input_location, "%s %+#D <deleted>", msgstr, candidate->fn); inform (input_location, "%s %+#D <deleted>", msgstr, candidate->fn);
else else
inform (input_location, "%s %+#D", msgstr, candidate->fn); inform (input_location, "%s %+#D", msgstr, candidate->fn);
...@@ -2750,12 +2757,12 @@ print_z_candidates (struct z_candidate *candidates) ...@@ -2750,12 +2757,12 @@ print_z_candidates (struct z_candidate *candidates)
{ {
tree fn = cand1->fn; tree fn = cand1->fn;
/* Skip builtin candidates and conversion functions. */ /* Skip builtin candidates and conversion functions. */
if (TREE_CODE (fn) != FUNCTION_DECL) if (!DECL_P (fn))
continue; continue;
cand2 = &cand1->next; cand2 = &cand1->next;
while (*cand2) while (*cand2)
{ {
if (TREE_CODE ((*cand2)->fn) == FUNCTION_DECL if (DECL_P ((*cand2)->fn)
&& equal_functions (fn, (*cand2)->fn)) && equal_functions (fn, (*cand2)->fn))
*cand2 = (*cand2)->next; *cand2 = (*cand2)->next;
else else
...@@ -3167,7 +3174,8 @@ build_new_function_call (tree fn, VEC(tree,gc) **args, bool koenig_p, ...@@ -3167,7 +3174,8 @@ build_new_function_call (tree fn, VEC(tree,gc) **args, bool koenig_p,
{ {
if (complain & tf_error) if (complain & tf_error)
{ {
if (!any_viable_p && candidates && ! candidates->next) if (!any_viable_p && candidates && ! candidates->next
&& (TREE_CODE (candidates->fn) == FUNCTION_DECL))
return cp_build_function_call_vec (candidates->fn, args, complain); return cp_build_function_call_vec (candidates->fn, args, complain);
if (TREE_CODE (fn) == TEMPLATE_ID_EXPR) if (TREE_CODE (fn) == TEMPLATE_ID_EXPR)
fn = TREE_OPERAND (fn, 0); fn = TREE_OPERAND (fn, 0);
......
2010-05-12 Jason Merrill <jason@redhat.com> 2010-05-12 Jason Merrill <jason@redhat.com>
* g++.dg/conversion/op1.C: Expect template candidate message.
* g++.dg/cpp0x/nullptr15.C: Likewise.
* g++.dg/cpp0x/pr31431-2.C: Likewise.
* g++.dg/cpp0x/pr31431.C: Likewise.
* g++.dg/cpp0x/temp_default2.C: Likewise.
* g++.dg/cpp0x/trailing4.C: Likewise.
* g++.dg/cpp0x/variadic-ex3.C: Likewise.
* g++.dg/cpp0x/variadic-ex4.C: Likewise.
* g++.dg/cpp0x/variadic-throw.C: Likewise.
* g++.dg/cpp0x/variadic35.C: Likewise.
* g++.dg/cpp0x/vt-35147.C: Likewise.
* g++.dg/cpp0x/vt-37737-1.C: Likewise.
* g++.dg/cpp0x/vt-37737-2.C: Likewise.
* g++.dg/ext/visibility/anon8.C: Likewise.
* g++.dg/ext/vla2.C: Likewise.
* g++.dg/other/pr28114.C: Likewise.
* g++.dg/other/ptrmem10.C: Likewise.
* g++.dg/other/ptrmem11.C: Likewise.
* g++.dg/overload/unknown1.C: Likewise.
* g++.dg/parse/template7.C: Likewise.
* g++.dg/parse/typename7.C: Likewise.
* g++.dg/template/conv11.C: Likewise.
* g++.dg/template/copy1.C: Likewise.
* g++.dg/template/deduce3.C: Likewise.
* g++.dg/template/dependent-expr5.C: Likewise.
* g++.dg/template/friend.C: Likewise.
* g++.dg/template/incomplete2.C: Likewise.
* g++.dg/template/local4.C: Likewise.
* g++.dg/template/local6.C: Likewise.
* g++.dg/template/operator10.C: Likewise.
* g++.dg/template/overload6.C: Likewise.
* g++.dg/template/ptrmem2.C: Likewise.
* g++.dg/template/ptrmem20.C: Likewise.
* g++.dg/template/ptrmem8.C: Likewise.
* g++.dg/template/sfinae2.C: Likewise.
* g++.dg/template/ttp25.C: Likewise.
* g++.dg/template/unify10.C: Likewise.
* g++.dg/template/unify11.C: Likewise.
* g++.dg/template/unify6.C: Likewise.
* g++.dg/template/unify7.C: Likewise.
* g++.dg/template/unify9.C: Likewise.
* g++.dg/template/varmod1.C: Likewise.
* g++.old-deja/g++.brendan/crash56.C: Likewise.
* g++.old-deja/g++.law/operators32.C: Likewise.
* g++.old-deja/g++.pt/crash28.C: Likewise.
* g++.old-deja/g++.pt/crash60.C: Likewise.
* g++.old-deja/g++.pt/explicit38.C: Likewise.
* g++.old-deja/g++.pt/explicit39.C: Likewise.
* g++.old-deja/g++.pt/explicit41.C: Likewise.
* g++.old-deja/g++.pt/explicit67.C: Likewise.
* g++.old-deja/g++.pt/explicit77.C: Likewise.
* g++.old-deja/g++.pt/expr2.C: Likewise.
* g++.old-deja/g++.pt/overload7.C: Likewise.
* g++.old-deja/g++.pt/ptrmem6.C: Likewise.
* g++.old-deja/g++.pt/spec5.C: Likewise.
* g++.old-deja/g++.pt/spec6.C: Likewise.
* g++.old-deja/g++.pt/t24.C: Likewise.
* g++.old-deja/g++.pt/unify4.C: Likewise.
* g++.old-deja/g++.pt/unify6.C: Likewise.
* g++.old-deja/g++.pt/unify8.C: Likewise.
* g++.old-deja/g++.robertl/eb119.C: Likewise.
* g++.old-deja/g++.robertl/eb79.C: Likewise.
* g++.old-deja/g++.robertl/eb98.C: Likewise.
* g++.dg/cpp0x/initlist32.C: New. * g++.dg/cpp0x/initlist32.C: New.
* g++.dg/template/conv11.C: New. * g++.dg/template/conv11.C: New.
......
class C class C
{ {
template<typename U> template<typename U>
operator U(); operator U(); // { dg-message "candidate" }
}; };
int fn (C c) int fn (C c)
......
...@@ -10,7 +10,7 @@ template <typename T, typename U> ...@@ -10,7 +10,7 @@ template <typename T, typename U>
inline typename tType_equal<T, U>::type inline typename tType_equal<T, U>::type
type_equal(U) { } type_equal(U) { }
template<typename T> T* g( T* t ); template<typename T> T* g( T* t ); // { dg-message "candidate" }
void test_g() void test_g()
{ {
......
// { dg-options "-std=gnu++0x" } // { dg-options "-std=gnu++0x" }
template<typename, typename..., typename> void foo(); template<typename, typename..., typename> void foo(); // { dg-message "candidate" }
void bar() void bar()
{ {
......
// { dg-options "-std=gnu++0x" } // { dg-options "-std=gnu++0x" }
template<typename..., typename> void foo(); template<typename..., typename> void foo(); // { dg-message "candidate" }
void bar() void bar()
{ {
......
// { dg-options "-std=c++0x" } // { dg-options "-std=c++0x" }
template <class T, class U = double> template <class T, class U = double>
void f(T t = 0, U u = 0); void f(T t = 0, U u = 0); // { dg-message "candidate" }
void g() void g()
{ {
......
...@@ -5,7 +5,7 @@ template<class T, class U> ...@@ -5,7 +5,7 @@ template<class T, class U>
auto f(T,U) -> decltype(T() + U()) auto f(T,U) -> decltype(T() + U())
{ return T() + U(); } { return T() + U(); }
template<class T> void g(T){} template<class T> void g(T){} // { dg-message "candidate" }
int main() { g(f); } // { dg-error "no matching function" } int main() { g(f); } // { dg-error "no matching function" }
// { dg-options "-std=gnu++0x" } // { dg-options "-std=gnu++0x" }
template<class X, class Y, class... Z> X f(Y); template<class X, class Y, class... Z> X f(Y); // { dg-message "candidate" }
void g() void g()
{ {
int i = f<int>(5.6); int i = f<int>(5.6);
......
// { dg-options "-std=gnu++0x" } // { dg-options "-std=gnu++0x" }
template<class X, class Y, class Z> X f(Y,Z); template<class X, class Y, class Z> X f(Y,Z); // { dg-message "candidate" }
template<class... Args> void f2(); template<class... Args> void f2();
void g() void g()
{ {
......
// { dg-options -std=c++0x } // { dg-options -std=c++0x }
// { dg-prune-output "note" }
// PR c++/33509 // PR c++/33509
template<int M, int N> struct pair template<int M, int N> struct pair
{ {
......
// { dg-options "-std=gnu++0x" } // { dg-options "-std=gnu++0x" }
template<int I, typename... Args> template<int I, typename... Args>
void get_ith(const Args&... args); void get_ith(const Args&... args); // { dg-message "candidate" }
void f() void f()
{ {
......
// { dg-options "-std=c++0x" } // { dg-options "-std=c++0x" }
template<typename _Tp> template<typename _Tp>
_Tp&& forward(_Tp&& __t) { return __t; } _Tp&& forward(_Tp&& __t) { return __t; } // { dg-message "candidate" }
void f(...); void f(...);
......
// { dg-options "-std=c++0x" } // { dg-options "-std=c++0x" }
// { dg-prune-output "note" }
void f() { } void f() { }
......
// { dg-options "-std=c++0x" } // { dg-options "-std=c++0x" }
template<class U, class... T> template<class U, class... T>
void f() void f() // { dg-message "candidate" }
{ {
f<T...>(); // { dg-error "no matching" } f<T...>(); // { dg-error "no matching" }
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// { dg-do compile } // { dg-do compile }
template <void (*fn) ()> template <void (*fn) ()>
void call () void call () // { dg-message "candidate" }
{ {
fn (); fn ();
} }
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
// errors. // errors.
template <unsigned int N> template <unsigned int N>
char* begin(char (&a) [N] ); char* begin(char (&a) [N] ); // { dg-message "candidate" }
void bar(int i) void bar(int i)
{ {
......
// Test to make sure we do not ICE on this invalid program. // Test to make sure we do not ICE on this invalid program.
template<int> void foo(struct {}*); // { dg-error "" } template<int> void foo(struct {}*); // { dg-message "" }
void bar() void bar()
{ {
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
template <class C, void (C::*M) ()> template <class C, void (C::*M) ()>
static static
void foo(void *obj) void foo(void *obj) // { dg-message "candidate" }
{ {
C *p = static_cast<C*>(obj); C *p = static_cast<C*>(obj);
(p->*M)(); (p->*M)();
......
...@@ -5,7 +5,7 @@ struct A {}; ...@@ -5,7 +5,7 @@ struct A {};
template <int A::* p> template <int A::* p>
int int
foo(A* q) foo(A* q) // { dg-message "candidate" }
{ {
return q->*p; return q->*p;
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
void foo(void); void foo(void);
int foo(int); int foo(int);
template <typename T> void bar(T f); template <typename T> void bar(T f); // { dg-message "candidate" }
void baz() { void baz() {
bar(foo); // { dg-error "<unresolved overloaded function type>" } bar(foo); // { dg-error "<unresolved overloaded function type>" }
......
template <int I> template <int I>
void f(); void f(); // { dg-message "candidate" }
void g() { f<(3, 2)>(); } // { dg-error "" } void g() { f<(3, 2)>(); } // { dg-error "" }
...@@ -7,8 +7,8 @@ ...@@ -7,8 +7,8 @@
struct A struct A
{ {
template<typename> void foo(int); template<typename> void foo(int); // { dg-message "candidate" }
template<typename T> void bar(T t) { template<typename T> void bar(T t) { // { dg-message "candidate" }
this->foo<typename T>(t); } // { dg-error "expected|parse error|no matching" } this->foo<typename T>(t); } // { dg-error "expected|parse error|no matching" }
template<typename T> void bad(T t) { template<typename T> void bad(T t) {
foo<typename T>(t); } // { dg-error "expected|parse error|no matching" } foo<typename T>(t); } // { dg-error "expected|parse error|no matching" }
......
int i; int i;
struct A struct A
{ {
template <class T> operator T&() { return i; } template <class T> operator T&() { return i; } // { dg-message "candidate" }
}; };
int main() int main()
......
...@@ -6,8 +6,8 @@ ...@@ -6,8 +6,8 @@
struct A struct A
{ {
A(A&); // { dg-message "candidate" } A(A&); // { dg-message "note" }
template <class T> A(T); template <class T> A(T); // { dg-message "candidate" }
}; };
A a = 0; // { dg-error "no matching function" } A a = 0; // { dg-error "no matching function" }
......
template <typename T> template <typename T>
void f(int, T (*)() = 0); void f(int, T (*)() = 0); // { dg-message "candidate" }
void g() { void g() {
typedef int A[2]; typedef int A[2];
......
...@@ -4,9 +4,9 @@ ...@@ -4,9 +4,9 @@
// contributed by Alexandre Oliva <aoliva@redhat.com> // contributed by Alexandre Oliva <aoliva@redhat.com>
// inspired in the failure reported in Red Hat bugzilla #168260. // inspired in the failure reported in Red Hat bugzilla #168260.
template<class F> void bind(F f) {} template<class F> void bind(F f) {} // { dg-message "note" }
template<class F> void bindm(F f) {} template<class F> void bindm(F f) {} // { dg-message "note" }
template<class F, class T> void bindm(F (T::*f)(void)) {} // { dg-message "note" } template<class F, class T> void bindm(F (T::*f)(void)) {} // { dg-message "note" }
template<class F> void bindn(F f) {} template<class F> void bindn(F f) {}
......
...@@ -7,7 +7,7 @@ extern ostream& cout; ...@@ -7,7 +7,7 @@ extern ostream& cout;
template <class T> struct s; template <class T> struct s;
template <class T> template <class T>
ostream& operator<<(ostream &o, const typename s<T>::t &x) ostream& operator<<(ostream &o, const typename s<T>::t &x) // { dg-message "note" }
{ {
return o; return o;
} }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
struct A; struct A;
template<A&> void foo(); template<A&> void foo(); // { dg-message "candidate" }
A a; // { dg-error "incomplete type" } A a; // { dg-error "incomplete type" }
......
// PR c++/17413 // PR c++/17413
template <typename T> void foo() {} template <typename T> void foo() {} // { dg-message "candidate" }
int main () { int main () {
struct S {}; struct S {};
......
template <class T> struct PCVector2 // { dg-message "candidate is" } template <class T> struct PCVector2 // { dg-message "note" }
{ {
template <class T2> PCVector2(const PCVector2<T> &cv) ; template <class T2> PCVector2(const PCVector2<T> &cv) ; // { dg-message "candidate" }
PCVector2<T> operator- (const PCVector2<T> &ov) const PCVector2<T> operator- (const PCVector2<T> &ov) const
{ {
......
// PR c++/30535 // PR c++/30535
// { dg-prune-output "note" }
struct A {}; struct A {};
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
// PR 21592:ICE // PR 21592:ICE
// Origin: Volker Reichelt <reichelt@gcc.gnu.org> // Origin: Volker Reichelt <reichelt@gcc.gnu.org>
template<typename T> void unique(T,T); template<typename T> void unique(T,T); // { dg-message "note" }
struct A struct A
{ {
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
struct A {}; struct A {};
template <typename T> T A::* Foo (); template <typename T> T A::* Foo (); // { dg-message "candidate" }
void Baz () void Baz ()
{ {
......
...@@ -8,7 +8,7 @@ struct B ...@@ -8,7 +8,7 @@ struct B
void foo(); void foo();
}; };
template<void (A::*)()> void bar(); template<void (A::*)()> void bar(); // { dg-message "candidate" }
void baz() void baz()
{ {
......
...@@ -11,7 +11,7 @@ struct B ...@@ -11,7 +11,7 @@ struct B
struct D : B {}; struct D : B {};
template <int (D::*fun)() const> int Get(); template <int (D::*fun)() const> int Get(); // { dg-message "candidate" }
int main () int main ()
{ {
......
...@@ -8,7 +8,7 @@ template<int T> struct cl { ...@@ -8,7 +8,7 @@ template<int T> struct cl {
const static int value = T; const static int value = T;
}; };
template<int I> void fn (char (*) [cl<I>::value] = 0 ); template<int I> void fn (char (*) [cl<I>::value] = 0 ); // { dg-message "candidate" }
void foo (void) void foo (void)
{ {
......
// { dg-do compile } // { dg-do compile }
template<typename T, template<T> class C> template<typename T, template<T> class C>
void f1(T, C<5>); void f1(T, C<5>); // { dg-message "note" }
template<typename T, template<T> class C> template<typename T, template<T> class C>
void f2(C<5>, T); void f2(C<5>, T);
template<typename T, template<T> class C> template<typename T, template<T> class C>
void f3(C<5>, T); void f3(C<5>, T); // { dg-message "note" }
template<typename T> struct metafun { typedef T type; }; template<typename T> struct metafun { typedef T type; };
template<> struct metafun<short> { typedef int type; }; template<> struct metafun<short> { typedef int type; };
template<typename T, template<typename metafun<T>::type> class C> template<typename T, template<typename metafun<T>::type> class C>
void f4(T, C<5>); void f4(T, C<5>); // { dg-message "note" }
template<int N> struct X {}; template<int N> struct X {};
void g() { void g() {
......
...@@ -12,16 +12,16 @@ struct MyClass { ...@@ -12,16 +12,16 @@ struct MyClass {
}; };
template<class CLASS> template<class CLASS>
void mFunction(void (CLASS::* method)()) {} void mFunction(void (CLASS::* method)()) {} // { dg-message "candidate" }
template<class CLASS> template<class CLASS>
void cFunction(void (CLASS::* method)() const) {} void cFunction(void (CLASS::* method)() const) {} // { dg-message "candidate" }
template<class CLASS> template<class CLASS>
void vFunction(void (CLASS::* method)() volatile) {} void vFunction(void (CLASS::* method)() volatile) {} // { dg-message "candidate" }
template<class CLASS> template<class CLASS>
void cvFunction(void (CLASS::* method)() const volatile) {} void cvFunction(void (CLASS::* method)() const volatile) {} // { dg-message "candidate" }
int main() { int main() {
mFunction(&MyClass::mMethod); mFunction(&MyClass::mMethod);
......
...@@ -8,7 +8,7 @@ struct A ...@@ -8,7 +8,7 @@ struct A
template <typename S, typename T, typename U, typename S::v = &S::v::s> template <typename S, typename T, typename U, typename S::v = &S::v::s>
typename S::A typename S::A
foo (S c, T t, U u) foo (S c, T t, U u) // { dg-message "candidate" }
{ {
} }
......
...@@ -8,7 +8,7 @@ template <typename T> void Foo1 (T const *a) {a (1);} // #2 ...@@ -8,7 +8,7 @@ template <typename T> void Foo1 (T const *a) {a (1);} // #2
template <typename T> T const *Foo2 (T *); template <typename T> T const *Foo2 (T *);
template <typename T> void Foo3 (T *, T const * = 0); template <typename T> void Foo3 (T *, T const * = 0); // { dg-message "candidate" }
void Bar () void Bar ()
{ {
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
// PR c++/3518 // PR c++/3518
template <typename T> void Foo (const T &); template <typename T> void Foo (const T &);
template <typename T> void Baz (const T (*)()); template <typename T> void Baz (const T (*)()); // { dg-message "candidate" }
int &f (); int &f ();
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
// Origin:Wolfgang Bangerth <bangerth@dealii.org> // Origin:Wolfgang Bangerth <bangerth@dealii.org>
// PR 21799: deduction of cvqualifiers on member functions was wrong // PR 21799: deduction of cvqualifiers on member functions was wrong
template <class T> void f (T &, void (T::*)() ); template <class T> void f (T &, void (T::*)() ); // { dg-message "candidate" }
struct X { struct X {
void g() const {} void g() const {}
......
// { dg-options "-w" } // { dg-options "-w" }
template<typename T> void foo(T); template<typename T> void foo(T); // { dg-message "candidate" }
void bar() void bar()
{ {
......
...@@ -292,7 +292,7 @@ SetLD<T>::contains(const T& item) const ...@@ -292,7 +292,7 @@ SetLD<T>::contains(const T& item) const
} }
template<class T> template<class T>
int int
operator==(const SetLD<T>& a, const SetLD<T>& b) operator==(const SetLD<T>& a, const SetLD<T>& b) // { dg-message "note" }
{ {
if (a.length() != b.length()) if (a.length() != b.length())
return FALSE; return FALSE;
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
// //
template <class T> template <class T>
void ffree(long rows, T** array) void ffree(long rows, T** array) // { dg-message "candidate" }
{ {
for( long i = 0; i < rows; i++ ) for( long i = 0; i < rows; i++ )
delete [] array[i]; // delete row delete [] array[i]; // delete row
...@@ -21,7 +21,7 @@ return array = new T[size]; ...@@ -21,7 +21,7 @@ return array = new T[size];
} }
template <class T> template <class T>
T** allocate2d(long d1, long d2, T**& array) T** allocate2d(long d1, long d2, T**& array) // { dg-message "note" }
{ {
if( allocate1d(d1, array) != 0 ) if( allocate1d(d1, array) != 0 )
{ {
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// { dg-options "" } // { dg-options "" }
template <class ARRY> template <class ARRY>
inline unsigned int asize(ARRY &a) inline unsigned int asize(ARRY &a) // { dg-message "candidate" }
{ {
return sizeof(a) / sizeof(a[0]); return sizeof(a) / sizeof(a[0]);
} }
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
template< typename SID, class SDR > template< typename SID, class SDR >
void k( SID sid, SDR* p, void k( SID sid, SDR* p,
void (SDR::*) void (SDR::*)
( typename SID::T ) ); ( typename SID::T ) ); // { dg-message "candidate" }
struct E { }; struct E { };
struct S { void f( int ); }; struct S { void f( int ); };
......
// { dg-do assemble } // { dg-do assemble }
template <int I> template <int I>
void f(int j); void f(int j); // { dg-message "candidate" }
void g() void g()
{ {
......
// { dg-do assemble } // { dg-do assemble }
template <class T> template <class T>
void f(int i); void f(int i); // { dg-message "candidate" }
void g() void g()
{ {
......
// { dg-do assemble } // { dg-do assemble }
template <int I> template <int I>
void f(int i); void f(int i); // { dg-message "candidate" }
void g() void g()
{ {
......
...@@ -9,9 +9,9 @@ void g(int); ...@@ -9,9 +9,9 @@ void g(int);
void g(double); void g(double);
template <int* IP> template <int* IP>
void foo(); void foo(); // { dg-message "note" }
template <long l> template <long l>
void foo(); void foo(); // { dg-message "note" }
void bar() void bar()
{ {
......
...@@ -7,7 +7,7 @@ template <int I, int J> ...@@ -7,7 +7,7 @@ template <int I, int J>
struct S<I, J, 2> : public S<I, I, I>, S<J, J, J> {}; struct S<I, J, 2> : public S<I, I, I>, S<J, J, J> {};
template <int I, int J, int K> template <int I, int J, int K>
void f(S<I, J, K>, S<I, I, I>); void f(S<I, J, K>, S<I, I, I>); // { dg-message "candidate" }
void g() { void g() {
S<0, 0, 0> s0; S<0, 0, 0> s0;
......
...@@ -4,7 +4,7 @@ template <int I> ...@@ -4,7 +4,7 @@ template <int I>
struct S {}; struct S {};
template <int J> template <int J>
void foo(S<J + 2>); void foo(S<J + 2>); // { dg-message "candidate" }
void bar() void bar()
{ {
......
// { dg-do assemble } // { dg-do assemble }
// { dg-prune-output "note" }
// Adapted from testcase by Corey Kosak <kosak@cs.cmu.edu> // Adapted from testcase by Corey Kosak <kosak@cs.cmu.edu>
......
...@@ -13,9 +13,9 @@ public: ...@@ -13,9 +13,9 @@ public:
}; };
template <void (A::*)() > template <void (A::*)() >
void g() {} void g() {} // { dg-message "candidate" }
template <int A::*> template <int A::*>
void h() {} void h() {} // { dg-message "candidate" }
int main() { int main() {
......
// { dg-do assemble } // { dg-do assemble }
template <class T> template <class T>
void f(T t1, T t2); void f(T t1, T t2); // { dg-message "candidate" }
template <> template <>
void f(int i, int j); void f(int i, int j);
template <class T> template <class T>
void g(T t1, T t2) {} void g(T t1, T t2) {} // { dg-message "candidate" }
template void g(int i, int j); template void g(int i, int j);
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
struct S1 struct S1
{ {
template <class T> template <class T>
void f(T t1, T t2); void f(T t1, T t2); // { dg-message "candidate" }
}; };
...@@ -14,7 +14,7 @@ template <class U> ...@@ -14,7 +14,7 @@ template <class U>
struct S2 struct S2
{ {
template <class T> template <class T>
void f(T t1, T t2); void f(T t1, T t2); // { dg-message "candidate" }
}; };
template <> template <>
......
// { dg-do assemble } // { dg-do assemble }
// { dg-options "" } // { dg-options "" }
template <class X> int f (X x, X y) { return 23; } template <class X> int f (X x, X y) { return 23; } // { dg-message "candidate" }
int foo () { int foo () {
return f (7); // { dg-error "" } return f (7); // { dg-error "" }
......
// { dg-do assemble } // { dg-do assemble }
template <class T> void f (T); template <class T> void f (T); // { dg-message "candidate" }
void g (); void g ();
void g (int); void g (int);
......
...@@ -19,7 +19,7 @@ template<> void fn<int &>() {} // ok, specialize A ...@@ -19,7 +19,7 @@ template<> void fn<int &>() {} // ok, specialize A
template<> void fn<void ()>() {} // ok, specialize A template<> void fn<void ()>() {} // ok, specialize A
// now make sure we moan when we really should // now make sure we moan when we really should
template<class T> void foo(T const *){} template<class T> void foo(T const *){} // { dg-message "candidate" }
void f() void f()
{ {
......
...@@ -8,9 +8,9 @@ ...@@ -8,9 +8,9 @@
// overload resolution. // overload resolution.
template <typename T> void Foo (T const **); template <typename T> void Foo (T const **); // { dg-message "candidate" }
template <typename T> void Bar (T const * const *); template <typename T> void Bar (T const * const *);
void Foo (int); // { dg-message "candidate" } void Foo (int); // { dg-message "note" }
void Foo (float); // { dg-message "note" } candidate void Foo (float); // { dg-message "note" } candidate
void baz (int **p1) void baz (int **p1)
......
// { dg-do assemble } // { dg-do assemble }
template<bool B> template<bool B>
void f() void f() // { dg-message "candidate" }
{ {
} }
......
// { dg-do assemble } // { dg-do assemble }
// { dg-prune-output "note" }
// Makes bogus x86 assembly code. // Makes bogus x86 assembly code.
#include <iostream> #include <iostream>
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
template<class T, unsigned int Length> template<class T, unsigned int Length>
inline inline
unsigned int unsigned int
extent(T (&x)[Length]) extent(T (&x)[Length]) // { dg-message "candidate" }
{ {
return Length; return Length;
} }
......
2010-05-12 Jason Merrill <jason@redhat.com>
* testsuite/20_util/auto_ptr/assign_neg.cc: Expect template
candidate messages.
* testsuite/20_util/unique_ptr/assign/assign_neg.cc: Likewise.
* testsuite/20_util/weak_ptr/comparison/cmp_neg.cc: Likewise.
2010-05-11 Silvius Rus <silvius.rus@gmail.com> 2010-05-11 Silvius Rus <silvius.rus@gmail.com>
PR libstdc++/43259 PR libstdc++/43259
......
...@@ -47,4 +47,5 @@ main() ...@@ -47,4 +47,5 @@ main()
return 0; return 0;
} }
// { dg-error "candidates" "" { target *-*-* } 134 } // { dg-error "candidates" "" { target *-*-* } 134 }
// { dg-error "note" "" { target *-*-* } 152 }
// { dg-error "::auto_ptr" "" { target *-*-* } 262 } // { dg-error "::auto_ptr" "" { target *-*-* } 262 }
...@@ -52,7 +52,8 @@ test03() ...@@ -52,7 +52,8 @@ test03()
// { dg-error "deleted function" "" { target *-*-* } 357 } // { dg-error "deleted function" "" { target *-*-* } 357 }
// { dg-error "used here" "" { target *-*-* } 42 } // { dg-error "used here" "" { target *-*-* } 42 }
// { dg-error "no matching" "" { target *-*-* } 48 } // { dg-error "no matching" "" { target *-*-* } 48 }
// { dg-warning "candidates are" "" { target *-*-* } 130 } // { dg-warning "note" "" { target *-*-* } 130 }
// { dg-warning "note" "" { target *-*-* } 134 }
// { dg-warning "note" "" { target *-*-* } 123 } // { dg-warning "note" "" { target *-*-* } 123 }
// { dg-warning "note" "" { target *-*-* } 118 } // { dg-warning "note" "" { target *-*-* } 118 }
// { dg-warning "note" "" { target *-*-* } 113 } // { dg-warning "note" "" { target *-*-* } 113 }
......
...@@ -40,3 +40,12 @@ main() ...@@ -40,3 +40,12 @@ main()
test01(); test01();
return 0; return 0;
} }
// { dg-warning "note" "" { target *-*-* } 281 }
// { dg-warning "note" "" { target *-*-* } 407 }
// { dg-warning "note" "" { target *-*-* } 831 }
// { dg-warning "note" "" { target *-*-* } 511 }
// { dg-warning "note" "" { target *-*-* } 1005 }
// { dg-warning "note" "" { target *-*-* } 340 }
// { dg-warning "note" "" { target *-*-* } 290 }
// { dg-warning "note" "" { target *-*-* } 190 }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment