From 835dee55a19b764fe246e5c86264af66b73bd313 Mon Sep 17 00:00:00 2001 From: Paolo Carlini Date: Thu, 17 Jul 2014 16:22:19 +0000 Subject: [PATCH] re PR c++/50961 (Fails to decay template function properly(?)) /cp 2014-07-17 Paolo Carlini PR c++/50961 * call.c (standard_conversion): Use resolve_nondeduced_context for type_unknown_p (EXPR) && TREE_CODE (TO) == BOOLEAN_TYPE. /testsuite 2014-07-17 Paolo Carlini PR c++/50961 * g++.dg/template/operator13.C: New. From-SVN: r212760 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/call.c | 22 +++++++++++++++------- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/template/operator13.C | 12 ++++++++++++ 4 files changed, 38 insertions(+), 7 deletions(-) create mode 100644 gcc/testsuite/g++.dg/template/operator13.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index e4b27f4112b..779e087e444 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2014-07-17 Paolo Carlini + + PR c++/50961 + * call.c (standard_conversion): Use resolve_nondeduced_context + for type_unknown_p (EXPR) && TREE_CODE (TO) == BOOLEAN_TYPE. + 2014-07-17 Paolo Carlini PR c++/61804 diff --git a/gcc/cp/call.c b/gcc/cp/call.c index ea8cb5f78c8..61e2769807b 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -1107,14 +1107,22 @@ standard_conversion (tree to, tree from, tree expr, bool c_cast_p, to = strip_top_quals (to); from = strip_top_quals (from); - if ((TYPE_PTRFN_P (to) || TYPE_PTRMEMFUNC_P (to)) - && expr && type_unknown_p (expr)) + if (expr && type_unknown_p (expr)) { - tsubst_flags_t tflags = tf_conv; - expr = instantiate_type (to, expr, tflags); - if (expr == error_mark_node) - return NULL; - from = TREE_TYPE (expr); + if (TYPE_PTRFN_P (to) || TYPE_PTRMEMFUNC_P (to)) + { + tsubst_flags_t tflags = tf_conv; + expr = instantiate_type (to, expr, tflags); + if (expr == error_mark_node) + return NULL; + from = TREE_TYPE (expr); + } + else if (TREE_CODE (to) == BOOLEAN_TYPE) + { + /* Necessary for eg, TEMPLATE_ID_EXPRs (c++/50961). */ + expr = resolve_nondeduced_context (expr); + from = TREE_TYPE (expr); + } } fcode = TREE_CODE (from); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 2e93ada4419..55cf9e5d014 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2014-07-17 Paolo Carlini + + PR c++/50961 + * g++.dg/template/operator13.C: New. + 2014-07-17 Kyrylo Tkachov * gcc.target/aarch64/simd/vfma_f64.c: New test. diff --git a/gcc/testsuite/g++.dg/template/operator13.C b/gcc/testsuite/g++.dg/template/operator13.C new file mode 100644 index 00000000000..1967c910e68 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/operator13.C @@ -0,0 +1,12 @@ +// PR c++/50961 + +template < class > void foo (); + +bool b1 = !foo; +bool b2 = foo ? true : false; + +void bar() +{ + if (foo) + ; +}