aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorMartin Sebor <msebor@redhat.com>2020-09-23 15:02:01 -0600
committerMartin Sebor <msebor@redhat.com>2020-09-23 15:02:01 -0600
commite92779db3304bc96a6b861f87c5edde8dd4d4030 (patch)
tree952c25aeac4d9625c19a76489b8b44f1566948bd /gcc
parent37c3c297396af3229e9de35ef437f3614e0b4b87 (diff)
downloadgcc-e92779db3304bc96a6b861f87c5edde8dd4d4030.zip
gcc-e92779db3304bc96a6b861f87c5edde8dd4d4030.tar.gz
gcc-e92779db3304bc96a6b861f87c5edde8dd4d4030.tar.bz2
Avoid assuming input corresponds to valid source code (PR c/97131).
gcc/c-family/ChangeLog: PR c/97131 * c-warn.c (warn_parm_ptrarray_mismatch): Handle more invalid input. gcc/testsuite/ChangeLog: PR c/97131 * gcc.dg/Warray-parameter-6.c: New test.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/c-family/c-warn.c5
-rw-r--r--gcc/testsuite/gcc.dg/Warray-parameter-6.c9
2 files changed, 14 insertions, 0 deletions
diff --git a/gcc/c-family/c-warn.c b/gcc/c-family/c-warn.c
index d6db85b..ebd011d 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 0000000..609dac9
--- /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'" }