From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1643) id 8D9743858C56; Thu, 13 Oct 2022 07:04:57 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8D9743858C56 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1665644697; bh=tzPpC4YC2dw1nIsh8w2VFym04UGsxdkIn+qGgbbptwI=; h=From:To:Subject:Date:From; b=yZI90Ovo9AWO9/fcXnv6lKQl+LvlVmzt438sFeF8c0afavDlBbvm1m4TRwVc6vmH8 96PJweNjWuCfzFf+qRV3WK8ZNlwnunUKjkomCNT1ezuIAwUPGBsLgSQzt2O+mszjZM rg3y9roKsG3YEbvpgRN0AnkRv6MaMqYgRBJDwsAs= 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] lang.opt: Remove overzealous warning initialisation X-Act-Checkin: gcc X-Git-Author: Arthur Cohen X-Git-Refname: refs/heads/devel/rust/master X-Git-Oldrev: b4096017e3b9ca499b56988b67e05667a02ca202 X-Git-Newrev: 4134055f1855ea5293fa598fc3503e07a11d1d9d Message-Id: <20221013070457.8D9743858C56@sourceware.org> Date: Thu, 13 Oct 2022 07:04:57 +0000 (GMT) List-Id: https://gcc.gnu.org/g:4134055f1855ea5293fa598fc3503e07a11d1d9d commit 4134055f1855ea5293fa598fc3503e07a11d1d9d Author: Arthur Cohen Date: Wed Oct 5 10:05:26 2022 +0200 lang.opt: Remove overzealous warning initialisation pipeline: Add default warning initialisation Option initialisations in lang.opt files are applied globally, so the test suites of other frontend would fail when the rust language was enabled. This should be reversed once @tschwinge `LangInit` option is merged Diff: --- gcc/rust/lang.opt | 6 +++--- gcc/rust/rust-lang.cc | 7 +++++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/gcc/rust/lang.opt b/gcc/rust/lang.opt index bb3b9983862..40297ad314d 100644 --- a/gcc/rust/lang.opt +++ b/gcc/rust/lang.opt @@ -39,7 +39,7 @@ Rust ; Documented in c.opt Wunused-variable -Rust Var(warn_unused_variable) Init(1) Warning +Rust Var(warn_unused_variable) Warning ; documented in common.opt Wunused-const-variable @@ -47,11 +47,11 @@ Rust Warning Alias(Wunused-const-variable=, 2, 0) Warn when a const variable is unused. Wunused-const-variable= -Rust Joined RejectNegative UInteger Var(warn_unused_const_variable) Init(1) Warning LangEnabledBy(Rust,Wunused-variable, 1, 0) IntegerRange(0, 2) +Rust Joined RejectNegative UInteger Var(warn_unused_const_variable) Warning LangEnabledBy(Rust,Wunused-variable, 1, 0) IntegerRange(0, 2) Warn when a const variable is unused. Wunused-result -Rust Var(warn_unused_result) Init(1) Warning +Rust Var(warn_unused_result) Warning Warn if a caller of a function, marked with attribute warn_unused_result, does not use its return value. frust-crate= diff --git a/gcc/rust/rust-lang.cc b/gcc/rust/rust-lang.cc index c9af790f66b..72f3dc09bab 100644 --- a/gcc/rust/rust-lang.cc +++ b/gcc/rust/rust-lang.cc @@ -162,6 +162,13 @@ grs_langhook_init_options_struct (struct gcc_options *opts) * builtins */ opts->x_flag_wrapv = 1; + /* We need to warn on unused variables by default */ + opts->x_warn_unused_variable = 1; + /* For const variables too */ + opts->x_warn_unused_const_variable = 1; + /* And finally unused result for #[must_use] */ + opts->x_warn_unused_result = 1; + // nothing yet - used by frontends to change specific options for the language Rust::Session::get_instance ().init_options (); }