From 17c66687862b6f2c9a5a33201b0628631e905fe7 Mon Sep 17 00:00:00 2001 From: manu Date: Tue, 26 Feb 2008 14:01:02 +0000 Subject: [PATCH] 2008-02-26 Manuel Lopez-Ibanez * common.opt (Wlarger-than=): New. * doc/invoke.texi (Warning Options): Replace -Wlarger-than- with -Wlarger-than=. * opts.c (common_handle_option): Handle -Wlarger-than=. * optc-gen.awk: Likewise. * opth-gen.awk: Likewise. * stor-layout.c (layout_decl): Use -Wlarger-than= for warning. * tree-optimize.c (tree_rest_of_compilation): Likewise. testsuite/ * gcc.dg/Wlarger-than2.c: New. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@132674 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 11 +++++++++++ gcc/common.opt | 5 ++++- gcc/doc/invoke.texi | 5 +++-- gcc/optc-gen.awk | 2 +- gcc/opth-gen.awk | 2 +- gcc/opts.c | 5 +++++ gcc/stor-layout.c | 4 ++-- gcc/testsuite/ChangeLog | 4 ++++ gcc/testsuite/gcc.dg/Wlarger-than2.c | 7 +++++++ gcc/tree-optimize.c | 4 ++-- 10 files changed, 40 insertions(+), 9 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/Wlarger-than2.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index b8c7161..fefe8c2 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,14 @@ +2008-02-26 Manuel Lopez-Ibanez + + * common.opt (Wlarger-than=): New. + * doc/invoke.texi (Warning Options): Replace -Wlarger-than- with + -Wlarger-than=. + * opts.c (common_handle_option): Handle -Wlarger-than=. + * optc-gen.awk: Likewise. + * opth-gen.awk: Likewise. + * stor-layout.c (layout_decl): Use -Wlarger-than= for warning. + * tree-optimize.c (tree_rest_of_compilation): Likewise. + 2008-02-26 Manuel Lopez-Ibanez * c-common.c (match_case_to_enum_1): Add appropriate diff --git a/gcc/common.opt b/gcc/common.opt index 670466b..5c62510 100644 --- a/gcc/common.opt +++ b/gcc/common.opt @@ -127,7 +127,10 @@ Warn when an inlined function cannot be inlined Wlarger-than- Common RejectNegative Joined UInteger Warning --Wlarger-than- Warn if an object is larger than bytes + +Wlarger-than= +Common RejectNegative Joined UInteger Warning +-Wlarger-than= Warn if an object is larger than bytes Wlogical-op Common Warning Var(warn_logical_op) diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 693f30d..6a80373 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -241,7 +241,7 @@ Objective-C and Objective-C++ Dialects}. -Wimplicit -Wimplicit-function-declaration -Wimplicit-int @gol -Wimport -Wno-import -Winit-self -Winline @gol -Wno-int-to-pointer-cast -Wno-invalid-offsetof @gol --Winvalid-pch -Wlarger-than-@var{len} -Wunsafe-loop-optimizations @gol +-Winvalid-pch -Wlarger-than=@var{len} -Wunsafe-loop-optimizations @gol -Wlogical-op -Wlong-long @gol -Wmain -Wmissing-braces -Wmissing-field-initializers @gol -Wmissing-format-attribute -Wmissing-include-dirs @gol @@ -3516,7 +3516,8 @@ Do not warn whenever an @samp{#else} or an @samp{#endif} are followed by text. Warn whenever a local variable shadows another local variable, parameter or global variable or whenever a built-in function is shadowed. -@item -Wlarger-than-@var{len} +@item -Wlarger-than=@var{len} +@opindex Wlarger-than=@var{len} @opindex Wlarger-than-@var{len} Warn whenever an object of larger than @var{len} bytes is defined. diff --git a/gcc/optc-gen.awk b/gcc/optc-gen.awk index f0bd8e5..cd102440 100644 --- a/gcc/optc-gen.awk +++ b/gcc/optc-gen.awk @@ -150,7 +150,7 @@ for (i = 0; i < n_opts; i++) { len = length (opts[i]); enum = "OPT_" opts[i] - if (opts[i] == "finline-limit=") + if (opts[i] == "finline-limit=" || opts[i] == "Wlarger-than=") enum = enum "eq" gsub ("[^A-Za-z0-9]", "_", enum) diff --git a/gcc/opth-gen.awk b/gcc/opth-gen.awk index f096112..9aa18a1 100644 --- a/gcc/opth-gen.awk +++ b/gcc/opth-gen.awk @@ -160,7 +160,7 @@ for (i = 0; i < n_opts; i++) { len = length (opts[i]); enum = "OPT_" opts[i] - if (opts[i] == "finline-limit=") + if (opts[i] == "finline-limit=" || opts[i] == "Wlarger-than=") enum = enum "eq" gsub ("[^A-Za-z0-9]", "_", enum) diff --git a/gcc/opts.c b/gcc/opts.c index 8bee44b..445cec3 100644 --- a/gcc/opts.c +++ b/gcc/opts.c @@ -1540,6 +1540,11 @@ common_handle_option (size_t scode, const char *arg, int value, break; case OPT_Wlarger_than_: + /* This form corresponds to -Wlarger-than-. + Kept for backward compatibility. + Don't use it as the first argument of warning(). */ + + case OPT_Wlarger_than_eq: larger_than_size = value; warn_larger_than = value != -1; break; diff --git a/gcc/stor-layout.c b/gcc/stor-layout.c index a7bcd05..67e4c25f 100644 --- a/gcc/stor-layout.c +++ b/gcc/stor-layout.c @@ -464,9 +464,9 @@ layout_decl (tree decl, unsigned int known_align) int size_as_int = TREE_INT_CST_LOW (size); if (compare_tree_int (size, size_as_int) == 0) - warning (OPT_Wlarger_than_, "size of %q+D is %d bytes", decl, size_as_int); + warning (OPT_Wlarger_than_eq, "size of %q+D is %d bytes", decl, size_as_int); else - warning (OPT_Wlarger_than_, "size of %q+D is larger than %wd bytes", + warning (OPT_Wlarger_than_eq, "size of %q+D is larger than %wd bytes", decl, larger_than_size); } } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index b627135..8fb14f2 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2008-02-26 Manuel Lopez-Ibanez + + * gcc.dg/Wlarger-than2.c: New. + 2008-02-26 Paolo Carlini PR c++/35323 diff --git a/gcc/testsuite/gcc.dg/Wlarger-than2.c b/gcc/testsuite/gcc.dg/Wlarger-than2.c new file mode 100644 index 0000000..eac67f4 --- /dev/null +++ b/gcc/testsuite/gcc.dg/Wlarger-than2.c @@ -0,0 +1,7 @@ +/* { dg-do compile } */ +/* { dg-options "-Wlarger-than=8" } */ +static void foo (void) +{ + char buf[9]; /* { dg-warning "size of.*9 bytes" } */ +} + diff --git a/gcc/tree-optimize.c b/gcc/tree-optimize.c index cb30ba4..544d75d 100644 --- a/gcc/tree-optimize.c +++ b/gcc/tree-optimize.c @@ -427,10 +427,10 @@ tree_rest_of_compilation (tree fndecl) = TREE_INT_CST_LOW (TYPE_SIZE_UNIT (ret_type)); if (compare_tree_int (TYPE_SIZE_UNIT (ret_type), size_as_int) == 0) - warning (OPT_Wlarger_than_, "size of return value of %q+D is %u bytes", + warning (OPT_Wlarger_than_eq, "size of return value of %q+D is %u bytes", fndecl, size_as_int); else - warning (OPT_Wlarger_than_, "size of return value of %q+D is larger than %wd bytes", + warning (OPT_Wlarger_than_eq, "size of return value of %q+D is larger than %wd bytes", fndecl, larger_than_size); } } -- 2.7.4