-
- Downloads
libcpp: adjust pedwarn handling
Using cpp_pedwarning (CPP_W_PEDANTIC instead of if (CPP_PEDANTIC cpp_error lets users suppress these diagnostics with #pragma GCC diagnostic ignored "-Wpedantic". This patch changes all instances of the cpp_error (CPP_DL_PEDWARN to cpp_pedwarning. In cases where the extension appears in a later C++ revision, we now condition the warning on the relevant -Wc++??-extensions flag instead of -Wpedantic; in such cases often the if (CPP_PEDANTIC) check is retained to preserve the default non-warning behavior. I didn't attempt to adjust the warning flags for the C compiler, since it seems to follow a different system than C++. The CPP_PEDANTIC check is also kept in _cpp_lex_direct to avoid an ICE in the self-tests from cb.diagnostics not being initialized. While working on testcases for these changes I noticed that the c-c++-common tests are not run with -pedantic-errors by default like the gcc.dg and g++.dg directories are. And if I specify -pedantic-errors with dg-options, the default -std= changes from c++?? to gnu++??, which interferes with some other pedwarns. So two of the tests are C++-only. libcpp/ChangeLog: * include/cpplib.h (enum cpp_warning_reason): Add CPP_W_CXX{14,17,20,23}_EXTENSIONS. * charset.cc (_cpp_valid_ucn, convert_hex, convert_oct) (convert_escape, narrow_str_to_charconst): Use cpp_pedwarning instead of cpp_error for pedwarns. * directives.cc (directive_diagnostics, _cpp_handle_directive) (do_line, do_elif): Likewise. * expr.cc (cpp_classify_number, eval_token): Likewise. * lex.cc (skip_whitespace, maybe_va_opt_error) (_cpp_lex_direct): Likewise. * macro.cc (_cpp_arguments_ok): Likewise. (replace_args): Use -Wvariadic-macros for pedwarn about empty macro arguments. gcc/c-family/ChangeLog: * c.opt: Add CppReason for Wc++{14,17,20,23}-extensions. * c-pragma.cc (handle_pragma_diagnostic_impl): Don't check OPT_Wc__23_extensions. gcc/testsuite/ChangeLog: * c-c++-common/pragma-diag-17.c: New test. * g++.dg/cpp0x/va-opt1.C: New test. * g++.dg/cpp23/named-universal-char-escape3.C: New test.
Showing
- gcc/c-family/c-pragma.cc 0 additions, 2 deletionsgcc/c-family/c-pragma.cc
- gcc/c-family/c.opt 4 additions, 4 deletionsgcc/c-family/c.opt
- gcc/testsuite/c-c++-common/pragma-diag-17.c 25 additions, 0 deletionsgcc/testsuite/c-c++-common/pragma-diag-17.c
- gcc/testsuite/g++.dg/cpp0x/va-opt1.C 18 additions, 0 deletionsgcc/testsuite/g++.dg/cpp0x/va-opt1.C
- gcc/testsuite/g++.dg/cpp23/named-universal-char-escape3.C 19 additions, 0 deletionsgcc/testsuite/g++.dg/cpp23/named-universal-char-escape3.C
- libcpp/charset.cc 35 additions, 30 deletionslibcpp/charset.cc
- libcpp/directives.cc 44 additions, 34 deletionslibcpp/directives.cc
- libcpp/expr.cc 44 additions, 33 deletionslibcpp/expr.cc
- libcpp/include/cpplib.h 4 additions, 0 deletionslibcpp/include/cpplib.h
- libcpp/lex.cc 13 additions, 11 deletionslibcpp/lex.cc
- libcpp/macro.cc 7 additions, 7 deletionslibcpp/macro.cc
Loading
Please register or sign in to comment