]> gcc.gnu.org Git - gcc.git/commitdiff
re PR c++/42013 (cv-qualification of conditional expression type depending on the...
authorJason Merrill <jason@redhat.com>
Thu, 12 Nov 2009 20:26:36 +0000 (15:26 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Thu, 12 Nov 2009 20:26:36 +0000 (15:26 -0500)
PR c++/42013
* call.c (build_conditional_expr): Check specifically for folding
to CALL_EXPR rather than TREE_SIDE_EFFECTS.

From-SVN: r154129

gcc/cp/ChangeLog
gcc/cp/call.c
gcc/testsuite/g++.dg/cpp0x/decltype19.C

index 861835b383d31cac386e41a4f77463923c4605cb..e0b5f2771da5b7b8f81ea3be3cf93d0a2b2ab7a8 100644 (file)
@@ -1,3 +1,9 @@
+2009-11-12  Jason Merrill  <jason@redhat.com>
+
+       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  <jason@redhat.com>
 
        * typeck.c (cv_qualified_p): New fn.
index e77a738660d4281352c43109213955cb4b954686..e4a6bca347fb6ab2d2fc9371054975bf3837dc6b 100644 (file)
@@ -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.  */
index 33ca71ff4929f60f2a4d59127af750fb972a50a1..41d602f34eb49dca7eceb7835dbf3448b1790e0d 100644 (file)
@@ -2,7 +2,7 @@
 
 template<typename _Tp>
   _Tp
-declval();
+__attribute ((const)) declval();
 
 template<typename _Tp, typename _Up>
   struct common_type
This page took 0.0719 seconds and 5 git commands to generate.