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 A3261385C419 for ; Thu, 29 Sep 2022 17:56:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A3261385C419 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=1664474162; 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: in-reply-to:in-reply-to:references:references; bh=CTUb4cZYbCTF+B1v/O/8CBEidI6IHGs8NA56b7xUgxg=; b=NxxNeEgS/4MzjQxsWYBjQ8EueroVdfsNt8uPkQr+fAhG6KIN0MZF6T/2j2Mi4RZ/bbYBuG Abn8L3cutb7LhJ2VHQsTpwfNe5fARn4POx536u0XI+qddymyIQF+R3zT8XOBh+CJNdMRZ/ G9o/SOvf+caZzMBbw8O50t+EAVfb44Q= Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-628-FRf6Rh2ePemxaXlIS7j8TQ-1; Thu, 29 Sep 2022 13:56:00 -0400 X-MC-Unique: FRf6Rh2ePemxaXlIS7j8TQ-1 Received: by mail-qk1-f199.google.com with SMTP id d18-20020a05620a241200b006ce80a4d74aso1754185qkn.6 for ; Thu, 29 Sep 2022 10:56:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=user-agent:in-reply-to:content-disposition:mime-version:references :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date; bh=CTUb4cZYbCTF+B1v/O/8CBEidI6IHGs8NA56b7xUgxg=; b=2boqm5FQXRynYtdv3zVheQvnGhsy0w3byXfC9wBGzGMUfQgRrsAdVnJvZ777PyV0jM k52hOvt9UNRgSFJylB368zp9UTVEb8175p7SWMkNjCPDqGg+PbjLXkzltysyaXREF9Yy aFjleIMYX+8FOQY0FKQ9+jtEEkCXV4fWI0knbs+DZoKGYwQiLdZBqTXRRpsPuGlIzsaq xy077hjN5m1QeyoSVOZf4nnpiZRxCbFciL1QHe2slNdrQ7xCrYdjB7y8+XaQvAXX363A 35dZ7oIT82Z0gsdkwNmwehvaZNh64ighx2+hn+OSxYWgQl2a14M+yt/0lH89DRR4pKhq CDMQ== X-Gm-Message-State: ACrzQf2E0HyJ71rP+dIjCp85z9CxEHU6LXG8uOeqHUVXy/LpyJzo3fzx uhn0qAxIDdwDJL4vGQpjqXy1UxQMKWFNYrka7NIT6MmTCdRF5N7VUrbIC01glTW9e9cWMG66s4S TzO3x/BgA5BqSry05WQ== X-Received: by 2002:a05:620a:14aa:b0:6cb:e3a2:311b with SMTP id x10-20020a05620a14aa00b006cbe3a2311bmr3206047qkj.266.1664474160386; Thu, 29 Sep 2022 10:56:00 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7MejxTaeuTevqjL2Z0nb/E56jVeZzpD4YmqhKRFVLhWzWcU8R2n71bW/iHbSTePfwUHwhuCg== X-Received: by 2002:a05:620a:14aa:b0:6cb:e3a2:311b with SMTP id x10-20020a05620a14aa00b006cbe3a2311bmr3206034qkj.266.1664474160183; Thu, 29 Sep 2022 10:56:00 -0700 (PDT) Received: from redhat.com (2603-7000-9500-2e39-0000-0000-0000-1db4.res6.spectrum.com. [2603:7000:9500:2e39::1db4]) by smtp.gmail.com with ESMTPSA id ay15-20020a05622a228f00b0035d5e5660cbsm2419866qtb.59.2022.09.29.10.55.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Sep 2022 10:55:59 -0700 (PDT) Date: Thu, 29 Sep 2022 13:55:57 -0400 From: Marek Polacek To: Patrick Palka Cc: gcc-patches@gcc.gnu.org, jwakely@redhat.com Subject: Re: [PATCH RFC] c++: streamline process for adding new builtin trait Message-ID: References: <20220929150504.829703-1-ppalka@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220929150504.829703-1-ppalka@redhat.com> User-Agent: Mutt/2.2.7 (2022-08-07) X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-6.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,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 Thu, Sep 29, 2022 at 11:05:04AM -0400, Patrick Palka via Gcc-patches wrote: > Adding a new builtin trait currently involves some boilerplate (as can > be seen in r13-2956-g9ca147154074a0) of defining corresponding RID_ and > CPTK_ enumerators and adding them to various switch statements across > many files. The exact switch statements we need to change is determined > by whether the proposed trait yields a type or an expression. > > This RFC patch attempts to streamline this process via a centralized > cp-trait.def file for declaring the important parts about a builtin trait > (whether it yields a type or an expression, its code, its spelling and > its arity) and using this file to automate away the switch statement > addition boilerplate. It also converts 9 traits to use this approach > by way of example (we can convert all the traits once the design is > settled). > > After this change, the process of adding a new builtin trait is just > (modulo tests): declare it in cp-trait.def, define its behavior in > finish_trait_type/expr, and handle it in diagnose_trait_expr if it's > an expression-yielding trait (this last step is unfortunate but since > the switch has no default case, we'll at least get a diagnostic if we > forget to do it). > > Does this look like a good approach? I think it'd be fantastic to have this. It's been very easy to forget to update pp_cxx_trait, or names_builtin_p. cp-trait.def just needs to describe what the arguments mean. Marek