File tree 2 files changed +18
-4
lines changed
2 files changed +18
-4
lines changed Original file line number Diff line number Diff line change @@ -138,10 +138,13 @@ class ASTWalker : public RecursiveASTVisitor<ASTWalker> {
138
138
// If the ref is without a qualifier, and is a member, ignore it. As it is
139
139
// available in current context due to some other construct (e.g. base
140
140
// specifiers, using decls) that has to spell the name explicitly.
141
+ //
141
142
// If it's an enum constant, it must be due to prior decl. Report references
142
- // to it instead.
143
- if (llvm::isa<EnumConstantDecl>(FD) && !DRE->hasQualifier ())
144
- report (DRE->getLocation (), FD);
143
+ // to it when qualifier isn't a type.
144
+ if (llvm::isa<EnumConstantDecl>(FD)) {
145
+ if (!DRE->getQualifier () || DRE->getQualifier ()->getAsNamespace ())
146
+ report (DRE->getLocation (), FD);
147
+ }
145
148
return true ;
146
149
}
147
150
Original file line number Diff line number Diff line change @@ -514,9 +514,20 @@ TEST(WalkAST, Functions) {
514
514
}
515
515
516
516
TEST (WalkAST, Enums) {
517
- testWalk (" enum E { $explicit^A = 42, B = 43 };" , " int e = ^A;" );
517
+ testWalk (" enum E { $explicit^A = 42 };" , " int e = ^A;" );
518
518
testWalk (" enum class $explicit^E : int;" , " enum class ^E : int {};" );
519
519
testWalk (" enum class E : int {};" , " enum class ^E : int ;" );
520
+ testWalk (" namespace ns { enum E { $explicit^A = 42 }; }" , " int e = ns::^A;" );
521
+ testWalk (" namespace ns { enum E { A = 42 }; } using ns::E::$explicit^A;" ,
522
+ " int e = ^A;" );
523
+ testWalk (" namespace ns { enum E { A = 42 }; } using enum ns::$explicit^E;" ,
524
+ " int e = ^A;" );
525
+ testWalk (R"( namespace ns { enum E { A = 42 }; }
526
+ struct S { using enum ns::E; };)" ,
527
+ " int e = S::^A;" );
528
+ testWalk (R"( namespace ns { enum E { A = 42 }; }
529
+ struct S { using ns::E::A; };)" ,
530
+ " int e = S::^A;" );
520
531
}
521
532
522
533
TEST (WalkAST, InitializerList) {
You can’t perform that action at this time.
0 commit comments