[PATCH] D86048: [AST][RecoveryExpr] Popagate the error-bit from a VarDecl's initializer to DeclRefExpr.

Haojian Wu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 5 01:41:57 PDT 2020


This revision was automatically updated to reflect the committed changes.
Closed by commit rG3423d5c9da81: [AST][RecoveryExpr] Popagate the error-bit from a VarDecl's initializer to… (authored by hokein).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D86048/new/

https://reviews.llvm.org/D86048

Files:
  clang/lib/AST/ComputeDependence.cpp
  clang/test/Sema/invalid-member.cpp


Index: clang/test/Sema/invalid-member.cpp
===================================================================
--- clang/test/Sema/invalid-member.cpp
+++ clang/test/Sema/invalid-member.cpp
@@ -19,3 +19,11 @@
 };
 // Should be able to evaluate sizeof without crashing.
 static_assert(sizeof(Z) == 1, "No valid members");
+
+constexpr int N = undef; // expected-error {{use of undeclared identifier}}
+template<int a>
+class ABC {};
+class T {
+  ABC<N> abc;
+};
+static_assert(sizeof(T) == 1, "No valid members");
Index: clang/lib/AST/ComputeDependence.cpp
===================================================================
--- clang/lib/AST/ComputeDependence.cpp
+++ clang/lib/AST/ComputeDependence.cpp
@@ -466,10 +466,12 @@
              : 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:


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D86048.296108.patch
Type: text/x-patch
Size: 1292 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20201005/37024122/attachment.bin>


More information about the cfe-commits mailing list