re PR c++/79896 (ICE in gimplify_expr, at gimplify.c:11950 on non-int128 target)
authorJakub Jelinek <jakub@redhat.com>
Fri, 10 Mar 2017 15:28:26 +0000 (16:28 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 10 Mar 2017 15:28:26 +0000 (16:28 +0100)
PR c++/79896
* decl.c (finish_enum_value_list): If value is error_mark_node,
don't copy it and change its type.
* init.c (constant_value_1): Return error_mark_node if DECL_INITIAL
of CONST_DECL is error_mark_node.

* g++.dg/ext/int128-5.C: New test.

From-SVN: r246034

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/cp/init.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/ext/int128-5.C [new file with mode: 0644]

index 4f4691a0393a20155dade6c862070b44cff3e640..a7acfa7eb36d6f136dad1f2b82d5029746aa503e 100644 (file)
@@ -1,3 +1,11 @@
+2017-03-10  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/79896
+       * decl.c (finish_enum_value_list): If value is error_mark_node,
+       don't copy it and change its type.
+       * init.c (constant_value_1): Return error_mark_node if DECL_INITIAL
+       of CONST_DECL is error_mark_node.
+
 2017-03-09  Marek Polacek  <polacek@redhat.com>
 
        PR c++/79900 - ICE in strip_typedefs
index 3e7316f3e0b739df02354e025769ad68eb1da8f6..2a97ffc6582d5d8d813b87a6608d203eade688eb 100644 (file)
@@ -14323,9 +14323,12 @@ finish_enum_value_list (tree enumtype)
       input_location = saved_location;
 
       /* Do not clobber shared ints.  */
-      value = copy_node (value);
+      if (value != error_mark_node)
+       {
+         value = copy_node (value);
 
-      TREE_TYPE (value) = enumtype;
+         TREE_TYPE (value) = enumtype;
+       }
       DECL_INITIAL (decl) = value;
     }
 
index 18043e8c57fcbca42050301f3e73acf0df39a5b3..8bfcbde903cfca1fb545e8a651b6ac24b4bb7d2a 100644 (file)
@@ -2162,7 +2162,8 @@ constant_value_1 (tree decl, bool strict_p, bool return_aggregate_cst_ok_p)
       init = DECL_INITIAL (decl);
       if (init == error_mark_node)
        {
-         if (DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P (decl))
+         if (TREE_CODE (decl) == CONST_DECL
+             || DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P (decl))
            /* Treat the error as a constant to avoid cascading errors on
               excessively recursive template instantiation (c++/9335).  */
            return init;
index efee7c1da46200fe13c97d70981ed276b858cca6..8b89d82e523dbc3a49ab45dc7f370fd48f856fb1 100644 (file)
@@ -1,3 +1,8 @@
+2017-03-10  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/79896
+       * g++.dg/ext/int128-5.C: New test.
+
 2017-03-10  Segher Boessenkool  <segher@kernel.crashing.org>
 
        PR testsuite/79356
diff --git a/gcc/testsuite/g++.dg/ext/int128-5.C b/gcc/testsuite/g++.dg/ext/int128-5.C
new file mode 100644 (file)
index 0000000..c2d9297
--- /dev/null
@@ -0,0 +1,10 @@
+// PR c++/79896
+// { dg-do compile { target { ilp32 && { ! int128 } } } }
+// { dg-options "" }
+
+enum E
+{
+  e1 = 0xffffffffffffffffULL,
+  e2,                  // { dg-error "overflow in enumeration values" }
+  e3
+} e = e3;