@@ -10851,12 +10851,19 @@ if this routine has a body (dump nothing if it has no body).
1085110851 a_boolean is_marked_weak = FALSE;
1085210852 a_boolean thread_local_init_case = FALSE;
1085310853 a_boolean for_inlining_only ;
10854+ a_boolean body_only_for_inlining = FALSE;
10855+ a_boolean need_gnu_inline_attr = FALSE;
1085410856
1085510857 if (c99_mode && rout -> definition_for_inlining_only &&
10856- !gcc_version_is (< 50000 )) {
10858+ !gcc_version_is (< 50000 )
10859+ #if GNU_EXTENSIONS_ALLOWED
10860+ && !rout -> gnu_c89_inline
10861+ #endif /* GNU_EXTENSIONS_ALLOWED */
10862+ ) {
1085710863 /* This is a C99 "inline definition", so we must suppress the "extern"
1085810864 keyword to avoid turning it into an external definition. (gcc did
10859- not support C99 inline semantics until version 5.1.0.) */
10865+ not support C99 inline semantics until version 5.1.0. A routine with
10866+ the gnu_inline attribute follows the GNU C89 rules instead.) */
1086010867 for_inlining_only = TRUE;
1086110868 } else {
1086210869 for_inlining_only = FALSE;
@@ -10881,8 +10888,25 @@ if this routine has a body (dump nothing if it has no body).
1088110888 provided only for the purpose of inlining -- "extern inline".
1088210889 Put out the definition in that case. */
1088310890 has_defn = TRUE;
10891+ body_only_for_inlining = TRUE;
1088410892 if (!for_inlining_only ) {
10885- storage_class = (a_storage_class )sc_extern ;
10893+ storage_class = sc_extern ;
10894+ /* This is not a C99 inline definition, so the body is put out as an
10895+ "extern __inline__" definition. Under the GNU C89 inline rules,
10896+ that is used only for inlining, but under the C99 rules it is an
10897+ external definition, and so would be defined in every translation
10898+ unit that contains it. Request the GNU C89 rules with the
10899+ gnu_inline attribute, except for gcc before 4.2, which does not
10900+ recognize the attribute (but always follows the GNU C89 rules). */
10901+ need_gnu_inline_attr = !gcc_is_generated_code_target ||
10902+ gnu_target_version_number >= 40200 ;
10903+ #if GNU_EXTENSIONS_ALLOWED
10904+ if (rout -> gnu_c89_inline ) {
10905+ /* form_routine_attributes already puts out the gnu_inline
10906+ attribute for this routine. */
10907+ need_gnu_inline_attr = FALSE;
10908+ } /* if */
10909+ #endif /* GNU_EXTENSIONS_ALLOWED */
1088610910 } /* if */
1088710911 } /* if */
1088810912 } /* if */
@@ -11145,13 +11169,17 @@ if this routine has a body (dump nothing if it has no body).
1114511169 /* gcc will be used to compile this generated code, so we know how to
1114611170 indicate an inline function. */
1114711171 /* gcc ignores __inline__ on functions with ellipses, so don't
11148- mark such functions as inline. Recent versions of gcc issue an
11149- error for a function marked both inline and weak, so don't mark a
11150- weak function as inline, either. */
11151- if (!f_skip_typerefs (rout -> type )-> variant .routine .extra_info ->
11152- has_ellipsis &&
11172+ mark such functions as inline, except for a definition only for
11173+ inlining, which would otherwise be an external definition. Recent
11174+ versions of gcc issue an error for a function marked both inline and
11175+ weak, so don't mark a weak function as inline, either. */
11176+ if ((!rout_type_supp (f_skip_typerefs (rout -> type ))-> has_ellipsis ||
11177+ body_only_for_inlining ) &&
1115311178 !is_marked_weak ) {
1115411179 write_tok_str ("__inline__ " );
11180+ if (need_gnu_inline_attr ) {
11181+ write_tok_str ("__attribute__((__gnu_inline__)) " );
11182+ } /* if */
1115511183 } /* if */
1115611184 } /* if */
1115711185#if GNU_EXTENSIONS_ALLOWED && !LOWER_IFUNC
0 commit comments