From: Jason Merrill Date: Thu, 12 Nov 2009 20:26:36 +0000 (-0500) Subject: re PR c++/42013 (cv-qualification of conditional expression type depending on the... X-Git-Tag: releases/gcc-4.5.0~2374 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d6c057abd6a83513d4b6356314b8c5752a7025af;p=thirdparty%2Fgcc.git re PR c++/42013 (cv-qualification of conditional expression type depending on the value of its first expression?!?) PR c++/42013 * call.c (build_conditional_expr): Check specifically for folding to CALL_EXPR rather than TREE_SIDE_EFFECTS. From-SVN: r154129 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 861835b383d3..e0b5f2771da5 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2009-11-12 Jason Merrill + + PR c++/42013 + * call.c (build_conditional_expr): Check specifically for folding + to CALL_EXPR rather than TREE_SIDE_EFFECTS. + 2009-11-12 Jason Merrill * typeck.c (cv_qualified_p): New fn. diff --git a/gcc/cp/call.c b/gcc/cp/call.c index e77a738660d4..e4a6bca347fb 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -3605,6 +3605,7 @@ build_conditional_expr (tree arg1, tree arg2, tree arg3, tree arg2_type; tree arg3_type; tree result = NULL_TREE; + tree result_save; tree result_type = NULL_TREE; bool lvalue_p = true; struct z_candidate *candidates = 0; @@ -3991,12 +3992,12 @@ build_conditional_expr (tree arg1, tree arg2, tree arg3, } valid_operands: - result = build3 (COND_EXPR, result_type, arg1, arg2, arg3); + result_save = build3 (COND_EXPR, result_type, arg1, arg2, arg3); + result = fold_if_not_in_template (result_save); - if (cp_unevaluated_operand && TREE_SIDE_EFFECTS (result)) - /* Avoid folding a ?: of two calls within decltype (c++/42013). */; - else - result = fold_if_not_in_template (result); + if (cp_unevaluated_operand && TREE_CODE (result) == CALL_EXPR) + /* Avoid folding to a CALL_EXPR within decltype (c++/42013). */ + result = result_save; /* We can't use result_type below, as fold might have returned a throw_expr. */ diff --git a/gcc/testsuite/g++.dg/cpp0x/decltype19.C b/gcc/testsuite/g++.dg/cpp0x/decltype19.C index 33ca71ff4929..41d602f34eb4 100644 --- a/gcc/testsuite/g++.dg/cpp0x/decltype19.C +++ b/gcc/testsuite/g++.dg/cpp0x/decltype19.C @@ -2,7 +2,7 @@ template _Tp -declval(); +__attribute ((const)) declval(); template struct common_type