In GCC, `#pragma GCC diagnostic warning "-Wfoo"` overrides command-line
`-Werror=foo` and errors that can become warnings (pedwarn with
-pedantic-errors and permerror).
```
#pragma GCC diagnostic warning "-Wnarrowing"
int x = {4.2};
#pragma GCC diagnostic warning "-Wundef"
#if FOO
#endif
// gcc -c -Werror=undef -Werror=narrowing => two warnings
```
These diagnostics are similar to our Warning/ExtWarn/Extension
diagnostics with DefaultError. This patch ports the behavior to Clang.
Fix #93474
Pull Request: https://github.com/llvm/llvm-project/pull/93647
13 lines
298 B
C++
13 lines
298 B
C++
#ifdef USE_PRAGMA
|
|
#pragma clang diagnostic push
|
|
#if USE_PRAGMA == 1
|
|
#pragma clang diagnostic warning "-Wshorten-64-to-32"
|
|
#else
|
|
#pragma clang diagnostic error "-Wshorten-64-to-32"
|
|
#endif
|
|
#endif
|
|
template <class T> int convert(T V) { return V; }
|
|
#ifdef USE_PRAGMA
|
|
#pragma clang diagnostic pop
|
|
#endif
|