]> git.ipfire.org Git - thirdparty/gcc.git/commit
PR c++/87921 - wrong error with inline static data member.
authorJason Merrill <jason@redhat.com>
Thu, 21 Feb 2019 02:24:40 +0000 (21:24 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Thu, 21 Feb 2019 02:24:40 +0000 (21:24 -0500)
commit752620bec6bd8c5139bdd8fccba471c5e7f27e19
tree1eae758075f42772117bea1e986e6e41bb507cd4
parent556bef7efc20fd95c79303c055059a24dcb72a5b
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.

From-SVN: r269064
gcc/cp/ChangeLog
gcc/cp/cp-tree.h
gcc/cp/decl.c
gcc/cp/decl2.c
gcc/cp/pt.c
gcc/cp/typeck2.c
gcc/testsuite/g++.dg/cpp1z/inline-var6.C [new file with mode: 0644]