From patchwork Wed Mar 15 22:29:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 1757622 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=g4k+39CL; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PcQ7S36Cqz246q for ; Thu, 16 Mar 2023 09:29:54 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7E94B385800A for ; Wed, 15 Mar 2023 22:29:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7E94B385800A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1678919392; bh=W4HBuE3O4ve1WwEocyCGmyGQBkmGc63CjoWWezTDoW8=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=g4k+39CLiJYUT+NrtxMr907pl9Zr7V1TadduAuaZrXr+jxH5TWyw5LsNKtKK9Z+Gf 6qAxUZ4MQ5WYdgQREM8ChG+cW5VRnd+ASEuGSQAJ/LxLa8xuK8HwGzhDY99VpeBw9H xcxtuPCg+s16prsVw4l31ytNzRXcP+zxxeacTbJk= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id A7E823858C83 for ; Wed, 15 Mar 2023 22:29:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A7E823858C83 Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-329-scKVoSxkNRqmtdgwnmlyDw-1; Wed, 15 Mar 2023 18:29:27 -0400 X-MC-Unique: scKVoSxkNRqmtdgwnmlyDw-1 Received: by mail-qk1-f199.google.com with SMTP id b34-20020a05620a272200b007460c05a463so1612311qkp.1 for ; Wed, 15 Mar 2023 15:29:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678919367; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=W4HBuE3O4ve1WwEocyCGmyGQBkmGc63CjoWWezTDoW8=; b=cslG9xaLkwwbe7xMnO22ipnxAQTO3p6Xs6p7HqlZOYWjVMnSw2qeanHQhpxuAImJT2 FBBmq/sNBXRxjG1KBNlw35suSfZs6inNqqdYP3Th46hFb++lpJ3lOW0p8uQAuivyByxo dw3mtaqc1NhgL68dRoBZXecctaqw+bgTTgA7FyR0S2WTwvvbKVuocl49uVIbJ1etgGdC AvkBMRP7zxEV/E1KAeVQdEttmGSIh70XTLuzbHlok65+xLdFTXQh4gOW3Gs4rj5hr/Fv DsXct+27UiP53tvMfHOUUYJHR7mcIkviZnegGS7ig0uFlM24PxDeTj6vVqp9HjscCjbJ iq4A== X-Gm-Message-State: AO0yUKUQJ6PUqjQP6zyI+OcKJI7A7bzpCy5Err0H44oe/uvDlOSjisDo UM/N6ivDCBXMIl3m0q+EzNJKXwl+vViokGPtDHAZIHnboc8unE0i1yXu0dqcw3dDC3vfHdq/kDn M/ydCRa4efzZaXtmFp5PA3CMv/DdscJUseB3m6fOvlG8yw81bovxnrM0anWkbvJOV+unKlsoScQ == X-Received: by 2002:a05:6214:124e:b0:56e:b3dc:fe8c with SMTP id r14-20020a056214124e00b0056eb3dcfe8cmr31985538qvv.28.1678919366700; Wed, 15 Mar 2023 15:29:26 -0700 (PDT) X-Google-Smtp-Source: AK7set+gf6gA4tQyK8459OpwphG5TI2VEJ0mynKsv43rOensc7eV4SRVeIekWUswXjpKr/DdoJgqmA== X-Received: by 2002:a05:6214:124e:b0:56e:b3dc:fe8c with SMTP id r14-20020a056214124e00b0056eb3dcfe8cmr31985509qvv.28.1678919366233; Wed, 15 Mar 2023 15:29:26 -0700 (PDT) Received: from jason.cygnus.com (130-44-159-43.s15913.c3-0.arl-cbr1.sbo-arl.ma.cable.rcncustomer.com. [130.44.159.43]) by smtp.gmail.com with ESMTPSA id 18-20020a370312000000b00745b3e62006sm4664421qkd.23.2023.03.15.15.29.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Mar 2023 15:29:25 -0700 (PDT) To: gcc-patches@gcc.gnu.org Cc: Iain Sandoe Subject: [pushed] c++: co_await and initializer_list [PR103871] Date: Wed, 15 Mar 2023 18:29:23 -0400 Message-Id: <20230315222923.846553-1-jason@redhat.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jason Merrill via Gcc-patches From: Jason Merrill Reply-To: Jason Merrill Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" Tested x86_64-pc-linux-gnu, applying to trunk. -- 8< -- When flatten_await_stmt processes the backing array for an initializer_list, we call cp_build_modify_expr to initialize the promoted variable from the TARGET_EXPR; that needs to be accepted. PR c++/103871 PR c++/98056 gcc/cp/ChangeLog: * typeck.cc (cp_build_modify_expr): Allow array initialization of DECL_ARTIFICIAL variable. gcc/testsuite/ChangeLog: * g++.dg/coroutines/co-await-initlist1.C: New test. --- gcc/cp/typeck.cc | 2 ++ .../g++.dg/coroutines/co-await-initlist1.C | 21 +++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 gcc/testsuite/g++.dg/coroutines/co-await-initlist1.C base-commit: 57052c6ed59c1a2ee4a67982f960e08593956955 diff --git a/gcc/cp/typeck.cc b/gcc/cp/typeck.cc index d5a3e501d8e..afb956087ce 100644 --- a/gcc/cp/typeck.cc +++ b/gcc/cp/typeck.cc @@ -9630,6 +9630,8 @@ cp_build_modify_expr (location_t loc, tree lhs, enum tree_code modifycode, } /* Allow array assignment in compiler-generated code. */ + else if (DECL_P (lhs) && DECL_ARTIFICIAL (lhs)) + /* OK, used by coroutines (co-await-initlist1.C). */; else if (!current_function_decl || !DECL_DEFAULTED_FN (current_function_decl)) { diff --git a/gcc/testsuite/g++.dg/coroutines/co-await-initlist1.C b/gcc/testsuite/g++.dg/coroutines/co-await-initlist1.C new file mode 100644 index 00000000000..b8e8923a9c8 --- /dev/null +++ b/gcc/testsuite/g++.dg/coroutines/co-await-initlist1.C @@ -0,0 +1,21 @@ +// PR c++/103871 +// { dg-do compile { target c++20 } } + +#include +#include + +struct my_coro { + struct promise_type { + my_coro get_return_object(); + std::suspend_never initial_suspend(); + std::suspend_never final_suspend() noexcept; + void unhandled_exception(); + }; +}; + +std::suspend_never inner(std::initializer_list); + +my_coro doesnt_work() +{ + co_await inner({ 1,2,3 }); +}