Enable inline namespaces in C++03 as an extension.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112566 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Parse/ParseDecl.cpp b/lib/Parse/ParseDecl.cpp
index 1f81202..0c68f76 100644
--- a/lib/Parse/ParseDecl.cpp
+++ b/lib/Parse/ParseDecl.cpp
@@ -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;
diff --git a/lib/Parse/ParseDeclCXX.cpp b/lib/Parse/ParseDeclCXX.cpp
index 26d460c..b277156 100644
--- a/lib/Parse/ParseDeclCXX.cpp
+++ b/lib/Parse/ParseDeclCXX.cpp
@@ -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);
diff --git a/lib/Parse/Parser.cpp b/lib/Parse/Parser.cpp
index 5405343..44bd0fb 100644
--- a/lib/Parse/Parser.cpp
+++ b/lib/Parse/Parser.cpp
@@ -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);
}