-
- Downloads
c++: replace in_template_function
All uses of in_template_function except for the one in cp_make_fname_decl seem like they could be generalized to consider any template context. To that end this patch replaces the predicate with a generalized in_template_context predicate that returns true if we're inside any template context. If we legitimately need to consider only function contexts, as in cp_make_fname_decl, we can just additionally check e.g. current_function_decl. One concrete benefit of this, which the adjusted testcase below demonstrates, is that we no longer instantiate/odr-use entities based on uses within a non-function template. gcc/cp/ChangeLog: * class.cc (build_base_path): Check in_template_context instead of in_template_function. (resolves_to_fixed_type_p): Likewise. * cp-tree.h (in_template_context): Define. (in_template_function): Remove. * decl.cc (cp_make_fname_decl): Check current_function_decl and in_template_context instead of in_template_function. * decl2.cc (mark_used): Check in_template_context instead of in_template_function. * pt.cc (in_template_function): Remove. * semantics.cc (enforce_access): Check in_template_context instead of current_template_parms directly. gcc/testsuite/ChangeLog: * g++.dg/warn/Waddress-of-packed-member2.C: No longer expect a() to be marked as odr-used.
Showing
- gcc/cp/class.cc 2 additions, 2 deletionsgcc/cp/class.cc
- gcc/cp/cp-tree.h 1 addition, 1 deletiongcc/cp/cp-tree.h
- gcc/cp/decl.cc 1 addition, 1 deletiongcc/cp/decl.cc
- gcc/cp/decl2.cc 1 addition, 1 deletiongcc/cp/decl2.cc
- gcc/cp/pt.cc 0 additions, 19 deletionsgcc/cp/pt.cc
- gcc/cp/semantics.cc 1 addition, 1 deletiongcc/cp/semantics.cc
- gcc/testsuite/g++.dg/warn/Waddress-of-packed-member2.C 1 addition, 1 deletiongcc/testsuite/g++.dg/warn/Waddress-of-packed-member2.C
Loading
Please register or sign in to comment