Bug 55578 - Disabling warnings inside macro definition doesn't work
Summary: Disabling warnings inside macro definition doesn't work
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.6.2
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: diagnostic
: 89718 (view as bug list)
Depends on:
Blocks:
 
Reported: 2012-12-03 18:41 UTC by Ruben Adamyan
Modified: 2019-03-15 03:36 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2012-12-09 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ruben Adamyan 2012-12-03 18:41:19 UTC
When compiling following code with just -Wall option I'm getting below mentioned warning.

#define FF() \
_Pragma("GCC diagnostic push") \
_Pragma("GCC diagnostic ignored \"-Wunused-variable\"") \
{int x;} \
_Pragma("GCC diagnostic pop")

int main()
{
  FF();
  return 0;
}

In function 'int main()':
warning: unused variable 'x' [-Wunused-variable]

But when I also specify -no-integrated-cpp or -save-temps options the warning doesn't show up.

It looks like when preprocessor and compiler work in one shop the warning doesn't get disabled. BTW this happens for any warning not just with unused-variable one.

GCC version is: 4.6.2
Command line is: gcc <file-name> -Wall
System is: Linux  2.6.18-238.el5 #1 SMP Sun Dec 19 14:22:44 EST 2010 x86_64 x86_64 x86_64 GNU/Linux
Comment 1 Paolo Carlini 2012-12-05 13:07:38 UTC
Maybe Dodji can have a look.
Comment 2 Andrew Pinski 2012-12-09 00:31:40 UTC
Confirmed.  It only happens with the C++ front-end though.  The exact same code does not warn with the C front-end.  I think this might be the pre-ahead of time tokenizer that happens for the C++ front-end but does not happen for C.
Comment 3 Eric Gallager 2019-03-14 19:10:36 UTC
*** Bug 89718 has been marked as a duplicate of this bug. ***
Comment 4 Eric Gallager 2019-03-14 19:27:04 UTC
(In reply to Andrew Pinski from comment #2)
> Confirmed.  It only happens with the C++ front-end though.  The exact same
> code does not warn with the C front-end.  I think this might be the
> pre-ahead of time tokenizer that happens for the C++ front-end but does not
> happen for C.

so related to bug 53431 then