else if (warn_narrowing == -1)
warn_narrowing = 0;
+ if (cxx_dialect >= cxx20)
+ {
+ /* Don't warn about C++20 compatibility changes in C++20 or later. */
+ warn_cxx20_compat = 0;
+ cpp_opts->cpp_warn_cxx20_compat = 0;
+ }
+
/* C++17 has stricter evaluation order requirements; let's use some of them
for earlier C++ as well, so chaining works as expected. */
if (c_dialect_cxx ()
C++ ObjC++ Warning Alias(Wc++20-compat) Undocumented
Wc++20-compat
-C++ ObjC++ Var(warn_cxx20_compat) Warning LangEnabledBy(C++ ObjC++,Wall)
+C++ ObjC++ Var(warn_cxx20_compat) Warning LangEnabledBy(C++ ObjC++,Wall) Init(0) CPP(cpp_warn_cxx20_compat) CppReason(CPP_W_CXX20_COMPAT)
Warn about C++ constructs whose meaning differs between ISO C++ 2017 and ISO C++ 2020.
Wc++11-extensions
/* Store the next token from the preprocessor in *TOKEN. Return true
if we reach EOF. If LEXER is NULL, assume we are handling an
initial #pragma pch_preprocess, and thus want the lexer to return
- processed strings. */
+ processed strings.
+
+ Diagnostics issued from this function must have their controlling option (if
+ any) in c.opt annotated as a libcpp option via the CppReason property. */
static void
cp_lexer_get_preprocessor_token (unsigned flags, cp_token *token)
--- /dev/null
+// { dg-do compile { target c++98_only } }
+// { dg-options "-Wc++11-compat" }
+
+// Validate suppression of -Wc++11-compat diagnostics.
+#pragma GCC diagnostic ignored "-Wc++11-compat"
+int alignof;
+int alignas;
+int constexpr;
+int decltype;
+int noexcept;
+int nullptr;
+int static_assert;
+int thread_local;
+int _Alignas;
+int _Alignof;
+int _Thread_local;
--- /dev/null
+// { dg-do compile { target c++17_down } }
+// { dg-options "-Wc++20-compat" }
+
+// Validate suppression of -Wc++20-compat diagnostics.
+#pragma GCC diagnostic ignored "-Wc++20-compat"
+int constinit;
+int consteval;
+int requires;
+int concept;
+int co_await;
+int co_yield;
+int co_return;
+int char8_t;
/* True if warn about differences between C++98 and C++11. */
bool cpp_warn_cxx11_compat;
+ /* True if warn about differences between C++17 and C++20. */
+ bool cpp_warn_cxx20_compat;
+
/* Nonzero if bidirectional control characters checking is on. See enum
cpp_bidirectional_level. */
unsigned char cpp_warn_bidirectional;
CPP_W_C90_C99_COMPAT,
CPP_W_C11_C2X_COMPAT,
CPP_W_CXX11_COMPAT,
+ CPP_W_CXX20_COMPAT,
CPP_W_EXPANSION_TO_DEFINED,
CPP_W_BIDIRECTIONAL
};
CPP_OPTION (pfile, cpp_warn_c90_c99_compat) = -1;
CPP_OPTION (pfile, cpp_warn_c11_c2x_compat) = -1;
CPP_OPTION (pfile, cpp_warn_cxx11_compat) = 0;
+ CPP_OPTION (pfile, cpp_warn_cxx20_compat) = 0;
CPP_OPTION (pfile, cpp_warn_deprecated) = 1;
CPP_OPTION (pfile, cpp_warn_long_long) = 0;
CPP_OPTION (pfile, dollars_in_ident) = 1;