From patchwork Wed Jul 24 21:34:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 1964521 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=N1BoG7+x; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WTnPb1gxhz1ydm for ; Thu, 25 Jul 2024 07:35:45 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 015093858C31 for ; Wed, 24 Jul 2024 21:35:44 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id 942043858D29 for ; Wed, 24 Jul 2024 21:35:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 942043858D29 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 942043858D29 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=1721856916; cv=none; b=lDmPb0uJY9jifbB6BnEMqfh3hEGzxlSWvjilCYqGQlvO+9mQsYPAZWzGKj4evblJCCvAfbZDoOyCb3bYEzow+6E/28o2DISRkfhlE2lVVcya2laJDfTVMFPcYTq9cT3QwuXbSbYgVqzfnkjfwGunAc1YboAuWfQ9BLX14JaG++E= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1721856916; c=relaxed/simple; bh=vyA/FeuG0bI0wDw7rCE6VrNtYBkcwAkWP6SQHKms7tg=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=V6g3AledpQv4suAAbk9tDcYbbYZmDnqVZO20ukBW4/GgO1fsdZ2OAcExtOlJcVZ5k75/XzcnzGVcBFEq17uGumkTQ9czScaxQMmE6OwYyklZ7NUH9RDf9eEmk4B56ScUZn0dP2b27/vSQU7UllE7JCsUqnnPWFbAtC2h9hRBiS8= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721856914; 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=A6Z8OitqFCI4dfBgUsUTFce1vfncXpy/BGD79xKCXUc=; b=N1BoG7+xWPuYkvinkPBuefW1U0dSUS9p1a/ripJQCYyYhoLTLgEF1V4iwLCKJRllTT6EXg Maoj0OWK6GFUp8CCJa1lfYwRZ9latMc2GlGfsq7KwOHBMOiqPkwjkLnfNMMvOy4NUlatHz 1CbN5aYmmhQq4s7S/RBvhKI3bUDgQM8= Received: from mail-yw1-f197.google.com (mail-yw1-f197.google.com [209.85.128.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-282-KbxPSkBNN7i_RTztLGxx-w-1; Wed, 24 Jul 2024 17:35:13 -0400 X-MC-Unique: KbxPSkBNN7i_RTztLGxx-w-1 Received: by mail-yw1-f197.google.com with SMTP id 00721157ae682-6698f11853aso6573027b3.0 for ; Wed, 24 Jul 2024 14:35:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721856912; x=1722461712; 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=A6Z8OitqFCI4dfBgUsUTFce1vfncXpy/BGD79xKCXUc=; b=wrRIt3neHjQmoDvLARq1Mh6ILDyVANWVZ6KLoWdJQkg4bnMX9xw7N9N7jdoPzKTlhw UbDKh1zr7eZNw/oKN/ZkH4MrlOeNsVFKYM7otIAb9cs3bzuYWhy41mFNG/B1IdO4Bbgj VV+W6KSMph5w02NmD5HWPw5dtCEQ8wMyeS1//jqSR362mo8bbRCwwulfvCVKkJCSER/4 AO3bxI6w97lTYJxyeMTN1dRLzRrfPjdXiYADMj7bPPuYqZwFnD4eUmQExfFxwRx9aD2F 6nKL0GqlWiPxrAXtGlbatIIVkK3IrcLIWVNXeboj8L+eOph3b0GAgEVWZcYUed3bpBgM JUFg== X-Gm-Message-State: AOJu0YxpNTDWXMAH3HEtp8M8gIm1wMxF2OZgFbv8pvfQkOirQzalFyWU Hhl2RO3y0Li/rDLXpCiCR146w38zNydFvDxIUdlJflJJwVfOklTxedn6z/2e9pYKhwKjfNcPa2B AiGSMT8J0Lj84joYyMuqahilXKS/tM2WFHXk8MXcZGQip+92vJBEfsJcXse8HNGs/SOtnOnieaj eJuk7TpyD7sHT5HSR/9rwddVuLD1lyRhc1k80= X-Received: by 2002:a05:690c:45c5:b0:61a:ccb0:7cdd with SMTP id 00721157ae682-675161751b6mr7817797b3.46.1721856912138; Wed, 24 Jul 2024 14:35:12 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEx++DOJ+iAlZ//B5p5Ve0+Npt9wFLXHpU4O68DK3o+j7/jcETyRAjC2yGQmmhaMZJien+v4g== X-Received: by 2002:a05:690c:45c5:b0:61a:ccb0:7cdd with SMTP id 00721157ae682-675161751b6mr7817707b3.46.1721856911743; Wed, 24 Jul 2024 14:35:11 -0700 (PDT) Received: from jason-thinkpadp1gen4i.rmtusma.csb (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 6a1803df08f44-6bb3fa9bcabsm136686d6.95.2024.07.24.14.35.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jul 2024 14:35:10 -0700 (PDT) From: Jason Merrill To: gcc-patches@gcc.gnu.org Subject: [pushed] c++: parse error with -std=c++14 -fconcepts [PR116071] Date: Wed, 24 Jul 2024 17:34:52 -0400 Message-ID: <20240724213509.3270629-1-jason@redhat.com> X-Mailer: git-send-email 2.45.2 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.3 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=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org Tested x86_64-pc-linux-gnu, applying to trunk. -- 8< -- cp_parser_simple_type_specifier tries a variety of different things that might qualify as a user-defined type: an actual type-name, a constrained auto, a CTAD placeholder. In a context where a type-specifier is optional, this is all tentative. With -std=c++14 -fconcepts, we try type-name and constrained auto in sub-tentative parses, and when we run out of things to try we haven't found anything but also haven't failed the outer tentative parse, so parse_definitely succeeds, discarding the nested-name-specifier. Fixed by failing if we didn't find anything. I said in r14-3203 that we should disable this combination of flags if further problems arise, but this seems like a more general problem that only happened to occur with just this combination of flags. So it lives on. PR c++/116071 gcc/cp/ChangeLog: * parser.cc (cp_parser_simple_type_specifier): Call cp_parser_simulate_error if nothing worked. gcc/testsuite/ChangeLog: * g++.dg/parse/pr116071.C: New test. --- gcc/cp/parser.cc | 10 +++++++--- gcc/testsuite/g++.dg/parse/pr116071.C | 18 ++++++++++++++++++ 2 files changed, 25 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/g++.dg/parse/pr116071.C base-commit: d2fc64c85788c135419cc3dcf5b4fa64558af547 diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc index 1fa0780944b..f79736c17ac 100644 --- a/gcc/cp/parser.cc +++ b/gcc/cp/parser.cc @@ -20786,9 +20786,13 @@ cp_parser_simple_type_specifier (cp_parser* parser, } /* If it didn't work out, we don't have a TYPE. */ - if ((flags & CP_PARSER_FLAGS_OPTIONAL) - && !cp_parser_parse_definitely (parser)) - type = NULL_TREE; + if (flags & CP_PARSER_FLAGS_OPTIONAL) + { + if (!type) + cp_parser_simulate_error (parser); + if (!cp_parser_parse_definitely (parser)) + type = NULL_TREE; + } /* Keep track of all name-lookups performed in class scopes. */ if (type diff --git a/gcc/testsuite/g++.dg/parse/pr116071.C b/gcc/testsuite/g++.dg/parse/pr116071.C new file mode 100644 index 00000000000..7590782d5ee --- /dev/null +++ b/gcc/testsuite/g++.dg/parse/pr116071.C @@ -0,0 +1,18 @@ +// PR c++/116071 +// { dg-options "-std=c++14 -fconcepts" } + +template struct S { ~S(); }; +template S::~S() { } + +template +struct result_of; + +template +struct result_of +{ + using type = void; +}; + +struct thread { + void join() { }; +};