diff options
author | Haojian Wu <hokein.wu@gmail.com> | 2020-10-05 10:35:29 +0200 |
---|---|---|
committer | Haojian Wu <hokein.wu@gmail.com> | 2020-10-05 10:35:29 +0200 |
commit | 3423d5c9da812b0076d1cf14e96ce453e35257b6 (patch) | |
tree | 0977511fea439eeb7737a266d34b512e71ca3d34 /clang/lib | |
parent | a3caf7f6102dc863425f9714b099af58397f0cd2 (diff) | |
download | llvm-3423d5c9da812b0076d1cf14e96ce453e35257b6.zip llvm-3423d5c9da812b0076d1cf14e96ce453e35257b6.tar.gz llvm-3423d5c9da812b0076d1cf14e96ce453e35257b6.tar.bz2 |
[AST][RecoveryExpr] Popagate the error-bit from a VarDecl's initializer to DeclRefExpr.
The error-bit was missing, if a DeclRefExpr (which refers to a VarDecl
with a contains-errors initializer).
It could cause different violations in clang -- the DeclRefExpr is value-dependent,
but not contains-errors, `ABC<DeclRefExpr>` could produce a non-error
and non-dependent type in non-template context, which will lead to
crashes in constexpr evaluation.
Reviewed By: sammccall
Differential Revision: https://reviews.llvm.org/D86048
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/AST/ComputeDependence.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/clang/lib/AST/ComputeDependence.cpp b/clang/lib/AST/ComputeDependence.cpp index 320025e..f8dfeed 100644 --- a/clang/lib/AST/ComputeDependence.cpp +++ b/clang/lib/AST/ComputeDependence.cpp @@ -466,10 +466,12 @@ ExprDependence clang::computeDependence(DeclRefExpr *E, const ASTContext &Ctx) { : Var->getType()->isIntegralOrEnumerationType()) && (Var->getType().isConstQualified() || Var->getType()->isReferenceType())) { - if (const Expr *Init = Var->getAnyInitializer()) - if (Init->isValueDependent()) { + if (const Expr *Init = Var->getAnyInitializer()) { + if (Init->isValueDependent()) Deps |= ExprDependence::ValueInstantiation; - } + if (Init->containsErrors()) + Deps |= ExprDependence::Error; + } } // (VD) - FIXME: Missing from the standard: |