From 386cc2cd034ea810f23ea0584e7113e70366d673 Mon Sep 17 00:00:00 2001 From: ebotcazou Date: Fri, 29 Sep 2006 06:52:04 +0000 Subject: [PATCH] * 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@117299 138bc75d-0d04-0410-961f-82ee72b054a4 --- 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 d3466cfedde..d078714d1ae 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 c49e834bf49..fac6f2f06e3 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 7fecc6feb9d..fe820bf0ccf 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 4358547883e..3874e39bb8c 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 65837bb0151..ffca59798ca 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; } -- 2.11.4.GIT