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" } */ }