"%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">;
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;
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);
}
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);
}
-// 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}}