https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86674

            Bug ID: 86674
           Summary: -W(no)-error=invalid-pch does not affect incorrect
                    language warning
           Product: gcc
           Version: 8.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: pch
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jwyatt at feralinteractive dot com
  Target Milestone: ---

-Werror=invalid-pch does not turn warnings caused by -Winvalid-pch into errors.
-Wno-error=invalid-pch does not turn errors caused by -Winvalid-pch -Werror
into warnings.

Context:
When compiling the same prefix for multiple languages,
https://gcc.gnu.org/onlinedocs/gcc/Precompiled-Headers.html suggests that they
can all co-exist in the same folder, since the compiler will search them all
and choose the correct one. However this will cause
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=17162.

As a result, in cases where -Werror is enabled, it would be useful to turn
-Winvalid-pch back into a warning.

Example - the contents of the files are irrelevant, just use empty files if
need be:
gcc -Wall -Wextra -x c-header Prefix.h -o Prefix.h.gch/c.h
gcc -Wall -Wextra -x c++-header Prefix.h -o Prefix.h.gch/c++.h
gcc -Wall -Wextra -Winvalid-pch -Werror -Wno-error=invalid-pch -include
Prefix.h -c Test.c
gcc -Wall -Wextra -Winvalid-pch -Werror -Wno-error=invalid-pch -include
Prefix.h -c Test.cpp

This produces only the following output:
cc1plus: error: ./Prefix.h.gch/c.h: not for GNU C++14 [-Werror]
cc1plus: all warnings being treated as errors

Reply via email to