diff options
author | Jason Merrill <jason@gcc.gnu.org> | 1998-05-24 18:37:10 -0400 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 1998-05-24 18:37:10 -0400 |
commit | 6b57ac2977821017212b879c4d0a80ed0f646ce5 (patch) | |
tree | 25d733423b5b8852475581fdaff777239157f6f2 | |
parent | 51c4eb9bbfd126580e88d86b8d740d2c0c011558 (diff) | |
download | gcc-6b57ac2977821017212b879c4d0a80ed0f646ce5.zip gcc-6b57ac2977821017212b879c4d0a80ed0f646ce5.tar.gz gcc-6b57ac2977821017212b879c4d0a80ed0f646ce5.tar.bz2 |
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
-rw-r--r-- | gcc/cp/ChangeLog | 11 | ||||
-rw-r--r-- | gcc/cp/decl.c | 2 | ||||
-rw-r--r-- | gcc/cp/error.c | 1 | ||||
-rw-r--r-- | gcc/cp/typeck.c | 6 | ||||
-rw-r--r-- | gcc/cp/typeck2.c | 2 |
5 files changed, 21 insertions, 1 deletions
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 <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. 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: |