]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
invoke.texi (Warning Options): Add new option -Wframe-larger-than=.
authorSeongbae Park <seongbae.park@gmail.com>
Wed, 20 Feb 2008 21:19:14 +0000 (21:19 +0000)
committerSeongbae Park <spark@gcc.gnu.org>
Wed, 20 Feb 2008 21:19:14 +0000 (21:19 +0000)
gcc/ChangeLog:

2008-02-20  Seongbae Park <seongbae.park@gmail.com>

* doc/invoke.texi (Warning Options): Add new option
-Wframe-larger-than=.
(-Wframe-larger-than): Document.

* flags.h (warn_frame_larger_than, frame_larger_than_size):
Add declarations for new option variables.

* final.c (final_start_function): Check the frame size
before emission and issue a Wframe-larger-than warning.

* opts.c (warn_frame_larger_than, frame_larger_than_size):
Add definitions for new option variables.
(common_handle_option): Handle new option OPT_Wframe_larger_than_.

* common.opt (Wframe-larger-than=): New option.

gcc/testsuite/ChangeLog:

2008-02-20  Seongbae Park <seongbae.park@gmail.com>

* gcc.dg/Wframe-larger-than.c: New option test.

From-SVN: r132496

gcc/ChangeLog
gcc/common.opt
gcc/doc/invoke.texi
gcc/final.c
gcc/flags.h
gcc/opts.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/Wframe-larger-than.c [new file with mode: 0644]

index b8cc999f8b7fb6e55d691beabaa7d56f3a5fd563..d17b56c7b61ca08a99d58614c259a8cb36c183d7 100644 (file)
@@ -1,3 +1,21 @@
+2008-02-20  Seongbae Park <seongbae.park@gmail.com>
+
+       * doc/invoke.texi (Warning Options): Add new option
+       -Wframe-larger-than=.
+       (-Wframe-larger-than): Document.
+
+       * flags.h (warn_frame_larger_than, frame_larger_than_size):
+       Add declarations for new option variables.
+
+       * final.c (final_start_function): Check the frame size
+       before emission and issue a Wframe-larger-than warning.
+
+       * opts.c (warn_frame_larger_than, frame_larger_than_size):
+       Add definitions for new option variables.
+       (common_handle_option): Handle new option OPT_Wframe_larger_than_.
+
+       * common.opt (Wframe-larger-than=): New option.
+
 2008-02-20  Uros Bizjak  <ubizjak@gmail.com>
 
        * config/i386/sse.md (<sse>_vmmul<mode>3): Fix typo in asm template.
index 810f879fe48a5a70bc6a23c81d430f474c31e467..ea48ba7d760fc2b00667ceb209ba872cab04e9e8 100644 (file)
@@ -110,6 +110,17 @@ Wfatal-errors
 Common Var(flag_fatal_errors)
 Exit on the first error occurred
 
+Wframe-larger-than=
+Common RejectNegative Joined UInteger
+-Wframe-larger-than=@var{len} Warn whenever a function's stack frame requires
+more than @var{len} bytes.  The computation done to determine
+the stack frame size is approximate and not conservative.
+The actual requirements may be somewhat greater than @var{len}
+even if you do not get a warning.  In addition, any space allocated
+via @code{alloca}, variable-length arrays, or related constructs
+is not included by the compiler when determining
+whether or not to issue a warning.
+
 Winline
 Common Var(warn_inline) Warning
 Warn when an inlined function cannot be inlined
index 1cb14ea11dc25d75ae37b9da4caf9cdf9ec96a31..cfac283637999277c1c0d0a9703c2f15d9a55e8a 100644 (file)
@@ -236,7 +236,8 @@ Objective-C and Objective-C++ Dialects}.
 -Werror  -Werror=* @gol
 -Wfatal-errors  -Wfloat-equal  -Wformat  -Wformat=2 @gol
 -Wno-format-extra-args -Wformat-nonliteral @gol
--Wformat-security  -Wformat-y2k -Wignored-qualifiers @gol
+-Wformat-security  -Wformat-y2k @gol
+-Wframe-larger-than=@var{len} -Wignored-qualifiers @gol
 -Wimplicit  -Wimplicit-function-declaration  -Wimplicit-int @gol
 -Wimport  -Wno-import  -Winit-self  -Winline @gol
 -Wno-int-to-pointer-cast -Wno-invalid-offsetof @gol
