This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Fix PR33763
On Mon, 16 Jan 2012, Richard Guenther wrote:
> + /* Do not merge an extern inline decl with any other decl either. */
> + if ((DECL_DECLARED_INLINE_P (newdecl)
> + && DECL_EXTERNAL (newdecl))
> + || (!flag_gnu89_inline
> + && (DECL_DECLARED_INLINE_P (newdecl)
> + || lookup_attribute ("gnu_inline",
> + DECL_ATTRIBUTES (newdecl)))))
> + return false;
That's not safe. Consider the following test with -std=c99
-pedantic-errors:
inline void h (void);
inline void h () {}
With your patch applied this gives an incorrect error "inline function 'h'
declared but never defined". The function was defined. Another case:
inline void h (void);
inline void h ();
void i (void) { h (0); }
inline void h (void) {}
You get the same bogus error - but not the correct error you should get
about "too many arguments to function 'h'".
For C99 inline functions, you only are allowed one body for the function -
but do need to merge declarations to get the correct composite type, and
correct diagnostics about whether the function was defined.
--
Joseph S. Myers
joseph@codesourcery.com