Commit 248ce2f8 by Paolo Carlini Committed by Paolo Carlini

re PR c++/44907 (SFINAE vs ambiguous base (the real one ;))

/cp
2010-07-12  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/44907
	* call.c (build_temp): Add tsubst_flags_t complain parameter;
	adjust build_special_member_call call, pass complain.
	(convert_like_real): Adjust build_temp call, pass complain.

/testsuite
2010-07-12  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/44907
	* g++.dg/template/sfinae19.C: New.
	* g++.dg/template/sfinae20.C: Likewise.

From-SVN: r162113
parent ac9b0eea
2010-07-12 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/44907
* call.c (build_temp): Add tsubst_flags_t complain parameter;
adjust build_special_member_call call, pass complain.
(convert_like_real): Adjust build_temp call, pass complain.
2010-07-09 Jason Merrill <jason@redhat.com>
PR c++/43120
......
......@@ -204,7 +204,7 @@ static void add_candidates (tree, tree, const VEC(tree,gc) *, tree, tree, bool,
tree, tree, int, struct z_candidate **);
static conversion *merge_conversion_sequences (conversion *, conversion *);
static bool magic_varargs_p (tree);
static tree build_temp (tree, tree, int, diagnostic_t *);
static tree build_temp (tree, tree, int, diagnostic_t *, tsubst_flags_t);
/* Returns nonzero iff the destructor name specified in NAME matches BASETYPE.
NAME can take many forms... */
......@@ -4851,7 +4851,7 @@ enforce_access (tree basetype_path, tree decl, tree diag_decl)
static tree
build_temp (tree expr, tree type, int flags,
diagnostic_t *diagnostic_kind)
diagnostic_t *diagnostic_kind, tsubst_flags_t complain)
{
int savew, savee;
VEC(tree,gc) *args;
......@@ -4859,7 +4859,7 @@ build_temp (tree expr, tree type, int flags,
savew = warningcount, savee = errorcount;
args = make_tree_vector_single (expr);
expr = build_special_member_call (NULL_TREE, complete_ctor_identifier,
&args, type, flags, tf_warning_or_error);
&args, type, flags, complain);
release_tree_vector (args);
if (warningcount > savew)
*diagnostic_kind = DK_WARNING;
......@@ -5132,7 +5132,7 @@ convert_like_real (conversion *convs, tree expr, tree fn, int argnum,
conversion (i.e. the second step of copy-initialization), so
don't allow any more. */
flags |= LOOKUP_NO_CONVERSION;
expr = build_temp (expr, totype, flags, &diag_kind);
expr = build_temp (expr, totype, flags, &diag_kind, complain);
if (diag_kind && fn)
{
if ((complain & tf_error))
......
2010-07-12 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/44907
* g++.dg/template/sfinae19.C: New.
* g++.dg/template/sfinae20.C: Likewise.
2010-07-12 Jie Zhang <jie@codesourcery.com>
* gcc.target/arm/interrupt-1.c: New test.
......
// PR c++/44907
struct A { };
struct B
: public A { };
struct C
: public A { };
struct D
: public B, public C { };
template<bool, typename T = void> struct enable_if { typedef T type; };
template<typename T> struct enable_if<false, T> { };
template<typename From, typename To>
class mini_is_convertible
{
typedef char one;
typedef struct { char arr[2]; } two;
template<typename To1>
static void test_aux(To1);
template<typename To1, typename From1>
static typename
enable_if<(sizeof(test_aux<To1>(From1()), 1) > 0), one>::type
test(int);
template<typename, typename>
static two test(...);
public:
static const bool value = sizeof(test<To, From>(0)) == 1;
};
template<typename From, typename To>
const bool mini_is_convertible<From, To>::value;
int Test1[mini_is_convertible<D*, A*>::value ? -1 : 1];
int Test2[mini_is_convertible<A*, D*>::value ? -1 : 1];
int Test3[mini_is_convertible<D, A>::value ? -1 : 1];
int Test4[mini_is_convertible<A, D>::value ? -1 : 1];
// PR c++/44907
// { dg-options "-std=c++0x" }
#include <utility>
struct A { };
struct B
: public A { };
struct C
: public A { };
struct D
: public B, public C { };
template<typename From, typename To>
class mini_is_convertible
{
typedef char one;
typedef struct { char arr[2]; } two;
template<typename To1>
static void test_aux(To1);
template<typename To1, typename From1>
static decltype(test_aux<To1>(std::declval<From1>()), one())
test(int);
template<typename, typename>
static two test(...);
public:
static const bool value = sizeof(test<To, From>(0)) == 1;
};
template<typename From, typename To>
const bool mini_is_convertible<From, To>::value;
static_assert (!mini_is_convertible<D*, A*>::value, "");
static_assert (!mini_is_convertible<A*, D*>::value, "");
static_assert (!mini_is_convertible<D&, A&>::value, "");
static_assert (!mini_is_convertible<A&, D&>::value, "");
static_assert (!mini_is_convertible<D, A>::value, "");
static_assert (!mini_is_convertible<A, D>::value, "");
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