From b55e7f34bc21a482d35dc2a9eaf38a878e0afbe4 Mon Sep 17 00:00:00 2001 From: Eric Botcazou Date: Fri, 29 Sep 2006 06:52:04 +0000 Subject: decl.c (gnat_to_gnu_entity): Do not set "const" flag on "pure" Ada subprograms if SJLJ exceptions are used. * decl.c (gnat_to_gnu_entity) : Do not set "const" flag on "pure" Ada subprograms if SJLJ exceptions are used. * trans.c (Handled_Sequence_Of_Statements_to_gnu): Set TREE_NO_WARNING on the declaration node of JMPBUF_SAVE. * utils.c (init_gigi_decls): Set DECL_IS_PURE on the declaration nodes of Get_Jmpbuf_Address_Soft and Get_GNAT_Exception. * utils2.c (build_call_0_expr): Do not set TREE_SIDE_EFFECTS. From-SVN: r117299 --- gcc/ada/ChangeLog | 10 ++++++++++ gcc/ada/decl.c | 16 +++++++++++++--- gcc/ada/trans.c | 5 +++++ gcc/ada/utils.c | 4 ++++ gcc/ada/utils2.c | 3 ++- 5 files changed, 34 insertions(+), 4 deletions(-) diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index d3466cf..d078714d 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,13 @@ +2006-09-28 Eric Botcazou + + * decl.c (gnat_to_gnu_entity) : Do not set "const" flag + on "pure" Ada subprograms if SJLJ exceptions are used. + * trans.c (Handled_Sequence_Of_Statements_to_gnu): Set TREE_NO_WARNING + on the declaration node of JMPBUF_SAVE. + * utils.c (init_gigi_decls): Set DECL_IS_PURE on the declaration nodes + of Get_Jmpbuf_Address_Soft and Get_GNAT_Exception. + * utils2.c (build_call_0_expr): Do not set TREE_SIDE_EFFECTS. + 2006-08-20 Laurent GUERBY PR ada/28716 diff --git a/gcc/ada/decl.c b/gcc/ada/decl.c index c49e834..fac6f2f 100644 --- a/gcc/ada/decl.c +++ b/gcc/ada/decl.c @@ -3768,11 +3768,20 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) if (TREE_CODE (gnu_return_type) == VOID_TYPE) pure_flag = false; + /* The semantics of "pure" in Ada essentially matches that of "const" + in the back-end. In particular, both properties are orthogonal to + the "nothrow" property. But this is true only if the EH circuitry + is explicit in the internal representation of the back-end. If we + are to completely hide the EH circuitry from it, we need to declare + that calls to pure Ada subprograms that can throw have side effects + since they can trigger an "abnormal" transfer of control flow; thus + they can be neither "const" nor "pure" in the back-end sense. */ gnu_type = build_qualified_type (gnu_type, - (TYPE_QUALS (gnu_type) - | (TYPE_QUAL_CONST * pure_flag) - | (TYPE_QUAL_VOLATILE * volatile_flag))); + TYPE_QUALS (gnu_type) + | (Exception_Mechanism == Back_End_Exceptions + ? TYPE_QUAL_CONST * pure_flag : 0) + | (TYPE_QUAL_VOLATILE * volatile_flag)); Sloc_to_locus (Sloc (gnat_entity), &input_location); @@ -3841,6 +3850,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) inline_flag, public_flag, extern_flag, attr_list, gnat_entity); + DECL_STUBBED_P (gnu_decl) = Convention (gnat_entity) == Convention_Stubbed; } diff --git a/gcc/ada/trans.c b/gcc/ada/trans.c index 7fecc6f..fe820bf 100644 --- a/gcc/ada/trans.c +++ b/gcc/ada/trans.c @@ -2167,6 +2167,11 @@ Handled_Sequence_Of_Statements_to_gnu (Node_Id gnat_node) build_call_0_expr (get_jmpbuf_decl), false, false, false, false, NULL, gnat_node); + /* 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 + it is uninitialized, although they will never be actually taken. */ + TREE_NO_WARNING (gnu_jmpsave_decl) = 1; gnu_jmpbuf_decl = create_var_decl (get_identifier ("JMP_BUF"), NULL_TREE, jmpbuf_type, NULL_TREE, false, false, false, false, diff --git a/gcc/ada/utils.c b/gcc/ada/utils.c index 4358547..3874e39 100644 --- a/gcc/ada/utils.c +++ b/gcc/ada/utils.c @@ -518,6 +518,8 @@ init_gigi_decls (tree long_long_float_type, tree exception_type) (get_identifier ("system__soft_links__get_jmpbuf_address_soft"), NULL_TREE, build_function_type (jmpbuf_ptr_type, NULL_TREE), NULL_TREE, false, true, true, NULL, Empty); + /* Avoid creating superfluous edges to __builtin_setjmp receivers. */ + DECL_IS_PURE (get_jmpbuf_decl) = 1; set_jmpbuf_decl = create_subprog_decl @@ -534,6 +536,8 @@ init_gigi_decls (tree long_long_float_type, tree exception_type) NULL_TREE, build_function_type (build_pointer_type (except_type_node), NULL_TREE), NULL_TREE, false, true, true, NULL, Empty); + /* Avoid creating superfluous edges to __builtin_setjmp receivers. */ + DECL_IS_PURE (get_excptr_decl) = 1; /* Functions that raise exceptions. */ raise_nodefer_decl diff --git a/gcc/ada/utils2.c b/gcc/ada/utils2.c index 65837bb..ffca597 100644 --- a/gcc/ada/utils2.c +++ b/gcc/ada/utils2.c @@ -1431,7 +1431,8 @@ build_call_0_expr (tree fundecl) build_unary_op (ADDR_EXPR, NULL_TREE, fundecl), NULL_TREE, NULL_TREE); - TREE_SIDE_EFFECTS (call) = 1; + /* We rely on build3 to compute TREE_SIDE_EFFECTS. This makes it possible + to propagate the DECL_IS_PURE flag on parameterless functions. */ return call; } -- cgit v1.1