diff options
Diffstat (limited to 'gcc/builtins.c')
-rw-r--r-- | gcc/builtins.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/gcc/builtins.c b/gcc/builtins.c index b58056cf334..20515e74235 100644 --- a/gcc/builtins.c +++ b/gcc/builtins.c @@ -4797,12 +4797,12 @@ expand_builtin_alloca (tree exp, bool cannot_accumulate) { rtx op0; rtx result; - bool valid_arglist; unsigned int align; - bool alloca_with_align = (DECL_FUNCTION_CODE (get_callee_fndecl (exp)) + tree fndecl = get_callee_fndecl (exp); + bool alloca_with_align = (DECL_FUNCTION_CODE (fndecl) == BUILT_IN_ALLOCA_WITH_ALIGN); - valid_arglist + bool valid_arglist = (alloca_with_align ? validate_arglist (exp, INTEGER_TYPE, INTEGER_TYPE, VOID_TYPE) : validate_arglist (exp, INTEGER_TYPE, VOID_TYPE)); @@ -4810,6 +4810,18 @@ expand_builtin_alloca (tree exp, bool cannot_accumulate) if (!valid_arglist) return NULL_RTX; + if ((alloca_with_align && !warn_vla_limit) + || (!alloca_with_align && !warn_alloca_limit)) + { + /* -Walloca-larger-than and -Wvla-larger-than settings override + the more general -Walloc-size-larger-than so unless either of + the former options is specified check the alloca arguments for + overflow. */ + tree args[] = { CALL_EXPR_ARG (exp, 0), NULL_TREE }; + int idx[] = { 0, -1 }; + maybe_warn_alloc_args_overflow (fndecl, exp, args, idx); + } + /* Compute the argument. */ op0 = expand_normal (CALL_EXPR_ARG (exp, 0)); |