From patchwork Sun Feb 17 11:58:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 1043647 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-496451-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="JTnG999S"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=oracle.com header.i=@oracle.com header.b="RGOsfX7O"; 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 442QWR3Htwz9sD4 for ; Sun, 17 Feb 2019 22:58:35 +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=hEKbVv1fnllEfcPOiCznDB2zvTer0p0uRg46OkEwwJDGJsnkF1 m4pmpczPXeKQJbDz5hUkp011rIfKxXV+u2b6ZVzLB+gvmdfo5z15OhlvcP8USEzb 3RHyNg1h8qEDICeQsBeXKLnos6yTj8bKSEIF1G9fpfGZ2cK9Q05VhVqJU= 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=1ryIrdKBwZZZD991xgtP18ebWdA=; b=JTnG999Sb83reBZ6FYsz BJcWM8FUSB2qXjClIVn0/bQ9Hx+tTa8nYzhmlPhrtlgIS+CjE2bdDXu/nqvpcuDs fpacQtyfcWPqg0imkX+SgIyBDzfW/W4L0uKJW05D+1DmSFaC/61vmgHNqiSjIcML A4Om7IUns6oyQM+v0P0euDw= Received: (qmail 66516 invoked by alias); 17 Feb 2019 11:58:27 -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 66496 invoked by uid 89); 17 Feb 2019 11:58:26 -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=cpp1y, deduction, exact, Hx-languages-length:1820 X-HELO: userp2130.oracle.com Received: from userp2130.oracle.com (HELO userp2130.oracle.com) (156.151.31.86) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 17 Feb 2019 11:58:25 +0000 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x1HBsMfs157160; Sun, 17 Feb 2019 11:58: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=etQ8wlD8I1mSBVNfeqMB8JQuObgYGqu46VSja88jXJo=; b=RGOsfX7OhUCmbX4/Mpe/n3Olts5btHgjCDF7VfMBzY0hZxc3Mu5sf1oje4HyrnZx0jJh i8t50HYgitL22x4dy5adM3yzCYEcwRrW9uCjbE3q51fy9GJAwwYqPef+2031kAaUVek9 c5YzmpyF3iU0zNlAuqSzWY4qzVbFPGa43QFTOLyFyWX7LaqSaegNNAkCU/q2H76mEWUv LDHtuUeWs1TKMTxhzUhVscTttg+Ee5XtFzmTvrg0yhX3vg6Q4xjZTGyOFz4lpjFoyCQe 0DMBUjzAEENz1ca4E+awnTloNU6Iz5Cm6urNndQa38Z76/7Adq1EID6KZh/1VwMbRLDj Eg== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp2130.oracle.com with ESMTP id 2qp9xtju59-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 17 Feb 2019 11:58:23 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id x1HBwMpI028263 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 17 Feb 2019 11:58:22 GMT Received: from abhmp0008.oracle.com (abhmp0008.oracle.com [141.146.116.14]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x1HBwMFn011810; Sun, 17 Feb 2019 11:58:22 GMT Received: from [192.168.1.4] (/79.19.31.237) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sun, 17 Feb 2019 11:58:21 +0000 To: "gcc-patches@gcc.gnu.org" Cc: Jason Merrill From: Paolo Carlini Subject: [C++ Patch] PR 84536 ("[7/8/9 Regression] ICE with non-type template parameter") Message-ID: Date: Sun, 17 Feb 2019 12:58:18 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.5.0 MIME-Version: 1.0 X-IsSubscribed: yes Hi, here, when we don't see an initializer we believe we are surely dealing with a case of C++17 template argument deduction for class templates, but, in fact, it's just an ill-formed C++14 template variable specialization. Conveniently, we can use here too the predicate variable_template_specialization_p. Not 100% sure about the exact wording of the error message, I added '#' to %qD to explicitly print the auto-using type too. Tested x86_64-linux. Thanks, Paolo. ///////////////////////// /cp 2019-02-17 Paolo Carlini PR c++/84536 * decl.c (cp_finish_decl): Do not ICE on a template variable specialization missing an initializer. /testsuite 2019-02-17 Paolo Carlini PR c++/84536 * g++.dg/cpp1y/var-templ60.C: New. Index: cp/decl.c =================================================================== --- cp/decl.c (revision 268968) +++ cp/decl.c (working copy) @@ -6946,7 +6946,15 @@ cp_finish_decl (tree decl, tree init, bool init_co { tree d_init; if (init == NULL_TREE) - gcc_assert (CLASS_PLACEHOLDER_TEMPLATE (auto_node)); + { + if (variable_template_specialization_p (decl)) + { + error ("initializer for %q#D is empty", decl); + TREE_TYPE (decl) = error_mark_node; + return; + } + gcc_assert (CLASS_PLACEHOLDER_TEMPLATE (auto_node)); + } d_init = init; if (d_init) { Index: testsuite/g++.dg/cpp1y/var-templ60.C =================================================================== --- testsuite/g++.dg/cpp1y/var-templ60.C (nonexistent) +++ testsuite/g++.dg/cpp1y/var-templ60.C (working copy) @@ -0,0 +1,9 @@ +// PR c++/84536 +// { dg-do compile { target c++14 } } + +template auto foo(N...); // { dg-error "initializer" } + +void bar() +{ + foo<>(); +}