From 8a47db4740eee9a50c2b301a79b1c7f7331fe296 Mon Sep 17 00:00:00 2001 From: sterling Date: Mon, 4 Jun 2012 17:52:42 +0000 Subject: [PATCH] 2012-06-04 Sterling Augustine * gcc/c-family/c-pretty-print.h (pp_c_flag_gnu_v3): New enumerator. * gcc/c-family/c-pretty-print.c (pp_c_specifier_qualifier_list): Check it at both the start and end of the function. * gcc/cp/error.c (dump_decl): Check pp_c_flag_gnu_v3. (decl_as_dwarf_string, lang_decl_dwarf_name): New functions. (lang_decl_name): Handle namespace decls. * gcc/cp/cp-tree.h: Declare decl_as_dwarf_string, lang_decl_dwarf_name. * gcc/cp/cp-lang.c: Call them. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@188195 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 11 +++++++++++ gcc/c-family/c-pretty-print.c | 4 +++- gcc/c-family/c-pretty-print.h | 3 ++- gcc/cp/cp-lang.c | 8 ++++---- gcc/cp/cp-tree.h | 2 ++ gcc/cp/error.c | 40 +++++++++++++++++++++++++++++++++++++++- 6 files changed, 61 insertions(+), 7 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 174c1c1..159092a 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,14 @@ +2012-06-04 Sterling Augustine + + * gcc/c-family/c-pretty-print.h (pp_c_flag_gnu_v3): New enumerator. + * gcc/c-family/c-pretty-print.c (pp_c_specifier_qualifier_list): Check + it at both the start and end of the function. + * gcc/cp/error.c (dump_decl): Check pp_c_flag_gnu_v3. + (decl_as_dwarf_string, lang_decl_dwarf_name): New functions. + (lang_decl_name): Handle namespace decls. + * gcc/cp/cp-tree.h: Declare decl_as_dwarf_string, lang_decl_dwarf_name. + * gcc/cp/cp-lang.c: Call them. + 2012-06-04 Aldy Hernandez PR middle-end/47530 diff --git a/gcc/c-family/c-pretty-print.c b/gcc/c-family/c-pretty-print.c index 929ad18..d445187 100644 --- a/gcc/c-family/c-pretty-print.c +++ b/gcc/c-family/c-pretty-print.c @@ -446,7 +446,7 @@ pp_c_specifier_qualifier_list (c_pretty_printer *pp, tree t) { const enum tree_code code = TREE_CODE (t); - if (TREE_CODE (t) != POINTER_TYPE) + if (!(pp->flags & pp_c_flag_gnu_v3) && code != POINTER_TYPE) pp_c_type_qualifier_list (pp, t); switch (code) { @@ -494,6 +494,8 @@ pp_c_specifier_qualifier_list (c_pretty_printer *pp, tree t) pp_simple_type_specifier (pp, t); break; } + if ((pp->flags & pp_c_flag_gnu_v3) && code != POINTER_TYPE) + pp_c_type_qualifier_list (pp, t); } /* parameter-type-list: diff --git a/gcc/c-family/c-pretty-print.h b/gcc/c-family/c-pretty-print.h index 8d399dd..2f9f94a 100644 --- a/gcc/c-family/c-pretty-print.h +++ b/gcc/c-family/c-pretty-print.h @@ -30,7 +30,8 @@ along with GCC; see the file COPYING3. If not see typedef enum { pp_c_flag_abstract = 1 << 1, - pp_c_flag_last_bit = 2 + pp_c_flag_gnu_v3 = 1 << 2, + pp_c_flag_last_bit = 3 } pp_c_pretty_print_flags; diff --git a/gcc/cp/cp-lang.c b/gcc/cp/cp-lang.c index 7b1f450..da7f1e1 100644 --- a/gcc/cp/cp-lang.c +++ b/gcc/cp/cp-lang.c @@ -118,11 +118,11 @@ cxx_dwarf_name (tree t, int verbosity) && (ANON_AGGRNAME_P (DECL_NAME (t)) || LAMBDANAME_P (DECL_NAME (t)))) return NULL; if (verbosity >= 2) - return decl_as_string (t, - TFF_DECL_SPECIFIERS | TFF_UNQUALIFIED_NAME - | TFF_NO_OMIT_DEFAULT_TEMPLATE_ARGUMENTS); + return decl_as_dwarf_string (t, + TFF_DECL_SPECIFIERS | TFF_UNQUALIFIED_NAME + | TFF_NO_OMIT_DEFAULT_TEMPLATE_ARGUMENTS); - return cxx_printable_name (t, verbosity); + return lang_decl_dwarf_name (t, verbosity, false); } static enum classify_record diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index d21c2bf..7c901be 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -5169,8 +5169,10 @@ extern const char *type_as_string (tree, int); extern const char *type_as_string_translate (tree, int); extern const char *decl_as_string (tree, int); extern const char *decl_as_string_translate (tree, int); +extern const char *decl_as_dwarf_string (tree, int); extern const char *expr_as_string (tree, int); extern const char *lang_decl_name (tree, int, bool); +extern const char *lang_decl_dwarf_name (tree, int, bool); extern const char *language_to_string (enum languages); extern const char *class_key_or_enum_as_string (tree); extern void print_instantiation_context (void); diff --git a/gcc/cp/error.c b/gcc/cp/error.c index 6595063..67ff513 100644 --- a/gcc/cp/error.c +++ b/gcc/cp/error.c @@ -1028,7 +1028,12 @@ dump_decl (tree t, int flags) dump_scope (CP_DECL_CONTEXT (t), flags); flags &= ~TFF_UNQUALIFIED_NAME; if (DECL_NAME (t) == NULL_TREE) - pp_cxx_ws_string (cxx_pp, M_("{anonymous}")); + { + if (!(pp_c_base (cxx_pp)->flags & pp_c_flag_gnu_v3)) + pp_cxx_ws_string (cxx_pp, M_("{anonymous}")); + else + pp_cxx_ws_string (cxx_pp, M_("(anonymous namespace)")); + } else pp_cxx_tree_identifier (cxx_pp, DECL_NAME (t)); } @@ -2556,6 +2561,21 @@ expr_as_string (tree decl, int flags) return pp_formatted_text (cxx_pp); } +/* Wrap decl_as_string with options appropriate for dwarf. */ + +const char * +decl_as_dwarf_string (tree decl, int flags) +{ + const char *name; + /* Curiously, reinit_cxx_pp doesn't reset the flags field, so setting the flag + here will be adequate to get the desired behaviour. */ + pp_c_base (cxx_pp)->flags |= pp_c_flag_gnu_v3; + name = decl_as_string (decl, flags); + /* Subsequent calls to the pretty printer shouldn't use this style. */ + pp_c_base (cxx_pp)->flags &= ~pp_c_flag_gnu_v3; + return name; +} + const char * decl_as_string (tree decl, int flags) { @@ -2573,6 +2593,21 @@ decl_as_string_translate (tree decl, int flags) return pp_formatted_text (cxx_pp); } +/* Wrap lang_decl_name with options appropriate for dwarf. */ + +const char * +lang_decl_dwarf_name (tree decl, int v, bool translate) +{ + const char *name; + /* Curiously, reinit_cxx_pp doesn't reset the flags field, so setting the flag + here will be adequate to get the desired behaviour. */ + pp_c_base (cxx_pp)->flags |= pp_c_flag_gnu_v3; + name = lang_decl_name (decl, v, translate); + /* Subsequent calls to the pretty printer shouldn't use this style. */ + pp_c_base (cxx_pp)->flags &= ~pp_c_flag_gnu_v3; + return name; +} + /* Generate the three forms of printable names for cxx_printable_name. */ const char * @@ -2596,6 +2631,9 @@ lang_decl_name (tree decl, int v, bool translate) if (TREE_CODE (decl) == FUNCTION_DECL) dump_function_name (decl, TFF_PLAIN_IDENTIFIER); + else if ((DECL_NAME (decl) == NULL_TREE) + && TREE_CODE (decl) == NAMESPACE_DECL) + dump_decl (decl, TFF_PLAIN_IDENTIFIER); else dump_decl (DECL_NAME (decl), TFF_PLAIN_IDENTIFIER); -- 2.7.4