[cfe-commits] r151377 - in /cfe/trunk: include/clang/Basic/DiagnosticParseKinds.td include/clang/Basic/DiagnosticSemaKinds.td lib/Parse/ParseDeclCXX.cpp lib/Sema/DeclSpec.cpp test/SemaCXX/cxx98-compat.cpp test/SemaCXX/decltype-98.cpp
Richard Smith
richard-llvm at metafoo.co.uk
Fri Feb 24 10:10:23 PST 2012
Author: rsmith
Date: Fri Feb 24 12:10:23 2012
New Revision: 151377
URL: http://llvm.org/viewvc/llvm-project?rev=151377&view=rev
Log:
__decltype is a GNU extension, not a C++11 extension.
Modified:
cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Parse/ParseDeclCXX.cpp
cfe/trunk/lib/Sema/DeclSpec.cpp
cfe/trunk/test/SemaCXX/cxx98-compat.cpp
cfe/trunk/test/SemaCXX/decltype-98.cpp
Modified: cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td?rev=151377&r1=151376&r2=151377&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td Fri Feb 24 12:10:23 2012
@@ -254,6 +254,12 @@
"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">;
Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=151377&r1=151376&r2=151377&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Feb 24 12:10:23 2012
@@ -1176,9 +1176,6 @@
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">;
Modified: cfe/trunk/lib/Parse/ParseDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDeclCXX.cpp?rev=151377&r1=151376&r2=151377&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseDeclCXX.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDeclCXX.cpp Fri Feb 24 12:10:23 2012
@@ -653,6 +653,9 @@
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);
Modified: cfe/trunk/lib/Sema/DeclSpec.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/DeclSpec.cpp?rev=151377&r1=151376&r2=151377&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/DeclSpec.cpp (original)
+++ cfe/trunk/lib/Sema/DeclSpec.cpp Fri Feb 24 12:10:23 2012
@@ -898,8 +898,6 @@
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);
Modified: cfe/trunk/test/SemaCXX/cxx98-compat.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx98-compat.cpp?rev=151377&r1=151376&r2=151377&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/cxx98-compat.cpp (original)
+++ cfe/trunk/test/SemaCXX/cxx98-compat.cpp Fri Feb 24 12:10:23 2012
@@ -99,6 +99,7 @@
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}}
Modified: cfe/trunk/test/SemaCXX/decltype-98.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/decltype-98.cpp?rev=151377&r1=151376&r2=151377&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/decltype-98.cpp (original)
+++ cfe/trunk/test/SemaCXX/decltype-98.cpp Fri Feb 24 12:10:23 2012
@@ -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}}
More information about the cfe-commits
mailing list