This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [C PATCH] Set DECL_EXTERNAL on inline functions without body (PR target/39013)


On Fri, Jan 30, 2009 at 9:28 AM, Jakub Jelinek <jakub@redhat.com> wrote:
> Hi!
>
> When an inline function doesn't have a body defined in current CU,
> we error on it with -std=gnu99 -pedantic-errors, or just warn, or don't
> warn, but in all cases but error we should IMHO set DECL_EXTERNAL on it,
> because the function is certainly not defined in current CU.
>
> Bootstrapped/regtested on x86_64-linux, ok for trunk?
>
> 2009-01-30  Jakub Jelinek  <jakub@redhat.com>
>
>        PR target/39013
>        * c-decl.c (pop_scope): Set DECL_EXTERNAL for functions declared
>        inline but never defined.
>
>        * gcc.target/i386/pr39013-1.c: New test.
>        * gcc.target/i386/pr39013-2.c: New test.
>
> --- gcc/c-decl.c.jj     2009-01-26 15:24:44.000000000 +0100
> +++ gcc/c-decl.c        2009-01-30 15:59:22.000000000 +0100
> @@ -781,14 +781,19 @@ pop_scope (void)
>              error ("nested function %q+D declared but never defined", p);
>              undef_nested_function = true;
>            }
> -         /* C99 6.7.4p6: "a function with external linkage... declared
> -            with an inline function specifier ... shall also be defined in the
> -            same translation unit."  */
>          else if (DECL_DECLARED_INLINE_P (p)
>                   && TREE_PUBLIC (p)
> -                  && !DECL_INITIAL (p)
> -                  && !flag_gnu89_inline)
> -           pedwarn (input_location, 0, "inline function %q+D declared but never defined", p);
> +                  && !DECL_INITIAL (p))
> +           {
> +             /* C99 6.7.4p6: "a function with external linkage... declared
> +                with an inline function specifier ... shall also be defined
> +                in the same translation unit."  */
> +             if (!flag_gnu89_inline)
> +               pedwarn (input_location, 0,
> +                        "inline function %q+D declared but never defined", p);
> +             if (!DECL_EXTERNAL (p))
> +               DECL_EXTERNAL (p) = 1;

Why not skip if (!DECL_EXTERNAL (p))?

-- 
H.J.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]