CVS-19981219: New PATCH for actually fixing the "main(){}" case

Jason Merrill jason@cygnus.com
Sat Jan 16 16:48:00 GMT 1999


I checked in this simpler solution:

Index: decl.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/decl.c,v
retrieving revision 1.294
diff -c -p -r1.294 decl.c
*** decl.c	1999/01/16 16:31:09	1.294
--- decl.c	1999/01/17 00:43:09
*************** grokdeclarator (declarator, declspecs, d
*** 9356,9371 ****
  	}
        else
  	{
! 	  if (! pedantic && ! warn_return_type
! 	      && funcdef_flag
! 	      && MAIN_NAME_P (dname)
! 	      && ctype == NULL_TREE
! 	      && in_namespace == NULL_TREE
! 	      && current_namespace == global_namespace)
! 	    /* Let `main () { }' slide, since it's so common.  */;
! 	  else
  	    cp_pedwarn ("ANSI C++ forbids declaration `%D' with no type",
  			dname);
  	  type = integer_type_node;
  	}
      }
--- 9356,9377 ----
  	}
        else
  	{
! 	  /* We handle `main' specially here, because 'main () { }' is so
! 	     common.  With no options, it is allowed.  With -Wreturn-type,
! 	     it is a warning.  It is only an error with -pedantic-errors.  */
! 	  int is_main = (funcdef_flag
! 			 && MAIN_NAME_P (dname)
! 			 && ctype == NULL_TREE
! 			 && in_namespace == NULL_TREE
! 			 && current_namespace == global_namespace);
! 
! 	  if (pedantic || ! is_main)
  	    cp_pedwarn ("ANSI C++ forbids declaration `%D' with no type",
  			dname);
+ 	  else if (warn_return_type)
+ 	    cp_warning ("ANSI C++ forbids declaration `%D' with no type",
+ 			dname);
+ 
  	  type = integer_type_node;
  	}
      }



More information about the Gcc-patches mailing list