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 C0B003858CDA for ; Thu, 30 Mar 2023 02:53:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C0B003858CDA Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1680144813; 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=M5dyNw3Y4efvYsNzRz8FipDArGcMGWym89eIQhdfCtM=; b=IiHsmci1QS8H/QziibGcpJsexUFvSvDWQwRd76YBbkvVAWSSp7sx+PQZPSOA8PBDeD+/48 3ABFszG2qgpDfwPJxtuTga06xCgX0WEK55WRE4gi349YsXzLv5NUJQzhT/ea3W+JI+mLyn PIplR4B8PNfwXXFtRa2ilqYMWocJJtY= Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-179-OFdubKN1MpqOV-EQge156A-1; Wed, 29 Mar 2023 22:53:31 -0400 X-MC-Unique: OFdubKN1MpqOV-EQge156A-1 Received: by mail-qt1-f197.google.com with SMTP id s4-20020a05622a1a8400b003dbc6fc558aso11374435qtc.3 for ; Wed, 29 Mar 2023 19:53:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680144810; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=M5dyNw3Y4efvYsNzRz8FipDArGcMGWym89eIQhdfCtM=; b=U37BBElQExvu4T99ALDpg6LJkoJZfzI473Ge9nCPrOgY2cZFqEucM+fmcxA/JN9ahw UqyJb9/0TfJTDvmN9B1xCW9rRComQJCwY4k4UGdSKo17QMn0kqmTgM1+qy7+A5LlTfgg ASpSPMktiJsNRc4t8mFaochr3PqmBniafvWX0QA6DziRK3xD/9X9Pm/ST4ZuTGnlFozX +//VHUvAXKqfi0hcmAI6Et2oLmZKqyr0q8q5tlHEUpY0h8OsvSQaqnE7i1Qn/mVRa9Ur FWBV7aIRvO/Ekrs034Pevs1J0Hopp9tqww4RxEY3s4S1mecTdywN1kAsVqJN5VWjVAOF JDoA== X-Gm-Message-State: AAQBX9crg0NLdNm3QG5lQLmmkT0BLOKgTMM1pmlQ0Yt13NCtRp7gp2UK dGknqImC18yMPUi+Ia4rW/ReijSBZ9OFr9aa17z/aUwO9Xa1nes2cjnFQLhL8Z2nG/h677uBVCD ho78uIYsbQ/UMK9fuZQ== X-Received: by 2002:a05:6214:5092:b0:56e:98a1:fff1 with SMTP id kk18-20020a056214509200b0056e98a1fff1mr35425791qvb.7.1680144810542; Wed, 29 Mar 2023 19:53:30 -0700 (PDT) X-Google-Smtp-Source: AKy350YAA1XNwYXizzrdlLxZXG/rh5eIkpAsDMi3d7eB6OicD1OniISRwyjdFODVQsrSo1LRSjntdg== X-Received: by 2002:a05:6214:5092:b0:56e:98a1:fff1 with SMTP id kk18-20020a056214509200b0056e98a1fff1mr35425779qvb.7.1680144810194; Wed, 29 Mar 2023 19:53:30 -0700 (PDT) Received: from [192.168.1.108] (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 a14-20020a0ccdce000000b005dd8b9345e5sm5106268qvn.125.2023.03.29.19.53.29 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 29 Mar 2023 19:53:29 -0700 (PDT) Message-ID: <31e043cd-7e1c-25d5-8a4a-f504d04d5287@redhat.com> Date: Wed, 29 Mar 2023 22:53:27 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.9.0 Subject: Re: [PATCH] c++: Avoid informs without a warning [PR109278] 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=-5.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,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 List-Id: On 3/29/23 16:57, Jakub Jelinek wrote: > On Wed, Mar 29, 2023 at 04:35:15PM -0400, Jason Merrill wrote: >>> On the following testcase we emit notes in >>> maybe_inform_about_fndecl_for_bogus_argument_init >>> despite no warning/error being printed before it. >>> This is for the extended floating point type conversions where pedwarn >>> is used, and complained is used there for 2 different purposes, >>> one is whether an unspecific error should be emitted if we haven't >>> complained otherwise, and one whether >>> maybe_inform_about_fndecl_for_bogus_argument_init should be called. >>> For the 2 pedwarns, currently it sets complained to true regardless of >>> whether pedwarn succeeded, which results in the undesirable notes printed >>> with -w. If complained is initialized to result of pedwarn, we would >>> emit an error later on. >>> >>> So, the following patch makes complained a tristate, the additional >>> error isn't printed if complained != 0, and >>> maybe_inform_about_fndecl_for_bogus_argument_init is called only if >>> complained == 1, so if pedwarn returns false, we can use complained = -1 >>> to tell later code not to emit an error and not to call >>> maybe_inform_about_fndecl_for_bogus_argument_init. >>> >>> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? >>> >>> 2023-03-25 Jakub Jelinek >>> >>> PR c++/109278 >>> * call.cc (convert_like_internal): If pedwarn for extended float >>> type conversions doesn't report anything, avoid calling >>> maybe_inform_about_fndecl_for_bogus_argument_init. >> >> I think we want the same handling for all the complained = permerror cases >> as well. > > I think it isn't really needed in those cases. > If I have say: > int foo (int); > int a = foo ({ { 1 } }); > int bar (bool); > decltype (nullptr) n; > int b = bar (n); > and compile with -fpermissive -w (which is I think the only way how to get > permerror return false), then it will later reach that: > if (!complained && expr != error_mark_node) > { > range_label_for_type_mismatch label (TREE_TYPE (expr), totype); > gcc_rich_location richloc (loc, &label); > complained = permerror (&richloc, > "invalid conversion from %qH to %qI", > TREE_TYPE (expr), totype); > } > if (complained) > maybe_inform_about_fndecl_for_bogus_argument_init (fn, argnum); > in current trunk or complained == 1 in the latter condition with the > patch. !complained is true, so it will call permerror, but because > of -fpermissive -w neither that permerror will emit anything and will set > complained to false, so maybe_inform_about_fndecl_for_bogus_argument_init > is not called. If I compile the above just with -fpermissive, it prints > the 2 warnings and 2 informs, if without -fpermissive, it prints the 2 > errors and 2 informs. Ah, makes sense. The patch is OK. > If you want, I can add the above snippet as 3 testcases (normal, > -fpermissive and -fpermissive -w). > > Jakub >