From d73ff859943b668ab90402b94e458a898a20e777 Mon Sep 17 00:00:00 2001 From: Gabriel Dos Reis Date: Sun, 22 Feb 2004 16:05:49 +0000 Subject: [PATCH] backport: re PR c++/13907 (valid conversion rejected unless -pedantic is set) Backport from mainline 2004-02-02 Mark Mitchell PR c++/13907 * call.c (convert_class_to_reference): Keep better track of pedantically invalid user-defined conversions. From-SVN: r78263 --- gcc/cp/ChangeLog | 8 ++++++++ gcc/cp/call.c | 22 +++++++++++++--------- gcc/testsuite/g++.dg/conversion/op2.C | 2 -- 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index eb0f336d880d..4415bda7aa70 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,11 @@ +2004-02-22 Gabriel Dos Reis + + Backport from mainline + 2004-02-02 Mark Mitchell + PR c++/13907 + * call.c (convert_class_to_reference): Keep better track of + pedantically invalid user-defined conversions. + 2004-02-14 Release Manager * GCC 3.3.3 Released. diff --git a/gcc/cp/call.c b/gcc/cp/call.c index ce9067865994..89fc25790f24 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -1091,15 +1091,19 @@ convert_class_to_reference (t, s, expr) LOOKUP_NORMAL); if (cand) - /* Build a standard conversion sequence indicating the - binding from the reference type returned by the - function to the desired REFERENCE_TYPE. */ - cand->second_conv - = (direct_reference_binding - (reference_type, - build1 (IDENTITY_CONV, - TREE_TYPE (TREE_TYPE (TREE_TYPE (cand->fn))), - NULL_TREE))); + { + /* Build a standard conversion sequence indicating the + binding from the reference type returned by the + function to the desired REFERENCE_TYPE. */ + cand->second_conv + = (direct_reference_binding + (reference_type, + build1 (IDENTITY_CONV, + TREE_TYPE (TREE_TYPE (TREE_TYPE (cand->fn))), + NULL_TREE))); + ICS_BAD_FLAG (cand->second_conv) + |= ICS_BAD_FLAG (TREE_VEC_ELT (cand->convs, 0)); + } } conversions = TREE_CHAIN (conversions); } diff --git a/gcc/testsuite/g++.dg/conversion/op2.C b/gcc/testsuite/g++.dg/conversion/op2.C index b400988108d2..d31896f23b62 100644 --- a/gcc/testsuite/g++.dg/conversion/op2.C +++ b/gcc/testsuite/g++.dg/conversion/op2.C @@ -5,10 +5,8 @@ struct A { operator const int & () const; }; - void f(int &); void f(const int &); - int main() { const A x = A(); -- 2.47.2