re PR middle-end/79788 (ICE in expand_expr_real_2, at expr.c:9557)
authorJakub Jelinek <jakub@redhat.com>
Tue, 18 Apr 2017 13:15:46 +0000 (15:15 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 18 Apr 2017 13:15:46 +0000 (15:15 +0200)
PR middle-end/79788
PR middle-end/80375
* c-common.c (c_common_type_for_mode): Don't handle
widest_*_literal_type_node here.
c_common_signed_or_unsigned_type): Likewise.
(c_common_nodes_and_builtins): Set widest_*_literal_type_node
to *intTI_type_node or *intDI_type_node depending on whether
TImode is supported by the target or not.

* gcc.dg/pr79788-1.c: New test.
* gcc.dg/pr79788-2.c: New test.

From-SVN: r246965

gcc/c-family/ChangeLog
gcc/c-family/c-common.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr79788-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/pr79788-2.c [new file with mode: 0644]

index ff6edbdbef6494a5996584cdbce5e72b6cd03092..10cf7617acbd763a4a8495639500ade82ad780fe 100644 (file)
@@ -1,3 +1,14 @@
+2017-04-18  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/79788
+       PR middle-end/80375
+       * c-common.c (c_common_type_for_mode): Don't handle
+       widest_*_literal_type_node here.
+       c_common_signed_or_unsigned_type): Likewise.
+       (c_common_nodes_and_builtins): Set widest_*_literal_type_node
+       to *intTI_type_node or *intDI_type_node depending on whether
+       TImode is supported by the target or not.
+
 2017-04-10  Martin Liska  <mliska@suse.cz>
 
        PR sanitizer/80350
index 824fdc71233af6c8d19361f57276f4f82a0d10d0..26d5be370d168f5b6da092b69908444d1645794a 100644 (file)
@@ -2179,10 +2179,6 @@ c_common_type_for_mode (machine_mode mode, int unsignedp)
       return (unsignedp ? int_n_trees[i].unsigned_type
              : int_n_trees[i].signed_type);
 
-  if (mode == TYPE_MODE (widest_integer_literal_type_node))
-    return unsignedp ? widest_unsigned_literal_type_node
-                    : widest_integer_literal_type_node;
-
   if (mode == QImode)
     return unsignedp ? unsigned_intQI_type_node : intQI_type_node;
 
@@ -2412,8 +2408,6 @@ c_common_signed_or_unsigned_type (int unsignedp, tree type)
       return (unsignedp ? int_n_trees[i].unsigned_type
              : int_n_trees[i].signed_type);
 
-  if (type1 == widest_integer_literal_type_node || type1 == widest_unsigned_literal_type_node)
-    return unsignedp ? widest_unsigned_literal_type_node : widest_integer_literal_type_node;
 #if HOST_BITS_PER_WIDE_INT >= 64
   if (type1 == intTI_type_node || type1 == unsigned_intTI_type_node)
     return unsignedp ? unsigned_intTI_type_node : intTI_type_node;
@@ -2534,10 +2528,6 @@ c_common_signed_or_unsigned_type (int unsignedp, tree type)
       return (unsignedp ? int_n_trees[i].unsigned_type
              : int_n_trees[i].signed_type);
 
-  if (TYPE_OK (widest_integer_literal_type_node))
-    return (unsignedp ? widest_unsigned_literal_type_node
-           : widest_integer_literal_type_node);
-
 #if HOST_BITS_PER_WIDE_INT >= 64
   if (TYPE_OK (intTI_type_node))
     return unsignedp ? unsigned_intTI_type_node : intTI_type_node;
@@ -4164,17 +4154,16 @@ c_common_nodes_and_builtins (void)
 #endif
 
   /* Create the widest literal types.  */
-  widest_integer_literal_type_node
-    = make_signed_type (HOST_BITS_PER_WIDE_INT * 2);
-  lang_hooks.decls.pushdecl (build_decl (UNKNOWN_LOCATION,
-                                        TYPE_DECL, NULL_TREE,
-                                        widest_integer_literal_type_node));
-
-  widest_unsigned_literal_type_node
-    = make_unsigned_type (HOST_BITS_PER_WIDE_INT * 2);
-  lang_hooks.decls.pushdecl (build_decl (UNKNOWN_LOCATION,
-                                        TYPE_DECL, NULL_TREE,
-                                        widest_unsigned_literal_type_node));
+  if (targetm.scalar_mode_supported_p (TImode))
+    {
+      widest_integer_literal_type_node = intTI_type_node;
+      widest_unsigned_literal_type_node = unsigned_intTI_type_node;
+    }
+  else
+    {
+      widest_integer_literal_type_node = intDI_type_node;
+      widest_unsigned_literal_type_node = unsigned_intDI_type_node;
+    }
 
   signed_size_type_node = c_common_signed_type (size_type_node);
 
index db98764c62772cd8721f415985609fd45c164a1b..728f2cfb600161ba8b60021a7ecc7e23013ac572 100644 (file)
@@ -1,3 +1,10 @@
+2017-04-18  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/79788
+       PR middle-end/80375
+       * gcc.dg/pr79788-1.c: New test.
+       * gcc.dg/pr79788-2.c: New test.
+
 2017-04-18  Marek Polacek  <polacek@redhat.com>
 
        PR c++/80244 - ICE with attribute in template alias.
diff --git a/gcc/testsuite/gcc.dg/pr79788-1.c b/gcc/testsuite/gcc.dg/pr79788-1.c
new file mode 100644 (file)
index 0000000..5ad546c
--- /dev/null
@@ -0,0 +1,11 @@
+/* PR middle-end/79788 */
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+long long
+foo (long long x, long long y)
+{
+  if (y > 1234567891234567891234567891234567812 / x)   /* { dg-warning "integer constant is too large for its type" } */
+    return x;
+  return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/pr79788-2.c b/gcc/testsuite/gcc.dg/pr79788-2.c
new file mode 100644 (file)
index 0000000..c9447b1
--- /dev/null
@@ -0,0 +1,11 @@
+/* PR middle-end/79788 */
+/* { dg-do compile } */
+/* { dg-options "-ftrapv" } */
+
+void bar (void);
+void
+foo (long long int p, long long int q)
+{
+  if (p >= 1234567891234567891234567891234567812 + q)  /* { dg-warning "integer constant is too large for its type" } */
+    bar ();
+}