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.133.124]) by sourceware.org (Postfix) with ESMTPS id 170AC3858D33 for ; Wed, 22 Nov 2023 03:51:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 170AC3858D33 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 170AC3858D33 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700625101; cv=none; b=n2ECwLRdkp7GwAM3bGbRK4c5Y5jDslMeugEXAu2Yy4p4gfuMlItql2OobB/xFQMNb8Pl1wNhmZS5EtHuzC++coqnJmm6c37FetmwMEhme2WuJjcPwlv3fYu7So1NthnMEQgEZxvCY+zDUezbu++VsiIlWjOEE6x89yfzBYxe6m8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700625101; c=relaxed/simple; bh=Wmem1JsFFNs10O2wDA4YIOLwLv7xS/e7HPBPDjKx6w4=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=HeVnq4AacneDRJuGNE/kSbgZMaFXinen3A/ihZPOEUVUU2HiSJzWW3NOaX5cqVkolywOkYWkN5r4D+ryT4HVxUeuzpfwDL2jkhzEBcDVudaMoUW9rsBbvbjzEpFZmWGpwCkC3flOxAPBGHw5+xOUPM4sKmapUI/lYTAFav0IjkA= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1700625099; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=BRqbZv+/Jufc8uD7S0zsdiMR/UQvEbAu4uiZzCQEzgU=; b=C7uPEdmAkOPqXgmO+AOKrnqo1ZSPF0wvLFXe9dB2JpZwnUSR9Tg+8YqFZAFxZqDZgUFLHU uQ1Al8/hdtexy4VPMpxyyGDP2oA1kxYzSVMHjG05PUktfsxJ/4IK6XvsxYgkIDbRIlxRvD PJ8iRQIKLDaaFVpLi+fM4WgmP5kjucA= Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-626-U1WX-HEfPVqa241PiC-5kg-1; Tue, 21 Nov 2023 22:51:38 -0500 X-MC-Unique: U1WX-HEfPVqa241PiC-5kg-1 Received: by mail-qk1-f200.google.com with SMTP id af79cd13be357-77a12fbe7eeso941647585a.2 for ; Tue, 21 Nov 2023 19:51:37 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700625097; x=1701229897; h=content-transfer-encoding:in-reply-to:from:references: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=BRqbZv+/Jufc8uD7S0zsdiMR/UQvEbAu4uiZzCQEzgU=; b=Z97SzhFO3OwDmLen2PKOdr9+1e3YsTWQ+3Z0KG+maOgWP69JRZJeJC5gJ1boATtCz5 cNSvXi3l2kmyihYqxfh9AKw06YbHH/mIUtqhyGGbT9XSa0AUFHxoOP58uoAyFIbPAyRF 16jxYFsei1OgjiqJDzzXWtMH7aspSNBRsvicrdmqZ5BKs44to4r1Fhe2zN+wxIMWDP9z b43HQ/xOoUQ01frMYeQN/D8cMpumZu37JOi8Ec+2LmMN0+Hb8f/3HpvKc8jUPvTlA10s OFWFcdeeckisN3pQDXQoAKcKu92o3/7rrrhJvMKFYwrtMlevBx6fP9dPV0BdnqtLDCqN 4BAg== X-Gm-Message-State: AOJu0YyNwSdKKzUDJ7gfiabkwLrJ1AuMZg1rUrX6hFIRtWLir2Zq2TAX mbRjXbvmhH/vOdQfFKjAzEcQigN9iehPQLin0aXhQMZTHn4JOJU5mqSBfAoyJR77vKWjXsDg4MR vqr6f8kV6YZEVNgAyKw== X-Received: by 2002:a05:620a:372a:b0:778:a8b3:6cb7 with SMTP id de42-20020a05620a372a00b00778a8b36cb7mr1281896qkb.9.1700625097574; Tue, 21 Nov 2023 19:51:37 -0800 (PST) X-Google-Smtp-Source: AGHT+IEhwfLGA3kCkg/Kg1NvoL24Y319rKiK6u5xeJrXlarDbG9BtuNvVCXBSya3CVUW3R2kgA1AmA== X-Received: by 2002:a05:620a:372a:b0:778:a8b3:6cb7 with SMTP id de42-20020a05620a372a00b00778a8b36cb7mr1281891qkb.9.1700625097333; Tue, 21 Nov 2023 19:51:37 -0800 (PST) Received: from [192.168.1.145] (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 ay33-20020a05620a17a100b007756e75b91bsm4113000qkb.78.2023.11.21.19.51.36 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 21 Nov 2023 19:51:36 -0800 (PST) Message-ID: <79a9ad09-2feb-4f3b-a4fe-1d13293fcd8b@redhat.com> Date: Tue, 21 Nov 2023 22:51:36 -0500 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] c++, v3: Implement C++26 P2741R3 - user-generated static_assert messages [PR110348] To: Jakub Jelinek , gcc-patches@gcc.gnu.org References: <4b133eec-f806-43af-800a-8339d50645fd@redhat.com> 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.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE 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 11/21/23 17:51, Jakub Jelinek wrote: > On Tue, Nov 21, 2023 at 11:19:56PM +0100, Jakub Jelinek wrote: >>>> + error_at (location, "% message must be a string " >>>> + "literal or object with % and " >>>> + "% members"); >>> >>> Let's print the type of the message as well. >> >> so add " while it has type %qT", TREE_TYPE (message) or something else? > > Now in patch form (except for the removal of warning_at for now): > > + if (TREE_CODE (message) != STRING_CST > + && !type_dependent_expression_p (message)) > + { > + message_sz > + = finish_class_member_access_expr (message, > + get_identifier ("size"), > + false, tf_none); > + message_data > + = finish_class_member_access_expr (message, > + get_identifier ("data"), > + false, tf_none); > + if (message_sz == error_mark_node || message_data == error_mark_node) > + { > + error_at (location, "% message must be a string " > + "literal or object with % and " > + "% members while it has type %qT", Actually, let's go back to the previous message, but change the tf_nones above to 'complain' so that we see those errors and then this explanation. Likewise with the conversion checks later in the function. > + TREE_TYPE (message)); > + return; > + } > + releasing_vec size_args, data_args; > + message_sz = finish_call_expr (message_sz, &size_args, false, false, > + tf_warning_or_error); > + message_data = finish_call_expr (message_data, &data_args, false, false, > + tf_warning_or_error); Can use 'complain' instead of tf_warning_or_error here, too. > + if (message_sz == error_mark_node || message_data == error_mark_node) > + return; > + if (tree s > + = cp_get_callee_fndecl_nofold (extract_call_expr (message_sz))) > + if (!DECL_DECLARED_CONSTEXPR_P (s)) > + warning_at (location, 0, "%qD used in % message " > + "is not %", s); >> I don't think we need this check, it should be covered by the later >> constant-expression checks. > > If the static_assert condition is true, we won't diagnose anything then. > clang++ there incorrectly errors, but I thought a warning could be useful > to users. Perhaps it could warn only if the condition is true? I don't think the extra warning is that useful, especially with no flag to suppress it; we specifically decided not to require the message to be constant if the condition is true, and involving a non-constexpr function is just one example of how it might not be constant. Jason