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 7DB163982411 for ; Tue, 30 Aug 2022 03:33:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 7DB163982411 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=1661830420; 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=JjqzVa5WFJIgsn4mrGIdmxaJqBBO8ODh0OPkHxPX64o=; b=g8mvNjHDzI+yKexB9ExLSwL3Wc3Rdm9HZ+T4tF+PcqThinTDrih/Y99QyMWeh1aKbLFlTV DRL7IpErY0tOpUoKg48QfqUgjooTzl+e7LzxodpRw1kCYsdy/JFtXRw/VBQMIuAxuS3whL 6q5ptFygl/KGzFomrnY7zS4XQFIKGlg= Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-593-VDQQZJMENLyR3eJryAMb_A-1; Mon, 29 Aug 2022 23:33:39 -0400 X-MC-Unique: VDQQZJMENLyR3eJryAMb_A-1 Received: by mail-qk1-f198.google.com with SMTP id r14-20020a05620a298e00b006be796b6164so4529823qkp.19 for ; Mon, 29 Aug 2022 20:33:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=JjqzVa5WFJIgsn4mrGIdmxaJqBBO8ODh0OPkHxPX64o=; b=75emyX6lllWgqVsN69U+N07uXDuRnIO4ZAo2p2uljQ0omzCigt/1dohS+rdETWO4Px 2YMladAnlg3xi0AGqGbp84wLTDXAP51rF87ZzyFpHDXaWy5WskudkM1iPouprVsTt2Uz 44ao09A8CIjNcocHzDycrgf/N/JKYHYYtBvbE/O544fYW7rBa5hl9Bcu0LKhtChSEis7 RBpvq4/vp7KVIZSB6JqMBflxWOyrDX12KDXicoeSkDkyTme8bra/N6oHew9SQiWiuqDY X2Sue2xX40viErEk7NYhJTLKYiGKEyp+GdiYuhOe8nM5IHEGo1Nwwf53PVfWObDUuH7d 7lag== X-Gm-Message-State: ACgBeo3f6v3ZEnLArFtLhsbcZ8U6uuUkU7htRNjid0CKo/gPw83K+aPK AmuaqQy/uDNzr488r2fclFXLzbGG1jPoJDxTsaJlJFEgmERE8EEiJ59OpdujoiZWE+S2d1T/2U2 6aVD6GLIQXoNxY9j2PA== X-Received: by 2002:a37:a853:0:b0:6ba:ceba:9656 with SMTP id r80-20020a37a853000000b006baceba9656mr10756413qke.466.1661830418046; Mon, 29 Aug 2022 20:33:38 -0700 (PDT) X-Google-Smtp-Source: AA6agR5cisBoOLPU6HY60svew1BVa6uQudnQdVTiikFqK/Epy7kN763+FsBkRptqxQ7wQzsHiqui5Q== X-Received: by 2002:a37:a853:0:b0:6ba:ceba:9656 with SMTP id r80-20020a37a853000000b006baceba9656mr10756402qke.466.1661830417746; Mon, 29 Aug 2022 20:33:37 -0700 (PDT) Received: from [192.168.1.101] (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 y13-20020a05620a44cd00b006bb8b5b79efsm7814819qkp.129.2022.08.29.20.33.36 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 29 Aug 2022 20:33:37 -0700 (PDT) Message-ID: Date: Mon, 29 Aug 2022 23:33:36 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.13.0 Subject: Re: [PATCH] c++: __has_builtin gives the wrong answer [PR106759] To: Marek Polacek , GCC Patches References: <20220829212603.632168-1-polacek@redhat.com> From: Jason Merrill In-Reply-To: <20220829212603.632168-1-polacek@redhat.com> 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=-13.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,NICE_REPLY_A,RCVD_IN_DNSWL_LOW,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 8/29/22 17:26, Marek Polacek wrote: > We've supported __is_nothrow_constructible since r11-4386, but > names_builtin_p didn't know about it, so it gave the wrong answer for > #if __has_builtin(__is_nothrow_constructible) > ... > #endif > > I've tested all C++-only built-ins and only two were missing. > > Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk? OK. > PR c++/106759 > > gcc/cp/ChangeLog: > > * cp-objcp-common.cc (names_builtin_p): Handle RID_IS_NOTHROW_ASSIGNABLE > and RID_IS_NOTHROW_CONSTRUCTIBLE. > > gcc/testsuite/ChangeLog: > > * g++.dg/ext/has-builtin-1.C: New test. > --- > gcc/cp/cp-objcp-common.cc | 2 + > gcc/testsuite/g++.dg/ext/has-builtin-1.C | 133 +++++++++++++++++++++++ > 2 files changed, 135 insertions(+) > create mode 100644 gcc/testsuite/g++.dg/ext/has-builtin-1.C > > diff --git a/gcc/cp/cp-objcp-common.cc b/gcc/cp/cp-objcp-common.cc > index 4079a4b4aec..1ffac08c32f 100644 > --- a/gcc/cp/cp-objcp-common.cc > +++ b/gcc/cp/cp-objcp-common.cc > @@ -460,6 +460,8 @@ names_builtin_p (const char *name) > case RID_IS_UNION: > case RID_IS_ASSIGNABLE: > case RID_IS_CONSTRUCTIBLE: > + case RID_IS_NOTHROW_ASSIGNABLE: > + case RID_IS_NOTHROW_CONSTRUCTIBLE: > case RID_UNDERLYING_TYPE: > case RID_REF_CONSTRUCTS_FROM_TEMPORARY: > case RID_REF_CONVERTS_FROM_TEMPORARY: > diff --git a/gcc/testsuite/g++.dg/ext/has-builtin-1.C b/gcc/testsuite/g++.dg/ext/has-builtin-1.C > new file mode 100644 > index 00000000000..fe25cb2f669 > --- /dev/null > +++ b/gcc/testsuite/g++.dg/ext/has-builtin-1.C > @@ -0,0 +1,133 @@ > +// PR c++/106759 > +// { dg-do compile } > +// Verify that __has_builtin gives the correct answer for C++ built-ins. > + > +#if !__has_builtin (__builtin_addressof) > +# error "__has_builtin (__builtin_addressof) failed" > +#endif > +#if !__has_builtin (__builtin_bit_cast) > +# error "__has_builtin (__builtin_bit_cast) failed" > +#endif > +#if !__has_builtin (__builtin_launder) > +# error "__has_builtin (__builtin_launder) failed" > +#endif > +#if !__has_builtin (__has_nothrow_assign) > +# error "__has_builtin (__has_nothrow_assign) failed" > +#endif > +#if !__has_builtin (__has_nothrow_constructor) > +# error "__has_builtin (__has_nothrow_constructor) failed" > +#endif > +#if !__has_builtin (__has_nothrow_copy) > +# error "__has_builtin (__has_nothrow_copy) failed" > +#endif > +#if !__has_builtin (__has_trivial_assign) > +# error "__has_builtin (__has_trivial_assign) failed" > +#endif > +#if !__has_builtin (__has_trivial_constructor) > +# error "__has_builtin (__has_trivial_constructor) failed" > +#endif > +#if !__has_builtin (__has_trivial_copy) > +# error "__has_builtin (__has_trivial_copy) failed" > +#endif > +#if !__has_builtin (__has_trivial_destructor) > +# error "__has_builtin (__has_trivial_destructor) failed" > +#endif > +#if !__has_builtin (__has_unique_object_representations) > +# error "__has_builtin (__has_unique_object_representations) failed" > +#endif > +#if !__has_builtin (__has_virtual_destructor) > +# error "__has_builtin (__has_virtual_destructor) failed" > +#endif > +#if !__has_builtin (__is_abstract) > +# error "__has_builtin (__is_abstract) failed" > +#endif > +#if !__has_builtin (__is_aggregate) > +# error "__has_builtin (__is_aggregate) failed" > +#endif > +#if !__has_builtin (__is_base_of) > +# error "__has_builtin (__is_base_of) failed" > +#endif > +#if !__has_builtin (__is_class) > +# error "__has_builtin (__is_class) failed" > +#endif > +#if !__has_builtin (__is_empty) > +# error "__has_builtin (__is_empty) failed" > +#endif > +#if !__has_builtin (__is_enum) > +# error "__has_builtin (__is_enum) failed" > +#endif > +#if !__has_builtin (__is_final) > +# error "__has_builtin (__is_final) failed" > +#endif > +#if !__has_builtin (__is_layout_compatible) > +# error "__has_builtin (__is_layout_compatible) failed" > +#endif > +#if !__has_builtin (__is_literal_type) > +# error "__has_builtin (__is_literal_type) failed" > +#endif > +#if !__has_builtin (__is_pointer_interconvertible_base_of) > +# error "__has_builtin (__is_pointer_interconvertible_base_of) failed" > +#endif > +#if !__has_builtin (__is_pod) > +# error "__has_builtin (__is_pod) failed" > +#endif > +#if !__has_builtin (__is_polymorphic) > +# error "__has_builtin (__is_polymorphic) failed" > +#endif > +#if !__has_builtin (__is_same) > +# error "__has_builtin (__is_same) failed" > +#endif > +#if !__has_builtin (__is_same_as) > +# error "__has_builtin (__is_same_as) failed" > +#endif > +#if !__has_builtin (__is_standard_layout) > +# error "__has_builtin (__is_standard_layout) failed" > +#endif > +#if !__has_builtin (__is_trivial) > +# error "__has_builtin (__is_trivial) failed" > +#endif > +#if !__has_builtin (__is_trivially_assignable) > +# error "__has_builtin (__is_trivially_assignable) failed" > +#endif > +#if !__has_builtin (__is_trivially_constructible) > +# error "__has_builtin (__is_trivially_constructible) failed" > +#endif > +#if !__has_builtin (__is_trivially_copyable) > +# error "__has_builtin (__is_trivially_copyable) failed" > +#endif > +#if !__has_builtin (__is_union) > +# error "__has_builtin (__is_union) failed" > +#endif > +#if !__has_builtin (__underlying_type) > +# error "__has_builtin (__underlying_type) failed" > +#endif > +#if !__has_builtin (__is_assignable) > +# error "__has_builtin (__is_assignable) failed" > +#endif > +#if !__has_builtin (__is_constructible) > +# error "__has_builtin (__is_constructible) failed" > +#endif > +#if !__has_builtin (__is_nothrow_assignable) > +# error "__has_builtin (__is_nothrow_assignable) failed" > +#endif > +#if !__has_builtin (__is_nothrow_constructible) > +# error "__has_builtin (__is_nothrow_constructible) failed" > +#endif > +#if !__has_builtin (__reference_constructs_from_temporary) > +# error "__has_builtin (__reference_constructs_from_temporary) failed" > +#endif > +#if !__has_builtin (__reference_converts_from_temporary) > +# error "__has_builtin (__reference_converts_from_temporary) failed" > +#endif > +#if !__has_builtin (__builtin_is_constant_evaluated) > +# error "__has_builtin (__builtin_is_constant_evaluated) failed" > +#endif > +#if !__has_builtin (__builtin_source_location) > +# error "__has_builtin (__builtin_source_location) failed" > +#endif > +#if !__has_builtin (__builtin_is_corresponding_member) > +# error "__has_builtin (__builtin_is_corresponding_member) failed" > +#endif > +#if !__has_builtin (__builtin_is_pointer_interconvertible_with_class) > +# error "__has_builtin (__builtin_is_pointer_interconvertible_with_class) failed" > +#endif > > base-commit: b504149d2c92ddfcfab62ea6d1ed49ae72493e38