From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2a07:de40:b251:101:10:150:64:1]) by sourceware.org (Postfix) with ESMTPS id ED90F388A419 for ; Wed, 10 Apr 2024 16:43:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org ED90F388A419 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org ED90F388A419 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a07:de40:b251:101:10:150:64:1 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712767402; cv=none; b=almdnvH7G+6FW9YzhXCFMWAsIn/pENBcQrv7zElnqtiJmbMJU62T1AeKboDveiz9M16twfyHIIgMOiAMNxANH1cBmh7gx4HCZlhG+qGprxihJd3IdHc9ytkq5jkDLaH059Rvxzf2mhhvj116BZvrpUYJ4CM66xrZ9ZW0qCHjwPE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712767402; c=relaxed/simple; bh=BAKfbSH7jMTB+QToHh0XHFRd4PsX0jeaUaJhwOfU9C8=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:Date: From:To:Subject:MIME-Version:Message-Id; b=GizUEYInsVSViYAlef/KsT2E8vgr1cVnI5j4R3/l+KxvVkc5Ot1bRlpNQ0X9REi+Lo/ll20X7Zgvq0/lkdjy+7xUVh0r86OtORv40z1n4TSs+5h2pZ57zwQXkSNOeNydLFWEfg6eUd3+FHCWkD3wbATH2WV+CHGfOMyFFsKegEk= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 21FDE3466B; Wed, 10 Apr 2024 16:43:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1712767388; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type; bh=tYjACmFkaLKhOmlBgdVPaDQ9giNn/R5Q9O857sN6m5g=; b=uAUYiPrDI4rqwmDPM39xX8aUPehk/9sqUdG9jtkS2vsfCtKLkXbdmQwLFEbVwnmm38tU8y W5h42qRiw7H6mwfohWvtQnhk/rF8zMCeTNtrkikBHfUAgWVbkOT7vCJLoih0A0X0VyIKsy HYKWei3rU4fCrEz6X2Tse7tyr6NmVQI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1712767388; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type; bh=tYjACmFkaLKhOmlBgdVPaDQ9giNn/R5Q9O857sN6m5g=; b=l8/BEEnkI7Zfk/Y6vTzN7jxuGfu8hnET54TP1r+h0f6hwgQpUlCt4DuInWtn/1GVH94wtI ueIrTZE2uwOyVHAA== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=Pwem4PGw; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=7USAGyV7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1712767387; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type; bh=tYjACmFkaLKhOmlBgdVPaDQ9giNn/R5Q9O857sN6m5g=; b=Pwem4PGweRpswScnOB1A1UJK5govXOB9Q13h85jcD6/xRR9dxzvMYncgs/ds7L2x1UQPdC EZxnEBIFX5KoRfo0K2vJQZ5QI+EXRquXvln4jxrsdEv8/uuA/+52418R9EM/SlFor+Fx/w 9W5o4g+2wngYOskpNHtaZhMKllbOLjU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1712767387; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type; bh=tYjACmFkaLKhOmlBgdVPaDQ9giNn/R5Q9O857sN6m5g=; b=7USAGyV7ywD4JLH+GYQx+zkWNcrgReBVwiGajWHNVlSuu/RDG+BH2meKVmyNa3LaxFLUki 01ZrWMcNfXXGtTBA== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id EFDB113942; Wed, 10 Apr 2024 16:43:06 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id N3/+OJrBFmYnSgAAD6G6ig (envelope-from ); Wed, 10 Apr 2024 16:43:06 +0000 Date: Wed, 10 Apr 2024 18:43:02 +0200 (CEST) From: Richard Biener To: gcc-patches@gcc.gnu.org cc: jason@redhat.com, Jakub Jelinek Subject: [PATCH] c++/114409 - ANNOTATE_EXPR and templates MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Message-Id: <20240410164306.EFDB113942@imap1.dmz-prg2.suse.org> X-Spam-Level: X-Spamd-Result: default: False [-4.51 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; ARC_NA(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; TO_DN_SOME(0.00)[]; MIME_TRACE(0.00)[0:+]; FROM_HAS_DN(0.00)[]; RCVD_TLS_ALL(0.00)[]; DKIM_TRACE(0.00)[suse.de:+]; RCVD_COUNT_TWO(0.00)[2]; FROM_EQ_ENVFROM(0.00)[]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; DNSWL_BLOCKED(0.00)[2a07:de40:b281:106:10:150:64:167:received,2a07:de40:b281:104:10:150:64:97:from]; MISSING_XM_UA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; DBL_BLOCKED_OPENRESOLVER(0.00)[pt.cc:url,suse.de:dkim,imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns] X-Rspamd-Action: no action X-Rspamd-Queue-Id: 21FDE3466B X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Spam-Score: -4.51 X-Spam-Status: No, score=-11.5 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,SPF_HELO_NONE,SPF_PASS,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 List-Id: The following fixes a mismatch in COMPOUND_EXPR handling in tsubst_expr vs tsubst_stmt where the latter allows a stmt in operand zero but the former doesn't. This makes a difference for the case at hand because when the COMPOUND_EXPR is wrapped inside an ANNOTATE_EXPR it gets handled by tsubst_expr and when not, tsubst_stmt successfully handles it and the contained DECL_EXPR in operand zero. The following makes handling of COMPOUND_EXPR in tsubst_expr consistent with that of tsubst_stmt for the operand that doesn't specify the result and thus the reason we choose either or the other for substing. Bootstrapped and tested on x86_64-unknown-linux-gnu, OK? Thanks, Richard. PR c++/114409 gcc/cp/ * pt.cc (tsubst_expr): Recurse to COMPOUND_EXPR operand zero using tsubst_stmt, when that returns NULL return the subst operand one, mimicing what tsubst_stmt does. gcc/testsuite/ * g++.dg/pr114409.C: New testcase. --- gcc/cp/pt.cc | 5 ++++- gcc/testsuite/g++.dg/pr114409.C | 8 ++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/pr114409.C diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc index bf4b89d8413..dae423a751f 100644 --- a/gcc/cp/pt.cc +++ b/gcc/cp/pt.cc @@ -20635,8 +20635,11 @@ tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl) case COMPOUND_EXPR: { - tree op0 = tsubst_expr (TREE_OPERAND (t, 0), args, + tree op0 = tsubst_stmt (TREE_OPERAND (t, 0), args, complain & ~tf_decltype, in_decl); + if (op0 == NULL_TREE) + /* If the first operand was a statement, we're done with it. */ + RETURN (RECUR (TREE_OPERAND (t, 1))); RETURN (build_x_compound_expr (EXPR_LOCATION (t), op0, RECUR (TREE_OPERAND (t, 1)), diff --git a/gcc/testsuite/g++.dg/pr114409.C b/gcc/testsuite/g++.dg/pr114409.C new file mode 100644 index 00000000000..6343fe8d9f3 --- /dev/null +++ b/gcc/testsuite/g++.dg/pr114409.C @@ -0,0 +1,8 @@ +// { dg-do compile } + +template int t() { +#pragma GCC unroll 4 + while (int ThisEntry = 0) { } // { dg-bogus "ignoring loop annotation" "" { xfail *-*-* } } + return 0; +} +int tt = t<1>(); -- 2.35.3