From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from esa4.mentor.iphmx.com (esa4.mentor.iphmx.com [68.232.137.252]) by sourceware.org (Postfix) with ESMTPS id ED1753858C50 for ; Sun, 21 Jan 2024 20:52:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org ED1753858C50 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=mentor.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org ED1753858C50 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=68.232.137.252 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705870365; cv=none; b=BJYllJL//sJo0TTn3KcL0PwnhWLDj9Rfw7gDdgMJo31sOGgQTMt3dXvVoHA6ZEqi09Mzor34RuAevT802VXwgvjuuCouYIS5oR7TVcYERqL457nKdYn9TFH7aCY1uZPGJG8luy6RS8otZIOgmmsNm5OSfrWOqVIb3EUpZWGvEBc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705870365; c=relaxed/simple; bh=S0KRQqfK1GZ8HOfYLKMpAeBiWh3hM8XiF74XQhB/Udk=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=sB6AYy1FKTqogTzGApQ3EeMh+3tcY17nB0RnxTJPaFl5mG0ZDdkXdf8hTtONIhHm8wVX23B3iHA/7ORnDVZgpEYiPpmYt0fwWQO+X9ERjftvwyUywFC6qzqOL1XLwr4Jh40UjT8chubJz0qjQu9mrWTnR3km5dl9hd4CT/JhpB0= ARC-Authentication-Results: i=1; server2.sourceware.org X-CSE-ConnectionGUID: IZTqNYNSTTKLzrXbi1x+Dw== X-CSE-MsgGUID: G+y0zjEWSF+1/DJYnHdfJg== X-IronPort-AV: E=Sophos;i="6.05,211,1701158400"; d="scan'208";a="28508745" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa4.mentor.iphmx.com with ESMTP; 21 Jan 2024 12:52:41 -0800 IronPort-SDR: MdiTdnPI2gH3mIDD+H+7DGM3Jc6QgEHuCLyyWQUPBqjm9gURWPlFya74E7gTR6XjkAxpxBM1Io 9KDbBqqYba53zXaxayR7O+lYSVXZ0dGALwS3bchZq9aQY/UFdWkvkV8+ZhgByTzNGKxlrEise/ OBpDCc3rEYgP7iwXeIw3bQdDOVFk75SiYDLpI3/gX4zKRqM7RJdaXpSdCh165LpdLtpxHYib2v rQHjP5Sg0AnL46N3vTZUuZ3FSnKYFnE3wdP2E1yNNdV0Uy2yV5JD7Bv6Adk60w0GeH5ShVkLYp z64= From: Sandra Loosemore To: Subject: [COMMITTED] Make the manual clearer about what options -Wunused enables [PR90464] Date: Sun, 21 Jan 2024 13:52:25 -0700 Message-ID: <20240121205225.817935-1-sandra@codesourcery.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: svr-orw-mbx-12.mgc.mentorg.com (147.34.90.212) To svr-orw-mbx-13.mgc.mentorg.com (147.34.90.213) X-Spam-Status: No, score=-10.1 required=5.0 tests=BAYES_00,GIT_PATCH_0,HEADER_FROM_DIFFERENT_DOMAINS,KAM_DMARC_STATUS,SPF_HELO_PASS,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: gcc/ChangeLog PR c++/90464 * doc/invoke.texi (Warning Options): Document that -Wunused-parameter isn't enabled by -Wunused unless -Wextra is provided, and that -Wunused does enable -Wunused-const-variable=1 for C. Clarify that -Wunused doesn't enable -Wunused-* options documented as behaving otherwise, and list them explicitly. --- gcc/doc/invoke.texi | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index f7a6e11d20e..278c931b6a3 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -7598,6 +7598,8 @@ This warning is enabled by @option{-Wall}. @opindex Wno-unused-parameter @item -Wunused-parameter Warn whenever a function parameter is unused aside from its declaration. +This option is not enabled by @code{-Wunused} unless @code{-Wextra} is also +specified. To suppress this warning use the @code{unused} attribute (@pxref{Variable Attributes}). @@ -7624,25 +7626,26 @@ To suppress this warning use the @code{unused} attribute @item -Wunused-const-variable @itemx -Wunused-const-variable=@var{n} Warn whenever a constant static variable is unused aside from its declaration. -@option{-Wunused-const-variable=1} is enabled by @option{-Wunused-variable} -for C, but not for C++. In C this declares variable storage, but in C++ this -is not an error since const variables take the place of @code{#define}s. To suppress this warning use the @code{unused} attribute (@pxref{Variable Attributes}). @table @gcctabopt @item -Wunused-const-variable=1 -This is the warning level that is enabled by @option{-Wunused-variable} for -C. It warns only about unused static const variables defined in the main +Warn about unused static const variables defined in the main compilation unit, but not about static const variables declared in any header included. +@option{-Wunused-const-variable=1} is enabled by either +@option{-Wunused-variable} or @option{-Wunused} for C, but not for +C++. In C this declares variable storage, but in C++ this is not an +error since const variables take the place of @code{#define}s. + @item -Wunused-const-variable=2 This warning level also warns for unused constant static variables in -headers (excluding system headers). This is the warning level of -@option{-Wunused-const-variable} and must be explicitly requested since -in C++ this isn't an error and in C it might be harder to clean up all +headers (excluding system headers). It is equivalent to the short form +@option{-Wunused-const-variable}. This level must be explicitly +requested in both C and C++ because it might be hard to clean up all headers included. @end table @@ -7661,11 +7664,16 @@ This warning is enabled by @option{-Wall}. @opindex Wunused @opindex Wno-unused @item -Wunused -All the above @option{-Wunused} options combined. +All the above @option{-Wunused} options combined, except those documented +as needing to be specified explicitly. In order to get a warning about an unused function parameter, you must either specify @option{-Wextra -Wunused} (note that @option{-Wall} implies -@option{-Wunused}), or separately specify @option{-Wunused-parameter}. +@option{-Wunused}), or separately specify @option{-Wunused-parameter} and/or +@option{-Wunused-but-set-parameter}. + +@option{-Wunused} enables only @option{-Wunused-const-variable=1} rather than +@option{-Wunused-const-variable}, and only for C, not C++. @opindex Wuse-after-free @opindex Wno-use-after-free -- 2.31.1