diff options
author | Nathan Sidwell <nathan@acm.org> | 2020-07-22 08:20:31 -0700 |
---|---|---|
committer | Nathan Sidwell <nathan@acm.org> | 2020-07-22 08:43:25 -0700 |
commit | 0f32c94fc72313798b3a9033c92ceb34f7b7febc (patch) | |
tree | 59649da06fa27294415cba4aaf3bcb560e7dc37d /gcc/cp/error.c | |
parent | 63fa0927e8aba59b1a301f7d13f5cd0e6bb62a66 (diff) | |
download | gcc-0f32c94fc72313798b3a9033c92ceb34f7b7febc.zip gcc-0f32c94fc72313798b3a9033c92ceb34f7b7febc.tar.gz gcc-0f32c94fc72313798b3a9033c92ceb34f7b7febc.tar.bz2 |
c++: More cleanups for modern C++
Here are some more places where we can declare variables at the
assignment point, rather than use C89. Also, let's name our variables
by what they contain -- the register allocator is perfectly able to
track liveness for us.
gcc/cp/
* decl.c (decls_match): Move variables into scopes
they're needed in.
(duplicate_decls): Use STRIP_TEMPLATE.
(build_typename_type): Move var decls to their assignments.
(begin_function_body): Likewise.
* decl2.c (get_guard): Likewise.
(mark_used): Use true for truthiness.
* error.c (dump_aggr_type): Hold the decl in a var called
'decl', not 'name'.
Diffstat (limited to 'gcc/cp/error.c')
-rw-r--r-- | gcc/cp/error.c | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/gcc/cp/error.c b/gcc/cp/error.c index 0d6375e..ecb41e8 100644 --- a/gcc/cp/error.c +++ b/gcc/cp/error.c @@ -701,7 +701,6 @@ class_key_or_enum_as_string (tree t) static void dump_aggr_type (cxx_pretty_printer *pp, tree t, int flags) { - tree name; const char *variety = class_key_or_enum_as_string (t); int typdef = 0; int tmplate = 0; @@ -711,23 +710,23 @@ dump_aggr_type (cxx_pretty_printer *pp, tree t, int flags) if (flags & TFF_CLASS_KEY_OR_ENUM) pp_cxx_ws_string (pp, variety); - name = TYPE_NAME (t); + tree decl = TYPE_NAME (t); - if (name) + if (decl) { - typdef = (!DECL_ARTIFICIAL (name) + typdef = (!DECL_ARTIFICIAL (decl) /* An alias specialization is not considered to be a typedef. */ && !alias_template_specialization_p (t, nt_opaque)); if ((typdef && ((flags & TFF_CHASE_TYPEDEF) - || (!flag_pretty_templates && DECL_LANG_SPECIFIC (name) - && DECL_TEMPLATE_INFO (name)))) - || DECL_SELF_REFERENCE_P (name)) + || (!flag_pretty_templates && DECL_LANG_SPECIFIC (decl) + && DECL_TEMPLATE_INFO (decl)))) + || DECL_SELF_REFERENCE_P (decl)) { t = TYPE_MAIN_VARIANT (t); - name = TYPE_NAME (t); + decl = TYPE_NAME (t); typdef = 0; } @@ -737,7 +736,7 @@ dump_aggr_type (cxx_pretty_printer *pp, tree t, int flags) || PRIMARY_TEMPLATE_P (CLASSTYPE_TI_TEMPLATE (t))); if (! (flags & TFF_UNQUALIFIED_NAME)) - dump_scope (pp, CP_DECL_CONTEXT (name), flags | TFF_SCOPE); + dump_scope (pp, CP_DECL_CONTEXT (decl), flags | TFF_SCOPE); flags &= ~TFF_UNQUALIFIED_NAME; if (tmplate) { @@ -747,9 +746,8 @@ dump_aggr_type (cxx_pretty_printer *pp, tree t, int flags) while (DECL_TEMPLATE_INFO (tpl)) tpl = DECL_TI_TEMPLATE (tpl); - name = tpl; + decl = tpl; } - name = DECL_NAME (name); } if (LAMBDA_TYPE_P (t)) @@ -762,7 +760,7 @@ dump_aggr_type (cxx_pretty_printer *pp, tree t, int flags) flags); pp_greater (pp); } - else if (!name || IDENTIFIER_ANON_P (name)) + else if (!decl || IDENTIFIER_ANON_P (DECL_NAME (decl))) { if (flags & TFF_CLASS_KEY_OR_ENUM) pp_string (pp, M_("<unnamed>")); @@ -770,7 +768,7 @@ dump_aggr_type (cxx_pretty_printer *pp, tree t, int flags) pp_printf (pp, M_("<unnamed %s>"), variety); } else - pp_cxx_tree_identifier (pp, name); + pp_cxx_tree_identifier (pp, DECL_NAME (decl)); if (tmplate) dump_template_parms (pp, TYPE_TEMPLATE_INFO (t), |