[clang] [Clang][NFC] Consolidate the parameter check for the `requires` expression parameter. (PR #110773)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Oct 1 21:15:09 PDT 2024
================
@@ -9519,15 +9519,28 @@ Sema::ActOnStartRequiresExpr(SourceLocation RequiresKWLoc,
} else if (Param->getType().hasQualifiers()) {
Diag(Param->getBeginLoc(), diag::err_void_param_qualified);
}
- }
-
- if (Param->hasDefaultArg())
+ } else if (Param->hasDefaultArg()) {
// C++2a [expr.prim.req] p4
// [...] A local parameter of a requires-expression shall not have a
// default argument. [...]
Diag(Param->getDefaultArgRange().getBegin(),
diag::err_requires_expr_local_parameter_default_argument);
- // Ignore default argument and move on
+ // Ignore default argument and move on
+ } else if (Param->isExplicitObjectParameter()) {
+ // C++23 [dcl.fct]p6:
+ // An explicit-object-parameter-declaration is a parameter-declaration
+ // with a this specifier. An explicit-object-parameter-declaration
+ // shall appear only as the first parameter-declaration of a
+ // parameter-declaration-list of either:
+ // - a member-declarator that declares a member function, or
+ // - a lambda-declarator.
+ //
+ // The parameter-declaration-list of a requires-expression is not such
+ // a context.
+ Diag(Param->getExplicitObjectParamThisLoc(),
+ diag::err_requires_expr_explicit_object_parameter);
+ Param->setExplicitObjectParameterLoc(SourceLocation());
----------------
c8ef wrote:
https://github.com/llvm/llvm-project/blob/e379094328e49731a606304f7e3559d4f1fa96f9/clang/lib/Sema/SemaType.cpp#L5175-L5179
I'm not entirely sure, but the check in function parameters do indeed perform this action.
https://github.com/llvm/llvm-project/pull/110773
More information about the cfe-commits
mailing list