From patchwork Mon Sep 3 20:59:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 965601 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-485047-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="DATwi0YU"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=oracle.com header.i=@oracle.com header.b="rajqmJLk"; 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 42431D4XhSz9ryn for ; Tue, 4 Sep 2018 07:26:05 +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=DPzL0U34KqRNmS2NyhDLNWZU9Ogb6b4H4wnaVpMLIguvHrSQoI vC5oL050jivzp+axSlE0hoM1Q5VuIXGrL6dWUECsYOusvvhLr0irpuu+y606IgDm tPvu99xt8vOKH58UlpMZ6YLoEXkGGW0iY61sW6JChjWallJanSkdwPWN0= 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=XrYuoP2Jdf5c55rNhPsxiZk0glI=; b=DATwi0YUC4gCywWpXrCa e/rJnq+Xmj7mREPe5PAIPNlR7cTaF3iVbivVYj7jI+HN+IWvizjGP0UZ1AWSEw/z hWuEih7uSoGDfsUV2ejoJHocvgjyveMsIpSJiVWEc9w3p6X5R3ZRTKRZj9yKU79d 5jO3EU4vTZJaUWyK91x4sf8= Received: (qmail 66053 invoked by alias); 3 Sep 2018 20:59:23 -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 65943 invoked by uid 89); 3 Sep 2018 20:59:22 -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 autolearn=ham version=3.3.2 spammy=NODE, Thus, essentially 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; Mon, 03 Sep 2018 20:59:20 +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 w83Kwt72008539; Mon, 3 Sep 2018 20:59: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-2018-07-02; bh=KHK17DOLy2Rexm7/2wqxPDPQNCult0PFr7u/FIuaLzg=; b=rajqmJLkfD3hmS/8ohq0o/JDX1w6EqoerE+hTa35Qy+plUruzECLwv9Div7AA2cVSPL1 rTYotYs+FXA5RFZsnH/e0FQQvtuWfV0MD6HQmisNbWygfZH5Ebt38CjWxu0dnq1xB0w6 lEJUc2cK/rOm6oMa814glqwbY1De/+SwyvRESQVeSfTUnrAMvLhXa95sbYxKS+SmJjVZ SCQLPqwqmFh4NjJxOHRfsXoLJcHafSANizjE24ohT23LX4fpIx9eHWeeqHQv4YVyvRz6 QObWD9mfkbuS7yV3zcHJeXi7cqrtNRc8P1EsGpVjr8/9Ob7OelPvTfjPmOohyWuKWvWd ug== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by userp2120.oracle.com with ESMTP id 2m7kdq9611-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 03 Sep 2018 20:59:16 +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 w83KxFdM029051 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 3 Sep 2018 20:59:15 GMT Received: from abhmp0002.oracle.com (abhmp0002.oracle.com [141.146.116.8]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w83KxEeI006385; Mon, 3 Sep 2018 20:59:14 GMT Received: from [192.168.1.4] (/80.181.162.101) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 03 Sep 2018 13:59:13 -0700 To: "gcc-patches@gcc.gnu.org" Cc: Jason Merrill , Nathan Sidwell From: Paolo Carlini Subject: [C++ Patch] PR 85065 ("[concepts] ICE with invalid use of a concept") Message-ID: <1323550c-2bd5-8351-231e-c4093ab960a4@oracle.com> Date: Mon, 3 Sep 2018 22:59:10 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 X-IsSubscribed: yes Hi, in this error-recovery ICE, upon the error make_constrained_auto assigns error_mark_node to PLACEHOLDER_TYPE_CONSTRAINTS (type) which then causes a crash later when hash_placeholder_constraint is called on it. I think we should cope with this somehow, I believe that consistency with the way we use error_mark_node in this part of the front-end prevents us from avoiding to assign the error_mark_node in the first place and, for the reasons explained in my previous patch, we want to unconditionally call make_constrained_auto. This said, catching in practice the error_mark_node would normally mean renouncing to the pattern 'if (tree c = ...)' which we lately appear to like a lot and seems indeed neat. Thus I'm wondering if we want instead to add a macro like ERROR_AS_NULL, which of course would be also useful in many other places - essentially in all the circumstances where we want to check for a kosher node, thus neither null nor error_mark_node. What do you think? What about the name, in case? Tested x86_64-linux. Thanks, Paolo. ///////////////// /cp 2018-09-03 Paolo Carlini PR c++/85065 * cp-tree.h (ERROR_AS_NULL): New. * pt.c (auto_hash::hash): Use it. (do_auto_deduction): Likewise. /testsuite 2018-09-03 Paolo Carlini PR c++/85065 * g++.dg/concepts/pr85065.C: New. Index: cp/cp-tree.h =================================================================== --- cp/cp-tree.h (revision 264063) +++ cp/cp-tree.h (working copy) @@ -1877,6 +1877,8 @@ struct GTY(()) language_function { /* In parser.c. */ extern tree cp_literal_operator_id (const char *); +#define ERROR_AS_NULL(NODE) ((NODE) == error_mark_node ? NULL_TREE : (NODE)) + /* TRUE if a tree code represents a statement. */ extern bool statement_code_p[MAX_TREE_CODES]; Index: cp/pt.c =================================================================== --- cp/pt.c (revision 264069) +++ cp/pt.c (working copy) @@ -26120,7 +26120,7 @@ struct auto_hash : default_hash_traits inline hashval_t auto_hash::hash (tree t) { - if (tree c = PLACEHOLDER_TYPE_CONSTRAINTS (t)) + if (tree c = ERROR_AS_NULL (PLACEHOLDER_TYPE_CONSTRAINTS (t))) /* Matching constrained-type-specifiers denote the same template parameter, so hash the constraint. */ return hash_placeholder_constraint (c); @@ -26879,7 +26879,7 @@ do_auto_deduction (tree type, tree init, tree auto /* Check any placeholder constraints against the deduced type. */ if (flag_concepts && !processing_template_decl) - if (tree constr = PLACEHOLDER_TYPE_CONSTRAINTS (auto_node)) + if (tree constr = ERROR_AS_NULL (PLACEHOLDER_TYPE_CONSTRAINTS (auto_node))) { /* Use the deduced type to check the associated constraints. If we have a partial-concept-id, rebuild the argument list so that Index: testsuite/g++.dg/concepts/pr85065.C =================================================================== --- testsuite/g++.dg/concepts/pr85065.C (nonexistent) +++ testsuite/g++.dg/concepts/pr85065.C (working copy) @@ -0,0 +1,6 @@ +// { dg-do compile { target c++14 } } +// { dg-additional-options "-fconcepts" } + +template concept bool C = true; + +C c = 0; // { dg-error "invalid reference to concept" }