From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 102823858D38 for ; Fri, 12 Apr 2024 18:12:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 102823858D38 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 102823858D38 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712945578; cv=none; b=EDwQo2mZlcQinUt6mDqvsGgS4RWfztAm5nxmPIHGMuLJmFZHYkve/7x8+Bcv12UihgtBu1ALMwiDnglPPgKGmbswFlzd/8G4FQtBS9Z/a3tSrQ5uXZ6l44MgQ0IQkgR8GjeeqfXsNXMCGqeveFJ9cd5eXa2ZYf52HYiFyMMDflI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712945578; c=relaxed/simple; bh=CfYiPL4vKIeJRdir4xdVcE4d3cVMMvKq1nLjNF785i8=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=VOn0SZb8CRmfV3Tqsuz2PvJZGM+OIdaLaXuR7NxOAwrb6Xi3XHopxyaVF8qCYXMlE6AT5fzhixJ7L+/byL6yIrPqURqqgamGnK+NOMQBHKRwfW36umSdLb08XcRv3z1fADUQuBj0qCM0pGR4jQmin8JBLlMyl8/gRWNJt9+RJok= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1712945575; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WsjV8cF09RQzzHakV2pvdZHoX4aax+Xv9ZyZWwWtG1M=; b=A5cP+TBl+iYbYEBHQAZIf7ifMMNxBPoEwz25QTDqa9QxRqApG4+VrquDmf/2zDqWSKJBQ5 kEB8WVM2YmWlZm/g5gRRf6+yyIpQ+h75da+GbLjeuObWVT8ESfi/XAY9Pu/dwQ8RFAiZAL JDQ4PFRm+2jOJU+FMGVa5jw1l2IoipM= Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-689-5GcjYZ7dPSKAqmn2gGf6wg-1; Fri, 12 Apr 2024 14:12:54 -0400 X-MC-Unique: 5GcjYZ7dPSKAqmn2gGf6wg-1 Received: by mail-qv1-f72.google.com with SMTP id 6a1803df08f44-6993edda019so14993096d6.3 for ; Fri, 12 Apr 2024 11:12:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712945573; x=1713550373; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=WsjV8cF09RQzzHakV2pvdZHoX4aax+Xv9ZyZWwWtG1M=; b=W7++MKdAtnBlNth+OJKlvR2nSSOojRd1zawLMFeQoHRxHnEj7Me+OJn46sed/IBYvi NHQrZxldECmTh2l0tpmpsxkRvUo/WAUa7gyML6TVmXV6mhKe8vz+cM6lsuUbSaPB08TN MvfteoZ1gyYqXxYk1rZSBwxnWESxXQK2iMMpVYHvWVoiPTWy/B2E5D7w57WrAUf2nrP5 QTva3Qnkoyfjh8UnwxgTMLiGGFFJk76lE5maWYby+HY7+O9hXpaY8CMq9g/yWh9N2CgS cqzfKrWRFoUZ4L5VH7230Ef4+2b1mg05SEqfqizAgoDc9PCJxnLDyX0isPCwmQkCrHzd jvdw== X-Gm-Message-State: AOJu0YxnB6ajVAnZVLaABuWxCvwRK7b2C4UrxQSl1yCxXGxAYR/5+fzM YHeirfMZLFamVZcJrVICQxuSjXSOX8QVPRJCWR6ahzzcXBFTkmzUI3SWaSxZkyDBUWlnB/qyIwi 7YonqgCHR+rT7O5/ME0bnN2ySlwyYDn/nWIr8TaWnMO4AcTulUwISEZqjIASdkL8= X-Received: by 2002:ad4:420a:0:b0:69b:45bb:2124 with SMTP id k10-20020ad4420a000000b0069b45bb2124mr3506192qvp.47.1712945573281; Fri, 12 Apr 2024 11:12:53 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH3f50Si1Uw8izUo0x71UbVrGC7ARdzkoKACC5OT12BbBXZecI+kNf+F/S3pTNkr8UUCOtfZg== X-Received: by 2002:ad4:420a:0:b0:69b:45bb:2124 with SMTP id k10-20020ad4420a000000b0069b45bb2124mr3506178qvp.47.1712945572985; Fri, 12 Apr 2024 11:12:52 -0700 (PDT) Received: from [192.168.1.130] (130-44-146-16.s12558.c3-0.arl-cbr1.sbo-arl.ma.cable.rcncustomer.com. [130.44.146.16]) by smtp.gmail.com with ESMTPSA id t2-20020a0cea22000000b0069b59f0a133sm970442qvp.97.2024.04.12.11.12.52 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 12 Apr 2024 11:12:52 -0700 (PDT) Message-ID: Date: Fri, 12 Apr 2024 14:12:51 -0400 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] c++: Fix bogus warnings about ignored annotations [PR114409] To: Jakub Jelinek Cc: gcc-patches@gcc.gnu.org References: From: Jason Merrill In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-6.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,KAM_TRUTHINESS,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,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 List-Id: On 3/22/24 04:08, Jakub Jelinek wrote: > Hi! > > The middle-end warns about the ANNOTATE_EXPR added for while/for loops > if they declare a var inside of the loop condition. > This is because the assumption is that ANNOTATE_EXPR argument is used > immediately in a COND_EXPR (later GIMPLE_COND), but simplify_loop_decl_cond > wraps the ANNOTATE_EXPR inside of a TRUTH_NOT_EXPR, so it no longer > holds. > > The following patch fixes that by adding the TRUTH_NOT_EXPR inside of the > ANNOTATE_EXPR argument if any. > > Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? OK > Note, the PR is mostly about ICE with the annotations used in a template, > this patch doesn't change anything on that and I really don't know what > should be done in that case. > > 2024-03-22 Jakub Jelinek > > PR c++/114409 > * semantics.cc (simplify_loop_decl_cond): Use cp_build_unary_op with > TRUTH_NOT_EXPR on ANNOTATE_EXPR argument (if any) rather than > ANNOTATE_EXPR itself. > > * g++.dg/ext/pr114409.C: New test. > > --- gcc/cp/semantics.cc.jj 2024-03-01 17:27:58.862888609 +0100 > +++ gcc/cp/semantics.cc 2024-03-21 15:24:57.296857864 +0100 > @@ -799,7 +799,11 @@ simplify_loop_decl_cond (tree *cond_p, t > *cond_p = boolean_true_node; > > if_stmt = begin_if_stmt (); > - cond = cp_build_unary_op (TRUTH_NOT_EXPR, cond, false, tf_warning_or_error); > + cond_p = &cond; > + while (TREE_CODE (*cond_p) == ANNOTATE_EXPR) > + cond_p = &TREE_OPERAND (*cond_p, 0); > + *cond_p = cp_build_unary_op (TRUTH_NOT_EXPR, *cond_p, false, > + tf_warning_or_error); > finish_if_stmt_cond (cond, if_stmt); > finish_break_stmt (); > finish_then_clause (if_stmt); > --- gcc/testsuite/g++.dg/ext/pr114409.C.jj 2024-03-21 15:27:44.077661090 +0100 > +++ gcc/testsuite/g++.dg/ext/pr114409.C 2024-03-21 15:27:15.331039726 +0100 > @@ -0,0 +1,22 @@ > +// PR c++/114409 > +// { dg-do compile } > +// { dg-options "-O2 -Wall" } > + > +void qux (int); > +int foo (int); > + > +void > +bar (int x) > +{ > + #pragma GCC novector > + while (int y = foo (x)) // { dg-bogus "ignoring loop annotation" } > + qux (y); > +} > + > +void > +baz (int x) > +{ > + #pragma GCC novector > + for (; int y = foo (x); ) // { dg-bogus "ignoring loop annotation" } > + qux (y); > +} > > Jakub >