[clang] [clang] Fix the local parameter of void type inside the `Requires` expression. (PR #109831)

Matheus Izvekov via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 30 16:46:23 PDT 2024


================
@@ -9509,6 +9509,19 @@ Sema::ActOnStartRequiresExpr(SourceLocation RequiresKWLoc,
   PushDeclContext(BodyScope, Body);
 
   for (ParmVarDecl *Param : LocalParameters) {
+    if (Param->getType()->isVoidType()) {
+      if (LocalParameters.size() > 1) {
+        Diag(Param->getBeginLoc(), diag::err_void_only_param);
+        Param->setInvalidDecl();
+      } else if (Param->getIdentifier()) {
+        Diag(Param->getBeginLoc(), diag::err_param_with_void_type);
+        Param->setInvalidDecl();
+      } else if (Param->getType().hasQualifiers()) {
+        Diag(Param->getBeginLoc(), diag::err_void_param_qualified);
+        Param->setInvalidDecl();
----------------
mizvekov wrote:

The error recovery which we apply for function parameters in these cases is to proceed with `int` as the parameter type, and not mark the parameters as invalid.
Why are we doing different here?

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


More information about the cfe-commits mailing list