summaryrefslogtreecommitdiff
path: root/gnu/egcs
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2007-11-26 22:47:23 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2007-11-26 22:47:23 +0000
commit411b684d5c659555d94f6bd0893da1da15ef157f (patch)
tree976cb2039c130b2390eb6e951531f6c229500d5a /gnu/egcs
parent39c42e0288ffa508378cb82d08d4718cc37f4a02 (diff)
Add a new warning to gcc, -Wvariable-decl, which causes it to warn for
auto declarations which size are not known at compile time. This flag will eventually be added to the kernel makefiles so that we can rely on -Wstack-larger-than work. ok deraadt@ mbalmer@ otto@ marco@
Diffstat (limited to 'gnu/egcs')
-rw-r--r--gnu/egcs/gcc/flags.h5
-rw-r--r--gnu/egcs/gcc/stmt.c3
-rw-r--r--gnu/egcs/gcc/toplev.c10
3 files changed, 17 insertions, 1 deletions
diff --git a/gnu/egcs/gcc/flags.h b/gnu/egcs/gcc/flags.h
index a63a4e5ab14..c2e0369ab6b 100644
--- a/gnu/egcs/gcc/flags.h
+++ b/gnu/egcs/gcc/flags.h
@@ -143,6 +143,11 @@ extern unsigned stack_larger_than_size;
extern int warn_aggregate_return;
+/* Nonzero means warn about any automatic declaration whose size is not
+ constant. */
+
+extern int warn_variable_decl;
+
/* Nonzero if generating code to do profiling. */
extern int profile_flag;
diff --git a/gnu/egcs/gcc/stmt.c b/gnu/egcs/gcc/stmt.c
index 7f8a571c4d1..26950fbafd4 100644
--- a/gnu/egcs/gcc/stmt.c
+++ b/gnu/egcs/gcc/stmt.c
@@ -3598,6 +3598,9 @@ expand_decl (decl)
{
rtx address, size;
+ if (warn_variable_decl)
+ warning ("variable-sized declaration");
+
/* Record the stack pointer on entry to block, if have
not already done so. */
if (thisblock->data.block.stack_level == 0)
diff --git a/gnu/egcs/gcc/toplev.c b/gnu/egcs/gcc/toplev.c
index f8f616fb300..3757bb9ac3f 100644
--- a/gnu/egcs/gcc/toplev.c
+++ b/gnu/egcs/gcc/toplev.c
@@ -1272,6 +1272,12 @@ int warn_inline;
int warn_aggregate_return;
+/* Nonzero means warn about any automatic declaration whose size is not
+ constant. */
+
+int warn_variable_decl;
+
+
/* Likewise for -W. */
lang_independent_options W_options[] =
@@ -1292,7 +1298,9 @@ lang_independent_options W_options[] =
{"stack-protector", &warn_stack_protector, 1,
"Warn when disabling stack protector for some reason"},
{"trampolines", &warn_trampolines, 1,
- "Warn when trampolines are emitted"}
+ "Warn when trampolines are emitted"},
+ {"variable-decl", &warn_variable_decl, 1,
+ "Warn about variable-sized declarations"}
};
/* Output files for assembler code (real compiler output)