diff options
author | Manuel López-Ibáñez <manu@gcc.gnu.org> | 2010-06-04 15:15:38 +0000 |
---|---|---|
committer | Manuel López-Ibáñez <manu@gcc.gnu.org> | 2010-06-04 15:15:38 +0000 |
commit | 49706e39a2b65519ef173e55637c41c899e0b968 (patch) | |
tree | 2537a481171fe231924d117a943f8cd28aebff61 /gcc/c-pretty-print.c | |
parent | b13ea8bd6dc138446ad640d934fc22498d915e82 (diff) | |
download | gcc-49706e39a2b65519ef173e55637c41c899e0b968.zip gcc-49706e39a2b65519ef173e55637c41c899e0b968.tar.gz gcc-49706e39a2b65519ef173e55637c41c899e0b968.tar.bz2 |
re PR c/25880 (improve message of warning for discarding qualifiers)
2010-06-04 Manuel López-Ibáñez <manu@gcc.gnu.org>
PR c/25880
* c-objc-common.c (c_tree_printer): Handle %V, %v and %#v.
* c-format.c (gcc_diag_flag_specs): Add hash.
(gcc_cxxdiag_flag_specs): Use gcc_diag_flag_specs directly.
(gcc_tdiag_char_table,gcc_cdiag_char_table): Handle %V and %v.
* c-pretty-print.c (pp_c_cv_qualifier): Rename as
pp_c_cv_qualifiers. Handle qualifiers spelling here.
(pp_c_type_qualifier_list): Call the function above.
* c-pretty-print.h (pp_c_cv_qualifiers): Declare.
* c-typeck.c (handle_warn_cast_qual): Print qualifiers.
(WARN_FOR_QUALIFIERS): New macro.
(convert_for_assignment): Use it.
testsuite/
* gcc.dg/assign-warn-2.c: Update.
* gcc.dg/cpp/line3.c: Update.
* gcc.dg/c99-array-lval-8.c: Update.
* gcc.dg/cast-qual-2.c: Update.
* gcc.dg/c99-arraydecl-3.c: Update.
* gcc.dg/assign-warn-1.c: Update.
* gcc.dg/format/gcc_diag-1.c: Update.
From-SVN: r160274
Diffstat (limited to 'gcc/c-pretty-print.c')
-rw-r--r-- | gcc/c-pretty-print.c | 41 |
1 files changed, 31 insertions, 10 deletions
diff --git a/gcc/c-pretty-print.c b/gcc/c-pretty-print.c index ca0608c..7f4b238 100644 --- a/gcc/c-pretty-print.c +++ b/gcc/c-pretty-print.c @@ -170,18 +170,43 @@ pp_c_exclamation (c_pretty_printer *pp) pp_base (pp)->padding = pp_none; } -/* Print out the external representation of CV-QUALIFIER. */ +/* Print out the external representation of QUALIFIERS. */ -static void -pp_c_cv_qualifier (c_pretty_printer *pp, const char *cv) +void +pp_c_cv_qualifiers (c_pretty_printer *pp, int qualifiers, bool func_type) { const char *p = pp_last_position_in_text (pp); + bool previous = false; + + if (!qualifiers) + return; + /* The C programming language does not have references, but it is much simpler to handle those here rather than going through the same logic in the C++ pretty-printer. */ if (p != NULL && (*p == '*' || *p == '&')) pp_c_whitespace (pp); - pp_c_ws_string (pp, cv); + + if (qualifiers & TYPE_QUAL_CONST) + { + pp_c_ws_string (pp, func_type ? "__attribute__((const))" : "const"); + previous = true; + } + + if (qualifiers & TYPE_QUAL_VOLATILE) + { + if (previous) + pp_c_whitespace (pp); + pp_c_ws_string (pp, func_type ? "__attribute__((noreturn))" : "volatile"); + previous = true; + } + + if (qualifiers & TYPE_QUAL_RESTRICT) + { + if (previous) + pp_c_whitespace (pp); + pp_c_ws_string (pp, flag_isoc99 ? "restrict" : "__restrict__"); + } } /* Pretty-print T using the type-cast notation '( type-name )'. */ @@ -242,12 +267,8 @@ pp_c_type_qualifier_list (c_pretty_printer *pp, tree t) t = TREE_TYPE (t); qualifiers = TYPE_QUALS (t); - if (qualifiers & TYPE_QUAL_CONST) - pp_c_cv_qualifier (pp, "const"); - if (qualifiers & TYPE_QUAL_VOLATILE) - pp_c_cv_qualifier (pp, "volatile"); - if (qualifiers & TYPE_QUAL_RESTRICT) - pp_c_cv_qualifier (pp, flag_isoc99 ? "restrict" : "__restrict__"); + pp_c_cv_qualifiers (pp, qualifiers, + TREE_CODE (t) == FUNCTION_TYPE); if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (t))) { |