https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87921
--- Comment #3 from Jason Merrill <jason at gcc dot gnu.org> --- Author: jason Date: Thu Feb 21 02:24:40 2019 New Revision: 269064 URL: https://gcc.gnu.org/viewcvs?rev=269064&root=gcc&view=rev Log: PR c++/87921 - wrong error with inline static data member. c_parse_final_cleanups checks DECL_IN_AGGR_P to avoid trying to emit a static data member that has not been defined. The inline variable patch changed that to exempt inline variables. But in this case we haven't instantiated the variable yet, so we really don't have a definition. This patch changes inline variable handling such that DECL_IN_AGGR_P is not set for a defined inline variable, so we can remove all the checks of DECL_INLINE_VAR_P after DECL_IN_AGGR_P. With that change we were failing on a static data member that had been instantiated due to a use before we got around to processing it in instantiate_class_template; we should detect that and avoid all the finish_static_data_member_decl processing, which assumes that it is the first time we're seeing the variable. * decl2.c (finish_static_data_member_decl): Don't set DECL_IN_AGGR_P for a non-template inline variable. Do nothing for an already-instantiated variable. (c_parse_final_cleanups): Check DECL_IN_AGGR_P without DECL_INLINE_VAR_P. * decl.c (check_initializer): Likewise. (make_rtl_for_nonlocal_decl): Likewise. * pt.c (instantiate_decl): Likewise. * typeck2.c (store_init_value): Likewise. Added: trunk/gcc/testsuite/g++.dg/cpp1z/inline-var6.C Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/cp-tree.h trunk/gcc/cp/decl.c trunk/gcc/cp/decl2.c trunk/gcc/cp/pt.c trunk/gcc/cp/typeck2.c