diff --git a/gcc/c-family/c-warn.c b/gcc/c-family/c-warn.c index d6db85b6de5..ebd011d1a42 100644 --- a/gcc/c-family/c-warn.c +++ b/gcc/c-family/c-warn.c @@ -3181,11 +3181,16 @@ warn_parm_ptrarray_mismatch (location_t origloc, tree curparms, tree newparms) 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) { if (curtyp == error_mark_node || newtyp == error_mark_node) + /* Bail on error. */ return; continue; diff --git a/gcc/testsuite/gcc.dg/Warray-parameter-6.c b/gcc/testsuite/gcc.dg/Warray-parameter-6.c new file mode 100644 index 00000000000..609dac96bb6 --- /dev/null +++ b/gcc/testsuite/gcc.dg/Warray-parameter-6.c @@ -0,0 +1,9 @@ +/* PR c/97131 - ICE: Segmentation fault in warn_parm_ptrarray_mismatch + { dg-do compile } + { dg-options "-Wall" } */ + +struct bm { }; + +void ms (struct bm (*at)[1]) { } + +void ms (int f1) { } // { dg-error "conflicting types for 'ms'" }