From patchwork Fri Sep 28 16:42:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 976407 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-486636-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.b="tXeYk9yU"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=oracle.com header.i=@oracle.com header.b="JJUR7E7k"; 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 42MHXb6dvgz9s3x for ; Sat, 29 Sep 2018 02:42:38 +1000 (AEST) 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=BfK28omWIVxSlNxJxvhayzkpW6iRD7Q1VNJBEFzWDwKYcNH7X8 z6esl4D/uS2W/7p003x3YPscdcJYWD8f+JydrJ0Tm1rEe4NfV2dOMgF/gH0yh12o VHWIErqPUGq6OAun0tcKlfMxi+/HUM264kzCG41lJCs+urasnmIZXa074= 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=UuwyW/4XIQhg9Q/aUbXFZmN2cdc=; b=tXeYk9yUhNJ+9bMEDqTl wtb8j+2CkN+0jmX9VBjRK2Nd0y6K2lVaJ9rbL6MyIyaXhzCmOwhqCNolF0D6thpX 9atE+dFr8M33mLGkE0RQ1d1dpQI+5qdqMYn9ZUJklqOBUEIJCnf/SiBqVkP7N8iq cp6NwQNb+OybzgD53jLuU+s= Received: (qmail 76992 invoked by alias); 28 Sep 2018 16:42:31 -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 76979 invoked by uid 89); 28 Sep 2018 16:42:31 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-11.1 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 spammy=acknowledge, luckily, declaring, raises X-HELO: userp2120.oracle.com Received: from userp2120.oracle.com (HELO userp2120.oracle.com) (156.151.31.85) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 28 Sep 2018 16:42:29 +0000 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w8SGdRS2071717; Fri, 28 Sep 2018 16:42:23 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-2018-07-02; bh=HD0Jm27+PGyyWAK9F+I/eZgcor+GVkVUqZkSkWOo+vQ=; b=JJUR7E7kfQ2jEfoGIkl0JPNemaQjDUdzNNkCyLn9vwOIu0jiNYW+9IApLhC6357Iu52K pKB+1gq6raPhVuE+Xg8RvMsxAhgO4xIdMrkcxBGwxbH4F8l5me1ClBJuPV3irIKvpZpo 4bUegcqhM2/EnSpCoWm9UFAfXBi8O523R7dfl+lERzBbV+RdP+b219rESJGS3ilnRufI LkmvAxovNZ9Ep5s3cx4NvRLnbeBhSrru29E3uXn/947i8zgI1yDdfAEswV5h2rHzV3+l 1GN51Z6tAf0+6w6jxdiMOGFT790n430RV3w4kVg41kMUzRp1QltnQ4kWdkr+K6JKPyw2 Hw== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by userp2120.oracle.com with ESMTP id 2mnvtv86tb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 28 Sep 2018 16:42:23 +0000 Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w8SGgMHT012560 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 28 Sep 2018 16:42:22 GMT Received: from abhmp0012.oracle.com (abhmp0012.oracle.com [141.146.116.18]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w8SGgMf3029847; Fri, 28 Sep 2018 16:42:22 GMT Received: from [192.168.1.4] (/87.21.233.110) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 28 Sep 2018 09:42:21 -0700 To: "gcc-patches@gcc.gnu.org" Cc: Jason Merrill , Nathan Sidwell From: Paolo Carlini Subject: [C++ Patch] PR 84423 ("[6/7/8/9 Regression] [concepts] ICE with invalid using declaration") Message-ID: <61471b27-ea85-8fc2-a7e3-178547e518d6@oracle.com> Date: Fri, 28 Sep 2018 18:42:19 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.0 MIME-Version: 1.0 X-IsSubscribed: yes Hi, the primary issue here is a rather straightforward error-recovery, where, after a sensible (but see below) error message we ICE in get_underlying_template - called by convert_template_argument - because we don't handle correctly error_mark_node as TREE_TYPE, as set in grokdeclarator. While working on it I noticed that the error message emitted by grokdeclarator seems suboptimal, because, per 10.1.3/2, we correctly handle the alias declaration like a typedef but, I believe, we don't want to just say *typedef* in the error message: luckily the infrastructure to be more accurate is fully available, because we need it to set TYPE_DECL_ALIAS_P anyway. Tested x86_64-linux. Thanks, Paolo. ////////////////////// /cp 2018-09-28 Paolo Carlini PR c++/84423 * pt.c (convert_template_argument): Immediately return error_mark_node if the second argument is erroneous. * decl.c (grokdeclarator): Improve error message for 'auto' in alias declaration. /testsuite 2018-09-28 Paolo Carlini PR c++/84423 * g++.dg/concepts/pr84423.C: New. Index: cp/decl.c =================================================================== --- cp/decl.c (revision 264687) +++ cp/decl.c (working copy) @@ -11879,6 +11879,7 @@ grokdeclarator (const cp_declarator *declarator, /* If this is declaring a typedef name, return a TYPE_DECL. */ if (typedef_p && decl_context != TYPENAME) { + bool alias_p = decl_spec_seq_has_spec_p (declspecs, ds_alias); tree decl; /* This declaration: @@ -11901,7 +11902,10 @@ grokdeclarator (const cp_declarator *declarator, if (type_uses_auto (type)) { - error ("typedef declared %"); + if (alias_p) + error ("% not allowed in alias declaration"); + else + error ("typedef declared %"); type = error_mark_node; } @@ -11961,7 +11965,7 @@ grokdeclarator (const cp_declarator *declarator, inlinep, friendp, raises != NULL_TREE, declspecs->locations); - if (decl_spec_seq_has_spec_p (declspecs, ds_alias)) + if (alias_p) /* Acknowledge that this was written: `using analias = atype;'. */ TYPE_DECL_ALIAS_P (decl) = 1; Index: cp/pt.c =================================================================== --- cp/pt.c (revision 264687) +++ cp/pt.c (working copy) @@ -7776,7 +7776,7 @@ convert_template_argument (tree parm, tree val; int is_type, requires_type, is_tmpl_type, requires_tmpl_type; - if (parm == error_mark_node) + if (parm == error_mark_node || error_operand_p (arg)) return error_mark_node; /* Trivially convert placeholders. */ Index: testsuite/g++.dg/concepts/pr84423.C =================================================================== --- testsuite/g++.dg/concepts/pr84423.C (nonexistent) +++ testsuite/g++.dg/concepts/pr84423.C (working copy) @@ -0,0 +1,8 @@ +// { dg-do compile { target c++11 } } +// { dg-additional-options "-fconcepts" } + +template using A = auto; // { dg-error "alias declaration" } + +template class> struct B {}; + +B b;