Bug 64698 - preprocessor ignores #pragma GCC diagnostic when using -save-temps
Summary: preprocessor ignores #pragma GCC diagnostic when using -save-temps
Status: RESOLVED DUPLICATE of bug 53920
Alias: None
Product: gcc
Classification: Unclassified
Component: preprocessor (show other bugs)
Version: unknown
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: diagnostic
Depends on:
Blocks:
 
Reported: 2015-01-20 20:07 UTC by Markus F.X.J. Oberhumer
Modified: 2022-06-17 18:57 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail: 11.1.0, 4.6.4
Last reconfirmed: 2015-01-20 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Markus F.X.J. Oberhumer 2015-01-20 20:07:43 UTC
This could be related to bug 53431, though this report is about C and not C++.

Actually I had thought that "-save-temps" just dumps the internal state, but that does not seem to be true.

The following code:

#pragma GCC diagnostic ignored "-Wundef"
#if FOO
#endif
int main (void) { return 42; }

compiled with 

gcc-4.9 -Wundef -Werror -save-temps -c bug_wundef.c

gives:

bug_wundef.c:2:5: error: "FOO" is not defined [-Werror=undef]
 #if FOO
     ^
cc1: all warnings being treated as errors

On the contrary

gcc-4.9 -Wundef -Werror -c bug_wundef.c

does not give any error.
Comment 1 Manuel López-Ibáñez 2015-01-20 22:40:40 UTC
Does it go through c-ppoutput.c(scan_translation_unit)? If so, this is the same issue as PR53920.
Comment 2 Markus F.X.J. Oberhumer 2021-05-27 13:15:35 UTC
Still a problem in 2021 with gcc-11.1.0
Comment 3 Lewis Hyatt 2022-06-17 18:57:08 UTC
It is indeed a dup of PR53920. Also, I have a patch awaiting review for PR53431; that fixes all 3.

*** This bug has been marked as a duplicate of bug 53920 ***