Skip to content

Incompatible behavior and warning for '#pragma GCC diagnostic pop' with no corresponding push #23065

Open
@llvmbot

Description

@llvmbot
Bugzilla Link 22691
Version 3.4
OS Linux
Reporter LLVM Bugzilla Contributor
CC @DougGregor

Extended Description

https://gcc.gnu.org/onlinedocs/gcc/Diagnostic-Pragmas.html states that "if a pop has no matching push, the command-line options are restored". This matches the actual behavior for GCC (provided you extend it to also mean that defaults are restored for things not specified on the command-line, which makes sense).

In clang, a pop without a corresponding push generates a warning and does not seem to restore warnings.

Test case:

void f(void) {
#pragma GCC diagnostic ignored "-Wunused-value"
    0;
#pragma GCC diagnostic pop
    0;
}

GCC generates a warning for the second '0;'. clang only generates a "warning: pragma diagnostic pop could not pop, no matching push".

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugzillaIssues migrated from bugzillaclang:frontendLanguage frontend issues, e.g. anything involving "Sema"confirmedVerified by a second party

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions