public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Do not erase warning data in gimple_set_location
@ 2022-06-10 10:57 Eric Botcazou
  2022-06-12 15:38 ` Jeff Law
  2022-06-13 11:15 ` Richard Biener
  0 siblings, 2 replies; 6+ messages in thread
From: Eric Botcazou @ 2022-06-10 10:57 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 555 bytes --]

Hi,

gimple_set_location is mostly invoked on newly built GIMPLE statements, so 
their location is UNKNOWN_LOCATION and setting it will clobber the warning 
data of the passed location, if any.

Tested on x86-64/Linux, OK for mainline and 12 branch?


2022-06-10  Eric Botcazou  <ebotcazou@adacore.com>

	* gimple.h (gimple_set_location): Do not copy warning data from
	the previous location when it is UNKNOWN_LOCATION.


2022-06-10  Eric Botcazou  <ebotcazou@adacore.com>

testsuite/
	* c-c++-common/nonnull-1.c: Remove XFAIL for C++.

-- 
Eric Botcazou

[-- Attachment #2: p.diff --]
[-- Type: text/x-patch, Size: 986 bytes --]

diff --git a/gcc/gimple.h b/gcc/gimple.h
index 6b1e89ad74e..870629cd562 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -1913,7 +1913,8 @@ static inline void
 gimple_set_location (gimple *g, location_t location)
 {
   /* Copy the no-warning data to the statement location.  */
-  copy_warning (location, g->location);
+  if (g->location != UNKNOWN_LOCATION)
+    copy_warning (location, g->location);
   g->location = location;
 }
 
diff --git a/gcc/testsuite/c-c++-common/nonnull-1.c b/gcc/testsuite/c-c++-common/nonnull-1.c
index ea987365302..7be4e3479dd 100644
--- a/gcc/testsuite/c-c++-common/nonnull-1.c
+++ b/gcc/testsuite/c-c++-common/nonnull-1.c
@@ -30,5 +30,5 @@ func (char *cp1, char *cp2, char *cp3, char *cp4)
 __attribute__((nonnull (1))) int
 func2 (char *cp)
 {
-  return (cp != NULL) ? 1 : 0; /* { dg-warning "'nonnull' argument" "cp compared to NULL" { xfail c++ } } */
+  return (cp != NULL) ? 1 : 0; /* { dg-warning "'nonnull' argument" "cp compared to NULL" } */
 }

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-06-14 13:33 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-10 10:57 [PATCH] Do not erase warning data in gimple_set_location Eric Botcazou
2022-06-12 15:38 ` Jeff Law
2022-06-13 11:15 ` Richard Biener
2022-06-13 15:39   ` Martin Sebor
2022-06-14 10:49   ` Eric Botcazou
2022-06-14 13:33     ` Richard Biener

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).