This is the mail archive of the gcc-patches@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]

C++ PATCHes: Minor nits



This patch fixes two small bugs:

  - Return types should not be included in the manglings for
    conversion operators under the new ABI.

  - `main' is not supposed to return a type other than `int'.
    For example:

      double main () {}

    is not valid C++.

--
Mark Mitchell                   mark@codesourcery.com
CodeSourcery, LLC               http://www.codesourcery.com

2000-08-25  Mark Mitchell  <mark@codesourcery.com>

	* decl.c (grokfndecl): Require that `main' return an `int'.
	* mangle.c (write_encoding): Don't mangle return types for
	conversion functions.

Index: testsuite/g++.old-deja/g++.other/main2.C
===================================================================
RCS file: main2.C
diff -N main2.C
*** /dev/null	Tue May  5 13:32:27 1998
--- main2.C	Fri Aug 25 00:26:27 2000
***************
*** 0 ****
--- 1,4 ----
+ // Build don't link:
+ // Origin: Mark Mitchell <mark@codesourcery.com>
+ 
+ double main () {} // ERROR - main must return `int'
Index: cp/decl.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/decl.c,v
retrieving revision 1.674
diff -c -p -r1.674 decl.c
*** decl.c	2000/08/23 06:36:15	1.674
--- decl.c	2000/08/25 07:26:38
*************** grokfndecl (ctype, type, declarator, ori
*** 8819,8826 ****
  	error ("cannot declare `::main' to be a template");
        if (inlinep)
  	error ("cannot declare `::main' to be inline");
!       else if (! publicp)
  	error ("cannot declare `::main' to be static");
        inlinep = 0;
        publicp = 1;
      }
--- 8819,8829 ----
  	error ("cannot declare `::main' to be a template");
        if (inlinep)
  	error ("cannot declare `::main' to be inline");
!       if (!publicp)
  	error ("cannot declare `::main' to be static");
+       if (!same_type_p (TREE_TYPE (TREE_TYPE (decl)),
+ 			integer_type_node))
+ 	error ("`main' must return `int'");
        inlinep = 0;
        publicp = 1;
      }
Index: cp/mangle.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/mangle.c,v
retrieving revision 1.14
diff -c -p -r1.14 mangle.c
*** mangle.c	2000/08/23 17:12:23	1.14
--- mangle.c	2000/08/25 07:26:39
*************** write_encoding (decl)
*** 643,648 ****
--- 643,649 ----
        write_bare_function_type (fn_type, 
  				(!DECL_CONSTRUCTOR_P (decl)
  				 && !DECL_DESTRUCTOR_P (decl)
+ 				 && !DECL_CONV_FN_P (decl)
  				 && decl_is_template_id (decl, NULL)));
      }
  }

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