This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: internal compiler bug when "calling" namespaces as a function
- To: njs3 at doc dot ic dot ac dot uk
- Subject: Re: internal compiler bug when "calling" namespaces as a function
- From: Martin von Loewis <martin at mira dot isdn dot cs dot tu-berlin dot de>
- Date: Sun, 24 May 1998 13:08:12 +0200
- CC: egcs-bugs at cygnus dot com, jason at cygnus dot com
- References: <E0ydHrR-0003Mk-00@oak66.doc.ic.ac.uk>
Thanks for your report. I've fixed this and some other illegal uses of
namespaces.
Martin
1998-05-24 Martin von Löwis <loewis@informatik.hu-berlin.de>
* error.c (dump_expr): Support namespaces.
* decl.c (push_namespace): Set type of namespace to unknown.
(init_decl_processing): Likewise.
* typeck.c (convert_arguments): Check for namespace parameters.
Index: decl.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/decl.c,v
retrieving revision 1.117
diff -c -p -r1.117 decl.c
*** decl.c 1998/05/22 23:13:27 1.117
--- decl.c 1998/05/24 07:04:40
*************** push_namespace (name)
*** 1816,1822 ****
if (need_new)
{
/* Make a new namespace, binding the name to it. */
! d = build_lang_decl (NAMESPACE_DECL, name, NULL_TREE);
/* The global namespace is not pushed, and the global binding
level is set elsewhere. */
if (!global)
--- 1820,1826 ----
if (need_new)
{
/* Make a new namespace, binding the name to it. */
! d = build_lang_decl (NAMESPACE_DECL, name, unknown_type_node);
/* The global namespace is not pushed, and the global binding
level is set elsewhere. */
if (!global)
*************** init_decl_processing ()
*** 5851,5857 ****
std_node = build_decl (NAMESPACE_DECL,
get_identifier (flag_honor_std ? "fake std":"std"),
! void_type_node);
pushdecl (std_node);
global_type_node = make_node (LANG_TYPE);
--- 5890,5896 ----
std_node = build_decl (NAMESPACE_DECL,
get_identifier (flag_honor_std ? "fake std":"std"),
! unknown_type_node);
pushdecl (std_node);
global_type_node = make_node (LANG_TYPE);
Index: error.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/error.c,v
retrieving revision 1.42
diff -c -p -r1.42 error.c
*** error.c 1998/05/20 23:53:04 1.42
--- error.c 1998/05/24 07:04:42
*************** dump_expr (t, nop)
*** 1191,1196 ****
--- 1191,1197 ----
case CONST_DECL:
case FUNCTION_DECL:
case TEMPLATE_DECL:
+ case NAMESPACE_DECL:
dump_decl (t, -1);
break;
Index: typeck.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/typeck.c,v
retrieving revision 1.72
diff -c -p -r1.72 typeck.c
*** typeck.c 1998/05/22 03:32:43 1.72
--- typeck.c 1998/05/24 11:01:45
*************** convert_arguments (return_loc, typelist,
*** 2921,2926 ****
--- 2921,2932 ----
if (val == error_mark_node)
return error_mark_node;
+ if (TREE_CODE (val) == NAMESPACE_DECL)
+ {
+ cp_error ("cannot pass `%D' as a function argument", val);
+ return error_mark_node;
+ }
+
if (type == void_type_node)
{
if (fndecl)
//Build don't link:
namespace x { };
void f(int);
int main()
{
x(); // ERROR - calling a namespace
x=4; // ERROR - assigning to a namespace
f(x); // ERROR - passing a namespace as parameter
}