From afa8c090bf5ee17d89628b4885efad3a7ea62505 Mon Sep 17 00:00:00 2001 From: Marek Polacek Date: Mon, 21 Oct 2019 18:45:45 +0000 Subject: PR c++/92062 - ODR-use ignored for static member of class template. has_value_dependent_address wasn't stripping location wrappers so it gave the wrong answer for "&x" in the static_assert. That led us to thinking that the expression isn't instantiation-dependent, and we skipped static initialization of A<0>::x. This patch adds stripping so that has_value_dependent_address gives the same answer as it used to before the location wrappers addition. * pt.c (has_value_dependent_address): Strip location wrappers. * g++.dg/cpp0x/constexpr-odr1.C: New test. * g++.dg/cpp0x/constexpr-odr2.C: New test. From-SVN: r277266 --- gcc/cp/ChangeLog | 5 +++++ gcc/cp/pt.c | 2 ++ 2 files changed, 7 insertions(+) (limited to 'gcc/cp') diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 29c6bbd..f861fb3 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,10 @@ 2019-10-21 Marek Polacek + PR c++/92062 - ODR-use ignored for static member of class template. + * pt.c (has_value_dependent_address): Strip location wrappers. + +2019-10-21 Marek Polacek + PR c++/92106 - ICE with structured bindings and -Wreturn-local-addr. * typeck.c (maybe_warn_about_returning_address_of_local): Avoid recursing on null initializer and return false instead. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 7f7f992..e154cac 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -6542,6 +6542,8 @@ check_valid_ptrmem_cst_expr (tree type, tree expr, static bool has_value_dependent_address (tree op) { + STRIP_ANY_LOCATION_WRAPPER (op); + /* We could use get_inner_reference here, but there's no need; this is only relevant for template non-type arguments, which can only be expressed as &id-expression. */ -- cgit v1.1