From patchwork Sat Aug 11 16:53:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Polacek X-Patchwork-Id: 956579 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-483533-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="Y/vDmfkW"; 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 41np380Q2Mz9s7X for ; Sun, 12 Aug 2018 02:53:22 +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:date :from:to:subject:message-id:mime-version:content-type; q=dns; s= default; b=uFk8ldYwZkMGlPVHxsJxcE+oK7lAeYuR0q6cOx+MObpW67izTANGI hagzG+ax9Yg4r1QF2uUF1G8Ro1BOIdKVTj4AXZ38z6HH5SBUlBwCypkWJwmtn4/C +D4RNvbvCfqJAdiWTqCmzNiTsrRmfg/7QnPYCJRMqr6hz5wtUVIALk= 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:date :from:to:subject:message-id:mime-version:content-type; s= default; bh=EBo07ZaHUyWOUVeMKPKGJ3X6CK0=; b=Y/vDmfkW42QiWbwe3k7l TOfPgCegWxuRbAaewkzKofXGvIPAGTc428X/hkV7qqk60RQyD+PVnc8vHNn2o0sa Uk9r9n7XH7zqFj8ZdF8+N0HEQ7tdwlipMXu7BDd9J9jYt/AcNb1sjTzrB4FTl8Sp 8ra5YVYwnyzrD+pToX8huuc= Received: (qmail 74988 invoked by alias); 11 Aug 2018 16:53:15 -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 74972 invoked by uid 89); 11 Aug 2018 16:53:14 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-12.6 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mx1.redhat.com Received: from mx3-rdu2.redhat.com (HELO mx1.redhat.com) (66.187.233.73) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 11 Aug 2018 16:53:13 +0000 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 24FFD8197015 for ; Sat, 11 Aug 2018 16:53:12 +0000 (UTC) Received: from redhat.com (ovpn-121-137.rdu2.redhat.com [10.10.121.137]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EEC1D7C36; Sat, 11 Aug 2018 16:53:11 +0000 (UTC) Date: Sat, 11 Aug 2018 12:53:10 -0400 From: Marek Polacek To: GCC Patches , Jason Merrill Subject: C++ PATCH for c++/86915, ICE with auto[] Message-ID: <20180811165310.GM4317@redhat.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) This fixes ICE-on-invalid with an array of auto. The problem was that create_array_type_for_decl got null name, so the error call crashed. We need to handle this case as elsewhere in the function. Bootstrapped/regtested on x86_64-linux, ok for trunk? 2018-08-11 Marek Polacek PR c++/86915 * decl.c (create_array_type_for_decl): Handle null name. * g++.dg/diagnostic/auto1.C: New test. --- gcc/cp/decl.c +++ gcc/cp/decl.c @@ -9838,7 +9838,10 @@ create_array_type_for_decl (tree name, tree type, tree size) type-specifier, the program is ill-formed. */ if (type_uses_auto (type)) { - error ("%qD declared as array of %qT", name, type); + if (name) + error ("%qD declared as array of %qT", name, type); + else + error ("creating array of %qT", type); return error_mark_node; } --- gcc/testsuite/g++.dg/diagnostic/auto1.C +++ gcc/testsuite/g++.dg/diagnostic/auto1.C @@ -0,0 +1,4 @@ +// PR c++/86915 +// { dg-do compile { target c++17 } } + +template struct S; // { dg-error "creating array of .auto." }