PR c/97463 - ICE in warn_parm_ptrarray_mismatch on an incompatible function redeclaration
authorMartin Sebor <msebor@redhat.com>
Fri, 23 Oct 2020 18:30:20 +0000 (12:30 -0600)
committerMartin Sebor <msebor@redhat.com>
Fri, 23 Oct 2020 18:30:20 +0000 (12:30 -0600)
gcc/c-family/ChangeLog:

PR c/97463
* c-warn.c (warn_parm_ptrarray_mismatch): Move null test earlier.

gcc/testsuite/ChangeLog:

PR c/97463
* gcc.dg/pr97463.c: New test.

gcc/c-family/c-warn.c
gcc/testsuite/gcc.dg/pr97463.c [new file with mode: 0644]

index ebd011d1a4228deae469b4c7adc254d89f180b88..a1b945053e80a64808609c66b5f06344bc7f0b0d 100644 (file)
@@ -3177,14 +3177,14 @@ warn_parm_ptrarray_mismatch (location_t origloc, tree curparms, tree newparms)
        {
          curtyp = TREE_TYPE (curtyp);
          newtyp = TREE_TYPE (newtyp);
+
+         if (!newtyp)
+           /* Bail on error.  */
+           return;
        }
       while (TREE_CODE (curtyp) == POINTER_TYPE
             && TREE_CODE (newtyp) == POINTER_TYPE);
 
-      if (!newtyp)
-       /* Bail on error.  */
-       return;
-
       if (TREE_CODE (curtyp) != ARRAY_TYPE
          || TREE_CODE (newtyp) != ARRAY_TYPE)
        {
diff --git a/gcc/testsuite/gcc.dg/pr97463.c b/gcc/testsuite/gcc.dg/pr97463.c
new file mode 100644 (file)
index 0000000..f93b07c
--- /dev/null
@@ -0,0 +1,7 @@
+/* PR c/97463 - ICE in warn_parm_ptrarray_mismatch on an incompatible
+   function redeclaration
+   { dg-do compile }
+   { dg-options "-Wall" } */
+
+void f (void**);
+void f (int n) { }      // { dg-error "conflicting types" }