Issue 129746
Summary `-isystem` does not suppress warnings from macros
Labels new issue
Assignees
Reporter elbeno
    Given a header `provoke_warning.hpp`:
```cpp
enum struct E { A, B, C };

namespace N {
 using enum E;
}

#define PROVOKE_WARNING using enum E;
```

And a source file `main.cpp`:
```cpp
#include <provoke_warning.hpp>

struct S {
  PROVOKE_WARNING;
};
```

When compile with:
`clang -std=c++17 -isystem . -c main.cpp`

We get:
```console
main.cpp:4:3: warning: using enum declaration is a C++20 extension [-Wc++20-extensions]
    4 | PROVOKE_WARNING;
      |   ^
./provoke_warning.hpp:7:31: note: expanded from macro 'PROVOKE_WARNING'
    7 | #define PROVOKE_WARNING using enum E;
 |                               ^ 
```

Notice that the warning we _would_ get from the `using enum` inside the namespace is not emitted (because of `-isystem`). However the use of the macro still gives a warning despite the fact that the macro came from a header included under `-isystem`.

--

I see why this could be difficult to remedy, and I already see the counterarguments: "it's a macro! It's in your code, not the library code!" So it's understandable why this happens, but that doesn't make it correct or expected.

This comes up in real code: https://github.com/catchorg/Catch2/issues/2910

_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to