diff mbox

[4/5] Document warning option -Wstring-plus-int

Message ID 1487761285.2882.67.camel@stu.xidian.edu.cn
State New
Headers show

Commit Message

Xi Ruoyao Feb. 22, 2017, 11:01 a.m. UTC
This patch adds document of -Wstring-plus-int.

gcc/ChangeLog:

2017-02-22  Xi Ruoyao  <ryxi@stu.xidian.edu.cn>

	* doc/invoke.texi (Warning Options): Document -Wstring-plus-int

---
 gcc/doc/invoke.texi | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

Comments

Gerald Pfeifer Feb. 25, 2017, 5:19 p.m. UTC | #1
On Wed, 22 Feb 2017, Xi Ruoyao wrote:
> 2017-02-22  Xi Ruoyao  <ryxi@stu.xidian.edu.cn>
> 
> 	* doc/invoke.texi (Warning Options): Document -Wstring-plus-int

In principle this looks fine, but...

> +@item -Wstring-plus-int
> +@opindex Wstring-plus-int
> +@opindex Wno-string-plus-int
> +Warn for adding an integer to a string pointer or string literal,
> +which seems an ill-formed attempt to append to the string.

...I will say this may not give people too much of an idea of what
it is about.

I.e., after reading the above, I was wondering who'd do "abc" + 1.

Of course, once I looked at your good additions to the testsuite,
I realized that this is really more about "abc" + '1'.  Technically
the description is correct, since character constants are integers.

Perhaps add something like

  "A typical example this warns about is @samp{"abc" + 'd'}."

?

Gerald
Xi Ruoyao Feb. 27, 2017, 8:49 a.m. UTC | #2
On 2017-02-25 Sat 18:19 +0100, Gerald Pfeifer wrote:

> I.e., after reading the above, I was wondering who'd do "abc" + 1.
> 
> Of course, once I looked at your good additions to the testsuite,
> I realized that this is really more about "abc" + '1'.  Technically
> the description is correct, since character constants are integers.
> 
> Perhaps add something like
> 
>   "A typical example this warns about is @samp{"abc" + 'd'}."
> 
> ?

Thanks for the advise. I'll make it clear and resubmit the patches
in early stage of GCC 8.
Jeff Law April 28, 2017, 8:28 p.m. UTC | #3
On 02/22/2017 04:01 AM, Xi Ruoyao wrote:
> This patch adds document of -Wstring-plus-int.
> 
> gcc/ChangeLog:
> 
> 2017-02-22  Xi Ruoyao  <ryxi@stu.xidian.edu.cn>
> 
> 	* doc/invoke.texi (Warning Options): Document -Wstring-plus-int
This is OK for the trunk once all 5 are approved.

jeff
diff mbox

Patch

diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index e1a1d13..6e929e8 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -307,7 +307,7 @@  Objective-C and Objective-C++ Dialects}.
 -Wsizeof-pointer-memaccess  -Wsizeof-array-argument @gol
 -Wstack-protector  -Wstack-usage=@var{len}  -Wstrict-aliasing @gol
 -Wstrict-aliasing=n  -Wstrict-overflow  -Wstrict-overflow=@var{n} @gol
--Wstringop-overflow=@var{n} @gol
+-Wstringop-overflow=@var{n} -Wstring-plus-int @gol
 -Wsuggest-attribute=@r{[}pure@r{|}const@r{|}noreturn@r{|}format@r{]} @gol
 -Wsuggest-final-types @gol  -Wsuggest-final-methods  -Wsuggest-override @gol
 -Wmissing-format-attribute  -Wsubobject-linkage @gol
@@ -5046,6 +5046,12 @@  whether to issue a warning.  Similarly to @option{-Wstringop-overflow=3} this
 setting of the option may result in warnings for benign code.
 @end table
 
+@item -Wstring-plus-int
+@opindex Wstring-plus-int
+@opindex Wno-string-plus-int
+Warn for adding an integer to a string pointer or string literal,
+which seems an ill-formed attempt to append to the string.
+
 @item -Wsuggest-attribute=@r{[}pure@r{|}const@r{|}noreturn@r{|}format@r{]}
 @opindex Wsuggest-attribute=
 @opindex Wno-suggest-attribute=