[clang] [C2y] Correctly handle incomplete types in generic selections (PR #141596)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Tue May 27 07:40:51 PDT 2025


================
@@ -1874,9 +1874,11 @@ ExprResult Sema::CreateGenericSelectionExpr(
 
         if (D != 0) {
           Diag(Types[i]->getTypeLoc().getBeginLoc(), D)
-            << Types[i]->getTypeLoc().getSourceRange()
-            << Types[i]->getType();
-          TypeErrorFound = true;
+              << Types[i]->getTypeLoc().getSourceRange() << Types[i]->getType();
+          if (getDiagnostics().getDiagnosticLevel(
----------------
AaronBallman wrote:

I think this already works the way you expect. You're basically looking for something like `DiagnosticsEngine::isIgnored()` but checking for errors rather than ignored, yes? If so, that function is implemented in terms of calling `getDiagnosticSeverity()`, but `getDiagnosticLevel()` is also implemented in terms of that as well. Both look at the actual state of the diagnostic.

https://github.com/llvm/llvm-project/pull/141596


More information about the cfe-commits mailing list