From patchwork Wed Jan 22 15:22:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 1227329 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-518031-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha1 header.s=default header.b=MIJTLUF1; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=oracle.com header.i=@oracle.com header.a=rsa-sha256 header.s=corp-2019-08-05 header.b=otDFUzVW; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 482q0557rsz9sQp for ; Thu, 23 Jan 2020 02:22:28 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to:cc :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=HcwVT/gWmLlg2rCOuBEgol1/Kjt1uy0+BGF5xNCwA2dRtdpzsN RSgTZ+RR394hDFxZp9bVp/sLyp821+6F3IHANmhD6+LcJ2a7I+TrQOCgdNxx99Wc /55z6mAvJE/aloYCB1XFv2xvPsMu5Bsyjl+uajRk0nQpAhHsmerUxUPA8= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to:cc :from:subject:message-id:date:mime-version:content-type; s= default; bh=E2DhxzuC37vzKXeHanjzmMOz7pY=; b=MIJTLUF1q17+aepCZtvJ /isIqIia1W0CKJWuqXiw+Pm6i7p8mvYPsIMUqCJGJgXlnsRskyO4odlwrOMdWlMq XHQC6nGoK1rg1V/gcYiAiCOahIb6WujqUz9KuQ1HDgzTF+rBW1xL7jjPpo917/OB cyG7sZEjrC5wNf/11k+AbEM= Received: (qmail 124213 invoked by alias); 22 Jan 2020 15:22:20 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 124201 invoked by uid 89); 22 Jan 2020 15:22:20 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-17.7 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_HELO_PASS autolearn=ham version=3.3.1 spammy=H*r:8.14.4 X-HELO: aserp2120.oracle.com Received: from aserp2120.oracle.com (HELO aserp2120.oracle.com) (141.146.126.78) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 22 Jan 2020 15:22:18 +0000 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id 00MFHwY3165239; Wed, 22 Jan 2020 15:22:16 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=to : cc : from : subject : message-id : date : mime-version : content-type; s=corp-2019-08-05; bh=C0XaVUJCAdAddF0DTRG5oPRrLkF7NhAMf049g5ii9gQ=; b=otDFUzVWEdjCeO7RwSibNJnuWfnFUcCc3vOVXTqzfOiVNMei0lEKtxlxXV/HohOE330l C4lgJekDgsYXvX+HxVKu3dIBh7956qudGe5UcOf/jv2Wotyx6i/4lLdAo/QqP4YB3AhJ Zys/poNtxnT3z6BuA6BOGQpUY2/EaraDXyRoB2z0kQruAD1+hD77ssvZCkQGt+NUVuiz lKz20UCagNyvnMfd5icLuN0ZWXinpM2p7rsLH/tBDD8YI5UiIEJixMTr8jD9Ugnl28j/ uy2u7ivb+7biH2bF2yNw/s3alVMn8pIDHDUPWM03P+6ofjopvaG0HSOzmNNGs9riH6+h CQ== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by aserp2120.oracle.com with ESMTP id 2xksyqcdcs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 22 Jan 2020 15:22:16 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id 00MFJBSl151692; Wed, 22 Jan 2020 15:22:16 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3030.oracle.com with ESMTP id 2xpq0u7v17-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 22 Jan 2020 15:22:16 +0000 Received: from abhmp0005.oracle.com (abhmp0005.oracle.com [141.146.116.11]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 00MFMFOZ016874; Wed, 22 Jan 2020 15:22:15 GMT Received: from [192.168.1.4] (/87.13.210.56) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 22 Jan 2020 07:22:14 -0800 To: "gcc-patches@gcc.gnu.org" Cc: Jason Merrill From: Paolo Carlini Subject: [C++ Patch] PR 92804 [10 Regression] ICE trying to use concept as a nested-name-specifier Message-ID: Date: Wed, 22 Jan 2020 16:22:12 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.3.0 MIME-Version: 1.0 X-IsSubscribed: yes Hi, in this simple issue we either wrongly talked about variable template-id in c++17 mode or ICEd in c++2a. I think we simply want to handle concept-ids first, both as represented in c++17 mode and as represented in c++2a mode. Tested x86_64-linux. Thanks, Paolo. /////////////////////// Fix "PR c++/92804 ICE trying to use concept as a nested-name-specifier" A rather simple ICE where we failed to properly check for concept-ids uses in nested-name-specifiers. Tested x86_64-linux. /cp PR c++/92804 * parser.c (cp_parser_nested_name_specifier_opt): Properly diagnose concept-ids. /testsuite PR c++/92804 * g++.dg/concepts/pr92804.C: New. diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index caafbefda8e..fe490d4a69f 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -6472,11 +6472,18 @@ cp_parser_nested_name_specifier_opt (cp_parser *parser, } else { - /* Variable template. */ tmpl = TREE_OPERAND (tid, 0); - gcc_assert (variable_template_p (tmpl)); - error_at (token->location, "variable template-id %qD " - "in nested-name-specifier", tid); + if (variable_concept_p (tmpl) + || standard_concept_p (tmpl)) + error_at (token->location, "concept-id %qD " + "in nested-name-specifier", tid); + else + { + /* Variable template. */ + gcc_assert (variable_template_p (tmpl)); + error_at (token->location, "variable template-id " + "%qD in nested-name-specifier", tid); + } } if (tmpl) inform (DECL_SOURCE_LOCATION (tmpl), diff --git a/gcc/testsuite/g++.dg/concepts/pr92804.C b/gcc/testsuite/g++.dg/concepts/pr92804.C new file mode 100644 index 00000000000..cc21426bb9e --- /dev/null +++ b/gcc/testsuite/g++.dg/concepts/pr92804.C @@ -0,0 +1,19 @@ +// { dg-do compile { target c++17 } } +// { dg-options "-fconcepts" } + +template +concept foo = true; // { dg-message "declared here" } + +template +void bar(T t) +{ + if constexpr (foo::value) // { dg-error "17:concept-id .foo. in nested-name-specifier" } + // { dg-error "expected|value" "" { target c++17 } .-1 } + { + } +} + +int main() +{ + bar(1); +}