(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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@71175
138bc75d-0d04-0410-961f-
82ee72b054a4
+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.
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); \
}
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);
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):
#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))
}
}
+/* 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
{
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;
default:
break;
}
- else if (DECL_TEMPLATE_INFO (t))
- pp_cxx_template_declaration (pp, t);
else switch (TREE_CODE (t))
{
case VAR_DECL:
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;
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
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
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:
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;