public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-2541] Use OEP_DECL_NAME when comparing VLA bounds [PR101585].
@ 2021-07-27 19:52 Martin Sebor
  0 siblings, 0 replies; only message in thread
From: Martin Sebor @ 2021-07-27 19:52 UTC (permalink / raw)
  To: gcc-cvs

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

commit r12-2541-ga0f9a5dcc3bbe6c7de499e17d201d0f2cb512649
Author: Martin Sebor <msebor@redhat.com>
Date:   Tue Jul 27 13:51:55 2021 -0600

    Use OEP_DECL_NAME when comparing VLA bounds [PR101585].
    
    Resolves:
    PR c/101585 - Bad interaction of -fsanitize=undefined and -Wvla-parameters
    
    gcc/c-family:
    
            PR c/101585
            * c-warn.c (warn_parm_ptrarray_mismatch): Use OEP_DECL_NAME.
    
    gcc/testsuite:
            PR c/101585
            * gcc.dg/Wvla-parameter-13.c: New test.

Diff:
---
 gcc/c-family/c-warn.c                    |  3 ++-
 gcc/testsuite/gcc.dg/Wvla-parameter-13.c | 18 ++++++++++++++++++
 2 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/gcc/c-family/c-warn.c b/gcc/c-family/c-warn.c
index 552a29f9944..84ad6633c96 100644
--- a/gcc/c-family/c-warn.c
+++ b/gcc/c-family/c-warn.c
@@ -3275,7 +3275,8 @@ warn_parm_ptrarray_mismatch (location_t origloc, tree curparms, tree newparms)
 	  /* Move on if the bounds look the same.  */
 	  if (!pcurbndpos && !pnewbndpos
 	      && curbnd && newbnd
-	      && operand_equal_p (curbnd, newbnd, OEP_LEXICOGRAPHIC))
+	      && operand_equal_p (curbnd, newbnd,
+				  OEP_DECL_NAME | OEP_LEXICOGRAPHIC))
 	    continue;
 
 	  if ((curbnd && TREE_CODE (curbnd) != INTEGER_CST)
diff --git a/gcc/testsuite/gcc.dg/Wvla-parameter-13.c b/gcc/testsuite/gcc.dg/Wvla-parameter-13.c
new file mode 100644
index 00000000000..f64d29c665e
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/Wvla-parameter-13.c
@@ -0,0 +1,18 @@
+/* PR c/101585 - Bad interaction of -fsanitize=undefined and -Wvla-parameters
+   { dg-do compile }
+   { dg-options "-Wall -fsanitize=undefined" } */
+
+void f1 (int n, int (*)[n]);
+void f1 (int n, int (*)[n]);            // { dg-bogus "\\\[-Wvla-parameter" }
+
+void g1 (int m, int (*)[m]);
+void g1 (int n, int (*)[n]);            // { dg-bogus "\\\[-Wvla-parameter" "pr101605" { xfail *-*-* } }
+
+void h1 (int n, int (*)[n]);
+void h1 (int n, int (*)[n + 1]);        // { dg-warning "\\\[-Wvla-parameter" }
+
+void f2 (int m, int n, int (*)[m][n]);
+void f2 (int n, int m, int (*)[n][m]);  // { dg-bogus "\\\[-Wvla-parameter" "pr101605" { xfail *-*-* } }
+
+void g2 (int m, int n, int (*)[m][n]);
+void g2 (int n, int m, int (*)[m][n]);  // { dg-warning "\\\[-Wvla-parameter" "pr101605" { xfail *-*-* } }


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

only message in thread, other threads:[~2021-07-27 19:52 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-27 19:52 [gcc r12-2541] Use OEP_DECL_NAME when comparing VLA bounds [PR101585] 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).