https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117977
Bug ID: 117977 Summary: duplicated warnings output Product: gcc Version: 15.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: alexey.lapshin at espressif dot com Target Milestone: --- Test code: #include <stddef.h> #include <assert.h> #define SPI1_HOST 1 #define SPI_HOST _Pragma ("GCC warning \"use SPI1_HOST\"") SPI1_HOST #define ERROR_CHECK(x) do { \ assert(x); \ } while(0) int foo(int host_id, void *ptr) { ptr = ptr; return host_id; } void main(void) { ERROR_CHECK(foo(SPI_HOST, NULL)); } Compiling with the latest GCC (15.0) gives doubled warnings: In file included from <source>:2: <source>:5:21: warning: use SPI1_HOST 5 | #define SPI_HOST _Pragma ("GCC warning \"use SPI1_HOST\"") SPI1_HOST | ^~~~~~~ <source>:16:5: note: in expansion of macro 'ERROR_CHECK' 16 | ERROR_CHECK(foo(SPI_HOST, | ^~~~~~~~~~~ <source>:16:21: note: in expansion of macro 'SPI_HOST' 16 | ERROR_CHECK(foo(SPI_HOST, | ^~~~~~~~ <source>:5:21: warning: use SPI1_HOST 5 | #define SPI_HOST _Pragma ("GCC warning \"use SPI1_HOST\"") SPI1_HOST | ^~~~~~~ <source>:16:5: note: in expansion of macro 'ERROR_CHECK' 16 | ERROR_CHECK(foo(SPI_HOST, | ^~~~~~~~~~~ <source>:16:21: note: in expansion of macro 'SPI_HOST' 16 | ERROR_CHECK(foo(SPI_HOST, | ^~~~~~~~ This is a bit weird because the preprocessor outputs only one use of _Pragma. C++ front-end handles this as expected. https://godbolt.org/z/ov3K3h5aP