Skip to content

Commit 41e1b10

Browse files
committed
[Clang][Sema] Check the return value of DiagnoseClassNameShadow in ActOnEnumConstant
Static analysis flagged that we were not checking the return value of DiagnoseClassNameShadow when we did so everywhere else. Modifying this case to match how other places uses it makes sense and does not change behavior. Likely if this check fails later actions will fail as well but it is more correct to exit early.
1 parent 54e72d1 commit 41e1b10

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

clang/lib/Sema/SemaDecl.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20134,9 +20134,10 @@ Decl *Sema::ActOnEnumConstant(Scope *S, Decl *theEnumDecl, Decl *lastEnumConst,
2013420134
// different from T:
2013520135
// - every enumerator of every member of class T that is an unscoped
2013620136
// enumerated type
20137-
if (getLangOpts().CPlusPlus && !TheEnumDecl->isScoped())
20138-
DiagnoseClassNameShadow(TheEnumDecl->getDeclContext(),
20139-
DeclarationNameInfo(Id, IdLoc));
20137+
if (getLangOpts().CPlusPlus && !TheEnumDecl->isScoped() &&
20138+
DiagnoseClassNameShadow(TheEnumDecl->getDeclContext(),
20139+
DeclarationNameInfo(Id, IdLoc)))
20140+
return nullptr;
2014020141

2014120142
EnumConstantDecl *New =
2014220143
CheckEnumConstant(TheEnumDecl, LastEnumConst, IdLoc, Id, Val);

0 commit comments

Comments
 (0)