Skip to content

Commit 290f5b5

Browse files
authored
[clang] fix using enum redecl in template regression (#159996)
This fixes a regression reported here: #155313 (comment) Since this regression was never released, there are no release notes.
1 parent f65d5a7 commit 290f5b5

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

clang/lib/Sema/SemaCXXScopeSpec.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,10 +220,11 @@ bool Sema::RequireCompleteDeclContext(CXXScopeSpec &SS,
220220
///
221221
bool Sema::RequireCompleteEnumDecl(EnumDecl *EnumD, SourceLocation L,
222222
CXXScopeSpec *SS) {
223-
if (EnumD->isCompleteDefinition()) {
223+
if (EnumDecl *Def = EnumD->getDefinition();
224+
Def && Def->isCompleteDefinition()) {
224225
// If we know about the definition but it is not visible, complain.
225226
NamedDecl *SuggestedDef = nullptr;
226-
if (!hasReachableDefinition(EnumD, &SuggestedDef,
227+
if (!hasReachableDefinition(Def, &SuggestedDef,
227228
/*OnlyNeedComplete*/ false)) {
228229
// If the user is going to see an error here, recover by making the
229230
// definition visible.

clang/test/SemaCXX/cxx20-using-enum.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,4 +288,14 @@ struct S {
288288
};
289289
};
290290
}
291+
292+
namespace Redecl {
293+
enum class A : int { X };
294+
enum class A : int;
295+
template <class> struct B {
296+
using enum A;
297+
using Z = decltype(X);
298+
};
299+
template struct B<int>;
300+
} // namespace Redecl
291301
#endif

0 commit comments

Comments
 (0)