[Clang] Raise an error on namespace aliases with qualified names. (#86122)

This commit is contained in:
Daniel M. Katz 2024-03-22 19:08:02 -04:00 committed by GitHub
parent 7fc2fbb3f1
commit 0024875417
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 14 additions and 0 deletions

View File

@ -437,6 +437,8 @@ Bug Fixes to C++ Support
- Clang's __builtin_bit_cast will now produce a constant value for records with empty bases. See:
(#GH82383)
- Fix a crash when instantiating a lambda that captures ``this`` outside of its context. Fixes (#GH85343).
- Fix an issue where a namespace alias could be defined using a qualified name (all name components
following the first `::` were ignored).
Bug Fixes to AST Handling
^^^^^^^^^^^^^^^^^^^^^^^^^

View File

@ -268,6 +268,8 @@ def err_expected_semi_after_namespace_name : Error<
"expected ';' after namespace name">;
def err_unexpected_namespace_attributes_alias : Error<
"attributes cannot be specified on namespace alias">;
def err_unexpected_qualified_namespace_alias : Error<
"namespace alias must be a single identifier">;
def err_unexpected_nested_namespace_attribute : Error<
"attributes cannot be specified on a nested namespace definition">;
def err_inline_namespace_alias : Error<"namespace alias cannot be inline">;

View File

@ -140,6 +140,14 @@ Parser::DeclGroupPtrTy Parser::ParseNamespace(DeclaratorContext Context,
SkipUntil(tok::semi);
return nullptr;
}
if (!ExtraNSs.empty()) {
Diag(ExtraNSs.front().NamespaceLoc,
diag::err_unexpected_qualified_namespace_alias)
<< SourceRange(ExtraNSs.front().NamespaceLoc,
ExtraNSs.back().IdentLoc);
SkipUntil(tok::semi);
return nullptr;
}
if (attrLoc.isValid())
Diag(attrLoc, diag::err_unexpected_namespace_attributes_alias);
if (InlineLoc.isValid())

View File

@ -47,6 +47,8 @@ namespace I {
namespace A1 { int i; }
namespace A2 = A1;
namespace A3::extra::specifiers = A2; // expected-error {{alias must be a single identifier}}
}
int f() {