From: Paolo Carlini Date: Thu, 11 Apr 2013 12:46:10 +0000 (+0000) Subject: re PR c++/56913 ([C++11] SFINAE for ill-formed pointer-to-member operators with incom... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=7c55f4101789d76d1a9bab69631edb171321f12f;p=gcc.git re PR c++/56913 ([C++11] SFINAE for ill-formed pointer-to-member operators with incompatible ref-qualifiers) /cp 2013-04-11 Paolo Carlini PR c++/56913 * typeck2.c (build_m_component_ref): Protect error calls with (complain & tf_error). /testsuite 2013-04-11 Paolo Carlini PR c++/56913 * g++.dg/cpp0x/sfinae44.C: New. From-SVN: r197780 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 8d0f6c13b1c..01fc3efc5be 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2013-04-11 Paolo Carlini + + PR c++/56913 + * typeck2.c (build_m_component_ref): Protect error calls with + (complain & tf_error). + 2013-04-11 Paolo Carlini PR c++/54216 diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c index 5c2b1b22611..a0bc50b2a5e 100644 --- a/gcc/cp/typeck2.c +++ b/gcc/cp/typeck2.c @@ -1722,11 +1722,19 @@ build_m_component_ref (tree datum, tree component, tsubst_flags_t complain) { bool lval = real_lvalue_p (datum); if (lval && FUNCTION_RVALUE_QUALIFIED (type)) - error ("pointer-to-member-function type %qT requires an rvalue", - ptrmem_type); + { + if (complain & tf_error) + error ("pointer-to-member-function type %qT requires an rvalue", + ptrmem_type); + return error_mark_node; + } else if (!lval && !FUNCTION_RVALUE_QUALIFIED (type)) - error ("pointer-to-member-function type %qT requires an lvalue", - ptrmem_type); + { + if (complain & tf_error) + error ("pointer-to-member-function type %qT requires an lvalue", + ptrmem_type); + return error_mark_node; + } } return build2 (OFFSET_REF, type, datum, component); } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 02639b1a72f..58447dbe1e9 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2013-04-11 Paolo Carlini + + PR c++/56913 + * g++.dg/cpp0x/sfinae44.C: New. + 2013-04-11 Arnaud Charlet * ada/acats/run_all.sh: Remove special handling of -gnat95 switch. diff --git a/gcc/testsuite/g++.dg/cpp0x/sfinae44.C b/gcc/testsuite/g++.dg/cpp0x/sfinae44.C new file mode 100644 index 00000000000..bbcae622630 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/sfinae44.C @@ -0,0 +1,26 @@ +// PR c++/56913 +// { dg-do compile { target c++11 } } + +template +T &&declval(); + +template().*declval())())> +constexpr bool test(int) +{ + return true; +} + +template +constexpr bool test(...) +{ + return false; +} + +struct S +{}; + +static_assert(!test(0), ""); +static_assert(test(0), ""); +static_assert(test(0), ""); +static_assert(!test(0), "");