This patch prevents the compiler from issuing -Winline warnings for functions that are compiler-generated. There are a lot of them in Ada and the warnings are too cryptic to be useful for the average user in this case.
Tested on i586-suse-linux, applied on the mainline. 2011-04-22 Eric Botcazou <ebotca...@adacore.com> * gcc-interface/gigi.h (create_subprog_decl): Add ARTIFICIAL_FLAG parameter. * gcc-interface/utils.c (create_subprog_decl): Likewise. Set DECL_ARTIFICIAL and DECL_NO_INLINE_WARNING_P on the DECL accordingly. * gcc-interface/decl.c (gnat_to_gnu_entity) <E_Subprogram_Type>: Add ARTIFICIAL_FLAG local variable and pass it to create_subprog_decl. <all>: Do not set flags on the reused DECL node coming from an alias. Set DECL_IGNORED_P on the DECL node built for subprograms if they don't need debug info here... * gcc-interface/trans.c (Subprogram_Body_to_gnu): ...and not here. (gigi): Adjust calls to create_subprog_decl. (build_raise_check): Likewise. (establish_gnat_vms_condition_handler): Likewise. (Compilation_Unit_to_gnu): Likewise. (gnat_to_gnu): Likewise. -- Eric Botcazou
Index: gcc-interface/utils.c =================================================================== --- gcc-interface/utils.c (revision 172811) +++ gcc-interface/utils.c (working copy) @@ -1795,7 +1795,7 @@ value_factor_p (tree value, HOST_WIDE_IN return false; } -/* Given 2 consecutive field decls PREV_FIELD and CURR_FIELD, return true +/* Given two consecutive field decls PREV_FIELD and CURR_FIELD, return true unless we can prove these 2 fields are laid out in such a way that no gap exist between the end of PREV_FIELD and the beginning of CURR_FIELD. OFFSET is the distance in bits between the end of PREV_FIELD and the starting @@ -1841,7 +1841,7 @@ potential_alignment_gap (tree prev_field return true; } -/* Returns a LABEL_DECL node for LABEL_NAME. */ +/* Return a LABEL_DECL node for LABEL_NAME. */ tree create_label_decl (tree label_name) @@ -1856,24 +1856,26 @@ create_label_decl (tree label_name) return label_decl; } -/* Returns a FUNCTION_DECL node. SUBPROG_NAME is the name of the subprogram, +/* Return a FUNCTION_DECL node. SUBPROG_NAME is the name of the subprogram, ASM_NAME is its assembler name, SUBPROG_TYPE is its type (a FUNCTION_TYPE node), PARAM_DECL_LIST is the list of the subprogram arguments (a list of PARM_DECL nodes chained through the TREE_CHAIN field). - INLINE_FLAG, PUBLIC_FLAG, EXTERN_FLAG, and ATTR_LIST are used to set the - appropriate fields in the FUNCTION_DECL. GNAT_NODE gives the location. */ + INLINE_FLAG, PUBLIC_FLAG, EXTERN_FLAG, ARTIFICIAL_FLAG and ATTR_LIST are + used to set the appropriate fields in the FUNCTION_DECL. GNAT_NODE is + used for the position of the decl. */ tree -create_subprog_decl (tree subprog_name, tree asm_name, - tree subprog_type, tree param_decl_list, bool inline_flag, - bool public_flag, bool extern_flag, - struct attrib *attr_list, Node_Id gnat_node) +create_subprog_decl (tree subprog_name, tree asm_name, tree subprog_type, + tree param_decl_list, bool inline_flag, bool public_flag, + bool extern_flag, bool artificial_flag, + struct attrib *attr_list, Node_Id gnat_node) { tree subprog_decl = build_decl (input_location, FUNCTION_DECL, subprog_name, subprog_type); tree result_decl = build_decl (input_location, RESULT_DECL, NULL_TREE, TREE_TYPE (subprog_type)); + DECL_ARGUMENTS (subprog_decl) = param_decl_list; /* If this is a non-inline function nested inside an inlined external function, we cannot honor both requests without cloning the nested @@ -1887,13 +1889,15 @@ create_subprog_decl (tree subprog_name, && DECL_EXTERNAL (current_function_decl)) DECL_DECLARED_INLINE_P (current_function_decl) = 0; - DECL_EXTERNAL (subprog_decl) = extern_flag; - TREE_PUBLIC (subprog_decl) = public_flag; - TREE_READONLY (subprog_decl) = TYPE_READONLY (subprog_type); + DECL_ARTIFICIAL (subprog_decl) = artificial_flag; + DECL_EXTERNAL (subprog_decl) = extern_flag; + DECL_DECLARED_INLINE_P (subprog_decl) = inline_flag; + DECL_NO_INLINE_WARNING_P (subprog_decl) = inline_flag && artificial_flag; + + TREE_PUBLIC (subprog_decl) = public_flag; + TREE_READONLY (subprog_decl) = TYPE_READONLY (subprog_type); TREE_THIS_VOLATILE (subprog_decl) = TYPE_VOLATILE (subprog_type); TREE_SIDE_EFFECTS (subprog_decl) = TYPE_VOLATILE (subprog_type); - DECL_DECLARED_INLINE_P (subprog_decl) = inline_flag; - DECL_ARGUMENTS (subprog_decl) = param_decl_list; DECL_ARTIFICIAL (result_decl) = 1; DECL_IGNORED_P (result_decl) = 1; Index: gcc-interface/decl.c =================================================================== --- gcc-interface/decl.c (revision 172811) +++ gcc-interface/decl.c (working copy) @@ -3934,6 +3934,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entit bool public_flag = Is_Public (gnat_entity) || imported_p; bool extern_flag = (Is_Public (gnat_entity) && !definition) || imported_p; + bool artificial_flag = !Comes_From_Source (gnat_entity); /* 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 if the EH circuitry is explicit in the @@ -4379,9 +4380,9 @@ gnat_to_gnu_entity (Entity_Id gnat_entit } else if (kind == E_Subprogram_Type) - gnu_decl = create_type_decl (gnu_entity_name, gnu_type, attr_list, - !Comes_From_Source (gnat_entity), - debug_info_p, gnat_entity); + gnu_decl + = create_type_decl (gnu_entity_name, gnu_type, attr_list, + artificial_flag, debug_info_p, gnat_entity); else { if (has_stub) @@ -4389,21 +4390,21 @@ gnat_to_gnu_entity (Entity_Id gnat_entit gnu_stub_name = gnu_ext_name; gnu_ext_name = create_concat_name (gnat_entity, "internal"); public_flag = false; + artificial_flag = true; } - gnu_decl = create_subprog_decl (gnu_entity_name, gnu_ext_name, - gnu_type, gnu_param_list, - inline_flag, public_flag, - extern_flag, attr_list, - gnat_entity); + gnu_decl + = create_subprog_decl (gnu_entity_name, gnu_ext_name, gnu_type, + gnu_param_list, inline_flag, public_flag, + extern_flag, artificial_flag, attr_list, + gnat_entity); if (has_stub) { tree gnu_stub_decl = create_subprog_decl (gnu_entity_name, gnu_stub_name, gnu_stub_type, gnu_stub_param_list, - inline_flag, true, - extern_flag, attr_list, - gnat_entity); + inline_flag, true, extern_flag, + false, attr_list, gnat_entity); SET_DECL_FUNCTION_STUB (gnu_decl, gnu_stub_decl); } @@ -4928,14 +4929,16 @@ gnat_to_gnu_entity (Entity_Id gnat_entit } /* If we really have a ..._DECL node, set a couple of flags on it. But we - cannot do that if we are reusing the ..._DECL node made for a renamed - object, since the predicates don't apply to it but to GNAT_ENTITY. */ - if (DECL_P (gnu_decl) && !(Present (Renamed_Object (gnat_entity)) && saved)) + cannot do so if we are reusing the ..._DECL node made for an alias or a + renamed object as the predicates don't apply to it but to GNAT_ENTITY. */ + if (DECL_P (gnu_decl) + && !Present (Alias (gnat_entity)) + && !(Present (Renamed_Object (gnat_entity)) && saved)) { if (!Comes_From_Source (gnat_entity)) DECL_ARTIFICIAL (gnu_decl) = 1; - if (!debug_info_p && TREE_CODE (gnu_decl) != FUNCTION_DECL) + if (!debug_info_p) DECL_IGNORED_P (gnu_decl) = 1; } Index: gcc-interface/gigi.h =================================================================== --- gcc-interface/gigi.h (revision 172811) +++ gcc-interface/gigi.h (working copy) @@ -646,29 +646,29 @@ extern tree create_field_decl (tree fiel tree record_type, tree size, tree pos, int packed, int addressable); -/* Returns a PARM_DECL node. PARAM_NAME is the name of the parameter, - PARAM_TYPE is its type. READONLY is true if the parameter is - readonly (either an In parameter or an address of a pass-by-ref - parameter). */ +/* Return a PARM_DECL node. PARAM_NAME is the name of the parameter and + PARAM_TYPE is its type. READONLY is true if the parameter is readonly + (either an In parameter or an address of a pass-by-ref parameter). */ extern tree create_param_decl (tree param_name, tree param_type, bool readonly); -/* Returns a FUNCTION_DECL node. SUBPROG_NAME is the name of the subprogram, +/* Return a LABEL_DECL node for LABEL_NAME. */ +extern tree create_label_decl (tree label_name); + +/* Return a FUNCTION_DECL node. SUBPROG_NAME is the name of the subprogram, ASM_NAME is its assembler name, SUBPROG_TYPE is its type (a FUNCTION_TYPE node), PARAM_DECL_LIST is the list of the subprogram arguments (a list of PARM_DECL nodes chained through the TREE_CHAIN field). - INLINE_FLAG, PUBLIC_FLAG, EXTERN_FLAG, and ATTR_LIST are used to set the - appropriate fields in the FUNCTION_DECL. GNAT_NODE gives the location. */ + INLINE_FLAG, PUBLIC_FLAG, EXTERN_FLAG, ARTIFICIAL_FLAG and ATTR_LIST are + used to set the appropriate fields in the FUNCTION_DECL. GNAT_NODE is + used for the position of the decl. */ extern tree create_subprog_decl (tree subprog_name, tree asm_name, - tree subprog_type, tree param_decl_list, - bool inlinee_flag, bool public_flag, - bool extern_flag, + tree subprog_type, tree param_decl_list, + bool inline_flag, bool public_flag, + bool extern_flag, bool artificial_flag, struct attrib *attr_list, Node_Id gnat_node); -/* Returns a LABEL_DECL node for LABEL_NAME. */ -extern tree create_label_decl (tree label_name); - /* Set up the framework for generating code for SUBPROG_DECL, a subprogram body. This routine needs to be invoked before processing the declarations appearing in the subprogram. */ Index: gcc-interface/trans.c =================================================================== --- gcc-interface/trans.c (revision 172811) +++ gcc-interface/trans.c (working copy) @@ -357,7 +357,7 @@ gigi (Node_Id gnat_root, int max_gnat_no build_function_type (ptr_void_type_node, tree_cons (NULL_TREE, sizetype, t)), - NULL_TREE, false, true, true, NULL, Empty); + NULL_TREE, false, true, true, true, NULL, Empty); DECL_IS_MALLOC (malloc_decl) = 1; /* malloc32 is a function declaration tree for a function to allocate @@ -367,7 +367,7 @@ gigi (Node_Id gnat_root, int max_gnat_no build_function_type (ptr_void_type_node, tree_cons (NULL_TREE, sizetype, t)), - NULL_TREE, false, true, true, NULL, Empty); + NULL_TREE, false, true, true, true, NULL, Empty); DECL_IS_MALLOC (malloc32_decl) = 1; /* free is a function declaration tree for a function to free memory. */ @@ -377,14 +377,14 @@ gigi (Node_Id gnat_root, int max_gnat_no tree_cons (NULL_TREE, ptr_void_type_node, t)), - NULL_TREE, false, true, true, NULL, Empty); + NULL_TREE, false, true, true, true, NULL, Empty); /* This is used for 64-bit multiplication with overflow checking. */ mulv64_decl = create_subprog_decl (get_identifier ("__gnat_mulv64"), NULL_TREE, build_function_type_list (int64_type, int64_type, int64_type, NULL_TREE), - NULL_TREE, false, true, true, NULL, Empty); + NULL_TREE, false, true, true, true, NULL, Empty); /* Name of the _Parent field in tagged record types. */ parent_name_id = get_identifier (Get_Name_String (Name_uParent)); @@ -405,7 +405,7 @@ gigi (Node_Id gnat_root, int max_gnat_no = create_subprog_decl (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); + NULL_TREE, false, true, true, true, NULL, Empty); DECL_IGNORED_P (get_jmpbuf_decl) = 1; set_jmpbuf_decl @@ -414,7 +414,7 @@ gigi (Node_Id gnat_root, int max_gnat_no NULL_TREE, build_function_type (void_type_node, tree_cons (NULL_TREE, jmpbuf_ptr_type, t)), - NULL_TREE, false, true, true, NULL, Empty); + NULL_TREE, false, true, true, true, NULL, Empty); DECL_IGNORED_P (set_jmpbuf_decl) = 1; /* setjmp returns an integer and has one operand, which is a pointer to @@ -424,7 +424,7 @@ gigi (Node_Id gnat_root, int max_gnat_no (get_identifier ("__builtin_setjmp"), NULL_TREE, build_function_type (integer_type_node, tree_cons (NULL_TREE, jmpbuf_ptr_type, t)), - NULL_TREE, false, true, true, NULL, Empty); + NULL_TREE, false, true, true, true, NULL, Empty); DECL_BUILT_IN_CLASS (setjmp_decl) = BUILT_IN_NORMAL; DECL_FUNCTION_CODE (setjmp_decl) = BUILT_IN_SETJMP; @@ -435,7 +435,7 @@ gigi (Node_Id gnat_root, int max_gnat_no (get_identifier ("__builtin_update_setjmp_buf"), NULL_TREE, build_function_type (void_type_node, tree_cons (NULL_TREE, jmpbuf_ptr_type, t)), - NULL_TREE, false, true, true, NULL, Empty); + NULL_TREE, false, true, true, true, NULL, Empty); DECL_BUILT_IN_CLASS (update_setjmp_buf_decl) = BUILT_IN_NORMAL; DECL_FUNCTION_CODE (update_setjmp_buf_decl) = BUILT_IN_UPDATE_SETJMP_BUF; @@ -446,7 +446,7 @@ gigi (Node_Id gnat_root, int max_gnat_no tree_cons (NULL_TREE, ptr_void_type_node, t)), - NULL_TREE, false, true, true, NULL, Empty); + NULL_TREE, false, true, true, true, NULL, Empty); DECL_IGNORED_P (begin_handler_decl) = 1; end_handler_decl @@ -455,7 +455,7 @@ gigi (Node_Id gnat_root, int max_gnat_no tree_cons (NULL_TREE, ptr_void_type_node, t)), - NULL_TREE, false, true, true, NULL, Empty); + NULL_TREE, false, true, true, true, NULL, Empty); DECL_IGNORED_P (end_handler_decl) = 1; /* If in no exception handlers mode, all raise statements are redirected to @@ -473,7 +473,7 @@ gigi (Node_Id gnat_root, int max_gnat_no tree_cons (NULL_TREE, integer_type_node, t))), - NULL_TREE, false, true, true, NULL, Empty); + NULL_TREE, false, true, true, true, NULL, Empty); TREE_THIS_VOLATILE (decl) = 1; TREE_SIDE_EFFECTS (decl) = 1; TREE_TYPE (decl) @@ -506,7 +506,7 @@ gigi (Node_Id gnat_root, int max_gnat_no (get_identifier ("system__soft_links__get_gnat_exception"), NULL_TREE, build_function_type (build_pointer_type (except_type_node), NULL_TREE), - NULL_TREE, false, true, true, NULL, Empty); + NULL_TREE, false, true, true, true, NULL, Empty); raise_nodefer_decl = create_subprog_decl @@ -515,7 +515,7 @@ gigi (Node_Id gnat_root, int max_gnat_no tree_cons (NULL_TREE, build_pointer_type (except_type_node), t)), - NULL_TREE, false, true, true, NULL, Empty); + NULL_TREE, false, true, true, true, NULL, Empty); /* Indicate that these never return. */ TREE_THIS_VOLATILE (raise_nodefer_decl) = 1; @@ -665,7 +665,7 @@ build_raise_check (int check, tree void_ tree_cons (NULL_TREE, integer_type_node, void_tree)))))), - NULL_TREE, false, true, true, NULL, Empty); + NULL_TREE, false, true, true, true, NULL, Empty); } else { @@ -678,7 +678,7 @@ build_raise_check (int check, tree void_ tree_cons (NULL_TREE, build_pointer_type (unsigned_char_type_node), tree_cons (NULL_TREE, integer_type_node, void_tree))), - NULL_TREE, false, true, true, NULL, Empty); + NULL_TREE, false, true, true, true, NULL, Empty); } TREE_THIS_VOLATILE (result) = 1; @@ -2427,7 +2427,8 @@ establish_gnat_vms_condition_handler (vo ptr_void_type_node, ptr_void_type_node, NULL_TREE), - NULL_TREE, 0, 1, 1, 0, Empty); + NULL_TREE, false, true, true, true, NULL, + Empty); /* ??? DECL_CONTEXT shouldn't have been set because of DECL_EXTERNAL. */ DECL_CONTEXT (gnat_vms_condition_handler_decl) = NULL_TREE; @@ -2508,10 +2509,6 @@ Subprogram_Body_to_gnu (Node_Id gnat_nod relayout_decl (gnu_result_decl); } - /* Propagate the debug mode. */ - if (!Needs_Debug_Info (gnat_subprog_id)) - DECL_IGNORED_P (gnu_subprog_decl) = 1; - /* Set the line number in the decl to correspond to that of the body so that the line number notes are written correctly. */ Sloc_to_locus (Sloc (gnat_node), &DECL_SOURCE_LOCATION (gnu_subprog_decl)); @@ -3774,7 +3771,8 @@ Compilation_Unit_to_gnu (Node_Id gnat_no tree gnu_elab_proc_decl = create_subprog_decl (create_concat_name (gnat_unit_entity, body_p ? "elabb" : "elabs"), - NULL_TREE, void_ftype, NULL_TREE, false, true, false, NULL, gnat_unit); + NULL_TREE, void_ftype, NULL_TREE, false, true, false, true, NULL, + gnat_unit); struct elab_info *info; VEC_safe_push (tree, gc, gnu_elab_proc_stack, gnu_elab_proc_decl); @@ -4505,7 +4503,7 @@ gnat_to_gnu (Node_Id gnat_node) (Entity (Prefix (gnat_node)), attr == Attr_Elab_Body ? "elabb" : "elabs"), NULL_TREE, void_ftype, NULL_TREE, false, - true, true, NULL, gnat_node); + true, true, true, NULL, gnat_node); gnu_result = Attribute_to_gnu (gnat_node, &gnu_result_type, attr); }