This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: internal compiler bug when "calling" namespaces as a function


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
}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]