]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR c/84999 (ICE in make_vector_type, at tree.c:9561)
authorJakub Jelinek <jakub@redhat.com>
Fri, 22 Jun 2018 20:55:40 +0000 (22:55 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 22 Jun 2018 20:55:40 +0000 (22:55 +0200)
Backported from mainline
2018-03-21  Jakub Jelinek  <jakub@redhat.com>

PR c/84999
* c-typeck.c (build_binary_op): If c_common_type_for_size fails when
building vector comparison, diagnose it and return error_mark_node.

* c-c++-common/pr84999.c: New test.

From-SVN: r261934

gcc/c/ChangeLog
gcc/c/c-typeck.c
gcc/testsuite/ChangeLog
gcc/testsuite/c-c++-common/pr84999.c [new file with mode: 0644]

index 866ad995ceb14a716eedbef5453d48ef386e9290..96b9effea12167d95bad87c74f8b4f01ebd9c5ea 100644 (file)
@@ -1,6 +1,12 @@
 2018-06-22  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       2018-03-21  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c/84999
+       * c-typeck.c (build_binary_op): If c_common_type_for_size fails when
+       building vector comparison, diagnose it and return error_mark_node.
+
        2018-03-15  Jakub Jelinek  <jakub@redhat.com>
 
        PR c/84853
index c72932986fa088d8068bd6992cb698d758563f98..363fa32d468db9f2359d97f4995b4bba81a5b710 100644 (file)
@@ -11301,6 +11301,13 @@ build_binary_op (location_t location, enum tree_code code,
           /* Always construct signed integer vector type.  */
           intt = c_common_type_for_size (GET_MODE_BITSIZE
                                           (TYPE_MODE (TREE_TYPE (type0))), 0);
+         if (!intt)
+           {
+             error_at (location, "could not find an integer type "
+                                 "of the same size as %qT",
+                       TREE_TYPE (type0));
+             return error_mark_node;
+           }
           result_type = build_opaque_vector_type (intt,
                                                  TYPE_VECTOR_SUBPARTS (type0));
           converted = 1;
@@ -11460,6 +11467,13 @@ build_binary_op (location_t location, enum tree_code code,
           /* Always construct signed integer vector type.  */
           intt = c_common_type_for_size (GET_MODE_BITSIZE
                                           (TYPE_MODE (TREE_TYPE (type0))), 0);
+         if (!intt)
+           {
+             error_at (location, "could not find an integer type "
+                                 "of the same size as %qT",
+                       TREE_TYPE (type0));
+             return error_mark_node;
+           }
           result_type = build_opaque_vector_type (intt,
                                                  TYPE_VECTOR_SUBPARTS (type0));
           converted = 1;
index bfe4de9a591a4e2d3774f9c387c2f32b2776d56e..9b18005b079698e6477af9a3261d5081595ea32c 100644 (file)
@@ -3,6 +3,9 @@
        Backported from mainline
        2018-03-21  Jakub Jelinek  <jakub@redhat.com>
 
+       PR c/84999
+       * c-c++-common/pr84999.c: New test.
+
        PR c++/84961
        * c-c++-common/pr43690.c: Don't expect errors on "m" (--x) and
        "m" (++x) in C++.
diff --git a/gcc/testsuite/c-c++-common/pr84999.c b/gcc/testsuite/c-c++-common/pr84999.c
new file mode 100644 (file)
index 0000000..42d5376
--- /dev/null
@@ -0,0 +1,12 @@
+/* PR c/84999 */
+/* { dg-do compile { target { i?86-*-* x86_64-*-* } } } */
+/* { dg-options "" } */
+
+typedef __float128 V __attribute__ ((__vector_size__ (2 * sizeof (__float128))));
+V a;
+typeof (a != 0) b;     /* { dg-error "could not find an integer type of the same size as" "" { target ia32 } } */
+typeof (a == 0) c;     /* { dg-error "could not find an integer type of the same size as" "" { target ia32 } } */
+typeof (a < 0) d;      /* { dg-error "could not find an integer type of the same size as" "" { target ia32 } } */
+typeof (a <= 0) e;     /* { dg-error "could not find an integer type of the same size as" "" { target ia32 } } */
+typeof (a > 0) f;      /* { dg-error "could not find an integer type of the same size as" "" { target ia32 } } */
+typeof (a >= 0) g;     /* { dg-error "could not find an integer type of the same size as" "" { target ia32 } } */