================
@@ -6469,9 +6469,22 @@ bool Sema::diagnoseQualifiedDeclaration(CXXScopeSpec
&SS, DeclContext *DC,
// The cases that DC is not NamespaceDecl should be handled in
// CheckRedeclarationExported.
return false;
- } else
+ } else {
+ unsigned DCKind = diag::EnclosingDeclKind::Namespace;
+ if (auto *TD = dyn_cast<TagDecl>(DC)) {
+ if (TD->isStruct())
+ DCKind = diag::EnclosingDeclKind::Struct;
+ else if (TD->isClass())
+ DCKind = diag::EnclosingDeclKind::Class;
+ else if (TD->isUnion())
+ DCKind = diag::EnclosingDeclKind::Union;
+ else if (TD->isEnum())
+ DCKind = diag::EnclosingDeclKind::Enum;
----------------
Kristianerik wrote:
Added a union test case in `qual-id-test.cpp`. I wasn’t able to construct a
test where an enum is the declaration context, enums can’t have out-of-line
member definitions, so a different error fires first. If you know of a way to
trigger it, I’m happy to add that test. The enum and interface cases are
included to avoid compiler warnings about unhandled `TagTypeKind` values in the
switch.
https://github.com/llvm/llvm-project/pull/230630
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits