decl.c (push_namespace): Namespaces have type void.
authorJason Merrill <jason@gcc.gnu.org>
Sun, 24 May 1998 22:37:10 +0000 (18:37 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Sun, 24 May 1998 22:37:10 +0000 (18:37 -0400)
* decl.c (push_namespace): Namespaces have type void.
* typeck2.c (incomplete_type_error): Complain about namespace
used as expression.
* typeck.c (decay_conversion): Likewise.
* error.c (dump_expr): Support namespaces.

From-SVN: r20035

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/cp/error.c
gcc/cp/typeck.c
gcc/cp/typeck2.c

index 341db45..917a302 100644 (file)
@@ -1,3 +1,14 @@
+1998-05-24  Jason Merrill  <jason@yorick.cygnus.com>
+
+       * decl.c (push_namespace): Namespaces have type void.
+       * typeck2.c (incomplete_type_error): Complain about namespace
+       used as expression.
+       * typeck.c (decay_conversion): Likewise.
+
+1998-05-24  Martin von Löwis  <loewis@informatik.hu-berlin.de>
+
+       * error.c (dump_expr): Support namespaces.
+
 1998-05-23  Jason Merrill  <jason@yorick.cygnus.com>
 
        * cp-tree.def: Add SRCLOC.
index aa1a419..1fb7938 100644 (file)
@@ -1816,7 +1816,7 @@ push_namespace (name)
   if (need_new)
     {
       /* Make a new namespace, binding the name to it. */
-      d = build_lang_decl (NAMESPACE_DECL, name, NULL_TREE);
+      d = build_lang_decl (NAMESPACE_DECL, name, void_type_node);
       /* The global namespace is not pushed, and the global binding
         level is set elsewhere.  */
       if (!global)
index c754819..4eb7da0 100644 (file)
@@ -1191,6 +1191,7 @@ dump_expr (t, nop)
     case CONST_DECL:
     case FUNCTION_DECL:
     case TEMPLATE_DECL:
+    case NAMESPACE_DECL:
       dump_decl (t, -1);
       break;
 
index 4dffd73..135bbd1 100644 (file)
@@ -1597,6 +1597,12 @@ decay_conversion (exp)
       type = TREE_TYPE (exp);
     }
 
+  if (TREE_CODE (exp) == NAMESPACE_DECL)
+    {
+      cp_error ("namespace `%D' used as expression", exp);
+      return error_mark_node;
+    }
+
   /* build_c_cast puts on a NOP_EXPR to make the result not an lvalue.
      Leave such NOP_EXPRs, since RHS is being used in non-lvalue context.  */
 
index 781d0d9..e53f2ac 100644 (file)
@@ -274,6 +274,8 @@ incomplete_type_error (value, type)
   if (value != 0 && (TREE_CODE (value) == VAR_DECL
                     || TREE_CODE (value) == PARM_DECL))
     cp_error ("`%D' has incomplete type", value);
+  else if (value && TREE_CODE (value) == NAMESPACE_DECL)
+    cp_error ("namespace `%D' used as expression", value);
   else
     {
     retry: