llvmbot wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: kadir çetinkaya (kadircet)

<details>
<summary>Changes</summary>

Fixes #<!-- -->173662 

---
Full diff: https://github.com/llvm/llvm-project/pull/175582.diff


2 Files Affected:

- (modified) clang/lib/Sema/SemaTemplateInstantiate.cpp (+5) 
- (added) clang/test/Sema/inst-with-broken-default-arg.cpp (+6) 


``````````diff
diff --git a/clang/lib/Sema/SemaTemplateInstantiate.cpp 
b/clang/lib/Sema/SemaTemplateInstantiate.cpp
index 35205f40cbcef..5577671786d39 100644
--- a/clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -3190,6 +3190,11 @@ bool Sema::SubstDefaultArgument(
            << FD << PatternExpr->getSourceRange();
   }
 
+  // Exit early if argument has error, we should've emitted the diagnostic when
+  // we constructed the default arg expr.
+  if (PatternExpr->containsErrors())
+    return true;
+
   EnterExpressionEvaluationContext EvalContext(
       *this, ExpressionEvaluationContext::PotentiallyEvaluated, Param);
   NonSFINAEContext _(*this);
diff --git a/clang/test/Sema/inst-with-broken-default-arg.cpp 
b/clang/test/Sema/inst-with-broken-default-arg.cpp
new file mode 100644
index 0000000000000..6b0794e73458b
--- /dev/null
+++ b/clang/test/Sema/inst-with-broken-default-arg.cpp
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 %s -verify
+// We expect this test to emit a diagnostic, but not crash.
+void foo() {
+  auto inner_y = [z = 0](auto inner_y, double inner_val = z) {}; // 
expected-error {{}}
+  inner_y(0);
+}

``````````

</details>


https://github.com/llvm/llvm-project/pull/175582
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to