[cfe-commits] r141999 - in /cfe/trunk: include/clang/Basic/DiagnosticParseKinds.td lib/Parse/ParseDeclCXX.cpp test/SemaCXX/cxx98-compat.cpp
Richard Smith
richard-llvm at metafoo.co.uk
Fri Oct 14 13:48:27 PDT 2011
Author: rsmith
Date: Fri Oct 14 15:48:27 2011
New Revision: 141999
URL: http://llvm.org/viewvc/llvm-project?rev=141999&view=rev
Log:
-Wc++98-compat: warn on C++11 attributes and alignas.
Modified:
cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
cfe/trunk/lib/Parse/ParseDeclCXX.cpp
cfe/trunk/test/SemaCXX/cxx98-compat.cpp
Modified: cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td?rev=141999&r1=141998&r2=141999&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td Fri Oct 14 15:48:27 2011
@@ -371,6 +371,11 @@
"'= %select{default|delete}0' is a function definition and must occur in a "
"standalone declaration">;
+def warn_cxx98_compat_alignas : Warning<"'alignas' is incompatible with C++98">,
+ InGroup<CXX98Compat>, DefaultIgnore;
+def warn_cxx98_compat_attribute : Warning<
+ "attributes are incompatible with C++98">,
+ InGroup<CXX98Compat>, DefaultIgnore;
def err_cxx0x_attribute_forbids_arguments : Error<
"C++11 attribute '%0' cannot have an argument list">;
def err_cxx0x_attribute_requires_arguments : Error<
Modified: cfe/trunk/lib/Parse/ParseDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDeclCXX.cpp?rev=141999&r1=141998&r2=141999&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseDeclCXX.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDeclCXX.cpp Fri Oct 14 15:48:27 2011
@@ -2622,6 +2622,7 @@
void Parser::ParseCXX0XAttributeSpecifier(ParsedAttributes &attrs,
SourceLocation *endLoc) {
if (Tok.is(tok::kw_alignas)) {
+ Diag(Tok.getLocation(), diag::warn_cxx98_compat_alignas);
ParseAlignmentSpecifier(attrs, endLoc);
return;
}
@@ -2629,6 +2630,8 @@
assert(Tok.is(tok::l_square) && NextToken().is(tok::l_square)
&& "Not a C++0x attribute list");
+ Diag(Tok.getLocation(), diag::warn_cxx98_compat_attribute);
+
ConsumeBracket();
ConsumeBracket();
Modified: cfe/trunk/test/SemaCXX/cxx98-compat.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx98-compat.cpp?rev=141999&r1=141998&r2=141999&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/cxx98-compat.cpp (original)
+++ cfe/trunk/test/SemaCXX/cxx98-compat.cpp Fri Oct 14 15:48:27 2011
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -std=c++0x -Wc++98-compat -verify %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 -Wc++98-compat -verify %s
template<typename ...T> // expected-warning {{variadic templates are incompatible with C++98}}
class Variadic1 {};
@@ -8,3 +8,6 @@
template<int ...I> // expected-warning {{variadic templates are incompatible with C++98}}
class Variadic3 {};
+
+int alignas(8) with_alignas; // expected-warning {{'alignas' is incompatible with C++98}}
+int with_attribute [[ ]]; // expected-warning {{attributes are incompatible with C++98}}
More information about the cfe-commits
mailing list