================
@@ -8499,23 +8498,63 @@ Decl *Sema::ActOnConceptDefinition(
     NewDecl->setInvalidDecl();
   }
 
+  DeclarationNameInfo NameInfo(NewDecl->getDeclName(), NewDecl->getBeginLoc());
+  LookupResult Previous(*this, NameInfo, LookupOrdinaryName,
+                        forRedeclarationInCurContext());
+  LookupName(Previous, S);
+  FilterLookupForScope(Previous, CurContext, S, /*ConsiderLinkage=*/false,
+                       /*AllowInlineNamespace*/ false);
+
+  // We cannot properly handle redeclarations until we parse the constraint
+  // expression, so only inject the name if we are sure we are not redeclaring 
a
+  // symbol
+  if (Previous.empty())
+    PushOnScopeChains(NewDecl, S, true);
----------------
zyn0217 wrote:

We need to restore the scope chain outside of 
`Sema::ActOnStartConceptDefinition()` if the later parsed requires expression 
turns out to be invalid. Otherwise, the use of the concept would still find the 
invalid concept Decl, and since the declaration doesn't have the expression 
anymore, we would run into crashes in evaluation.

https://github.com/llvm/llvm-project/pull/103867
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to