Open
Description
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".