diff options
author | gdr <gdr@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-03-21 23:55:03 +0000 |
---|---|---|
committer | gdr <gdr@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-03-21 23:55:03 +0000 |
commit | 69cb846fbd50d181d11688a7609862cb0cdec503 (patch) | |
tree | 2e58fc55718cfb98106df9ec9e9dac796b80a2e8 /gcc/cp/error.c | |
parent | 401fe9a1c76dbfc38368b14392299c3759bc277b (diff) | |
download | gcc-69cb846fbd50d181d11688a7609862cb0cdec503.tar.gz |
* pretty-print.c (pp_base_maybe_space): New function.
* pretty-print.h (pp_base_maybe_space): Declare.
(pp_maybe_space): New macro.
cp/
* error.c (enum pad): Remove.
(dump_qualifiers): Likewise.
(dump_type): Replace dump_qualifiers with
* pp_cxx_cv_qualifier_seq.
(dump_aggr_type): Likewise.
(dump_type_suffix): Likewise.
(dump_simple_decl): Likewise.
(dump_function_decl): Likewise.
(cv_to_string): Likewise.
(dump_type_prefix): Likewise. Adjust return void.
* cxx-pretty-print.c (pp_cxx_cv_qualifier_seq): Move to
cxx_pretty_print.h.
(pp_cxx_template_keyword_if_needed): Document.
(pp_cxx_qualified_id): Document case FUNCTION_DECL. Tidy.
(pp_cxx_expression): Handle NON_DEPENDENT_EXPR and
MUST_NOT_THROW_EXPR.
testsuite/
* g++.dg/template/qualttp20.C: Adjust dg- regexp.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@79796 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cp/error.c')
-rw-r--r-- | gcc/cp/error.c | 96 |
1 files changed, 27 insertions, 69 deletions
diff --git a/gcc/cp/error.c b/gcc/cp/error.c index 5b2490e76f2..324975c4d67 100644 --- a/gcc/cp/error.c +++ b/gcc/cp/error.c @@ -32,8 +32,6 @@ Boston, MA 02111-1307, USA. */ #include "langhooks-def.h" #include "cxx-pretty-print.h" -enum pad { none, before, after }; - #define pp_template_argument_list_start(PP) \ pp_non_consecutive_character (PP, '<') #define pp_template_argument_list_end(PP) \ @@ -72,12 +70,11 @@ static void dump_expr (tree, int); static void dump_unary_op (const char *, tree, int); static void dump_binary_op (const char *, tree, int); static void dump_aggr_type (tree, int); -static enum pad dump_type_prefix (tree, int); +static void dump_type_prefix (tree, int); static void dump_type_suffix (tree, int); static void dump_function_name (tree, int); static void dump_expr_list (tree, int); static void dump_global_iord (tree); -static enum pad dump_qualifiers (tree, enum pad); static void dump_parameters (tree, int); static void dump_exception_spec (tree, int); static const char *class_key_or_enum (tree); @@ -143,38 +140,6 @@ dump_scope (tree scope, int flags) } } -/* Dump type qualifiers, providing padding as requested. Return an - indication of whether we dumped something. */ - -static enum pad -dump_qualifiers (tree t, enum pad p) -{ - static const int masks[] = - {TYPE_QUAL_CONST, TYPE_QUAL_VOLATILE, TYPE_QUAL_RESTRICT}; - static const char *const names[] = - {"const", "volatile", "__restrict"}; - int ix; - int quals = TYPE_QUALS (t); - int do_after = p == after; - - if (quals) - { - for (ix = 0; ix != 3; ix++) - if (masks[ix] & quals) - { - if (p == before) - pp_space (cxx_pp); - p = before; - pp_identifier (cxx_pp, names[ix]); - } - if (do_after) - pp_space (cxx_pp); - } - else - p = none; - return p; -} - /* Dump the template ARGument under control of FLAGS. */ static void @@ -367,7 +332,7 @@ dump_type (tree t, int flags) break; case TEMPLATE_TYPE_PARM: - dump_qualifiers (t, after); + pp_cxx_cv_qualifier_seq (cxx_pp, t); if (TYPE_IDENTIFIER (t)) pp_tree_identifier (cxx_pp, TYPE_IDENTIFIER (t)); else @@ -390,7 +355,7 @@ dump_type (tree t, int flags) break; } case TYPENAME_TYPE: - dump_qualifiers (t, after); + pp_cxx_cv_qualifier_seq (cxx_pp, t); pp_string (cxx_pp, "typename "); dump_typename (t, flags); break; @@ -460,7 +425,7 @@ dump_aggr_type (tree t, int flags) int typdef = 0; int tmplate = 0; - dump_qualifiers (t, after); + pp_cxx_cv_qualifier_seq (cxx_pp, t); if (flags & TFF_CLASS_KEY_OR_ENUM) { @@ -520,15 +485,12 @@ dump_aggr_type (tree t, int flags) deal with prefix and suffix. Arrays must also do this for DECL nodes, like int a[], and for things like - int *[]&. - - Return indicates how you should pad an object name after this. I.e. you - want to pad non-*, non-& cores, but not pad * or & types. */ + int *[]&. */ -static enum pad +static void dump_type_prefix (tree t, int flags) { - enum pad padding = before; + pp_base (cxx_pp)->padding = pp_none; if (TYPE_PTRMEMFUNC_P (t)) { @@ -543,53 +505,49 @@ dump_type_prefix (tree t, int flags) { tree sub = TREE_TYPE (t); - padding = dump_type_prefix (sub, flags); + dump_type_prefix (sub, flags); if (TREE_CODE (sub) == ARRAY_TYPE) { pp_space (cxx_pp); pp_left_paren (cxx_pp); } pp_character (cxx_pp, "&*"[TREE_CODE (t) == POINTER_TYPE]); - padding = dump_qualifiers (t, before); + pp_base (cxx_pp)->padding = pp_before; + pp_cxx_cv_qualifier_seq (cxx_pp, t); } break; case OFFSET_TYPE: offset_type: - padding = dump_type_prefix (TREE_TYPE (t), flags); + dump_type_prefix (TREE_TYPE (t), flags); if (TREE_CODE (t) == OFFSET_TYPE) /* pmfs deal with this in d_t_p */ { - if (padding != none) - pp_space (cxx_pp); + pp_maybe_space (cxx_pp); dump_type (TYPE_OFFSET_BASETYPE (t), flags); pp_colon_colon (cxx_pp); } pp_star (cxx_pp); - padding = dump_qualifiers (t, none); + pp_cxx_cv_qualifier_seq (cxx_pp, t); break; /* Can only be reached through function pointer -- this would not be correct if FUNCTION_DECLs used it. */ case FUNCTION_TYPE: - padding = dump_type_prefix (TREE_TYPE (t), flags); - if (padding != none) - pp_space (cxx_pp); + dump_type_prefix (TREE_TYPE (t), flags); + pp_maybe_space (cxx_pp); pp_left_paren (cxx_pp); - padding = none; break; case METHOD_TYPE: - padding = dump_type_prefix (TREE_TYPE (t), flags); - if (padding != none) - pp_space (cxx_pp); + dump_type_prefix (TREE_TYPE (t), flags); + pp_maybe_space (cxx_pp); pp_left_paren (cxx_pp); - padding = none; dump_aggr_type (TYPE_METHOD_BASETYPE (t), flags); pp_colon_colon (cxx_pp); break; case ARRAY_TYPE: - padding = dump_type_prefix (TREE_TYPE (t), flags); + dump_type_prefix (TREE_TYPE (t), flags); break; case ENUMERAL_TYPE: @@ -612,7 +570,7 @@ dump_type_prefix (tree t, int flags) case VECTOR_TYPE: case TYPEOF_TYPE: dump_type (t, flags); - padding = before; + pp_base (cxx_pp)->padding = pp_before; break; default: @@ -622,7 +580,6 @@ dump_type_prefix (tree t, int flags) pp_identifier (cxx_pp, "<typeprefixerror>"); break; } - return padding; } /* Dump the suffix of type T, under control of FLAGS. This is the part @@ -659,8 +616,8 @@ dump_type_suffix (tree t, int flags) dump_parameters (arg, flags & ~TFF_FUNCTION_DEFAULT_ARGUMENTS); if (TREE_CODE (t) == METHOD_TYPE) - dump_qualifiers - (TREE_TYPE (TREE_VALUE (TYPE_ARG_TYPES (t))), before); + pp_cxx_cv_qualifier_seq + (cxx_pp, TREE_TYPE (TREE_VALUE (TYPE_ARG_TYPES (t)))); dump_exception_spec (TYPE_RAISES_EXCEPTIONS (t), flags); dump_type_suffix (TREE_TYPE (t), flags); break; @@ -736,8 +693,8 @@ dump_simple_decl (tree t, tree type, int flags) { if (flags & TFF_DECL_SPECIFIERS) { - if (dump_type_prefix (type, flags) != none) - pp_space (cxx_pp); + dump_type_prefix (type, flags); + pp_maybe_space (cxx_pp); } if (!DECL_INITIAL (t) || TREE_CODE (DECL_INITIAL (t)) != TEMPLATE_PARM_INDEX) dump_scope (CP_DECL_CONTEXT (t), flags); @@ -1095,8 +1052,8 @@ dump_function_decl (tree t, int flags) dump_parameters (parmtypes, flags); if (TREE_CODE (fntype) == METHOD_TYPE) - dump_qualifiers (TREE_TYPE (TREE_VALUE (TYPE_ARG_TYPES (fntype))), - before); + pp_cxx_cv_qualifier_seq + (cxx_pp, TREE_TYPE (TREE_VALUE (TYPE_ARG_TYPES (fntype)))); if (flags & TFF_EXCEPTION_SPECIFICATION) dump_exception_spec (TYPE_RAISES_EXCEPTIONS (fntype), flags); @@ -2116,7 +2073,8 @@ static const char * cv_to_string (tree p, int v) { pp_clear_output_area (cxx_pp); - dump_qualifiers (p, v ? before : none); + pp_base (cxx_pp)->padding = v ? pp_before : pp_none; + pp_cxx_cv_qualifier_seq (cxx_pp, p); return pp_formatted_text (cxx_pp); } |