re PR c++/47482 ([C++0x] ICE: unexpected expression ‘sizeof ("A")’ of kind sizeof_expr)
authorJason Merrill <jason@redhat.com>
Mon, 14 Feb 2011 21:52:24 +0000 (16:52 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Mon, 14 Feb 2011 21:52:24 +0000 (16:52 -0500)
PR c++/47482
* parser.c (cp_parser_enumerator_definition): Call
fold_non_dependent_expr.

From-SVN: r170156

gcc/cp/ChangeLog
gcc/cp/parser.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/regress/enum1.C [new file with mode: 0644]

index c3f780abe0494e11994312330d4f25e0d9680f04..61a3e4addc2ac1be31efa19cdf60910a1a4e3586 100644 (file)
@@ -1,3 +1,9 @@
+2011-02-14  Jason Merrill  <jason@redhat.com>
+
+       PR c++/47482
+       * parser.c (cp_parser_enumerator_definition): Call
+       fold_non_dependent_expr.
+
 2011-02-09  Jason Merrill  <jason@redhat.com>
 
        * decl.c (cp_make_fname_decl): Set DECL_THIS_STATIC at toplevel.
index 11039b899ccd4e94f0585f3be5aeffb5ea789d08..8f4a1219a736677e38582a5ddee3e5679959f978 100644 (file)
@@ -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);
 }
index 9d200a419afd51cc5343d47fcf7aa4ed706aeedc..cd73643e916bf9e6a4350225b2bec70136e1d118 100644 (file)
@@ -1,3 +1,7 @@
+2011-02-14  Jason Merrill  <jason@redhat.com>
+
+       * g++.dg/cpp0x/regress/enum1.C: New.
+
 2011-02-14  Eric Botcazou  <ebotcazou@adacore.com>
 
        * gnat.dg/include.adb: New test.
diff --git a/gcc/testsuite/g++.dg/cpp0x/regress/enum1.C b/gcc/testsuite/g++.dg/cpp0x/regress/enum1.C
new file mode 100644 (file)
index 0000000..6e29f9e
--- /dev/null
@@ -0,0 +1,8 @@
+// PR c++/47482
+// { dg-options -std=c++0x }
+
+template<class>
+struct K
+{
+  enum { A = sizeof"A", B = +A };
+};