From patchwork Sat Jan 20 14:40:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sandra Loosemore X-Patchwork-Id: 1888768 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; 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 [8.43.85.97]) (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 4THK0V6dgVz1yPv for ; Sun, 21 Jan 2024 01:40:42 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C8F26385842D for ; Sat, 20 Jan 2024 14:40:40 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from esa1.mentor.iphmx.com (esa1.mentor.iphmx.com [68.232.129.153]) by sourceware.org (Postfix) with ESMTPS id 3776F3858D39 for ; Sat, 20 Jan 2024 14:40:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3776F3858D39 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 3776F3858D39 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=68.232.129.153 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705761622; cv=none; b=q/id5IElTEJJLgMlpiWyOeg/r3gtRIYjw+PuNmdU6yzpzI97h2mr8VF4SLARftbLRP0MmK144F6MglgPTb7mDCDsxApCO1WKwmWG9QVEa8hlWzbfzejAOb9diJFHl+1VLlDnj4GCCLYrYqM1fudbIkTp+FNJEXfXWrhNQToiPiQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705761622; c=relaxed/simple; bh=sZdA6wUXvXUYBuiLJFLZjiAzvKjlTxEwuCgdvcFE/fs=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=mGQnu0M8VM6J+uuOAr9al2GP+zH2yptKoRmALmqyG0yAXtGgC+sUI0mEXXYVd2HAMc0tlO46khVeqS2k9qhx04ZB7hNx19G57aUeEfmukfJ1gX2QA3ydmq8L9I4pIe675BtYw1bLVXoWJO+fUmIRcHw1PNqHYEbT6w9UQjjyYS0= ARC-Authentication-Results: i=1; server2.sourceware.org X-CSE-ConnectionGUID: UUEnObo+SmGoPc8AC51GLA== X-CSE-MsgGUID: ag0+kw9hRjOVoBtgeWTbjw== X-IronPort-AV: E=Sophos;i="6.05,208,1701158400"; d="scan'208";a="32112107" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa1.mentor.iphmx.com with ESMTP; 20 Jan 2024 06:40:18 -0800 IronPort-SDR: hPNbWWBVV/Je+Y6+yrjes1kEU8/SkPs0/GNTCXrcdC5n9Ap8q94sNEHEGFZ52yoYs7A93EKg+R 3a01/zY1pWvksmh7Cd6zQYwjKtRaxbnyzXGQbT2znAegUocCDQo8H8Sk0PQO+SJ2FeyyxIwNt6 BAldLIH8iFO/f8TX5+tkqN0gfLlXgY5LRy5Ca69YjZKf6moI1FmvRGiXanpqWIU9nHPQdzkEsJ ZA70JeHtRxTc3lJ/hw8DODQcXhy8up5w01mktijzOhZ5Rcsxk233tXfhFUB1lmeRxsBy8h/HRA dVM= From: Sandra Loosemore To: Subject: [COMMITTED] Correct documentation for -Warray-parameter [PR102998] Date: Sat, 20 Jan 2024 07:40:01 -0700 Message-ID: <20240120144001.230328-1-sandra@codesourcery.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-ClientProxiedBy: svr-orw-mbx-15.mgc.mentorg.com (147.34.90.215) 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 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 gcc/ChangeLog PR c/102998 * doc/invoke.texi (Option Summary): Add -Warray-parameter. (Warning Options): Correct/edit discussion of -Warray-parameter to make the first example less confusing, and fill in missing info. --- gcc/doc/invoke.texi | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 313f363f5f2..930c5dc7236 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -332,6 +332,7 @@ Objective-C and Objective-C++ Dialects}. -Wno-aggressive-loop-optimizations -Warith-conversion -Warray-bounds -Warray-bounds=@var{n} -Warray-compare +-Warray-parameter -Warray-parameter=@var{n} -Wno-attributes -Wattribute-alias=@var{n} -Wno-attribute-alias -Wno-attribute-warning -Wbidi-chars=@r{[}none@r{|}unpaired@r{|}any@r{|}ucn@r{]} @@ -8467,25 +8468,28 @@ bool same = arr1 == arr2; @option{-Warray-compare} is enabled by @option{-Wall}. @opindex Wno-array-parameter +@opindex Warray-parameter @item -Warray-parameter @itemx -Warray-parameter=@var{n} -Warn about redeclarations of functions involving arguments of array or +Warn about redeclarations of functions involving parameters of array or pointer types of inconsistent kinds or forms, and enable the detection of out-of-bounds accesses to such parameters by warnings such as @option{-Warray-bounds}. -If the first function declaration uses the array form the bound specified +If the first function declaration uses the array form for a parameter +declaration, the bound specified in the array is assumed to be the minimum number of elements expected to be provided in calls to the function and the maximum number of elements accessed by it. Failing to provide arguments of sufficient size or accessing more than the maximum number of elements may be diagnosed by warnings such -as @option{-Warray-bounds}. At level 1 the warning diagnoses inconsistencies +as @option{-Warray-bounds} or @option{-Wstringop-overflow}. +At level 1, the warning diagnoses inconsistencies involving array parameters declared using the @code{T[static N]} form. -For example, the warning triggers for the following redeclarations because -the first one allows an array of any size to be passed to @code{f} while -the second one with the keyword @code{static} specifies that the array -argument must have at least four elements. +For example, the warning triggers for the second declaration of @code{f} +because the first one with the keyword @code{static} specifies that +the array argument must have at least four elements, while the second +allows an array of any size to be passed to @code{f}. @smallexample void f (int[static 4]); @@ -8493,7 +8497,7 @@ void f (int[]); // warning (inconsistent array form) void g (void) @{ - int *p = (int *)malloc (4); + int *p = (int *)malloc (1 * sizeof (int)); f (p); // warning (array too small) @dots{} @} @@ -8514,6 +8518,10 @@ void g (int[8]); // warning (inconsistent array bound) @option{-Wvla-parameter} option triggers warnings for similar inconsistencies involving Variable Length Array arguments. +The short form of the option @option{-Warray-parameter} is equivalent to +@option{-Warray-parameter=2}. The negative form @option{-Wno-array-parameter} +is equivalent to @option{-Warray-parameter=0}. + @opindex Wattribute-alias @opindex Wno-attribute-alias @item -Wattribute-alias=@var{n}