On Fri, 11 Jan 2019, Martin Sebor wrote: > gcc/testsuite/ChangeLog: > > PR c/88718 > * gcc.dg/inline-40.c: New test. > * gcc.dg/inline-41.c: New test.
We already have tests inline-40.c and inline-41.c; these need to be renumbered accordingly. > + if (add) > + { > + if (csi->function == func > + || csi->function) > + continue; Since func is non-NULL, this is equivalent to "if (csi->function)". Don't you want to break, not continue, in the case where csi->function (as all the tentative entries come first)? As-is, this looks like it would have quadratic cost if a file has many inline functions each referencing some file-scope static. (The "Avoid adding another tentative record for this DECL if one already exists." also looks quadratic, but having very many functions in a file seems more likely than very many references to statics in a single declaration that is not a definition.) > @@ -5165,6 +5259,11 @@ finish_decl (tree decl, location_t init_loc, tree > set_user_assembler_name (decl, asmspec); > } > > + /* Remove any tentative record of a non-static inline function > + referencing a static decl made a DECL that is not a definition. */ > + if (TREE_CODE (decl) == FUNCTION_DECL) > + update_tentative_inline_static (decl); > + You also need to do the update when the declaration wasn't a function declaration at all. The present patch produces spurious warnings for: static int i; int a[sizeof i]; inline void f (void) {} because the reference to i in the declaration of a gets treated as if it were in the definition of f. Also, you need to distinguish the case of updating for a function definition, and updating for a declaration that's not a definition, for a function that was previously defined. E.g. inline void f (int a[sizeof (int)]) {} static int i; inline void f (int a[sizeof i]); must not diagnose a reference to i in f (you have such tests with the declaration before the definition, but none that I can see with the declaration after the definition). I think this means the caller of update_tentative_inline_static should specify whether to add or remove, rather than update_tentative_inline_static trying to deduce it from properties of a DECL (that don't say whether the particular declaration in question is a definition or not, just whether a definition has been seen). -- Joseph S. Myers jos...@codesourcery.com