[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
Tue Sep 24 10:35:42 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);
+ Body->setInvalidDecl();
+ } else if (Param->getIdentifier()) {
+ Diag(Param->getBeginLoc(), diag::err_param_with_void_type);
+ Body->setInvalidDecl();
+ } else if (Param->getType().hasQualifiers()) {
+ Diag(Param->getBeginLoc(), diag::err_void_param_qualified);
+ Body->setInvalidDecl();
+ }
+ }
----------------
mizvekov wrote:
Can we unify these with the parameter type checks in SemaType?
Also, it would make sense to perform the same error recovery here, which is to just adjust these parameter types
to `int`, or perhaps some other error recovery, but consistently between requires local parameters and function parameters.
I don't think it's helpful to mark the requires body as invalid, but in some scenarios we can mark the parameter itself as invalid, if needed.
https://github.com/llvm/llvm-project/pull/109831
More information about the cfe-commits
mailing list