aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSeongbae Park <seongbae.park@gmail.com>2008-02-20 21:19:14 +0000
committerSeongbae Park <spark@gcc.gnu.org>2008-02-20 21:19:14 +0000
commita214518f7f23a6f5d2f81b4a4824c68488831c48 (patch)
treed6c21e69cb0b12b3fcf52d86ecdbdc5d17f346c5
parentc8910ef9e2bbec3bfcfaedcd5f79d7b40a7a79ad (diff)
downloadgcc-a214518f7f23a6f5d2f81b4a4824c68488831c48.zip
gcc-a214518f7f23a6f5d2f81b4a4824c68488831c48.tar.gz
gcc-a214518f7f23a6f5d2f81b4a4824c68488831c48.tar.bz2
invoke.texi (Warning Options): Add new option -Wframe-larger-than=.
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
-rw-r--r--gcc/ChangeLog18
-rw-r--r--gcc/common.opt11
-rw-r--r--gcc/doc/invoke.texi7
-rw-r--r--gcc/final.c9
-rw-r--r--gcc/flags.h6
-rw-r--r--gcc/opts.c10
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gcc.dg/Wframe-larger-than.c13
8 files changed, 77 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index b8cc999..d17b56c 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -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.
diff --git a/gcc/common.opt b/gcc/common.opt
index 810f879..ea48ba7 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -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
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 1cb14ea..cfac283 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -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
diff --git a/gcc/final.c b/gcc/final.c
index 12891c2..8d1cebe 100644
--- a/gcc/final.c
+++ b/gcc/final.c
@@ -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 ());
diff --git a/gcc/flags.h b/gcc/flags.h
index e317473..e204150 100644
--- a/gcc/flags.h
+++ b/gcc/flags.h
@@ -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. */
diff --git a/gcc/opts.c b/gcc/opts.c
index 96643ef..8b8a1a9 100644
--- a/gcc/opts.c
+++ b/gcc/opts.c
@@ -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;
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 34ccb96..4973788 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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
index 0000000..fab0adf
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/Wframe-larger-than.c
@@ -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" } */