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 83F563858C2D for ; Mon, 23 Oct 2023 20:36:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 83F563858C2D 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 83F563858C2D Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698093385; cv=none; b=REzjhiYxSJ/BtAu19Cm1CTXuQc3bLGufp4/lLxujdANvrR89I/SwR2dLaULWMg/rlpC50ArgoOPwjEthwtE9+miadl9V2CRU2PNIiYaMD1r47L1JNmW47Hl54frwK09QpIhfOEyx/37yFV8ZVqvEkN9uaYlYCEQhGqaE8VQWeYU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698093385; c=relaxed/simple; bh=K1Au2RaGeVvD88J3l1O/XKfiGCP1zs5GYzyNxmIlTRc=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=OUe3M8Vo0TyPHpsW1WuQeEYvcybWhjfgYQqxRgUEU400Lj8kki/6Gbj/f9lygsOLsp5GH0K6vwzBxnZ1BGTw8uAqCHrWcdUqD2kJO3c1VfpQWERcAixXssDwG1nSV/qlMdTOOO28bzCSXSeVoO22EzY8OgMgWt3I5x69ToFV3LU= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1698093384; 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=arEE5pN3knvfmhdJlk/VHWe1SNAmgBqb2hPYHRiBiec=; b=OmQrKGauCysMEU+HTxn9gQErER0Y8lBX6HJ5TQo776Wfa8pJId/Hhm2DeyiSdQlikDY8GX eyzWHCeXovH7pmt92HdYFG1hnHbjKmY88thIfL+OXq2w04aGetpZbt20sOh0Xi8euKmQmG CWLi+j4OxGAGv0JOXsM1b04BDJ4FzKc= Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-607-goQV7RqoOomMsMOkcvtCqA-1; Mon, 23 Oct 2023 16:36:22 -0400 X-MC-Unique: goQV7RqoOomMsMOkcvtCqA-1 Received: by mail-qk1-f197.google.com with SMTP id af79cd13be357-7789f06778aso833072585a.0 for ; Mon, 23 Oct 2023 13:36:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698093382; x=1698698182; 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=arEE5pN3knvfmhdJlk/VHWe1SNAmgBqb2hPYHRiBiec=; b=t4DREQwiVmzfHwXob/iKX4izu9czsXq4+IgzBlOLcon+62DwuJftMDauR2Y97Y5izk hbTQXfFil909SJmDJ/FjRxIoVu27sZCsofJONTJMtP2RpFp+IN2QlgagLT2COj3SjiTL 17vHVuDuLO2J+yRNLzumPcvWaQPJU6nDIpf42Y/rdBMR0G1Qwgff9CBCgiRW45UKATsE VqHq5dZ5SJEU0wTFA7tXbYpQoNaDxTKb6XFuEdwZOAcOKqAPYAAja5mjvNECHbNb8dvO B1HCA69IBUqXMqQ7LuH1AIRl56wKh8nwXPbPmZUrMLhxUXO1TLbh1D5q1VnLzRkaN+zx Ufaw== X-Gm-Message-State: AOJu0YyTJ3LBROJhD6tQtQjCwVSynDqSpX9L9xIwJzZWPuJ4kRWQjUlo jVqXxhUezxK7UZF1A2bKse2C9yeYgSKUDICzaTWdv7sHdz6GHT0VWlC0xeTlIPynRv/+2V9wjRo MMy+P6oTqvZ/b2Uo= X-Received: by 2002:a05:620a:2590:b0:76c:a952:c70f with SMTP id x16-20020a05620a259000b0076ca952c70fmr13478318qko.35.1698093382299; Mon, 23 Oct 2023 13:36:22 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGLmS427oi/SFBBM+mKT79w6/J7V3M56qmHPR9d2nUE519ZgsrbepljiVQ5bDMEAF1uFZEY5w== X-Received: by 2002:a05:620a:2590:b0:76c:a952:c70f with SMTP id x16-20020a05620a259000b0076ca952c70fmr13478301qko.35.1698093381985; Mon, 23 Oct 2023 13:36:21 -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 cx21-20020a05620a51d500b00773fe8971bbsm2986322qkb.90.2023.10.23.13.36.21 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 23 Oct 2023 13:36:21 -0700 (PDT) Message-ID: <8a535c33-972c-4e23-8826-f662460a05e4@redhat.com> Date: Mon, 23 Oct 2023 16:36:20 -0400 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v23 03/33] c++: Accept the use of built-in trait identifiers To: Ken Matsui , gcc-patches@gcc.gnu.org Cc: libstdc++@gcc.gnu.org References: <20231017113822.677344-1-kmatsui@gcc.gnu.org> <20231020135748.1846670-1-kmatsui@gcc.gnu.org> <20231020135748.1846670-4-kmatsui@gcc.gnu.org> From: Jason Merrill In-Reply-To: <20231020135748.1846670-4-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=-6.4 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_H4,RCVD_IN_MSPIKE_WL,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 10/20/23 09:53, Ken Matsui wrote: > This patch accepts the use of built-in trait identifiers when they are > actually not used as traits. Specifically, we check if the subsequent token > is '(' for ordinary built-in traits or is '<' only for the special > __type_pack_element built-in trait. If those identifiers are used > differently, the parser treats them as normal identifiers. This allows > us to accept code like: struct __is_pointer {};. > > +/* Peeks the corresponding built-in trait if a given token is > a built-in trait. Otherwise, returns nullptr. */ > > static const cp_trait * > +cp_lexer_peek_trait (cp_lexer *lexer, const cp_token *token1) Passing in both the lexer and the peeked token seems awkward, let's just pass in the lexer. Looking up the peeked token again is fast. > { > + if (token1->type == CPP_NAME && IDENTIFIER_TRAIT_P (token1->u.value)) > + { > + const cp_trait &trait = cp_traits[IDENTIFIER_CP_INDEX (token1->u.value)]; > + const bool is_pack_element = (trait.kind == CPTK_TYPE_PACK_ELEMENT); > + > + /* Check if the subsequent token is a `<' token to > + __type_pack_element or is a `(' token to everything else. */ git complains about indentation with spaces instead of a tab on this line. Jason