summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/Expr.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/AST/Expr.cpp')
-rw-r--r--clang/lib/AST/Expr.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp
index b4de2155adce..f5ad402e3bd7 100644
--- a/clang/lib/AST/Expr.cpp
+++ b/clang/lib/AST/Expr.cpp
@@ -264,11 +264,14 @@ namespace {
}
QualType Expr::getEnumCoercedType(const ASTContext &Ctx) const {
- if (isa<EnumType>(this->getType()))
- return this->getType();
- else if (const auto *ECD = this->getEnumConstantDecl())
- return Ctx.getTypeDeclType(cast<EnumDecl>(ECD->getDeclContext()));
- return this->getType();
+ if (isa<EnumType>(getType()))
+ return getType();
+ if (const auto *ECD = getEnumConstantDecl()) {
+ const auto *ED = cast<EnumDecl>(ECD->getDeclContext());
+ if (ED->isCompleteDefinition())
+ return Ctx.getTypeDeclType(ED);
+ }
+ return getType();
}
SourceLocation Expr::getExprLoc() const {