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 497323854574 for ; Mon, 28 Nov 2022 20:52:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 497323854574 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=1669668763; 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; bh=fo1s7KjMS7zUhBlwfEZbJkPzT90+PnZ5XfFCPrp1DLE=; b=IfM2Q6imGuWx7WZBUx/w/FxfKGZdjo6+4M+yAyrCI2+Ug7NwmxuM1mOhvrdQ51Tw3PqQep byehI4yyojfdRW9MYNMZxQA6lbjlBaT4og4LfsTiwurFpMnbSH2jcmqF3wkrG8eGPB2YZ6 S01v7lsXu6I4/ypv2TgMaDB62SnrFug= Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-436-Yoy5Bg-KMUSSAhSxYyOuzA-1; Mon, 28 Nov 2022 15:52:41 -0500 X-MC-Unique: Yoy5Bg-KMUSSAhSxYyOuzA-1 Received: by mail-qv1-f70.google.com with SMTP id q17-20020a056214019100b004b1d3c9f3acso15433511qvr.0 for ; Mon, 28 Nov 2022 12:52:41 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=fo1s7KjMS7zUhBlwfEZbJkPzT90+PnZ5XfFCPrp1DLE=; b=hX0NngJ4uIX+Thl4nVMCaVmaoz4t6XEmzFJ7T1TDQlPk7oUa5qX1o2FlJWhc0uPhUi 9RaSj5emBFTECEWWCaxvmSo8dpsmaRin1ZQZYCbEHYzXg22drRGBT9JILj25GTCVZOLE 3ZfZJa10lAGHmLgq4Cwu8i8wygtMG9iAGS/AAC2XumD5SPCenlz19r+0UtOAFdPq3K5q R6Zn/2JZwzIUehtgZEU/c6RiSl+iO02xvWjpzcZiOb5uEQXJ11LqHyjKoWzDlxyVQXP7 oV3Yv3wB1MGGeyQGylHc3JjuwgTw3L4urKH+9D++KPD3ZAjOtPzEmKiezmypXc6D2967 ADAA== X-Gm-Message-State: ANoB5pmEsB2gXfaRIGz/ZNp1vfLx3qlnZzn9IJgSRfJo7cAOhjYgUv8f hcmMa/fHzek6giyZkg/RYlJw6mQubYZUgsIatQGpZg1aXq+MjNTBBkkESsbYt3HvY1ppXdEDfpO 9P6bcYGq2HL3xL6dQtFWlkaleVfWAO1q/hVIQ4F6lpppd1/H9f/xra35MP9J8gT2WYQ== X-Received: by 2002:ac8:67c5:0:b0:3a4:f665:7791 with SMTP id r5-20020ac867c5000000b003a4f6657791mr50621962qtp.380.1669668760983; Mon, 28 Nov 2022 12:52:40 -0800 (PST) X-Google-Smtp-Source: AA0mqf7wjE23w4ORJtGP+MSHUgE0C3rppqhrjoowUIhHonEpd6BXMK6DHjTDTd0EuR9HQf+cBvw2zA== X-Received: by 2002:ac8:67c5:0:b0:3a4:f665:7791 with SMTP id r5-20020ac867c5000000b003a4f6657791mr50621935qtp.380.1669668760601; Mon, 28 Nov 2022 12:52:40 -0800 (PST) Received: from jason.com (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 w30-20020a05620a0e9e00b006faaf6dc55asm8929446qkm.22.2022.11.28.12.52.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Nov 2022 12:52:40 -0800 (PST) From: Jason Merrill To: gcc-patches@gcc.gnu.org Subject: [pushed] c++: simple-requirement starting with 'typename' [PR101733] Date: Mon, 28 Nov 2022 15:52:36 -0500 Message-Id: <20221128205236.541407-1-jason@redhat.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-Spam-Status: No, score=-12.5 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_H2,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: Tested x86_64-pc-linux-gnu, applying to trunk. -- 8< -- Usually a requirement starting with 'typename' is a type-requirement, but it might be a simple-requirement such as a functional cast to a typename-type. PR c++/101733 gcc/cp/ChangeLog: * parser.cc (cp_parser_requirement): Parse tentatively for the 'typename' case. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/concepts-requires32.C: New test. --- gcc/cp/parser.cc | 15 ++++++++++++++- gcc/testsuite/g++.dg/cpp2a/concepts-requires32.C | 11 +++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/cpp2a/concepts-requires32.C diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc index 82459b7683a..a13fbe41309 100644 --- a/gcc/cp/parser.cc +++ b/gcc/cp/parser.cc @@ -30737,7 +30737,20 @@ cp_parser_requirement (cp_parser *parser) if (cp_lexer_next_token_is (parser->lexer, CPP_OPEN_BRACE)) return cp_parser_compound_requirement (parser); else if (cp_lexer_next_token_is_keyword (parser->lexer, RID_TYPENAME)) - return cp_parser_type_requirement (parser); + { + /* It's probably a type-requirement. */ + cp_parser_parse_tentatively (parser); + tree req = cp_parser_type_requirement (parser); + if (cp_parser_parse_definitely (parser)) + return req; + /* No, maybe it's something like typename T::type(); */ + cp_parser_parse_tentatively (parser); + req = cp_parser_simple_requirement (parser); + if (cp_parser_parse_definitely (parser)) + return req; + /* Non-tentative for the error. */ + return cp_parser_type_requirement (parser); + } else if (cp_lexer_next_token_is_keyword (parser->lexer, RID_REQUIRES)) return cp_parser_nested_requirement (parser); else diff --git a/gcc/testsuite/g++.dg/cpp2a/concepts-requires32.C b/gcc/testsuite/g++.dg/cpp2a/concepts-requires32.C new file mode 100644 index 00000000000..117b8920787 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp2a/concepts-requires32.C @@ -0,0 +1,11 @@ +// PR c++/101733 +// { dg-do compile { target c++20 } } + +template +requires requires { + typename T::type; + (typename T::type()); // (1) + T::type(); // (2) + typename T::type(); // (3) +} +void f(T) { } base-commit: 47d81b1b89d615cea27307c713a4afe591e1cd2d prerequisite-patch-id: 275d90e1bd8b940c1cca2840bc38dc4fafa0797b -- 2.31.1