From patchwork Wed Dec 16 19:52:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Sidwell X-Patchwork-Id: 1417380 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=acm.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=oTzN91+7; dkim-atps=neutral Received: from sourceware.org (unknown [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Cx5Pw01WSz9sRR for ; Thu, 17 Dec 2020 06:52:35 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 91F40383300B; Wed, 16 Dec 2020 19:52:32 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-qk1-x72d.google.com (mail-qk1-x72d.google.com [IPv6:2607:f8b0:4864:20::72d]) by sourceware.org (Postfix) with ESMTPS id 6AFB7383508C for ; Wed, 16 Dec 2020 19:52:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 6AFB7383508C Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=acm.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=nathanmsidwell@gmail.com Received: by mail-qk1-x72d.google.com with SMTP id w79so24036658qkb.5 for ; Wed, 16 Dec 2020 11:52:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:to:from:subject:message-id:date:user-agent:mime-version :content-language; bh=QaluJWnZ5cqo+C5qUVHsFOOAQKUdqgN+zFTSqvNK6/Y=; b=oTzN91+7MdGQUkSH3p9+PKJ4MwPtzW0Hwu2Yl/UgNhBrYIZDqNVvmXwu356z0Zjhpk qC/WkDZlZmQBJyHxQW93xV3BgU5UWTpmGmlrLFaK4vNBRRaJwzPK/mUhavgiFd4Cpct7 VxliHrM9gP6mfw6qIat5G4lk0ceD8L9z5E0ORsqofQdG8c35B5OIqAR7TFNwTENk3Nyx byjTVmm3UjpXK5sOSw5B5tCc9RGBKFnPXb8QY0qP5kKtX2h0eyx53a3xwLK6mM2mDm0l J4C5JHlxHvdE0ld0Lpyh6+aOG9uQCSbYbYTQ2fLEdcD/1Ynk2DIw30fCSjMlayEwFGft 9FyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:to:from:subject:message-id:date :user-agent:mime-version:content-language; bh=QaluJWnZ5cqo+C5qUVHsFOOAQKUdqgN+zFTSqvNK6/Y=; b=KW3MkFg7PZlWnVBBAtIx2pbSh/6LrO7nAPNtudtBwDSHGmBRfdWbP7GPHXahNoYwtu V15BWruugK/a1/GO8i8nI1xrIdwhcUg7qQQAQun64BjVrVT7Fx+JHuJv7Q2Hc1c54yD8 WLpmWLydbFVSY/jQmarj+sQh99HqeIkes/33qLzlxj8pxuQptzGEhF7FEGuvHGV+oUqn lKn0SrZiu1TxYuCV5G1IlCtKK1y8WOChSwUZc/0/zqRrUpiPsoE7XuxMe/s7ucLuQiYv 2JuUGCpiv4n8Lb2oN1ryhEKzeYN9xDx9kicYPk0nRMSyrxbPUI2rqP0Q5TMhX9J6RDU4 Xi5g== X-Gm-Message-State: AOAM532jl/DrLwlk2047JvkNn7nlyOubhV92laS5oK16TfNT2S8KVGtO C7jr5ofVh5NoObvmYPQ/z+cbjo+XZxI= X-Google-Smtp-Source: ABdhPJxRLDi4kkiWng6FXGiXuoT3ZIXtxtYIA2izuK7pRoJK+rHUz5wMHKPMByGwKHLoSmd0MbhO2g== X-Received: by 2002:a05:620a:1398:: with SMTP id k24mr42280891qki.109.1608148348585; Wed, 16 Dec 2020 11:52:28 -0800 (PST) Received: from ?IPv6:2620:10d:c0a8:1102:e0c4:86e9:6418:b0da? ([2620:10d:c091:480::1:c154]) by smtp.googlemail.com with ESMTPSA id l11sm1620109qtn.83.2020.12.16.11.52.27 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 16 Dec 2020 11:52:27 -0800 (PST) To: GCC Patches From: Nathan Sidwell Subject: c++: Fix template parm ICE [PR 98297] Message-ID: <3e8e338f-990f-8fd8-5aa4-26f0b737e68f@acm.org> Date: Wed, 16 Dec 2020 14:52:26 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 MIME-Version: 1.0 Content-Language: en-US X-Spam-Status: No, score=-11.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" I think this is nonsense code, we seem to be naming an instantiation of a template template parm. But this fixes the ICE. Perhaps we should diagnose the issue earlier? gcc/cp/ * parser.c (cp_parser_elaborated_type_specifier): Test BOUND_TEMPLATE_TEMPLATE_PARM before checking for instantiation. gcc/testsuite/ * g++.dg/template/pr98297.C: New. pushing to trunk diff --git c/gcc/cp/parser.c w/gcc/cp/parser.c index 7ea8c28830e..3883339aa64 100644 --- c/gcc/cp/parser.c +++ w/gcc/cp/parser.c @@ -19650,7 +19650,9 @@ cp_parser_elaborated_type_specifier (cp_parser* parser, if (TREE_CODE (type) == TYPENAME_TYPE) warning (OPT_Wattributes, "attributes ignored on uninstantiated type"); - else if (tag_type != enum_type && CLASSTYPE_TEMPLATE_INSTANTIATION (type) + else if (tag_type != enum_type + && TREE_CODE (type) != BOUND_TEMPLATE_TEMPLATE_PARM + && CLASSTYPE_TEMPLATE_INSTANTIATION (type) && ! processing_explicit_instantiation) warning (OPT_Wattributes, "attributes ignored on template instantiation"); diff --git c/gcc/testsuite/g++.dg/template/pr98297.C w/gcc/testsuite/g++.dg/template/pr98297.C new file mode 100644 index 00000000000..0dd63a57b5c --- /dev/null +++ w/gcc/testsuite/g++.dg/template/pr98297.C @@ -0,0 +1,6 @@ +// PR 98297, ICE +// { dg-do compile { target c++11 } } +template