mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-19 13:16:46 +00:00
[Clang] Raise an error on namespace aliases with qualified names. (#86122)
This commit is contained in:
parent
7fc2fbb3f1
commit
0024875417
@ -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
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -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">;
|
||||
|
@ -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())
|
||||
|
@ -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() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user