aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-cfg.cc
diff options
context:
space:
mode:
authorPatrick Palka <ppalka@redhat.com>2022-09-08 09:45:45 -0400
committerPatrick Palka <ppalka@redhat.com>2022-09-08 09:45:45 -0400
commit4db3cb781c355341fa041e6b5bbbfc495c6a0fdb (patch)
treeb113e95a7756fe473ce3e7c834e8ded99649157e /gcc/tree-cfg.cc
parent95c7d5899521a9e266c68cbcc92edfd2cde8694e (diff)
downloadgcc-4db3cb781c355341fa041e6b5bbbfc495c6a0fdb.zip
gcc-4db3cb781c355341fa041e6b5bbbfc495c6a0fdb.tar.gz
gcc-4db3cb781c355341fa041e6b5bbbfc495c6a0fdb.tar.bz2
c++: unnecessary instantiation of constexpr var [PR99130]
Here the use of 'value' from within an unevaluated context causes us to overeagerly instantiate it, via maybe_instantiate_decl called from mark_used, despite the use occurring in a context that doesn't require a definition. This seems to only affect constexpr variable specializations, though we used to have the same issue for constexpr function specializations until r6-1309-g81371eff9bc7ef made us delay their instantiation until necessary during constexpr evaluation. This patch expands upon the r6-1309 fix to make mark_used avoid unnecessarily instantiating constexpr variable specializations too, by pulling out from maybe_instantiate_decl the condition (decl_maybe_constant_var_p (decl) || (TREE_CODE (decl) == FUNCTION_DECL && DECL_OMP_DECLARE_REDUCTION_P (decl)) || undeduced_auto_decl (decl)) into each of its three callers (including mark_used), removing the problematic first test from mark_used, and simplifying accordingly. The net result is that only mark_used is changed because the other two callers, resolve_address_of_overloaded_function and decl_constant_var_p, already guard the call appropriately. (This relaxation of mark_used seems to be safe because during constexpr evaluation we already take care to instantiate a constexpr variable as necessary via decl_constant_value etc). PR c++/99130 gcc/cp/ChangeLog: * decl2.cc (maybe_instantiate_decl): Adjust function comment. Check VAR_OR_FUNCTION_DECL_P. Pull out the disjunction into ... (mark_used): ... here, removing the decl_maybe_constant_var_p part of it. gcc/testsuite/ChangeLog: * g++.dg/cpp0x/constexpr-decltype5.C: New test.
Diffstat (limited to 'gcc/tree-cfg.cc')
0 files changed, 0 insertions, 0 deletions