From 6b57ac2977821017212b879c4d0a80ed0f646ce5 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Sun, 24 May 1998 18:37:10 -0400 Subject: [PATCH] decl.c (push_namespace): Namespaces have type void. * 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 | 11 +++++++++++ gcc/cp/decl.c | 2 +- gcc/cp/error.c | 1 + gcc/cp/typeck.c | 6 ++++++ gcc/cp/typeck2.c | 2 ++ 5 files changed, 21 insertions(+), 1 deletion(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 341db45..917a302 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,14 @@ +1998-05-24 Jason Merrill + + * 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 + + * error.c (dump_expr): Support namespaces. + 1998-05-23 Jason Merrill * cp-tree.def: Add SRCLOC. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index aa1a419..1fb7938 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -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) diff --git a/gcc/cp/error.c b/gcc/cp/error.c index c754819..4eb7da0 100644 --- a/gcc/cp/error.c +++ b/gcc/cp/error.c @@ -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; diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 4dffd73..135bbd1 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -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. */ diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c index 781d0d9..e53f2ac 100644 --- a/gcc/cp/typeck2.c +++ b/gcc/cp/typeck2.c @@ -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: -- 2.7.4