[cfe-commits] r112566 - in /cfe/trunk: include/clang/Basic/DiagnosticParseKinds.td lib/Parse/ParseDecl.cpp lib/Parse/ParseDeclCXX.cpp lib/Parse/Parser.cpp test/CXX/dcl.dcl/basic.namespace/namespace.def/p1.cpp
Sebastian Redl
sebastian.redl at getdesigned.at
Mon Aug 30 17:36:45 PDT 2010
Author: cornedbee
Date: Mon Aug 30 19:36:45 2010
New Revision: 112566
URL: http://llvm.org/viewvc/llvm-project?rev=112566&view=rev
Log:
Enable inline namespaces in C++03 as an extension.
Modified:
cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
cfe/trunk/lib/Parse/ParseDecl.cpp
cfe/trunk/lib/Parse/ParseDeclCXX.cpp
cfe/trunk/lib/Parse/Parser.cpp
cfe/trunk/test/CXX/dcl.dcl/basic.namespace/namespace.def/p1.cpp
Modified: cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td?rev=112566&r1=112565&r2=112566&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td Mon Aug 30 19:36:45 2010
@@ -154,6 +154,8 @@
"%0 declared as a reference to a reference">;
def err_rvalue_reference : Error<
"rvalue references are only allowed in C++0x">;
+def ext_inline_namespace : Extension<
+ "inline namespaces are a C++0x feature">;
def err_argument_required_after_attribute : Error<
"argument required after attribute">;
def err_missing_param : Error<"expected parameter declarator">;
Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=112566&r1=112565&r2=112566&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Mon Aug 30 19:36:45 2010
@@ -324,8 +324,8 @@
SingleDecl = ParseDeclarationStartingWithTemplate(Context, DeclEnd);
break;
case tok::kw_inline:
- // Could be the start of an inline namespace.
- if (getLang().CPlusPlus0x && NextToken().is(tok::kw_namespace)) {
+ // Could be the start of an inline namespace. Allowed as an ext in C++03.
+ if (getLang().CPlusPlus && NextToken().is(tok::kw_namespace)) {
if (Attr.HasAttr)
Diag(Attr.Range.getBegin(), diag::err_attributes_not_allowed)
<< Attr.Range;
Modified: cfe/trunk/lib/Parse/ParseDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDeclCXX.cpp?rev=112566&r1=112565&r2=112566&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseDeclCXX.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDeclCXX.cpp Mon Aug 30 19:36:45 2010
@@ -103,6 +103,10 @@
return 0;
}
+ // If we're still good, complain about inline namespaces in non-C++0x now.
+ if (!getLang().CPlusPlus0x && InlineLoc.isValid())
+ Diag(InlineLoc, diag::ext_inline_namespace);
+
// Enter a scope for the namespace.
ParseScope NamespaceScope(this, Scope::DeclScope);
Modified: cfe/trunk/lib/Parse/Parser.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/Parser.cpp?rev=112566&r1=112565&r2=112566&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/Parser.cpp (original)
+++ cfe/trunk/lib/Parse/Parser.cpp Mon Aug 30 19:36:45 2010
@@ -484,8 +484,8 @@
}
case tok::kw_inline:
- if (getLang().CPlusPlus0x && NextToken().is(tok::kw_namespace)) {
- // Inline namespaces
+ if (getLang().CPlusPlus && NextToken().is(tok::kw_namespace)) {
+ // Inline namespaces. Allowed as an extension even in C++03.
SourceLocation DeclEnd;
return ParseDeclaration(Declarator::FileContext, DeclEnd, Attr);
}
Modified: cfe/trunk/test/CXX/dcl.dcl/basic.namespace/namespace.def/p1.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/dcl.dcl/basic.namespace/namespace.def/p1.cpp?rev=112566&r1=112565&r2=112566&view=diff
==============================================================================
--- cfe/trunk/test/CXX/dcl.dcl/basic.namespace/namespace.def/p1.cpp (original)
+++ cfe/trunk/test/CXX/dcl.dcl/basic.namespace/namespace.def/p1.cpp Mon Aug 30 19:36:45 2010
@@ -1,7 +1,9 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -std=c++0x %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 -pedantic %s
+
+// Intentionally compiled as C++03 to test the extension warning.
namespace a {} // original
namespace a {} // ext
-inline namespace b {} // inline original
-inline namespace b {} // inline ext
-inline namespace {} // inline unnamed
+inline namespace b {} // inline original expected-warning {{inline namespaces are}}
+inline namespace b {} // inline ext expected-warning {{inline namespaces are}}
+inline namespace {} // inline unnamed expected-warning {{inline namespaces are}}
More information about the cfe-commits
mailing list