From patchwork Tue Apr 10 13:54:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 896723 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-476133-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="cnoz6EeC"; 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 40L7vx3YfFz9s06 for ; Tue, 10 Apr 2018 23:54:53 +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 :mime-version:from:date:message-id:subject:to:content-type; q= dns; s=default; b=RP/5qz0Tg9GypuRyNfQxHKdBAIg8bWIZqG0o5Mbx6ADmhh kXXO46eCrpuAHBMGQt7kwEENoU+Ozqwrm9e0L5yGMSAc4rzGwL5XnGb8aH+ifBsK kGHW1bIgnTEziHWWabVPvJ1CC9uolSjW87cxqBnTeIIzfUrjes5foP0gluY6s= 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 :mime-version:from:date:message-id:subject:to:content-type; s= default; bh=TriNTrBR6hnBSWvPQHzF0oeEiDw=; b=cnoz6EeCoqBWlQubi4rw 8I7xGkQWLBv8qR2YpuzKu2GPsidp3p0LD7gM5EoC2QW6V4jHv7EFV15fjF4hPEOB gJZhWz1SihlBJCP/pTUuEftA5FLNOnfSSKULA+0WVnqd+kuQE8nm47W8e3V6HsrL w/BZTHWNc1LY68SRwIRU/qA= Received: (qmail 90504 invoked by alias); 10 Apr 2018 13:54:46 -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 90495 invoked by uid 89); 10 Apr 2018 13:54:45 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.6 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 spammy=Hx-languages-length:1503 X-HELO: mail-oi0-f50.google.com Received: from mail-oi0-f50.google.com (HELO mail-oi0-f50.google.com) (209.85.218.50) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 10 Apr 2018 13:54:44 +0000 Received: by mail-oi0-f50.google.com with SMTP id f63-v6so11207381oic.4 for ; Tue, 10 Apr 2018 06:54:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=XsPQ8Roj3wDO6OTIaMarKwTqm5pmG3VLVCq0ViBCtDo=; b=G3BmmkejF9js+4PBPjIogr0PKUffosab+CadW9Te/mtSoSp3eQyWMsT0Qi3kuN137/ n45/E32NkpWxB7ZWOz51TxHSP7O/TXs7CRgDjzcK0vCCCC6LG9A3bAxgporlQE6IfgFL EVCgxfMoNcewEH3169gIx8AtxPUFje2/xycxmB3s1yLABUbJzHM4OFygWJYhcree8J+P d9Rk4iZsU+eavKWZOsYYhmtsxKSlhRyGPEpLQsxYg7GQCRTjBSrFMYjYDN6mbjuYGRWJ dZJAa+QSjnI/mxETAP+dvpJQ+X8YG5tr7rkJ8thrZ0cNDrqPJxOo9n2kjZVKmspbIter 4HJw== X-Gm-Message-State: ALQs6tC9G4hHKQ/OZHjWjOlBGQPquUQ+LBoJlJPCEUW5gzUNp896dtBw VV4WWUVG8WqQXnR8aGg5UTbGLdPhxEFkTE59yzSktMQp X-Google-Smtp-Source: AIpwx49dyxCSQWxfd2ZSW3f1VIbPG1/tYT1bn2j463wbfZY6YowdanJkmRwQXg7vU/J4wN5CQuo2KJ+fwt/EPmrFfMA= X-Received: by 2002:aca:4b0d:: with SMTP id y13-v6mr370559oia.22.1523368482893; Tue, 10 Apr 2018 06:54:42 -0700 (PDT) MIME-Version: 1.0 Received: by 10.201.7.234 with HTTP; Tue, 10 Apr 2018 06:54:22 -0700 (PDT) From: Jason Merrill Date: Tue, 10 Apr 2018 09:54:22 -0400 Message-ID: Subject: C++ PATCH for c++/85285, ICE with flexible array after substitution To: gcc-patches List X-IsSubscribed: yes Checking for a flexible array in a union is currently done by grokdeclarator, so it wasn't being caught after substitution. I didn't see a good place to handle it for both cases, and it's small enough, so I just copied it over. Tested x86_64-pc-linux-gnu, applying to trunk. commit e63bd3e7471152b3c39cbfc58e735e3efeb458b7 Author: Jason Merrill Date: Mon Apr 9 17:24:19 2018 -0400 PR c++/85285 - ICE with flexible array after substitution. * pt.c (instantiate_class_template_1): Check for flexible array in union. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index db3d7e38d85..76e546cdeaa 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -10904,6 +10904,14 @@ instantiate_class_template_1 (tree type) cxx_incomplete_type_error (r, rtype); TREE_TYPE (r) = error_mark_node; } + else if (TREE_CODE (rtype) == ARRAY_TYPE + && TYPE_DOMAIN (rtype) == NULL_TREE + && (TREE_CODE (type) == UNION_TYPE + || TREE_CODE (type) == QUAL_UNION_TYPE)) + { + error ("flexible array member %qD in union", r); + TREE_TYPE (r) = error_mark_node; + } } /* If it is a TYPE_DECL for a class-scoped ENUMERAL_TYPE, diff --git a/gcc/testsuite/g++.dg/ext/flexary30.C b/gcc/testsuite/g++.dg/ext/flexary30.C new file mode 100644 index 00000000000..59b7587594c --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/flexary30.C @@ -0,0 +1,8 @@ +// PR c++/85285 + +template union A +{ + T x; // { dg-error "flexible array" } +}; + +A a;