@@ -3518,6 +3519,10 @@ global variable or whenever a built-in function is shadowed.
 @opindex Wlarger-than-@var{len}
 Warn whenever an object of larger than @var{len} bytes is defined.
 
+@item -Wframe-larger-than=@var{len}
+@opindex Wframe-larger-than
+Warn whenever the size of a function frame is larger than @var{len} bytes.
+
 @item -Wunsafe-loop-optimizations
 @opindex Wunsafe-loop-optimizations
 @opindex Wno-unsafe-loop-optimizations
index 12891c2d50dad9d85aba946d3d806dfaccc741b5..8d1cebead414795323dac95500d611005ca02018 100644 (file)
@@ -1524,6 +1524,15 @@ final_start_function (rtx first ATTRIBUTE_UNUSED, FILE *file,
       TREE_ASM_WRITTEN (DECL_INITIAL (current_function_decl)) = 1;
     }
 
+  if (warn_frame_larger_than
+    && get_frame_size () > frame_larger_than_size)
+  {
+      /* Issue a warning */
+      warning (OPT_Wframe_larger_than_,
+               "the frame size of %wd bytes is larger than %wd bytes",
+               get_frame_size (), frame_larger_than_size);
+  }
+
   /* First output the function prologue: code to set up the stack frame.  */
   targetm.asm_out.function_prologue (file, get_frame_size ());
 
index e3174732995912204f6efd8bccd791ec13e83ede..e2041500c149cee314268cdd5cdab96b4819a051 100644 (file)
@@ -137,6 +137,12 @@ extern void set_Wstrict_aliasing (int onoff);
 extern bool warn_larger_than;
 extern HOST_WIDE_INT larger_than_size;
 
+/* Nonzero means warn about any function whose frame size is larger
+   than N bytes. */
+
+extern bool warn_frame_larger_than;
+extern HOST_WIDE_INT frame_larger_than_size;
+
 /* Temporarily suppress certain warnings.
    This is set while reading code from a system header file.  */
 
index 96643ef48fa87622871bc59917940c0865e7ddc5..8b8a1a9c364b6488b6b4f0c6ab4ad9d1c15d6e96 100644 (file)
@@ -58,6 +58,11 @@ bool extra_warnings;
 bool warn_larger_than;
 HOST_WIDE_INT larger_than_size;
 
+/* True to warn about any function whose frame size is larger
+ * than N bytes. */
+bool warn_frame_larger_than;
+HOST_WIDE_INT frame_larger_than_size;
+
 /* Hack for cooperation between set_Wunused and set_Wextra.  */
 static bool maybe_warn_unused_parameter;
 
@@ -1498,6 +1503,11 @@ common_handle_option (size_t scode, const char *arg, int value,
       warn_larger_than = value != -1;
       break;
 
+    case OPT_Wframe_larger_than_:
+      frame_larger_than_size = value;
+      warn_frame_larger_than = value != -1;
+      break;
+
     case OPT_Wstrict_aliasing:
       set_Wstrict_aliasing (value);
       break;
index 34ccb964a48dbeaaa764adb56ab47dbc69a72361..49737884753fed2fa032055b9b5bd22eaab58f8b 100644 (file)
@@ -1,3 +1,7 @@
+2008-02-20  Seongbae Park <seongbae.park@gmail.com>
+
+       * gcc.dg/Wframe-larger-than.c: New option test.
+
 2008-02-20  Tobias Burnus  <burnus@net-b.de>
 
        PR fortran/34997
diff --git a/gcc/testsuite/gcc.dg/Wframe-larger-than.c b/gcc/testsuite/gcc.dg/Wframe-larger-than.c
new file mode 100644 (file)
index 0000000..fab0adf
--- /dev/null
@@ -0,0 +1,13 @@
+/* Test -Wframe-larger-than for warning
+   when the frame size is bigger than specified.
+   Origin: Seongbae Park <seongbae.park@gmail.com> */
+
+/* { dg-do compile } */
+/* { dg-options "-Wframe-larger-than=2048" } */
+
+extern void func(char *);
+
+void foo (void) {
+  char array[4096];
+  func(array);
+} /* { dg-warning "the frame size of .* bytes is larger than 2048 bytes" } */