From patchwork Wed Apr 29 18:50:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Sidwell X-Patchwork-Id: 1279582 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=2620:52:3:1:0:246e:9693:128c; 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=jJe6imtE; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (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 49C6zN2XhCz9sP7 for ; Thu, 30 Apr 2020 04:50:54 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C2AA43894E70; Wed, 29 Apr 2020 18:50:49 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-qt1-x834.google.com (mail-qt1-x834.google.com [IPv6:2607:f8b0:4864:20::834]) by sourceware.org (Postfix) with ESMTPS id DB7093893640 for ; Wed, 29 Apr 2020 18:50:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org DB7093893640 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-qt1-x834.google.com with SMTP id z90so2780692qtd.10 for ; Wed, 29 Apr 2020 11:50:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:to:cc:from:subject:message-id:date:user-agent:mime-version :content-language; bh=4H2UI1wlYuDBqLDDFgaSAOPQprz59UTDWJTql1oBWck=; b=jJe6imtE+3WXMHjbfv0xrs7UVecCt1pb9fa/7pJI07eN6zk1YzC6Z0TXcHo+wM7Cud k9DPkoTV7UREbOlL/05vUWJGYqnIof1la4fhrJr8HKP4aHYKYmzwEy/LoPZc3W/gxeGI Of1KnhV8zEYLrkKaGbEMbIyrHTDjiUTGzmYWQjjXpwUCcbYo8EwqeSDyNxWATUpNWOR1 n+6zNGrIsWGWXa6h1FM+RTY3ELYdKhoU48J0zkYdR+gqhdlyu49pr765PqnFoKFCupOM anv0URDsD7QUyP45yaOYw/K7oV2W4bcbRWAzzvKmfGrl40zSBihdkpKAkm7EkIvHTwo6 XY/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:to:cc:from:subject:message-id:date :user-agent:mime-version:content-language; bh=4H2UI1wlYuDBqLDDFgaSAOPQprz59UTDWJTql1oBWck=; b=cnERvo84Hsqp7OzzPrYVP83r36KFoH6FeWUSd3lvr9N5ctvCjNNfazBI6eg9W6A7bV G+rHxLBjJMvZzySHc2r4Gvj+W2zmJPspGCUfMv1GhUIMbkAW356WJFDW3Opjsm3ogh8y FHJe4ZYUQTEdkZ8O352wKmSFmxgaSje+uDRZ033wB0S6KJho1yPYpeFgNcZgz995rRLT naLG29+zKljcJQqyNvE2hI6ZxezLV+Y6IV2mvjkPo0GDFWXBRaBd334F3sSxxTKrsYf9 0sjPO0EgjVXUXgCfd+iKjvwUn/e2mdzuhGXMjTtEGc645MnyvBxiw6kcW2E2Y+PUPqs6 u5Qg== X-Gm-Message-State: AGi0PuYdQbzefQHDC+eUWq6BdmFcxjuJaeZYGEUEW4Ndx4uvvlghyT28 bwAfgr44IkM7qdMlRHE7nYs= X-Google-Smtp-Source: APiQypLk7BuL+IZBlNcWIWIORJfK6THwLhj9bP5sSUga7LKNBed3ajzXkdh6WdvBEVX1ENshBOb27w== X-Received: by 2002:ac8:4c8d:: with SMTP id j13mr34938092qtv.142.1588186238168; Wed, 29 Apr 2020 11:50:38 -0700 (PDT) Received: from ?IPv6:2620:10d:c0a8:1102:180f:177f:7260:803c? ([2620:10d:c091:480::1:40ec]) by smtp.googlemail.com with ESMTPSA id x16sm21336qkh.14.2020.04.29.11.50.36 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 29 Apr 2020 11:50:36 -0700 (PDT) To: Jason Merrill From: Nathan Sidwell Subject: [PR c+ 94827]: template parm with default requires Message-ID: <863ac97a-8780-89da-03b2-82b060b00cb5@acm.org> Date: Wed, 29 Apr 2020 14:50:35 -0400 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=-20.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, 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: , Cc: GCC Patches Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" Jason, this is the patch you suggested, as I understood it. I kept finish_nested_require's saving of the (converted) current_template_parms, becase of the comment about use in diagnostics. Is this what you meant? boostrapped on x86_64-linux. nathan 2020-04-27 Jason Merrill Nathan Sidwell PR c++/94827 * constraint.cc (map_arguments): If ARGS is null, it's a self-mapping of parms. (finish_nested_requirement): Do not pass argified current_template_parms to normalization. diff --git c/gcc/cp/constraint.cc w/gcc/cp/constraint.cc index 06161b8c8c4..a6009dc0c47 100644 --- c/gcc/cp/constraint.cc +++ w/gcc/cp/constraint.cc @@ -546,12 +546,16 @@ static tree map_arguments (tree parms, tree args) { for (tree p = parms; p; p = TREE_CHAIN (p)) - { - int level; - int index; - template_parm_level_and_index (TREE_VALUE (p), &level, &index); - TREE_PURPOSE (p) = TMPL_ARG (args, level, index); - } + if (args) + { + int level; + int index; + template_parm_level_and_index (TREE_VALUE (p), &level, &index); + TREE_PURPOSE (p) = TMPL_ARG (args, level, index); + } + else + TREE_PURPOSE (p) = TREE_VALUE (p); + return parms; } @@ -2953,12 +2957,15 @@ finish_compound_requirement (location_t loc, tree expr, tree type, bool noexcept tree finish_nested_requirement (location_t loc, tree expr) { + /* Currently open template headers have dummy arg vectors, so don't + pass into normalization. */ + tree norm = normalize_constraint_expression (expr, NULL_TREE, false); + tree args = current_template_parms + ? template_parms_to_args (current_template_parms) : NULL_TREE; + /* Save the normalized constraint and complete set of normalization arguments with the requirement. We keep the complete set of arguments around for re-normalization during diagnostics. */ - tree args = current_template_parms - ? template_parms_to_args (current_template_parms) : NULL_TREE; - tree norm = normalize_constraint_expression (expr, args, false); tree info = build_tree_list (args, norm); /* Build the constraint, saving its normalization as its type. */ diff --git c/gcc/testsuite/g++.dg/concepts/pr94827.C w/gcc/testsuite/g++.dg/concepts/pr94827.C new file mode 100644 index 00000000000..a6c147bf303 --- /dev/null +++ w/gcc/testsuite/g++.dg/concepts/pr94827.C @@ -0,0 +1,7 @@ +// PR 94287 ICE looking inside open template-parm level +// { dg-do compile { target c++17 } } +// { dg-options -fconcepts } +template +void foo(T) {} +