From patchwork Fri Jan 15 19:43:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Sidwell X-Patchwork-Id: 1427298 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=Pw8k5hxx; 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 4DHWp917M9z9sVF for ; Sat, 16 Jan 2021 06:43:58 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B9DAF3987C00; Fri, 15 Jan 2021 19:43:56 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-qk1-x729.google.com (mail-qk1-x729.google.com [IPv6:2607:f8b0:4864:20::729]) by sourceware.org (Postfix) with ESMTPS id DE15E385782E for ; Fri, 15 Jan 2021 19:43:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org DE15E385782E 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-x729.google.com with SMTP id 143so12790846qke.10 for ; Fri, 15 Jan 2021 11:43:54 -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=sS1qzpquLhFgnsNkfYzVebzrv7doPWyHDbykVU9D4Ms=; b=Pw8k5hxxuTqWbmWBUjO4+ZUqhxC8i/0jfrhjm4lmt3s7V9VwwXaZsQ/95I1S9fQFXb hgGpiYLOdaDkPqcEOrGtaauG/h1KrfYs9FSQ7Pl5DwRQRVof5QpafOu8MTqQB9ZyWHwz h5FKvParjCJYEToXaOaKsAyj6r4M5BUR0llMsazwFK6hyBXP7HUXe/1ylgjuQXNdPwxw gQs9ALmzlwrGuxqTZwFrxV4iZg6r1SjnTg83oJ7q5Y6PibWpuP7Y1K4fQN5XUQ19ViKQ UmQa+PWSGGQcH0noTzhALMVCi16BAhHNXMXKqGyCXK64P6C8fzKC8Ds4Hgbp0UExCiU0 /ADg== 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=sS1qzpquLhFgnsNkfYzVebzrv7doPWyHDbykVU9D4Ms=; b=KeSXhuCLYJNczSSfP9QT4BmUoNEThh1FHCSBY/jaR9kkC1hdPknxpl0aaGUApsDTJs ES1/WousWCVI2hzcuSalkDZ1bPlDo2AaN7i7EGw4onyekDgDM9xSjynoDUgl013j5D/L lnp8Kj15bHYqhX363mBLuWg5vgoDZEuJsoqwlDwI79uhzlAqcfapxkjv7SqN7L/AV4eL LMMHakJi8+vgwy1Za24SM6M8bPGXdHYsiZbtdizRrXu2YfGOuFooy3ZRCDO315fBKTVw Z7JBl5ggmXlRzRMm+BokU04R7d084ddTJctuHBKJEtL7YtxcdVGfXlkxgp42AJK7+lL/ pLNA== X-Gm-Message-State: AOAM532BmT1MkGoGkYDEAD6mM6KEumbTany5fl4h5Ero8UcIEH2/sTlK 4oUw/kwgHWg4E4Aqz7+5JlI= X-Google-Smtp-Source: ABdhPJwlKY+9MJgSDRzduZBqkXPsig9033H+bGPcFB8/4m+f0BZSrCohdTtIyXj5ZhAGHInb4fXUbw== X-Received: by 2002:a37:c49:: with SMTP id 70mr14143167qkm.365.1610739834452; Fri, 15 Jan 2021 11:43:54 -0800 (PST) Received: from ?IPv6:2620:10d:c0a8:1102:94f0:c004:1b13:10bd? ([2620:10d:c091:480::1:b690]) by smtp.googlemail.com with ESMTPSA id q20sm5649119qkj.49.2021.01.15.11.43.53 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 15 Jan 2021 11:43:53 -0800 (PST) To: GCC Patches From: Nathan Sidwell Subject: c++: Fix qualified array-type construction [PR 98538] Message-ID: Date: Fri, 15 Jan 2021 14:43:52 -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.4 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" This was an assert that was too picky. The reason I had to alter array construction was that on stream in, we cannot dynamically determine a type's dependentness. Thus on stream out of the 'problematic' types, we save the dependentness for reconstruction. Fortunately the paths into cp_build_qualified_type_real from streamin with arrays do have the array's dependentess set as needed. PR c++/98538 gcc/cp/ * tree.c (cp_build_qualified_type_real): Propagate an array's dependentness to the copy, if known. gcc/testsuite/ g++.dg/template/pr98538.C: New. diff --git c/gcc/cp/tree.c w/gcc/cp/tree.c index 3a9a86de34a..55325d7c671 100644 --- c/gcc/cp/tree.c +++ w/gcc/cp/tree.c @@ -1332,10 +1332,12 @@ cp_build_qualified_type_real (tree type, if (!t) { - gcc_checking_assert (TYPE_DEPENDENT_P_VALID (type) - || !dependent_type_p (type)); + /* If we already know the dependentness, tell the array type + constructor. This is important for module streaming, as we cannot + dynamically determine that on read in. */ t = build_cplus_array_type (element_type, TYPE_DOMAIN (type), - TYPE_DEPENDENT_P (type)); + TYPE_DEPENDENT_P_VALID (type) + ? int (TYPE_DEPENDENT_P (type)) : -1); /* Keep the typedef name. */ if (TYPE_NAME (t) != TYPE_NAME (type)) diff --git c/gcc/testsuite/g++.dg/template/pr98538.C w/gcc/testsuite/g++.dg/template/pr98538.C new file mode 100644 index 00000000000..b62e8a96af8 --- /dev/null +++ w/gcc/testsuite/g++.dg/template/pr98538.C @@ -0,0 +1,18 @@ +// PR c++/98538 +// { dg-do compile { target c++11 } } +// ICE bulding a dependent array type variant + +template using A = int[1]; +template> struct X { }; + +template +void +f (const A) +{ + const A a; +} + +template +struct Y { + const A a; +};