diff options
author | Hristian Kirtchev <kirtchev@adacore.com> | 2007-08-16 14:21:07 +0200 |
---|---|---|
committer | Arnaud Charlet <charlet@gcc.gnu.org> | 2007-08-16 14:21:07 +0200 |
commit | dae2b8eaa891aa280bb99103045bde802af66086 (patch) | |
tree | 0989d9ca5b50bc66dbae68eaaf4a0c7ab927a05e /gcc/ada/trans.c | |
parent | ace980d5d8b6443b4e0d8d5b9cdcd34083c5e09b (diff) | |
download | gcc-dae2b8eaa891aa280bb99103045bde802af66086.zip gcc-dae2b8eaa891aa280bb99103045bde802af66086.tar.gz gcc-dae2b8eaa891aa280bb99103045bde802af66086.tar.bz2 |
sem_res.adb (Comes_From_Predefined_Lib_Unit): New.
2007-08-16 Hristian Kirtchev <kirtchev@adacore.com>
Bob Duff <duff@adacore.com>
Nicolas Setton <setton@adacore.com>
* sem_res.adb (Comes_From_Predefined_Lib_Unit): New.
(Resolve): Alphabetize local variables. Add new variable From_Lib. When
the statement which is being resolved comes from a predefined library
unit, all non-predefined library interpretations are skipped.
(Resolve_Op_Concat): If string concatenation was folded in the parser,
but the "&" is user defined, give an error, because the folding would
be wrong.
* sinfo.ads, sinfo.adb (Is_Folded_In_Parser): New flag to indicate that
the parser has folded a long sequence of concatenations of string
literals.
* trans.c (Handled_Sequence_Of_Statements_to_gnu): Mark "JMPBUF_SAVE"
and "JMP_BUF" variables as artificial.
(N_String_Literal): Do not use alloca for very long string literals. Use
xmalloc/free instead. Otherwise the stack might overflow.
* utils.c (init_gigi_decls): Mark "JMPBUF_T" type as created by the
compiler.
From-SVN: r127550
Diffstat (limited to 'gcc/ada/trans.c')
-rw-r--r-- | gcc/ada/trans.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/gcc/ada/trans.c b/gcc/ada/trans.c index 7a9b7f2..f6ba98c 100644 --- a/gcc/ada/trans.c +++ b/gcc/ada/trans.c @@ -101,6 +101,11 @@ DEF_VEC_ALLOC_P(parm_attr,gc); struct language_function GTY(()) { +/* We should avoid allocating more than ALLOCA_THRESHOLD bytes via alloca, for + fear of running out of stack space. If we need more, we use xmalloc/free + instead. */ +#define ALLOCA_THRESHOLD 1000 + VEC(parm_attr,gc) *parm_attr_cache; }; @@ -2508,6 +2513,8 @@ Handled_Sequence_Of_Statements_to_gnu (Node_Id gnat_node) build_call_0_expr (get_jmpbuf_decl), false, false, false, false, NULL, gnat_node); + DECL_ARTIFICIAL (gnu_jmpsave_decl) = 1; + /* The __builtin_setjmp receivers will immediately reinstall it. Now because of the unstructured form of EH used by setjmp_longjmp, there might be forward edges going to __builtin_setjmp receivers on which @@ -2517,6 +2524,7 @@ Handled_Sequence_Of_Statements_to_gnu (Node_Id gnat_node) NULL_TREE, jmpbuf_type, NULL_TREE, false, false, false, false, NULL, gnat_node); + DECL_ARTIFICIAL (gnu_jmpbuf_decl) = 1; set_block_jmpbuf_decl (gnu_jmpbuf_decl); @@ -3118,8 +3126,12 @@ gnat_to_gnu (Node_Id gnat_node) { String_Id gnat_string = Strval (gnat_node); int length = String_Length (gnat_string); - char *string = (char *) alloca (length + 1); int i; + char *string; + if (length >= ALLOCA_THRESHOLD) + string = xmalloc (length + 1); /* in case of large strings */ + else + string = (char *) alloca (length + 1); /* Build the string with the characters in the literal. Note that Ada strings are 1-origin. */ @@ -3135,6 +3147,9 @@ gnat_to_gnu (Node_Id gnat_node) /* Strings in GCC don't normally have types, but we want this to not be converted to the array type. */ TREE_TYPE (gnu_result) = gnu_result_type; + + if (length >= ALLOCA_THRESHOLD) /* free if heap-allocated */ + free (string); } else { |