OSDN Git Service

gcc/ChangeLog:
authorspark <spark@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 20 Feb 2008 21:19:14 +0000 (21:19 +0000)
committerspark <spark@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 20 Feb 2008 21:19:14 +0000 (21:19 +0000)
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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@132496 138bc75d-0d04-0410-961f-82ee72b054a4

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 b8cc999..d17b56c 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 810f879..ea48ba7 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 1cb14ea..cfac283 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 12891c2..8d1cebe 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 e317473..e204150 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 96643ef..8b8a1a9 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 34ccb96..4973788 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" } */