From patchwork Fri Jul 5 17:49:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Palka X-Patchwork-Id: 1957427 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=JQn68FMe; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.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 ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WG1JT38BSz1xql for ; Sat, 6 Jul 2024 03:50:32 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 714D03831384 for ; Fri, 5 Jul 2024 17:50:30 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id DF9F338323C1 for ; Fri, 5 Jul 2024 17:50:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DF9F338323C1 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org DF9F338323C1 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1720201811; cv=none; b=U6QgHG5ppocacgfnt20jtvEUwNi70Epk8PPT0S45/fNuTR0LFgIW9t1IFahIfzdc6r+h1PesKWfBlsU13b3llTdZ0VxgwU7kdzXmBFOhdtLLJkXNChfcx5F/bMZa4dezlmcB6hcB4o4bGXWfqtjHo7aTbkr9nWc63rQJwpbXXqI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1720201811; c=relaxed/simple; bh=ikzCcBwXKstAShRrf1JPBeCajC0UJr461tJd0Q+1utA=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=s4Tzjcg7VMfU1fFubkjN3SKoFs0zqRntQXp9H7YZSdK7zZoIYV4nuqDZegdGbUqCaSljAfhp8v2At8M/V2jjPn7Rc757OrQe9ODblqLHE4Yf5EmhJtrCM8j5yhrFl90TT0hMOP3aVPaurzgD1naJ0lP9/rzqNWEjADho8cDTNec= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720201809; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=DORWoT4duNr/TjpztbZmG2jWCIfIX9yt54Hj8vMvIUw=; b=JQn68FMenkfj80yjJr1iEit60odWCxwAOYTCb1hzSutJM3XJ2SBwmV20juhl6pce5eVfYS Q3mYOnv54AQmDY/Fcwe/xykOuUNkiiWAELkpUaNqFv+QvAnjFdlX7ogoio4rcbDvqpy35i 44CGcp26UAMESpUyJHvGC34GITs7dXo= Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-595-rgDVA0k8OiGTL_Rg3LXEng-1; Fri, 05 Jul 2024 13:50:07 -0400 X-MC-Unique: rgDVA0k8OiGTL_Rg3LXEng-1 Received: by mail-qv1-f70.google.com with SMTP id 6a1803df08f44-6b5dfeae8caso23791306d6.2 for ; Fri, 05 Jul 2024 10:50:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720201806; x=1720806606; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=DORWoT4duNr/TjpztbZmG2jWCIfIX9yt54Hj8vMvIUw=; b=ZF9rvIwhpWQJ1uxoAY7X6KjqXoBE/StYHAF/bHBzzTYyVd07PqgcHQbTu0wACAQUkP A+lFYiXEkXl802HcZED0ugcb36FaKWfFx9tWkf04oUS/v7Yk0NgLXtZvKI5suAfrciFC zq9+BrEGIf3/oaZfumfxiBWIef/25vy43Fqxrm+k1MXoAJeBPfD9jgo7UqzPjkLfonhL ML1nSuX/LjNxxnaD8tsOMHPd0vPPD/q9UD/xRy6Mywioh2OyxWNkO9UMAJ9oCztYdlkx 3OYceKNxZtLrCsYhz2DWMZoANz1KHSOBwqSyz2pnfLefhh2Fr+JBKSm0A4gjCmuQqJm0 ZLqQ== X-Gm-Message-State: AOJu0Yxct5cSmMCWj5igzkSFKYPeqhvsX9m0hLT3CI6+dy2HE8uyA6xO 5iAFr+aYv6uEIOBF68ZDvsv+im4qWqLthOfZc58Ql0F3hF3XuPoqPdYttzNZ7IoWpqXxGZZCjqR ko92o+pct148FbIfhD6AOkxlAwFZjTb4TGKQ3/1cRIhvZYTw8MHhPxz2BBSuBhT8K2BY34NnekS nrJFSL1SafKgGhaAwHX4ew2CXNhdFnHk07fh3B X-Received: by 2002:a05:6214:1d2c:b0:6b2:b11b:c326 with SMTP id 6a1803df08f44-6b5ed0423a6mr64198936d6.48.1720201806416; Fri, 05 Jul 2024 10:50:06 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGSG3QMBfFM8O18EdwnkAuGoIAL7j8A2XvL8rbX5XI8E/LqH6QyqSgxsJF1R+teYHO7Q5/lEA== X-Received: by 2002:a05:6214:1d2c:b0:6b2:b11b:c326 with SMTP id 6a1803df08f44-6b5ed0423a6mr64198716d6.48.1720201806074; Fri, 05 Jul 2024 10:50:06 -0700 (PDT) Received: from localhost.localdomain (ool-18bb2a2e.dyn.optonline.net. [24.187.42.46]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6b5eead59c2sm15526406d6.134.2024.07.05.10.50.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jul 2024 10:50:05 -0700 (PDT) From: Patrick Palka To: gcc-patches@gcc.gnu.org Cc: jason@redhat.com, Patrick Palka Subject: [PATCH] c++: missing SFINAE during alias CTAD [PR115296] Date: Fri, 5 Jul 2024 13:49:58 -0400 Message-ID: <20240705174959.2440677-1-ppalka@redhat.com> X-Mailer: git-send-email 2.45.2.746.g06e570c0df MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-13.4 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look OK for trunk/14? -- >8 -- During the alias CTAD transformation, if substitution failed for some guide we should just discard the guide silently. We currently do discard the guide, but not silently, which causes us to reject the below testcase due to forming a too-large array type when transforming the user-defined deduction guides. This patch fixes this by passing complain=tf_none instead of =tf_warning_or_error in the couple of spots where we expect subsitution to possibly fail and so subsequently check for error_mark_node. PR c++/115296 gcc/cp/ChangeLog: * pt.cc (alias_ctad_tweaks): Pass complain=tf_none to tsubst_decl and tsubst_constraint_info. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/class-deduction-alias23.C: New test. --- gcc/cp/pt.cc | 4 ++-- .../g++.dg/cpp2a/class-deduction-alias23.C | 20 +++++++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/g++.dg/cpp2a/class-deduction-alias23.C diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc index d1316483e24..a382dce8788 100644 --- a/gcc/cp/pt.cc +++ b/gcc/cp/pt.cc @@ -30451,7 +30451,7 @@ alias_ctad_tweaks (tree tmpl, tree uguides) /* Parms are to have DECL_CHAIN tsubsted, which would be skipped if cp_unevaluated_operand. */ cp_evaluated ev; - g = tsubst_decl (DECL_TEMPLATE_RESULT (f), targs, complain, + g = tsubst_decl (DECL_TEMPLATE_RESULT (f), targs, tf_none, /*use_spec_table=*/false); } if (g == error_mark_node) @@ -30478,7 +30478,7 @@ alias_ctad_tweaks (tree tmpl, tree uguides) { if (tree outer_targs = outer_template_args (f)) ci = tsubst_constraint_info (ci, outer_targs, complain, in_decl); - ci = tsubst_constraint_info (ci, targs, complain, in_decl); + ci = tsubst_constraint_info (ci, targs, tf_none, in_decl); } if (ci == error_mark_node) continue; diff --git a/gcc/testsuite/g++.dg/cpp2a/class-deduction-alias23.C b/gcc/testsuite/g++.dg/cpp2a/class-deduction-alias23.C new file mode 100644 index 00000000000..e5766586761 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp2a/class-deduction-alias23.C @@ -0,0 +1,20 @@ +// PR c++/115296 +// { dg-do compile { target c++20 } } + +using size_t = decltype(sizeof(0)); + +template +struct span { span(T); }; + +template +span(T(&)[N]) -> span; // { dg-bogus "array exceeds maximum" } + +template +requires (sizeof(T(&)[N]) != 42) // { dg-bogus "array exceeds maximum" } +span(T*) -> span; + +template +using array_view = span; + +span x = 0; +array_view y = 0;