Commit dda04398 by Nathan Sidwell Committed by Nathan Sidwell

PR c++/19203, implement DR 214

cp:
	PR c++/19203, implement DR 214
	* call.c (joust): Use more_specialized_fn.
	* cp-tree.h (DEDUCE_ORDER): Remove.
	(more_specialized): Replace with ...
	(more_specialized_fn): ... this.
	* pt.c (maybe_adjust_types_for_deduction): Remove DEDUCE_ORDER
	case.
	(type_unification_real): Remove DEDUCE_ORDER case.
	(more_specialized): Replace with ...
	(more_specialized_fn): ... this.  Implement DR 214.
	(most_specialized_instantiation): Use get_bindings_real directly.
testsuite:
	PR c++/19203, DR 214
	* g++.dg/parse/ambig3.C: Not ambiguous.
	* g++.dg/template/spec20.C: New.
	* g++.dg/template/spec21.C: New.

From-SVN: r97336
parent 27954bdb
2005-03-31 Nathan Sidwell <nathan@codesourcery.com>
PR c++/19203, implement DR 214
* call.c (joust): Use more_specialized_fn.
* cp-tree.h (DEDUCE_ORDER): Remove.
(more_specialized): Replace with ...
(more_specialized_fn): ... this.
* pt.c (maybe_adjust_types_for_deduction): Remove DEDUCE_ORDER
case.
(type_unification_real): Remove DEDUCE_ORDER case.
(more_specialized): Replace with ...
(more_specialized_fn): ... this. Implement DR 214.
(most_specialized_instantiation): Use get_bindings_real directly.
2005-03-31 Gabriel Dos Reis <gdr@integrable-solutions.net>
PR c++/18644
......
......@@ -6084,10 +6084,9 @@ joust (struct z_candidate *cand1, struct z_candidate *cand2, bool warn)
if (cand1->template_decl && cand2->template_decl)
{
winner = more_specialized
winner = more_specialized_fn
(TI_TEMPLATE (cand1->template_decl),
TI_TEMPLATE (cand2->template_decl),
DEDUCE_ORDER,
/* Tell the deduction code how many real function arguments
we saw, not counting the implicit 'this' argument. But,
add_function_candidate() suppresses the "this" argument
......
......@@ -3112,8 +3112,7 @@ extern int function_depth;
typedef enum unification_kind_t {
DEDUCE_CALL,
DEDUCE_CONV,
DEDUCE_EXACT,
DEDUCE_ORDER
DEDUCE_EXACT
} unification_kind_t;
/* Macros for operating on a template instantiation level node. */
......@@ -3998,7 +3997,7 @@ extern tree instantiate_class_template (tree);
extern tree instantiate_template (tree, tree, tsubst_flags_t);
extern int fn_type_unification (tree, tree, tree, tree, tree, unification_kind_t, int);
extern void mark_decl_instantiated (tree, int);
extern int more_specialized (tree, tree, int, int);
extern int more_specialized_fn (tree, tree, int);
extern void mark_class_instantiated (tree, int);
extern void do_decl_instantiation (tree, tree);
extern void do_type_instantiation (tree, tree, tsubst_flags_t);
......
2005-03-31 Nathan Sidwell <nathan@codesourcery.com>
PR c++/19203, DR 214
* g++.dg/parse/ambig3.C: Not ambiguous.
* g++.dg/template/spec20.C: New.
* g++.dg/template/spec21.C: New.
2005-03-31 Steve Ellcey <sje@cup.hp.com>
PR target/20045
......
......@@ -5,8 +5,17 @@
template <int> struct A { static const int i = 1; };
template <int> struct B {};
template <typename> void foo(B<0>) {} // { dg-error "" }
template <typename> int foo(B<0>)
{
return 0;
}
template <typename, int j> B<A<j>::i-1> foo(B<j>) { return B<0>(); } // { dg-error "" }
template <typename, int j> B<A<j>::i-1> foo(B<j>)
{
return B<0>();
}
void bar() { foo<int>(B<0>()); } // { dg-error "ambiguous" }
int main()
{
return foo<int>(B<0>());
}
// Copyright (C) 2005 Free Software Foundation, Inc.
// Contributed by Nathan Sidwell 31 Mar 2005 <nathan@codesourcery.com>
// Origin: Giovanni Bajo <giovannibajo@libero.it>
// Bug 19203: Failure to implement DR 214
template <class A>
void foo(const A& a);
template <class RET, class ARG1>
int foo(RET (&)(ARG1)); // this one
float decl(int);
int bar(void)
{
return foo(decl);
}
// Copyright (C) 2005 Free Software Foundation, Inc.
// Contributed by Nathan Sidwell 31 Mar 2005 <nathan@codesourcery.com>
// { dg-do run }
// DR214
template <class T> T f(int) {return 0;}
template <class T, class U> T f(U){return 1;}
template <typename T, typename R> T checked_cast (R const &) {return 0;}
template <typename T, typename R> T checked_cast (R *) {return 1;}
int main ()
{
int i = 0;
if (f<int>(1))
return 1;
if (checked_cast<int>(i) != 0)
return 2;
if (checked_cast<int>(&i) != 1)
return 3;
return 0;
}
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