-
- Downloads
c++: Fix pragma suppression of -Wc++20-compat diagnostics [PR106423]
Gcc's '#pragma GCC diagnostic' directives are processed in "early mode" (see handle_pragma_diagnostic_early) for the C++ frontend and, as such, require that the target diagnostic option be enabled for the preprocessor (see c_option_is_from_cpp_diagnostics). This change modifies the -Wc++20-compat option definition to register it as a preprocessor option so that its associated diagnostics can be suppressed. The changes also implicitly disable the option in C++20 and later modes. These changes are consistent with the definition of the -Wc++11-compat option. This support is motivated by the need to suppress the following diagnostic otherwise issued in C++17 and earlier modes due to the char8_t typedef present in the uchar.h header file in glibc 2.36. warning: identifier ‘char8_t’ is a keyword in C++20 [-Wc++20-compat] Tests are added to validate suppression of both -Wc++11-compat and -Wc++20-compat related diagnostics (fixes were only needed for the C++20 case). PR c++/106423 gcc/c-family/ChangeLog: * c-opts.cc (c_common_post_options): Disable -Wc++20-compat diagnostics in C++20 and later. * c.opt (Wc++20-compat): Enable hooks for the preprocessor. gcc/cp/ChangeLog: * parser.cc (cp_lexer_saving_tokens): Add comment regarding diagnostic requirements. gcc/testsuite/ChangeLog: * g++.dg/cpp0x/keywords2.C: New test. * g++.dg/cpp2a/keywords2.C: New test. libcpp/ChangeLog: * include/cpplib.h (cpp_warning_reason): Add CPP_W_CXX20_COMPAT. * init.cc (cpp_create_reader): Add cpp_warn_cxx20_compat.
Showing
- gcc/c-family/c-opts.cc 7 additions, 0 deletionsgcc/c-family/c-opts.cc
- gcc/c-family/c.opt 1 addition, 1 deletiongcc/c-family/c.opt
- gcc/cp/parser.cc 4 additions, 1 deletiongcc/cp/parser.cc
- gcc/testsuite/g++.dg/cpp0x/keywords2.C 16 additions, 0 deletionsgcc/testsuite/g++.dg/cpp0x/keywords2.C
- gcc/testsuite/g++.dg/cpp2a/keywords2.C 13 additions, 0 deletionsgcc/testsuite/g++.dg/cpp2a/keywords2.C
- libcpp/include/cpplib.h 4 additions, 0 deletionslibcpp/include/cpplib.h
- libcpp/init.cc 1 addition, 0 deletionslibcpp/init.cc
Loading
Please register or sign in to comment