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 31C0A3849AF6 for ; Thu, 2 May 2024 19:50:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 31C0A3849AF6 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 31C0A3849AF6 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=1714679413; cv=none; b=MGHt+svpK/FRmLjDo7QALyYXu8RDvyqS/YKi/NcR8Nw95zBGNgpM13KKuTjKKmkNviR4HbV+3RF+snd3Y7dw7a1a+0kN6g7Brw6J+80oqNi7jD+Kcj/ZMAes3o/FzVhKMjgg0V4kj4grh03nhDx0PejQl80r7NGVlTvQKDoaSnk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1714679413; c=relaxed/simple; bh=dGP6HUOzjFBXBu8yUYomSbxqUg5qxK1iZX5zoHN/wZE=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=c6O2KGhNWrtuHkd1ydabWWBj4C8cNHjE85MG6JAcTJR23U2kKqI2PHLhE3uI/DzShNryx4/6qdYbgbjpoKKg9klSjfOZcO6V93zZmxyJKQX7uy8TNn7eKoWNdSCY7ccuf4Yr2ObItJq1Yi+UMuYmDpY60ifLctsN499ct4vFiak= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1714679410; 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=P777u+pE5twsQtfSBRLpOSCgCsWx8rjMXRYB/penL7U=; b=eqrjhNmpUe2PLhSRX+7+HBBf6PNscShNmZSC3OhR0GMgmOG1+R2tRBmpa9VQqAt/LnusPg Mo498llyzkTmxk4rt5k7jncd+oPlqlYX8hAwTb2/NxDY9EaMY6+HEklhAy2VTxfzHTkI+9 SgLhIlp5txi2Jfh12VtB3IDMTEHCBqY= Received: from mail-vk1-f197.google.com (mail-vk1-f197.google.com [209.85.221.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-556-YB0H2Sa2NCeeT1PiY0GoLg-1; Thu, 02 May 2024 15:50:03 -0400 X-MC-Unique: YB0H2Sa2NCeeT1PiY0GoLg-1 Received: by mail-vk1-f197.google.com with SMTP id 71dfb90a1353d-4dcacd883b3so4489281e0c.2 for ; Thu, 02 May 2024 12:50:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714679402; x=1715284202; 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=P777u+pE5twsQtfSBRLpOSCgCsWx8rjMXRYB/penL7U=; b=O52NrT/K+fT19qwjHMjV+j9j04zyIEbBPdVWFAhqPzl+29quxikaIg8dZrXU+wv9fU 4QCO00/gVYj/N6CttejDG/iKHAAf1L3d1HTO5am981fYiszQNbbrzi7mdBdnf2Pdbf1g FJwsjxYzFMsWsAqCPP5xBS+bpMKAslJuxy1BCTGif+H4TqXLtBC7VIEKukTSe/MXReLe 4R56KS/tzwycZGU1IIQ7ogQGbUfZ03A+zZ9uW1PeKnPvPOaTTjl5yJsUtwQE8zDjsCkf tIC+EarZqbouip2KsAqq02L0i643FDXZQVVo2Ei0rv194sG07i3JSeXL0ZbPtR+QEsAb CK0g== X-Gm-Message-State: AOJu0YwovqE2iPwF+NQ/CyCRM5x/1IOwkBbKGKS1f7YWAXNFklnEUG4H YSH/CT0H818C7HAnLTRsnMWDbyeRtIZesUPmYcYDUCGCWHh7CU1xPd44qwLw2bgvKqXEl7+mLnK MwLW+Kn6AokFLFjhTxQBr1EJz3p1sdDPHKVW6/RTqWZilEiKfVl8CJdHXu/te X-Received: by 2002:a05:6122:36a2:b0:4c8:ee1:5a0b with SMTP id ec34-20020a05612236a200b004c80ee15a0bmr743768vkb.15.1714679402572; Thu, 02 May 2024 12:50:02 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFNX6eJyvJDujU1MEgJfRWrjkBbfWWw+9pZf9PirTKJIi+00Fw5YeOcoHyCs8YgpthUaxzdiw== X-Received: by 2002:a05:6122:36a2:b0:4c8:ee1:5a0b with SMTP id ec34-20020a05612236a200b004c80ee15a0bmr743749vkb.15.1714679402183; Thu, 02 May 2024 12:50:02 -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 fd15-20020a05622a4d0f00b0043a7cb47069sm770697qtb.9.2024.05.02.12.50.01 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 02 May 2024 12:50:01 -0700 (PDT) Message-ID: <33199585-c98b-4ac8-ba7c-9a24ef01482b@redhat.com> Date: Thu, 2 May 2024 15:50:00 -0400 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v17 05/26] c++: Implement __is_pointer built-in trait To: Ken Matsui , gcc-patches@gcc.gnu.org Cc: libstdc++@gcc.gnu.org References: <20240502161614.3705912-1-kmatsui@gcc.gnu.org> <20240502184529.97337-1-kmatsui@gcc.gnu.org> <20240502184529.97337-6-kmatsui@gcc.gnu.org> From: Jason Merrill In-Reply-To: <20240502184529.97337-6-kmatsui@gcc.gnu.org> 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,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=unavailable 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 5/2/24 14:42, Ken Matsui wrote: > This patch implements built-in trait for std::is_pointer. OK. > gcc/cp/ChangeLog: > > * cp-trait.def: Define __is_pointer. > * constraint.cc (diagnose_trait_expr): Handle CPTK_IS_POINTER. > * semantics.cc (trait_expr_value): Likewise. > (finish_trait_expr): Likewise. > > gcc/testsuite/ChangeLog: > > * g++.dg/ext/has-builtin-1.C: Test existence of __is_pointer. > Arrange the order lexically around __is_pointer. > * g++.dg/ext/is_pointer.C: New test. > > Signed-off-by: Ken Matsui > --- > gcc/cp/constraint.cc | 3 ++ > gcc/cp/cp-trait.def | 1 + > gcc/cp/semantics.cc | 4 ++ > gcc/testsuite/g++.dg/ext/has-builtin-1.C | 9 +++-- > gcc/testsuite/g++.dg/ext/is_pointer.C | 51 ++++++++++++++++++++++++ > 5 files changed, 65 insertions(+), 3 deletions(-) > create mode 100644 gcc/testsuite/g++.dg/ext/is_pointer.C > > diff --git a/gcc/cp/constraint.cc b/gcc/cp/constraint.cc > index d9caf546423..5a8aaa70fa6 100644 > --- a/gcc/cp/constraint.cc > +++ b/gcc/cp/constraint.cc > @@ -3829,6 +3829,9 @@ diagnose_trait_expr (tree expr, tree args) > case CPTK_IS_POD: > inform (loc, " %qT is not a POD type", t1); > break; > + case CPTK_IS_POINTER: > + inform (loc, " %qT is not a pointer", t1); > + break; > case CPTK_IS_POLYMORPHIC: > inform (loc, " %qT is not a polymorphic type", t1); > break; > diff --git a/gcc/cp/cp-trait.def b/gcc/cp/cp-trait.def > index e9347453829..18e2d0f3480 100644 > --- a/gcc/cp/cp-trait.def > +++ b/gcc/cp/cp-trait.def > @@ -82,6 +82,7 @@ DEFTRAIT_EXPR (IS_NOTHROW_CONVERTIBLE, "__is_nothrow_convertible", 2) > DEFTRAIT_EXPR (IS_OBJECT, "__is_object", 1) > DEFTRAIT_EXPR (IS_POINTER_INTERCONVERTIBLE_BASE_OF, "__is_pointer_interconvertible_base_of", 2) > DEFTRAIT_EXPR (IS_POD, "__is_pod", 1) > +DEFTRAIT_EXPR (IS_POINTER, "__is_pointer", 1) > DEFTRAIT_EXPR (IS_POLYMORPHIC, "__is_polymorphic", 1) > DEFTRAIT_EXPR (IS_REFERENCE, "__is_reference", 1) > DEFTRAIT_EXPR (IS_SAME, "__is_same", 2) > diff --git a/gcc/cp/semantics.cc b/gcc/cp/semantics.cc > index 351235a639a..86372ea0aba 100644 > --- a/gcc/cp/semantics.cc > +++ b/gcc/cp/semantics.cc > @@ -12586,6 +12586,9 @@ trait_expr_value (cp_trait_kind kind, tree type1, tree type2) > case CPTK_IS_POD: > return pod_type_p (type1); > > + case CPTK_IS_POINTER: > + return TYPE_PTR_P (type1); > + > case CPTK_IS_POLYMORPHIC: > return CLASS_TYPE_P (type1) && TYPE_POLYMORPHIC_P (type1); > > @@ -12825,6 +12828,7 @@ finish_trait_expr (location_t loc, cp_trait_kind kind, tree type1, tree type2) > case CPTK_IS_MEMBER_OBJECT_POINTER: > case CPTK_IS_MEMBER_POINTER: > case CPTK_IS_OBJECT: > + case CPTK_IS_POINTER: > case CPTK_IS_REFERENCE: > case CPTK_IS_SAME: > case CPTK_IS_SCOPED_ENUM: > diff --git a/gcc/testsuite/g++.dg/ext/has-builtin-1.C b/gcc/testsuite/g++.dg/ext/has-builtin-1.C > index b2e2f2f694d..4cbe6fe8cea 100644 > --- a/gcc/testsuite/g++.dg/ext/has-builtin-1.C > +++ b/gcc/testsuite/g++.dg/ext/has-builtin-1.C > @@ -119,12 +119,15 @@ > #if !__has_builtin (__is_object) > # error "__has_builtin (__is_object) 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_pointer) > +# error "__has_builtin (__is_pointer) failed" > +#endif > +#if !__has_builtin (__is_pointer_interconvertible_base_of) > +# error "__has_builtin (__is_pointer_interconvertible_base_of) failed" > +#endif > #if !__has_builtin (__is_polymorphic) > # error "__has_builtin (__is_polymorphic) failed" > #endif > diff --git a/gcc/testsuite/g++.dg/ext/is_pointer.C b/gcc/testsuite/g++.dg/ext/is_pointer.C > new file mode 100644 > index 00000000000..d6e39565950 > --- /dev/null > +++ b/gcc/testsuite/g++.dg/ext/is_pointer.C > @@ -0,0 +1,51 @@ > +// { dg-do compile { target c++11 } } > + > +#define SA(X) static_assert((X),#X) > + > +SA(!__is_pointer(int)); > +SA(__is_pointer(int*)); > +SA(__is_pointer(int**)); > + > +SA(__is_pointer(const int*)); > +SA(__is_pointer(const int**)); > +SA(__is_pointer(int* const)); > +SA(__is_pointer(int** const)); > +SA(__is_pointer(int* const* const)); > + > +SA(__is_pointer(volatile int*)); > +SA(__is_pointer(volatile int**)); > +SA(__is_pointer(int* volatile)); > +SA(__is_pointer(int** volatile)); > +SA(__is_pointer(int* volatile* volatile)); > + > +SA(__is_pointer(const volatile int*)); > +SA(__is_pointer(const volatile int**)); > +SA(__is_pointer(const int* volatile)); > +SA(__is_pointer(volatile int* const)); > +SA(__is_pointer(int* const volatile)); > +SA(__is_pointer(const int** volatile)); > +SA(__is_pointer(volatile int** const)); > +SA(__is_pointer(int** const volatile)); > +SA(__is_pointer(int* const* const volatile)); > +SA(__is_pointer(int* volatile* const volatile)); > +SA(__is_pointer(int* const volatile* const volatile)); > + > +SA(!__is_pointer(int&)); > +SA(!__is_pointer(const int&)); > +SA(!__is_pointer(volatile int&)); > +SA(!__is_pointer(const volatile int&)); > + > +SA(!__is_pointer(int&&)); > +SA(!__is_pointer(const int&&)); > +SA(!__is_pointer(volatile int&&)); > +SA(!__is_pointer(const volatile int&&)); > + > +SA(!__is_pointer(int[3])); > +SA(!__is_pointer(const int[3])); > +SA(!__is_pointer(volatile int[3])); > +SA(!__is_pointer(const volatile int[3])); > + > +SA(!__is_pointer(int(int))); > +SA(__is_pointer(int(*const)(int))); > +SA(__is_pointer(int(*volatile)(int))); > +SA(__is_pointer(int(*const volatile)(int)));