Commit a2a9e21c by Gabriel Dos Reis Committed by Gabriel Dos Reis

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
parent 1ab237df
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.
......
......@@ -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);
......
......@@ -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 *);
......
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):
......
......@@ -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;
......
......@@ -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
......
......@@ -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:
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment