From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id D20823858D39; Tue, 27 Sep 2022 06:41:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D20823858D39 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1664260909; bh=k7Km2iP8BjEgzBi6xXtWLT7fBxljMTxf9Mh26hfmOTU=; h=From:To:Subject:Date:In-Reply-To:References:From; b=MqPtf/U6eck/bRfH7MSPITzWNUCv+4JOh+QmVLmg5RDFDXMUOE2AprXf/dtXT8eU/ ZadECyE7K1BCbiWIZ/qxqneQjlke9PhwS7IHadmyLpOb/UeqePGZEL/ApDKc5qTa4J Ya1sPfruuO+OtB2dRKWuBRTSDaokVhbT5KzZyWAA= From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/106651] [C++23] P1169 - static operator() Date: Tue, 27 Sep 2022 06:41:49 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: unknown X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: jakub at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D106651 --- Comment #3 from CVS Commits --- The master branch has been updated by Jakub Jelinek : https://gcc.gnu.org/g:303976a6076f2839354702fd2caa049fa7cbbdc2 commit r13-2892-g303976a6076f2839354702fd2caa049fa7cbbdc2 Author: Jakub Jelinek Date: Tue Sep 27 08:36:28 2022 +0200 c++: Implement C++23 P1169R4 - static operator() [PR106651] The following patch attempts to implement C++23 P1169R4 - static operat= or() paper's compiler side (there is some small library side too not impleme= nted yet). This allows static members as user operator() declarations and static specifier on lambdas without lambda capture. The synthetized conversion operator changes for static lambdas as it can just return the operator() static method address, doesn't need to create a t= hunk for it. The change in call.cc (joust) is to avoid ICEs because we assumed that = len could be different only if both candidates are direct calls but it can = be one direct and one indirect call, and to implement the [over.match.best.general]/1 and [over.best.ics.general] changes from the paper (implemented always as Jason is sure it doesn't make a differ= ence in C++20 and earlier unless static member function operator() or static lambda which we accept with pedwarn in earlier standards too app= ears and my testing confirmed that). 2022-09-27 Jakub Jelinek PR c++/106651 gcc/c-family/ * c-cppbuiltin.cc (c_cpp_builtins): Predefine __cpp_static_call_operator=3D202207L for C++23. gcc/cp/ * cp-tree.h (LAMBDA_EXPR_STATIC_P): Implement C++23 P1169R4 - static operator(). Define. * parser.cc (CP_PARSER_FLAGS_ONLY_MUTABLE_OR_CONSTEXPR): Docume= nt that it also allows static. (cp_parser_lambda_declarator_opt): Handle static lambda specifi= er. (cp_parser_decl_specifier_seq): Allow RID_STATIC for CP_PARSER_FLAGS_ONLY_MUTABLE_OR_CONSTEXPR. * decl.cc (grok_op_properties): If operator() isn't a method, use a different error wording, if it is static member function, allow it (for C++20 and older with a pedwarn unless it is a lambda function or template instantiation). * call.cc (joust): Don't ICE if one candidate is static member function and the other is an indirect call. If the parameter conversion on the other candidate is user defined conversion, ellipsis or bad conversion, make static member function candida= te a winner for that parameter. * lambda.cc (maybe_add_lambda_conv_op): Handle static lambdas. * error.cc (dump_lambda_function): Print static for static lamb= das. gcc/testsuite/ * g++.dg/template/error30.C: Adjust expected diagnostics. * g++.dg/cpp1z/constexpr-lambda13.C: Likewise. * g++.dg/cpp23/feat-cxx2b.C: Test __cpp_static_call_operator. * g++.dg/cpp23/static-operator-call1.C: New test. * g++.dg/cpp23/static-operator-call2.C: New test. * g++.old-deja/g++.jason/operator.C: Adjust expected diagnostic= s.=