OSDN Git Service

* c-pretty-print.h (pp_c_left_brace): Declare.
authorgdr <gdr@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 7 Sep 2003 18:52:53 +0000 (18:52 +0000)
committergdr <gdr@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 7 Sep 2003 18:52:53 +0000 (18:52 +0000)
(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

gcc/ChangeLog
gcc/c-pretty-print.c
gcc/c-pretty-print.h
gcc/cp/ChangeLog
gcc/cp/cxx-pretty-print.c
gcc/cp/decl.c
gcc/cp/error.c
gcc/testsuite/g++.dg/lookup/struct1.C

index 9796923..d907564 100644 (file)
@@ -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.
index 922d987..0fd5bb1 100644 (file)
@@ -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);
index 66ca33c..2bc1dbc 100644 (file)
@@ -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 *);
index dccc526..5dbfab4 100644 (file)
@@ -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):
index 2efe0bc..975ace6 100644 (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;
index 7e87cac..ca13790 100644 (file)
@@ -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
index d8d70e7..5c94d75 100644 (file)
@@ -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:
index c8bc056..dd8d54b 100644 (file)
@@ -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;