From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1643) id F07473857C44; Mon, 29 Aug 2022 15:36:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org F07473857C44 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1661787366; bh=TbwJ7nd7PIRYtosy1EPE293cIWY4KuB4EOBhLRblK1s=; h=From:To:Subject:Date:From; b=nmPbZaUYq5po62yN16ZEL9WB+swK0L9NRxMS8PSXJcJL+nyTO5sod5/SAQjoe6LdK VlcsjvdRMI7ucKMqNjQI5EUdAQnjCEh+5IKIF4S14CNOah2RJlbq1XDTaJppPSgn3v IyRUMnHOf2VyNcZ4gYgAby7d1iDo33uvZ5etegTs= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Thomas Schwinge To: gcc-cvs@gcc.gnu.org Subject: [gcc/devel/rust/master] Fix warnings on diagnostics X-Act-Checkin: gcc X-Git-Author: Philip Herron X-Git-Refname: refs/heads/devel/rust/master X-Git-Oldrev: c52268c6d22bcecef596dffd3c31b78d225f59b6 X-Git-Newrev: 43b7dd91fb0df9cdb7708581089bd3cd36f14a43 Message-Id: <20220829153606.F07473857C44@sourceware.org> Date: Mon, 29 Aug 2022 15:36:06 +0000 (GMT) List-Id: https://gcc.gnu.org/g:43b7dd91fb0df9cdb7708581089bd3cd36f14a43 commit 43b7dd91fb0df9cdb7708581089bd3cd36f14a43 Author: Philip Herron Date: Thu Aug 25 13:19:54 2022 +0100 Fix warnings on diagnostics Diff: --- gcc/rust/backend/rust-constexpr.cc | 12 +++-- gcc/rust/backend/rust-tree.cc | 91 +++++++++++++++++++------------------- 2 files changed, 54 insertions(+), 49 deletions(-) diff --git a/gcc/rust/backend/rust-constexpr.cc b/gcc/rust/backend/rust-constexpr.cc index 87b1a843493..f2e3e51c4ab 100644 --- a/gcc/rust/backend/rust-constexpr.cc +++ b/gcc/rust/backend/rust-constexpr.cc @@ -4539,10 +4539,14 @@ is_valid_constexpr_fn (tree fun, bool complain) ret = false; if (complain) { - auto_diagnostic_group d; - error ("invalid type for parameter %d of % " - "function %q+#D", - DECL_PARM_INDEX (parm), fun); + // auto_diagnostic_group d; + // error ("invalid type for parameter %d of % " + // "function %q+#D", + // DECL_PARM_INDEX (parm), fun); + Location locus = Location (DECL_SOURCE_LOCATION (fun)); + rust_error_at ( + locus, "invalid type for parameter %d of % function", + DECL_PARM_INDEX (parm)); } } diff --git a/gcc/rust/backend/rust-tree.cc b/gcc/rust/backend/rust-tree.cc index e6ae96931b8..9dac0dce53d 100644 --- a/gcc/rust/backend/rust-tree.cc +++ b/gcc/rust/backend/rust-tree.cc @@ -3269,19 +3269,19 @@ check_for_uninitialized_const_var (tree decl, bool constexpr_context_p, if (show_notes && CLASS_TYPE_P (type) && (complain & tf_error)) { - tree defaulted_ctor; - - inform (DECL_SOURCE_LOCATION (TYPE_MAIN_DECL (type)), - "%q#T has no user-provided default constructor", type); - defaulted_ctor = in_class_defaulted_default_constructor (type); - if (defaulted_ctor) - inform (DECL_SOURCE_LOCATION (defaulted_ctor), - "constructor is not user-provided because it is " - "explicitly defaulted in the class body"); - inform (DECL_SOURCE_LOCATION (field), - "and the implicitly-defined constructor does not " - "initialize %q#D", - field); + // tree defaulted_ctor; + + // inform (DECL_SOURCE_LOCATION (TYPE_MAIN_DECL (type)), + // "%q#T has no user-provided default constructor", type); + // defaulted_ctor = in_class_defaulted_default_constructor (type); + // if (defaulted_ctor) + // inform (DECL_SOURCE_LOCATION (defaulted_ctor), + // "constructor is not user-provided because it is " + // "explicitly defaulted in the class body"); + // inform (DECL_SOURCE_LOCATION (field), + // "and the implicitly-defined constructor does not " + // "initialize %q#D", + // field); } return false; @@ -3823,24 +3823,24 @@ strip_top_quals (tree t) /* Print an inform about the declaration of the incomplete type TYPE. */ -void -cxx_incomplete_type_inform (const_tree type) -{ - if (!TYPE_MAIN_DECL (type)) - return; - - location_t loc = DECL_SOURCE_LOCATION (TYPE_MAIN_DECL (type)); - tree ptype = strip_top_quals (CONST_CAST_TREE (type)); - - if (current_class_type && TYPE_BEING_DEFINED (current_class_type) - && same_type_p (ptype, current_class_type)) - inform (loc, - "definition of %q#T is not complete until " - "the closing brace", - ptype); - else - inform (loc, "forward declaration of %q#T", ptype); -} +// void +// cxx_incomplete_type_inform (const_tree type) +// { +// if (!TYPE_MAIN_DECL (type)) +// return; + +// location_t loc = DECL_SOURCE_LOCATION (TYPE_MAIN_DECL (type)); +// tree ptype = strip_top_quals (CONST_CAST_TREE (type)); + +// if (current_class_type && TYPE_BEING_DEFINED (current_class_type) +// && same_type_p (ptype, current_class_type)) +// inform (loc, +// "definition of %q#T is not complete until " +// "the closing brace", +// ptype); +// else +// inform (loc, "forward declaration of %q#T", ptype); +// } // forked from gcc/cp/typeck2.cc cxx_incomplete_type_diagnostic @@ -3853,7 +3853,7 @@ void cxx_incomplete_type_diagnostic (location_t loc, const_tree value, const_tree type, diagnostic_t diag_kind) { - bool is_decl = false, complained = false; + // bool is_decl = false, complained = false; gcc_assert (diag_kind == DK_WARNING || diag_kind == DK_PEDWARN || diag_kind == DK_ERROR); @@ -3869,9 +3869,10 @@ cxx_incomplete_type_diagnostic (location_t loc, const_tree value, if (VAR_P (value) || TREE_CODE (value) == PARM_DECL || TREE_CODE (value) == FIELD_DECL) { - complained = emit_diagnostic (diag_kind, DECL_SOURCE_LOCATION (value), - 0, "%qD has incomplete type", value); - is_decl = true; + // complained = emit_diagnostic (diag_kind, DECL_SOURCE_LOCATION + // (value), + // 0, "%qD has incomplete type", value); + // is_decl = true; } } retry: @@ -3879,16 +3880,16 @@ retry: switch (TREE_CODE (type)) { - case RECORD_TYPE: - case UNION_TYPE: - case ENUMERAL_TYPE: - if (!is_decl) - complained - = emit_diagnostic (diag_kind, loc, 0, - "invalid use of incomplete type %q#T", type); - if (complained) - cxx_incomplete_type_inform (type); - break; + // case RECORD_TYPE: + // case UNION_TYPE: + // case ENUMERAL_TYPE: + // if (!is_decl) + // complained + // = emit_diagnostic (diag_kind, loc, 0, + // "invalid use of incomplete type %q#T", type); + // if (complained) + // cxx_incomplete_type_inform (type); + // break; case VOID_TYPE: emit_diagnostic (diag_kind, loc, 0, "invalid use of %qT", type);