Hello, Today I ran into a problem building today's GCC trunk with an older GCC 4.3. There is a warning in libcpp/macro.c about tokens_buff_remove_last_token declared inline after being called. (This is apparently valid C99 but is it also valid C89?) After some digging and diffing, it turns out that the warning exists in GCC 4.3 but not in newer GCC versions. Anyone trying to build a recent trunk (r180082 or newer) with GCC 4.3 or earlier should run into this problem.
Simple test case: typedef struct _cpp_buff _cpp_buff; struct _cpp_buff { struct _cpp_buff *next; unsigned char *base, *cur, *limit; }; static void tokens_buff_remove_last_token (_cpp_buff *); void foo (_cpp_buff *buff) { tokens_buff_remove_last_token (buff); } static inline void tokens_buff_remove_last_token (_cpp_buff *tokens_buff) { return; } t.c:3: warning: `tokens_buff_remove_last_token' declared inline after being called t.c:3: warning: previous declaration of `tokens_buff_remove_last_token' was here The warning is easy to fix, but the underlying problem requires a closer look also. This warning and another one for a similar issue were removed with the patch from Honza to remove all non-"unit-at-a-time" code in r138140: http://gcc.gnu.org/viewcvs?view=revision&revision=138140 http://gcc.gnu.org/ml/gcc-patches/2008-07/msg01756.html This hunk removed the warning from the compiler: Index: c-decl.c =================================================================== *** c-decl.c (revision 138005) --- c-decl.c (working copy) *************** diagnose_mismatched_decls (tree newdecl, *** 1515,1544 **** "noinline follows inline declaration ", newdecl); warned = true; } - - /* Inline declaration after use or definition. - ??? Should we still warn about this now we have unit-at-a-time - mode and can get it right? - Definitely don't complain if the decls are in different translation - units. - C99 permits this, so don't warn in that case. (The function - may not be inlined everywhere in function-at-a-time mode, but - we still shouldn't warn.) */ - if (DECL_DECLARED_INLINE_P (newdecl) && !DECL_DECLARED_INLINE_P (olddecl) - && same_translation_unit_p (olddecl, newdecl) - && flag_gnu89_inline) - { - if (TREE_USED (olddecl)) - { - warning (0, "%q+D declared inline after being called", olddecl); - warned = true; - } - else if (DECL_INITIAL (olddecl)) - { - warning (0, "%q+D declared inline after its definition", olddecl); - warned = true; - } - } } else /* PARM_DECL, VAR_DECL */ { --- 1515,1520 ---- Is it valid in dialects older than C99 to declare a function static inline after calling it? Should the warnings be brought back in the compiler? One reason to bring the warnings back could be that there is now no way for anyone bootstrapping GCC to detect this warning. If it is still a goal that recently modern GCC's should be able to build the latest GCC, then it would be good if the latest GCC warns about the same things in a given C dialect as older GCC versions do. What to do? Ciao! Steven