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 341db452630604b594b8c76b90836b2bc3a6e248..917a3028d65f52be0b17617f495c8e040302831f 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 aa1a419571dd710dbbc623a10cb85fffae2fedf2..1fb79382e6fe82ceff24d59a3c24e9082cf1ca12 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 c75481956374a56a7f9157ac465e3671f0eafc45..4eb7da0692bfa58ab50e3c35e0a6f5aaf9b5227b 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 4dffd73f435cb84ceb77b2d94c70a316c24fca53..135bbd1f61bfb33a040dba06f075bfbbd72721b7 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 781d0d9172558eea17508f7a46bb7f3a99118272..e53f2ac14ba3aa7c156835d35b9823417d18f156 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: