summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Redl <sebastian.redl@getdesigned.at>2010-08-31 00:36:45 +0000
committerSebastian Redl <sebastian.redl@getdesigned.at>2010-08-31 00:36:45 +0000
commit5a5f2c76b6f70c207df50ebb6c7c467cc9e64407 (patch)
tree170a56854aa886bc6bf8c88c95e2f3f1e638d9ab
parent35034569c708f0e01fc28e260b340c0b58a277d8 (diff)
downloadbcm5719-llvm-5a5f2c76b6f70c207df50ebb6c7c467cc9e64407.tar.gz
bcm5719-llvm-5a5f2c76b6f70c207df50ebb6c7c467cc9e64407.zip
Enable inline namespaces in C++03 as an extension.
llvm-svn: 112566
-rw-r--r--clang/include/clang/Basic/DiagnosticParseKinds.td2
-rw-r--r--clang/lib/Parse/ParseDecl.cpp4
-rw-r--r--clang/lib/Parse/ParseDeclCXX.cpp4
-rw-r--r--clang/lib/Parse/Parser.cpp4
-rw-r--r--clang/test/CXX/dcl.dcl/basic.namespace/namespace.def/p1.cpp10
5 files changed, 16 insertions, 8 deletions
diff --git a/clang/include/clang/Basic/DiagnosticParseKinds.td b/clang/include/clang/Basic/DiagnosticParseKinds.td
index d9d5014476a..646fd0d1bfb 100644
--- a/clang/include/clang/Basic/DiagnosticParseKinds.td
+++ b/clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -154,6 +154,8 @@ def err_illegal_decl_reference_to_reference : Error<
"%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">;
diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp
index 1f81202f014..0c68f7664e6 100644
--- a/clang/lib/Parse/ParseDecl.cpp
+++ b/clang/lib/Parse/ParseDecl.cpp
@@ -324,8 +324,8 @@ Parser::DeclGroupPtrTy Parser::ParseDeclaration(unsigned Context,
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/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp
index 26d460c6ffb..b277156a0d0 100644
--- a/clang/lib/Parse/ParseDeclCXX.cpp
+++ b/clang/lib/Parse/ParseDeclCXX.cpp
@@ -103,6 +103,10 @@ Decl *Parser::ParseNamespace(unsigned Context,
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/clang/lib/Parse/Parser.cpp b/clang/lib/Parse/Parser.cpp
index 54053435322..44bd0fbc0c0 100644
--- a/clang/lib/Parse/Parser.cpp
+++ b/clang/lib/Parse/Parser.cpp
@@ -484,8 +484,8 @@ Parser::DeclGroupPtrTy Parser::ParseExternalDeclaration(CXX0XAttributeList Attr,
}
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);
}
diff --git a/clang/test/CXX/dcl.dcl/basic.namespace/namespace.def/p1.cpp b/clang/test/CXX/dcl.dcl/basic.namespace/namespace.def/p1.cpp
index 04584dace9a..6ffa873cd46 100644
--- a/clang/test/CXX/dcl.dcl/basic.namespace/namespace.def/p1.cpp
+++ b/clang/test/CXX/dcl.dcl/basic.namespace/namespace.def/p1.cpp
@@ -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}}
OpenPOWER on IntegriCloud