On 2/19/20 1:02 AM, Martin Sebor wrote:
PR 93804 points out that issuing -Wredundant-tags for declarations
in C headers included in C++ isn't helpful because the tags cannot
be removed without breaking C programs that depend on the headers.

Attached is a patch that avoids the warning in these cases tested
on x86_64-linux.  While strictly not a regression (and even though
I initially considered it a GCC 11 enhancement), since most C++
code includes some C headers, without the patch the warning would
likely cause too much noise to be widely useful.

+      const line_map_ordinary *map = NULL;
+      linemap_resolve_location (line_table, key_loc,
+                               LRK_MACRO_DEFINITION_LOCATION,
+                               &map);
+      if (!MAIN_FILE_P (map))
+       key_redundant = false;

Checking which file it came from seems like unnecessary complication; is it important to still warn in extern "C" blocks in the main source file?

Jason

Reply via email to