diff mbox

C++ PATCH for c++/47482 (C++0x ICE with sizeof)

Message ID 4D59A410.4030901@redhat.com
State New
Headers show

Commit Message

Jason Merrill Feb. 14, 2011, 9:52 p.m. UTC
This turned out to be not actually a problem in the constexpr code, but 
rather exposed by it; if we're going to pull out the DECL_INITIAL of an 
enumerator CONST_DECL in integral_constant_value, we need to make sure 
it's folded ahead of time.

Tested x86_64-pc-linux-gnu, applied to trunk.
commit 7cad41e9a0ad658e8916474209983f25fa50b92e
Author: Jason Merrill <jason@redhat.com>
Date:   Fri Feb 11 14:45:53 2011 -0500

    	PR c++/47482
    	* parser.c (cp_parser_enumerator_definition): Call
    	fold_non_dependent_expr.
diff mbox

Patch

diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 11039b8..8f4a121 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -13763,6 +13763,10 @@  cp_parser_enumerator_definition (cp_parser* parser, tree type)
   if (check_for_bare_parameter_packs (value))
     value = error_mark_node;
 
+  /* integral_constant_value will pull out this expression, so make sure
+     it's folded as appropriate.  */
+  value = fold_non_dependent_expr (value);
+
   /* Create the enumerator.  */
   build_enumerator (identifier, value, type, loc);
 }
diff --git a/gcc/testsuite/g++.dg/cpp0x/regress/enum1.C b/gcc/testsuite/g++.dg/cpp0x/regress/enum1.C
new file mode 100644
index 0000000..6e29f9e
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/regress/enum1.C
@@ -0,0 +1,8 @@ 
+// PR c++/47482
+// { dg-options -std=c++0x }
+
+template<class>
+struct K
+{
+  enum { A = sizeof"A", B = +A };
+};