From patchwork Mon Mar 9 22:23:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Palka X-Patchwork-Id: 1251845 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=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=WaGzEL/c; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [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 48bt765gD8z9sNg for ; Tue, 10 Mar 2020 09:24:17 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 14C153953056; Mon, 9 Mar 2020 22:24:15 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) by sourceware.org (Postfix) with ESMTP id CA383395304E for ; Mon, 9 Mar 2020 22:24:12 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583792652; 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: in-reply-to:in-reply-to:references:references; bh=JPE3p0+7kIFfSk143UkXyKazMD9lq+Ly3OLby0eMuic=; b=WaGzEL/cfc/iFIbLDxIUfCQp1KV5yXTyKRsMYAHWAmHs0kdiA9A9pw+oR+1nxfPBQe6kRe eyNN1VYUwAGGqOgwGjdAN744DXiY5yLzN80xX7RL40qxpgGweKUu2Lbee+g69fqmU1nMPd +8V+WAHXjCUrTivG7gCUVouMHVCRlhc= Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-417-odV3dZ9GM76AUNtztA1atw-1; Mon, 09 Mar 2020 18:24:09 -0400 X-MC-Unique: odV3dZ9GM76AUNtztA1atw-1 Received: by mail-qv1-f70.google.com with SMTP id v2so7544400qvi.6 for ; Mon, 09 Mar 2020 15:24:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=XL2F5e+yNlwwELZr1a9yiiMNEdELehpo2B810ozuiFY=; b=D6oHjSjdy93rrdStKBgNhOcH1VdYofxhSjfhj/1DNy8A1wsVMTxpYNQo6x1pncH7Kp IT8dZqxGLpKp5Iv9t/RumuNm7yN8OCqyoiq1PtpLQSrF1FqxM90w5lj4zz/KKQXXE5vb AuIbiiEpoAhpmdlPn5YLtyagIQ+S2XD6nknc28YL558LvnHt6cMxk117JTgqgylfA2XA n2MY6bNSMYpmTwOmSm7kUQYac4TGSRrnCoNw5+QqWbPTyaRXMpduNtLi9lYb2qJWGPZG GGHRCs5z+6XJU/yEpHETz0dVaYc1BRwcMRRtEX+XJDp46Uck6/BYJEicflWCVI/JZYwA +8qA== X-Gm-Message-State: ANhLgQ042PlDpvm/iVyRlW/2H5KyQBMPho0VMqRtuJ19WzT6RGSarx25 DAQkYowU1ibjgkpbRRjNXkwrk4cc0SyLnvmQfnvfx1/LXNIEvv107W0YXlsFvi/DEtgDY4+bkf9 1bKNh7meW3PdbLsgQKw== X-Received: by 2002:a05:620a:66b:: with SMTP id a11mr10568126qkh.423.1583792648488; Mon, 09 Mar 2020 15:24:08 -0700 (PDT) X-Google-Smtp-Source: ADFU+vumsY0dCSs0lBCuMvKJZNeAkAfNHKidZlj2FFN205BInCsDsZAEZsSIZHTOkAPo3stQisvEZA== X-Received: by 2002:a05:620a:66b:: with SMTP id a11mr10568111qkh.423.1583792648182; Mon, 09 Mar 2020 15:24:08 -0700 (PDT) Received: from localhost.localdomain (ool-457d493a.dyn.optonline.net. [69.125.73.58]) by smtp.gmail.com with ESMTPSA id b7sm4781064qkh.0.2020.03.09.15.24.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Mar 2020 15:24:07 -0700 (PDT) From: Patrick Palka To: gcc-patches@gcc.gnu.org Subject: [PATCH 2/2] c++: Respect current_constraint_diagnosis_depth in diagnose_compound_requirement Date: Mon, 9 Mar 2020 18:23:58 -0400 Message-Id: <20200309222358.688229-2-ppalka@redhat.com> X-Mailer: git-send-email 2.26.0.rc0 In-Reply-To: <20200309222358.688229-1-ppalka@redhat.com> References: <20200309222358.688229-1-ppalka@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-27.1 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS 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: asutton@lock3software.com Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" The first patch tries to avoid changing our current default diagnostics. But for the sake of consistency we arguably should also respect current_constraint_diagnosis_depth in diagnose_compound_requirement() like we do in the other error-replaying diagnostic routine. But doing so would be a change to our default diagnostics behavior, so the change has been split out into this separate patch for separate consideration. gcc/cp/ChangeLog: * constraint.cc (diagnose_compound_requirement): When diagnosing a compound requirement, maybe replay the satisfaction failure, subject to the current diagnosis depth. gcc/testsuite/ChangeLog: * g++.dg/concepts/diagnostic1.C: Pass -fconcepts-diagnostics-depth=2. * g++.dg/concepts/diagnostic5.C: Adjust expected diagnostics. * g++.dg/cpp2a/concepts-requires5.C: Pass -fconcepts-diagnostics-depth=2. --- gcc/cp/constraint.cc | 36 ++++++++++++++----- gcc/testsuite/g++.dg/concepts/diagnostic1.C | 1 + gcc/testsuite/g++.dg/concepts/diagnostic5.C | 5 +-- gcc/testsuite/g++.dg/cpp2a/concepts-iconv1.C | 1 + .../g++.dg/cpp2a/concepts-requires5.C | 2 +- 5 files changed, 31 insertions(+), 14 deletions(-) diff --git a/gcc/cp/constraint.cc b/gcc/cp/constraint.cc index c5e3d64daa6..2ad82937c7e 100644 --- a/gcc/cp/constraint.cc +++ b/gcc/cp/constraint.cc @@ -3282,20 +3282,38 @@ diagnose_compound_requirement (tree req, tree args, tree in_decl) if (!type_deducible_p (expr, type, placeholder, args, quiet)) { tree orig_expr = TREE_OPERAND (req, 0); - inform (loc, "%qE does not satisfy return-type-requirement", - orig_expr); - - /* Further explain the reason for the error. */ - type_deducible_p (expr, type, placeholder, args, noisy); + if (current_constraint_diagnosis_depth + < concepts_diagnostics_max_depth) + { + inform (loc, + "%qE does not satisfy return-type-requirement, " + "because", orig_expr); + /* Further explain the reason for the error. */ + type_deducible_p (expr, type, placeholder, args, noisy); + } + else + { + inform (loc, "%qE does not satisfy return-type-requirement", + orig_expr); + concepts_diagnostics_max_depth_exceeded_p = true; + } } } else if (!expression_convertible_p (expr, type, quiet)) { tree orig_expr = TREE_OPERAND (req, 0); - inform (loc, "cannot convert %qE to %qT", orig_expr, type); - - /* Further explain the reason for the error. */ - expression_convertible_p (expr, type, noisy); + if (current_constraint_diagnosis_depth + < concepts_diagnostics_max_depth) + { + inform (loc, "cannot convert %qE to %qT because", orig_expr, type); + /* Further explain the reason for the error. */ + expression_convertible_p (expr, type, noisy); + } + else + { + inform (loc, "cannot convert %qE to %qT", orig_expr, type); + concepts_diagnostics_max_depth_exceeded_p = true; + } } } } diff --git a/gcc/testsuite/g++.dg/concepts/diagnostic1.C b/gcc/testsuite/g++.dg/concepts/diagnostic1.C index 7da08db2792..c6589e2e671 100644 --- a/gcc/testsuite/g++.dg/concepts/diagnostic1.C +++ b/gcc/testsuite/g++.dg/concepts/diagnostic1.C @@ -1,6 +1,7 @@ // PR c++/67159 // { dg-do compile { target c++17_only } } // { dg-options "-fconcepts" } +// { dg-additional-options "-fconcepts-diagnostics-depth=2" } template concept bool SameAs = __is_same_as(T, U); diff --git a/gcc/testsuite/g++.dg/concepts/diagnostic5.C b/gcc/testsuite/g++.dg/concepts/diagnostic5.C index 3c3b42f566c..734c7fb87a6 100644 --- a/gcc/testsuite/g++.dg/concepts/diagnostic5.C +++ b/gcc/testsuite/g++.dg/concepts/diagnostic5.C @@ -4,8 +4,7 @@ template concept c1 = requires { typename T::blah; }; // { dg-message "satisfaction of .c1." "" { target *-*-* } .-1 } -// { dg-message "satisfaction of .c1." "" { target *-*-* } .-2 } -// { dg-message ".typename T::blah. is invalid" "" { target *-*-* } .-3 } +// { dg-message ".typename T::blah. is invalid" "" { target *-*-* } .-2 } template concept c2 = requires (T x) { *x; }; @@ -27,8 +26,6 @@ template concept c5 = requires (T x) { { &x } -> c1; }; // { dg-message "satisfaction of .c5." "" { target *-*-* } .-1 } // { dg-message "in requirements with .char x." "" { target *-*-* } .-2 } -// { dg-message "does not satisfy return-type-requirement" "" { target *-*-* } .-3 } -// { dg-error "deduced expression type does not satisfy" "" { target *-*-* } .-4 } template requires (c1 || c2) || (c3 || c4) || c5 // { dg-message "49: no operand" } diff --git a/gcc/testsuite/g++.dg/cpp2a/concepts-iconv1.C b/gcc/testsuite/g++.dg/cpp2a/concepts-iconv1.C index 4d521c30748..4e2d13f8eb3 100644 --- a/gcc/testsuite/g++.dg/cpp2a/concepts-iconv1.C +++ b/gcc/testsuite/g++.dg/cpp2a/concepts-iconv1.C @@ -1,5 +1,6 @@ // PR c++/67240 // { dg-do compile { target c++2a } } +// { dg-additional-options "-fconcepts-diagnostics-depth=2" } template concept Same = __is_same_as(T,U); diff --git a/gcc/testsuite/g++.dg/cpp2a/concepts-requires5.C b/gcc/testsuite/g++.dg/cpp2a/concepts-requires5.C index 133d29e45a4..2f912b13d6a 100644 --- a/gcc/testsuite/g++.dg/cpp2a/concepts-requires5.C +++ b/gcc/testsuite/g++.dg/cpp2a/concepts-requires5.C @@ -1,5 +1,5 @@ // { dg-do compile { target c++2a } } -// { dg-additional-options -fconcepts-ts } +// { dg-additional-options "-fconcepts-ts -fconcepts-diagnostics-depth=2" } // Test conversion requirements (not in C++20)