diff options
author | Gabriel Dos Reis <gdr@integrable-solutions.net> | 2003-09-07 18:52:53 +0000 |
---|---|---|
committer | Gabriel Dos Reis <gdr@gcc.gnu.org> | 2003-09-07 18:52:53 +0000 |
commit | a2a9e21c333495766fc733fedbf1821b9b333840 (patch) | |
tree | a053051804681d6afd59965f85bf34dfc364a70f /gcc | |
parent | 1ab237dfa3b2afa84b952ac457eb01df96638757 (diff) | |
download | gcc-a2a9e21c333495766fc733fedbf1821b9b333840.zip gcc-a2a9e21c333495766fc733fedbf1821b9b333840.tar.gz gcc-a2a9e21c333495766fc733fedbf1821b9b333840.tar.bz2 |
re PR c++/11762 (namespace aliasing ICE in warn_extern_redeclared_static)
* c-pretty-print.h (pp_c_left_brace): Declare.
(pp_c_right_brace): Likewise.
* c-pretty-print.c (pp_c_left_brace): Now a function
(pp_c_right_brace): Likewise.
cp/
PR c++/11762
* error.c (dump_decl): Handle namespace-alias-definition.
* decl.c (warn_extern_redeclared_static): There is no point in
checking changes in storage class specifier for a namespace
declaration.
(duplicate_decls): Tidy diagnostic message.
* cxx-pretty-print.c (pp_cxx_left_brace): New macro.
(pp_cxx_right_brace): Likewise.
(pp_cxx_original_namespace_definition): New function.
(pp_cxx_namespace_alias_definition): Likewise.
(pp_cxx_declaration): Use them. Handle NAMESPACE_DECLs.
From-SVN: r71175
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/c-pretty-print.c | 26 | ||||
-rw-r--r-- | gcc/c-pretty-print.h | 2 | ||||
-rw-r--r-- | gcc/cp/ChangeLog | 14 | ||||
-rw-r--r-- | gcc/cp/cxx-pretty-print.c | 56 | ||||
-rw-r--r-- | gcc/cp/decl.c | 9 | ||||
-rw-r--r-- | gcc/cp/error.c | 13 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/lookup/struct1.C | 4 |
8 files changed, 107 insertions, 24 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 9796923..d907564 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2003-09-07 Gabriel Dos Reis <gcc@integrable-solutions.net> + + * c-pretty-print.h (pp_c_left_brace): Declare. + (pp_c_right_brace): Likewise. + * c-pretty-print.c (pp_c_left_brace): Now a function + (pp_c_right_brace): Likewise. + Sun Sep 7 14:50:03 CEST 2003 Jan Hubicka <jh@suse.cz> * cfgcleanup.c (try_simplify_condjump): Fix again the preivous patch. diff --git a/gcc/c-pretty-print.c b/gcc/c-pretty-print.c index 922d987..0fd5bb1 100644 --- a/gcc/c-pretty-print.c +++ b/gcc/c-pretty-print.c @@ -41,18 +41,6 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA pp_c_whitespace (PP); \ } while (0) -#define pp_c_left_brace(PP) \ - do { \ - pp_left_brace (PP); \ - pp_base (PP)->padding = pp_none; \ - } while (0) - -#define pp_c_right_brace(PP) \ - do { \ - pp_right_brace (PP); \ - pp_base (PP)->padding = pp_none; \ - } while (0) - #define pp_c_left_bracket(PP) \ do { \ pp_left_bracket (PP); \ @@ -116,6 +104,20 @@ pp_c_right_paren (c_pretty_printer *pp) } void +pp_c_left_brace (c_pretty_printer *pp) +{ + pp_left_brace (pp); + pp_base (pp)->padding = pp_none; +} + +void +pp_c_right_brace (c_pretty_printer *pp) +{ + pp_right_brace (pp); + pp_base (pp)->padding = pp_none; +} + +void pp_c_dot (c_pretty_printer *pp) { pp_dot (pp); diff --git a/gcc/c-pretty-print.h b/gcc/c-pretty-print.h index 66ca33c..2bc1dbc 100644 --- a/gcc/c-pretty-print.h +++ b/gcc/c-pretty-print.h @@ -157,6 +157,8 @@ extern void pp_c_pretty_printer_init (c_pretty_printer *); void pp_c_whitespace (c_pretty_printer *); void pp_c_left_paren (c_pretty_printer *); void pp_c_right_paren (c_pretty_printer *); +void pp_c_left_brace (c_pretty_printer *); +void pp_c_right_brace (c_pretty_printer *); void pp_c_dot (c_pretty_printer *); void pp_c_ampersand (c_pretty_printer *); void pp_c_arrow (c_pretty_printer *); diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index dccc526..5dbfab4 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,17 @@ +2003-09-07 Gabriel Dos Reis <gcc@integrable-solutions.net> + + PR c++/11762 + * error.c (dump_decl): Handle namespace-alias-definition. + * decl.c (warn_extern_redeclared_static): There is no point in + checking changes in storage class specifier for a namespace + declaration. + (duplicate_decls): Tidy diagnostic message. + * cxx-pretty-print.c (pp_cxx_left_brace): New macro. + (pp_cxx_right_brace): Likewise. + (pp_cxx_original_namespace_definition): New function. + (pp_cxx_namespace_alias_definition): Likewise. + (pp_cxx_declaration): Use them. Handle NAMESPACE_DECLs. + Sun Sep 7 13:15:14 CEST 2003 Jan Hubicka <jh@suse.cz> * decl2.c (maybe_emit_vtables, write_out_vars, finish_file): diff --git a/gcc/cp/cxx-pretty-print.c b/gcc/cp/cxx-pretty-print.c index 2efe0bc..975ace6 100644 --- a/gcc/cp/cxx-pretty-print.c +++ b/gcc/cp/cxx-pretty-print.c @@ -45,6 +45,8 @@ static void pp_cxx_template_parameter (cxx_pretty_printer *, tree); #define pp_cxx_whitespace(PP) pp_c_whitespace (pp_c_base (PP)) #define pp_cxx_left_paren(PP) pp_c_left_paren (pp_c_base (PP)) #define pp_cxx_right_paren(PP) pp_c_right_paren (pp_c_base (PP)) +#define pp_cxx_left_brace(PP) pp_c_left_brace (pp_c_base (PP)) +#define pp_cxx_right_brace(PP) pp_c_right_brace (pp_c_base (PP)) #define pp_cxx_dot(PP) pp_c_dot (pp_c_base (PP)) #define pp_cxx_arrow(PP) pp_c_arrow (pp_c_base (PP)) #define pp_cxx_semicolon(PP) pp_c_semicolon (pp_c_base (PP)) @@ -1471,6 +1473,45 @@ pp_cxx_statement (cxx_pretty_printer *pp, tree t) } } +/* original-namespace-definition: + namespace identifier { namespace-body } + + As an edge case, we also handle unnamed namespace definition here. */ + +static void +pp_cxx_original_namespace_definition (cxx_pretty_printer *pp, tree t) +{ + pp_cxx_identifier (pp, "namespace"); + if (DECL_NAME (t) != anonymous_namespace_name) + pp_cxx_unqualified_id (pp, t); + pp_cxx_whitespace (pp); + pp_cxx_left_brace (pp); + /* We do not print the namespace-body. */ + pp_cxx_whitespace (pp); + pp_cxx_right_brace (pp); +} + +/* namespace-alias: + identifier + + namespace-alias-definition: + namespace identifier = qualified-namespace-specifier ; + + qualified-namespace-specifier: + ::(opt) nested-name-specifier(opt) namespace-name */ + +static void +pp_cxx_namespace_alias_definition (cxx_pretty_printer *pp, tree t) +{ + pp_cxx_identifier (pp, "namespace"); + pp_cxx_unqualified_id (pp, t); + pp_cxx_whitespace (pp); + pp_equal (pp); + pp_cxx_whitespace (pp); + pp_cxx_qualified_id (pp, DECL_NAMESPACE_ALIAS (t)); + pp_cxx_semicolon (pp); +} + /* simple-declaration: decl-specifier-seq(opt) init-declarator-list(opt) */ static void @@ -1618,9 +1659,13 @@ pp_cxx_declaration (cxx_pretty_printer *pp, tree t) { if (!DECL_LANG_SPECIFIC (t)) pp_cxx_simple_declaration (pp, t); - else if (DECL_USE_TEMPLATE (t) > 1) + else if (DECL_USE_TEMPLATE (t)) switch (DECL_USE_TEMPLATE (t)) { + case 1: + pp_cxx_template_declaration (pp, t); + break; + case 2: pp_cxx_explicit_specialization (pp, t); break; @@ -1632,8 +1677,6 @@ pp_cxx_declaration (cxx_pretty_printer *pp, tree t) default: break; } - else if (DECL_TEMPLATE_INFO (t)) - pp_cxx_template_declaration (pp, t); else switch (TREE_CODE (t)) { case VAR_DECL: @@ -1648,6 +1691,13 @@ pp_cxx_declaration (cxx_pretty_printer *pp, tree t) pp_cxx_simple_declaration (pp, t); break; + case NAMESPACE_DECL: + if (DECL_NAMESPACE_ALIAS (t)) + pp_cxx_namespace_alias_definition (pp, t); + else + pp_cxx_original_namespace_definition (pp, t); + break; + default: pp_unsupported_tree (pp, t); break; diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 7e87cac..ca13790 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -2736,7 +2736,8 @@ warn_extern_redeclared_static (tree newdecl, tree olddecl) if (TREE_CODE (newdecl) == TYPE_DECL || TREE_CODE (newdecl) == TEMPLATE_DECL - || TREE_CODE (newdecl) == CONST_DECL) + || TREE_CODE (newdecl) == CONST_DECL + || TREE_CODE (newdecl) == NAMESPACE_DECL) return; /* Don't get confused by static member functions; that's a different @@ -3004,8 +3005,10 @@ duplicate_decls (tree newdecl, tree olddecl) else if (current_class_type == NULL_TREE || IDENTIFIER_ERROR_LOCUS (DECL_ASSEMBLER_NAME (newdecl)) != current_class_type) { - error ("conflicting types for `%#D'", newdecl); - cp_error_at ("previous declaration as `%#D'", olddecl); + error ("conflicting declaration '%#D'", newdecl); + cp_error_at ("'%D' has a previous declaration as `%#D'", + olddecl, olddecl); + return false; } } else if (TREE_CODE (newdecl) == FUNCTION_DECL diff --git a/gcc/cp/error.c b/gcc/cp/error.c index d8d70e7..5c94d75 100644 --- a/gcc/cp/error.c +++ b/gcc/cp/error.c @@ -831,11 +831,16 @@ dump_decl (tree t, int flags) break; case NAMESPACE_DECL: - dump_scope (CP_DECL_CONTEXT (t), flags); - if (DECL_NAME (t) == anonymous_namespace_name) - pp_identifier (cxx_pp, "<unnamed>"); + if (flags & TFF_DECL_SPECIFIERS) + pp_cxx_declaration (cxx_pp, t); else - pp_tree_identifier (cxx_pp, DECL_NAME (t)); + { + dump_scope (CP_DECL_CONTEXT (t), flags); + if (DECL_NAME (t) == anonymous_namespace_name) + pp_identifier (cxx_pp, "<unnamed>"); + else + pp_tree_identifier (cxx_pp, DECL_NAME (t)); + } break; case SCOPE_REF: diff --git a/gcc/testsuite/g++.dg/lookup/struct1.C b/gcc/testsuite/g++.dg/lookup/struct1.C index c8bc056..dd8d54b 100644 --- a/gcc/testsuite/g++.dg/lookup/struct1.C +++ b/gcc/testsuite/g++.dg/lookup/struct1.C @@ -3,10 +3,10 @@ struct A; typedef struct A B; // { dg-error "previous declaration" } -struct B; // { dg-error "conflicting types" } +struct B; // { dg-error "conflicting declaration" } typedef struct { int i; } C; // { dg-error "previous declaration" } -struct C; // { dg-error "conflicting types" } +struct C; // { dg-error "conflicting declaration" } struct D; typedef struct D D; |