From patchwork Mon Sep 26 11:53:44 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 116409 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 638A6B6F69 for ; Mon, 26 Sep 2011 21:55:27 +1000 (EST) Received: (qmail 6570 invoked by alias); 26 Sep 2011 11:55:18 -0000 Received: (qmail 6560 invoked by uid 22791); 26 Sep 2011 11:55:17 -0000 X-SWARE-Spam-Status: No, hits=-2.3 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from acsinet15.oracle.com (HELO acsinet15.oracle.com) (141.146.126.227) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 26 Sep 2011 11:55:03 +0000 Received: from rtcsinet22.oracle.com (rtcsinet22.oracle.com [66.248.204.30]) by acsinet15.oracle.com (Switch-3.4.4/Switch-3.4.4) with ESMTP id p8QBsxUL015456 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 26 Sep 2011 11:55:02 GMT Received: from acsmt358.oracle.com (acsmt358.oracle.com [141.146.40.158]) by rtcsinet22.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id p8QBsw71002754 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 26 Sep 2011 11:54:58 GMT Received: from abhmt119.oracle.com (abhmt119.oracle.com [141.146.116.71]) by acsmt358.oracle.com (8.12.11.20060308/8.12.11) with ESMTP id p8QBsqRh001181; Mon, 26 Sep 2011 06:54:52 -0500 Received: from [192.168.1.4] (/79.33.220.20) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 26 Sep 2011 04:54:52 -0700 Message-ID: <4E8067C8.1070206@oracle.com> Date: Mon, 26 Sep 2011 13:53:44 +0200 From: Paolo Carlini User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:6.0.2) Gecko/20110907 Thunderbird/6.0.2 MIME-Version: 1.0 To: "gcc-patches@gcc.gnu.org" CC: Jason Merrill Subject: [C++ Patch] Fix for ICE when instantiating non-type template with nullptr X-IsSubscribed: yes 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 Hi, in private email, Daniel pointed out that, post my recent fix in this area, instantiation is not handled yet. Thus I prepared the very simple patch below. Should we provide a more specific error message? Tested x86_64-linux. Thanks, Paolo. //////////////////// /cp 2011-09-26 Paolo Carlini * pt.c (convert_nontype_argument): Handle NULLPTR_TYPE. /testsuite 2011-09-26 Paolo Carlini * g++.dg/cpp0x/nullptr25.C: New. Index: testsuite/g++.dg/cpp0x/nullptr25.C =================================================================== --- testsuite/g++.dg/cpp0x/nullptr25.C (revision 0) +++ testsuite/g++.dg/cpp0x/nullptr25.C (revision 0) @@ -0,0 +1,6 @@ +// { dg-options -std=c++0x } + +template +struct nt{}; + +nt x; Index: cp/pt.c =================================================================== --- cp/pt.c (revision 179187) +++ cp/pt.c (working copy) @@ -5951,6 +5951,16 @@ convert_nontype_argument (tree type, tree expr, ts if (expr == error_mark_node) return expr; } + else if (NULLPTR_TYPE_P (type)) + { + if (expr != nullptr_node) + { + error ("%qE is not a valid template argument for type %qT " + "because it is of type %qT", expr, type, TREE_TYPE (expr)); + return NULL_TREE; + } + return expr; + } /* A template non-type parameter must be one of the above. */ else gcc_unreachable ();