diff options
-rw-r--r-- | clang/include/clang/Basic/DiagnosticParseKinds.td | 6 | ||||
-rw-r--r-- | clang/include/clang/Basic/DiagnosticSemaKinds.td | 3 | ||||
-rw-r--r-- | clang/lib/Parse/ParseDeclCXX.cpp | 3 | ||||
-rw-r--r-- | clang/lib/Sema/DeclSpec.cpp | 2 | ||||
-rw-r--r-- | clang/test/SemaCXX/cxx98-compat.cpp | 1 | ||||
-rw-r--r-- | clang/test/SemaCXX/decltype-98.cpp | 4 |
6 files changed, 12 insertions, 7 deletions
diff --git a/clang/include/clang/Basic/DiagnosticParseKinds.td b/clang/include/clang/Basic/DiagnosticParseKinds.td index 3fd7e90083a..b3f2067ff68 100644 --- a/clang/include/clang/Basic/DiagnosticParseKinds.td +++ b/clang/include/clang/Basic/DiagnosticParseKinds.td @@ -254,6 +254,12 @@ def err_missing_comma_before_ellipsis : Error< "C requires a comma prior to the ellipsis in a variadic function type">; def err_unexpected_typedef_ident : Error< "unexpected type name %0: expected identifier">; +def ext_gnu_decltype : Extension< + "'__decltype' type specifier is a GNU extension">, + InGroup<GNU>, DefaultIgnore; +def warn_cxx98_compat_decltype : Warning< + "'decltype' type specifier is incompatible with C++98">, + InGroup<CXX98Compat>, DefaultIgnore; def err_unexpected_scope_on_base_decltype : Error< "unexpected namespace scope prior to decltype">; def err_expected_class_name : Error<"expected class name">; diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index bfece366f14..b961e0961a3 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -1176,9 +1176,6 @@ def warn_cxx98_compat_temp_copy : Warning< InGroup<CXX98CompatBindToTemporaryCopy>, DefaultIgnore; // C++11 decltype -def warn_cxx98_compat_decltype : Warning< - "'decltype' type specifier is incompatible with C++98">, - InGroup<CXX98Compat>, DefaultIgnore; def err_decltype_in_declarator : Error< "'decltype' cannot be used to name a declaration">; diff --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp index c2bf54db2cd..5468700bc92 100644 --- a/clang/lib/Parse/ParseDeclCXX.cpp +++ b/clang/lib/Parse/ParseDeclCXX.cpp @@ -653,6 +653,9 @@ SourceLocation Parser::ParseDecltypeSpecifier(DeclSpec &DS) { return EndLoc; } } else { + Diag(Tok, Tok.getIdentifierInfo()->isStr("decltype") + ? diag::warn_cxx98_compat_decltype : diag::ext_gnu_decltype); + ConsumeToken(); BalancedDelimiterTracker T(*this, tok::l_paren); diff --git a/clang/lib/Sema/DeclSpec.cpp b/clang/lib/Sema/DeclSpec.cpp index 11818f6fa24..72a51bc474c 100644 --- a/clang/lib/Sema/DeclSpec.cpp +++ b/clang/lib/Sema/DeclSpec.cpp @@ -898,8 +898,6 @@ void DeclSpec::Finish(DiagnosticsEngine &D, Preprocessor &PP) { if (TypeSpecType == TST_char16 || TypeSpecType == TST_char32) Diag(D, TSTLoc, diag::warn_cxx98_compat_unicode_type) << (TypeSpecType == TST_char16 ? "char16_t" : "char32_t"); - if (TypeSpecType == TST_decltype) - Diag(D, TSTLoc, diag::warn_cxx98_compat_decltype); if (Constexpr_specified) Diag(D, ConstexprLoc, diag::warn_cxx98_compat_constexpr); diff --git a/clang/test/SemaCXX/cxx98-compat.cpp b/clang/test/SemaCXX/cxx98-compat.cpp index b7abe266f2d..879c72211d1 100644 --- a/clang/test/SemaCXX/cxx98-compat.cpp +++ b/clang/test/SemaCXX/cxx98-compat.cpp @@ -99,6 +99,7 @@ char16_t c16 = 0; // expected-warning {{'char16_t' type specifier is incompatibl char32_t c32 = 0; // expected-warning {{'char32_t' type specifier is incompatible with C++98}} constexpr int const_expr = 0; // expected-warning {{'constexpr' specifier is incompatible with C++98}} decltype(const_expr) decl_type = 0; // expected-warning {{'decltype' type specifier is incompatible with C++98}} +__decltype(const_expr) decl_type2 = 0; // ok void no_except() noexcept; // expected-warning {{noexcept specifications are incompatible with C++98}} bool no_except_expr = noexcept(1 + 1); // expected-warning {{noexcept expressions are incompatible with C++98}} void *null = nullptr; // expected-warning {{'nullptr' is incompatible with C++98}} diff --git a/clang/test/SemaCXX/decltype-98.cpp b/clang/test/SemaCXX/decltype-98.cpp index db52565e6c7..44d5896c53e 100644 --- a/clang/test/SemaCXX/decltype-98.cpp +++ b/clang/test/SemaCXX/decltype-98.cpp @@ -1,3 +1,3 @@ -// RUN: %clang_cc1 -std=c++98 -fsyntax-only -verify %s +// RUN: %clang_cc1 -std=c++98 -fsyntax-only -verify %s -Wgnu extern int x; -__decltype(1) x = 3; +__decltype(1) x = 3; // expected-warning {{is a GNU extension}} |