public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r11-2924] PR c/96596 - ICE in match_builtin_function_types on a declaration of a built-in with invalid array a
@ 2020-08-28 14:29 Martin Sebor
  0 siblings, 0 replies; only message in thread
From: Martin Sebor @ 2020-08-28 14:29 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:ba6373a39782139789f0eeba7c0e607ec6dfb477

commit r11-2924-gba6373a39782139789f0eeba7c0e607ec6dfb477
Author: Martin Sebor <msebor@redhat.com>
Date:   Fri Aug 28 08:26:32 2020 -0600

    PR c/96596 - ICE in match_builtin_function_types on a declaration of a built-in with invalid array argument
    
    gcc/c/ChangeLog:
    
            PR c/96596
            * c-decl.c (match_builtin_function_types): Avoid dealing with erroneous
            argument type.
    
    gcc/testsuite/ChangeLog:
    
            PR c/96596
            * gcc.dg/Wbuiltin-declaration-mismatch-16.c: New test.

Diff:
---
 gcc/c/c-decl.c                                          |  5 ++++-
 gcc/testsuite/gcc.dg/Wbuiltin-declaration-mismatch-16.c | 12 ++++++++++++
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/gcc/c/c-decl.c b/gcc/c/c-decl.c
index 5d6b504fe78..190c00bd435 100644
--- a/gcc/c/c-decl.c
+++ b/gcc/c/c-decl.c
@@ -1712,7 +1712,10 @@ match_builtin_function_types (tree newtype, tree oldtype,
 	return NULL_TREE;
 
       tree oldtype = TYPE_MAIN_VARIANT (TREE_VALUE (oldargs));
-      tree newtype = TYPE_MAIN_VARIANT (TREE_VALUE (newargs));
+      tree newtype = TREE_VALUE (newargs);
+      if (newtype == error_mark_node)
+       return NULL_TREE;
+      newtype = TYPE_MAIN_VARIANT (newtype);
 
       if (!types_close_enough_to_match (oldtype, newtype))
 	return NULL_TREE;
diff --git a/gcc/testsuite/gcc.dg/Wbuiltin-declaration-mismatch-16.c b/gcc/testsuite/gcc.dg/Wbuiltin-declaration-mismatch-16.c
new file mode 100644
index 00000000000..494fff9ec60
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/Wbuiltin-declaration-mismatch-16.c
@@ -0,0 +1,12 @@
+/* PR c/96596 - ICE on a declaration of a built-in with invalid array
+   argument
+   { dg-do compile } */
+
+void __builtin_abort (int[foo]);            /* { dg-error "'foo' undeclared" } */
+void __builtin_trap (int[__SIZE_MAX__]);    /* { dg-error "size of unnamed array is too large" } */
+void __builtin_unreachable (int[][]);       /* { dg-error "array type has incomplete element type" } */
+
+void __builtin_exit (int, int[+]);          /* { dg-error "expected expression before" } */
+
+/* { dg-prune-output "\\\[-Wbuiltin-declaration-mismatch" }  */
+


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-08-28 14:29 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-28 14:29 [gcc r11-2924] PR c/96596 - ICE in match_builtin_function_types on a declaration of a built-in with invalid array a Martin Sebor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).