diff mbox

C++ PATCH for c++/64727 (darwin-cfstring-3.C failure)

Message ID 54C25E95.6050008@redhat.com
State New
Headers show

Commit Message

Jason Merrill Jan. 23, 2015, 2:45 p.m. UTC
The problem here was that darwin uses CONST_DECL for an aggregate 
constant, while the C++ front end expects it to only be used for 
enumerators.  Adjusting that in this one place fixes the testcase.

Tested x86_64-pc-linux-gnu, applying to trunk.
diff mbox

Patch

commit e7e659890bfa248aa57eefd62992a71d8d0bd399
Author: Jason Merrill <jason@redhat.com>
Date:   Thu Jan 22 16:58:01 2015 -0500

    	PR c++/64727
    	* constexpr.c (cxx_eval_constant_expression): Allow for lvalue use
    	of CONST_DECL.

diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c
index e3e838e..3a33c9f 100644
--- a/gcc/cp/constexpr.c
+++ b/gcc/cp/constexpr.c
@@ -2955,10 +2955,11 @@  cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t,
       return (*ctx->values->get (t));
 
     case VAR_DECL:
+    case CONST_DECL:
+      /* We used to not check lval for CONST_DECL, but darwin.c uses
+	 CONST_DECL for aggregate constants.  */
       if (lval)
 	return t;
-      /* else fall through. */
-    case CONST_DECL:
       if (ctx->strict)
 	r = decl_really_constant_value (t);
       else