common.opt (Wlarger-than=): New.
authorManuel López-Ibáñez <manu@gcc.gnu.org>
Tue, 26 Feb 2008 14:01:02 +0000 (14:01 +0000)
committerManuel López-Ibáñez <manu@gcc.gnu.org>
Tue, 26 Feb 2008 14:01:02 +0000 (14:01 +0000)
2008-02-26  Manuel Lopez-Ibanez  <manu@gcc.gnu.org>

* 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.

From-SVN: r132674

gcc/ChangeLog
gcc/common.opt
gcc/doc/invoke.texi
gcc/optc-gen.awk
gcc/opth-gen.awk
gcc/opts.c
gcc/stor-layout.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/Wlarger-than2.c [new file with mode: 0644]
gcc/tree-optimize.c

index b8c7161f521025277a436a45ece030df58ec3ca0..fefe8c2f3dd002320a3e627c4e5332a2962a0127 100644 (file)
@@ -1,3 +1,14 @@
+2008-02-26  Manuel Lopez-Ibanez  <manu@gcc.gnu.org>
+
+       * 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 <manu@gcc.gnu.org>
 
        * c-common.c (match_case_to_enum_1): Add appropriate
index 670466bdb3099da596e0cb42bc5058c56294ea1c..5c62510f7000270fe2e58030543d58a36857135d 100644 (file)
@@ -127,7 +127,10 @@ Warn when an inlined function cannot be inlined
 
 Wlarger-than-
 Common RejectNegative Joined UInteger Warning
--Wlarger-than-<number> Warn if an object is larger than <number> bytes
+
+Wlarger-than=
+Common RejectNegative Joined UInteger Warning
+-Wlarger-than=<number> Warn if an object is larger than <number> bytes
 
 Wlogical-op
 Common Warning Var(warn_logical_op)
index 693f30de694faa554bc0b17c40e51c53c9d4df55..6a80373e43dd01965801d044bcae2389c7d72832 100644 (file)
@@ -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.
 
index f0bd8e5946cb71f2e2100f324f62f2cd41324582..cd1024406daf9f0d59a83e92d641215bf1e873ea 100644 (file)
@@ -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)
 
index f096112cc907a549d284fd12d27ff3c2258a1f9b..9aa18a12ad93e816b6b9b9bd9d8049678b79bd2b 100644 (file)
@@ -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)
 
index 8bee44b947abe4c02565f1c8dfbde0444fc03ded..445cec3729635281db0d99d85a40b5b7daaa9e1f 100644 (file)
@@ -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;
index a7bcd054400fe6e5ad66ff78a6eff23d9c766224..67e4c25fbdc25104e25947f5c3d20a6026baf888 100644 (file)
@@ -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);
        }
     }
index b627135f100c0faf7f1e7550cf993c0f1a884a52..8fb14f23f53da0bab2f4774b7caf586ac6d4a2ee 100644 (file)
@@ -1,3 +1,7 @@
+2008-02-26  Manuel Lopez-Ibanez  <manu@gcc.gnu.org>
+
+       * gcc.dg/Wlarger-than2.c: New.
+       
 2008-02-26  Paolo Carlini  <pcarlini@suse.de>
 
         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 (file)
index 0000000..eac67f4
--- /dev/null
@@ -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" } */
+}
+
index cb30ba401cd2e6f915e87348570ec5032abaf903..544d75daabec7fb55180540e20f0a2f8c6b7291f 100644 (file)
@@ -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);
        }
     }