Hi!

finish_declspecs when an error has been reported earlier when parsing
declspecs sets specs->type = integer_type_node; for easier error recovery,
e.g.:
    case cts_floatn_nx:
      gcc_assert (!specs->long_p && !specs->short_p
                  && !specs->signed_p && !specs->unsigned_p);
      if (FLOATN_NX_TYPE_NODE (specs->floatn_nx_idx) == NULL_TREE)
        specs->type = integer_type_node;
...
or
    case cts_fract:
      gcc_assert (!specs->complex_p);
      if (!targetm.fixed_point_supported_p ())
        specs->type = integer_type_node;
...
But we don't do this for unsupported __intNNN types, happily keep e.g.
__int128 type in the IL even when it is not supported.  E.g. on the
following testcase that results in ICE though, because for the vector
comparison we want to look up corresponding integer type and don't find
any.

Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux,
ok for trunk and 7.2?

2017-04-20  Jakub Jelinek  <ja...@redhat.com>

        PR c/80468
        * c-decl.c (finish_declspecs) <case cts_int_n>: If int_n_idx is not
        enabled, set specs->type to integer_type_node.

        * gcc.dg/pr80468.c: New test.

--- gcc/c/c-decl.c.jj   2017-03-30 15:24:22.000000000 +0200
+++ gcc/c/c-decl.c      2017-04-20 13:53:11.447417038 +0200
@@ -10929,9 +10929,12 @@ finish_declspecs (struct c_declspecs *sp
     case cts_int_n:
       gcc_assert (!specs->long_p && !specs->short_p && !specs->long_long_p);
       gcc_assert (!(specs->signed_p && specs->unsigned_p));
-      specs->type = (specs->unsigned_p
-                    ? int_n_trees[specs->int_n_idx].unsigned_type
-                    : int_n_trees[specs->int_n_idx].signed_type);
+      if (! int_n_enabled_p[specs->int_n_idx])
+       specs->type = integer_type_node;
+      else
+       specs->type = (specs->unsigned_p
+                      ? int_n_trees[specs->int_n_idx].unsigned_type
+                      : int_n_trees[specs->int_n_idx].signed_type);
       if (specs->complex_p)
        {
          pedwarn (specs->locations[cdw_complex], OPT_Wpedantic,
--- gcc/testsuite/gcc.dg/pr80468.c.jj   2017-04-20 13:51:16.620957496 +0200
+++ gcc/testsuite/gcc.dg/pr80468.c      2017-04-20 13:52:07.955268819 +0200
@@ -0,0 +1,10 @@
+/* PR c/80468 */
+/* { dg-do compile { target { ! int128 } } } */
+/* { dg-options "" } */
+
+void
+foo (void)
+{
+  __attribute__ ((__vector_size__ (4 * sizeof (unsigned)))) __int128 b;        
/* { dg-error "is not supported on this target" } */
+  0 != b;
+}


        Jakub

Reply via email to