OSDN Git Service

2005-10-28 Andrew Pinski <pinskia@physics.uc.edu>
authorpinskia <pinskia@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 28 Oct 2005 20:25:55 +0000 (20:25 +0000)
committerpinskia <pinskia@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 28 Oct 2005 20:25:55 +0000 (20:25 +0000)
        PR C++/23229
        * decl.c (grokfndecl): Create a new function type
        after erroring out about main not returning int.
2005-10-28  Andrew Pinski  <pinskia@physics.uc.edu>

PR C++/23229
        * g++.dg/warn/main-2.C: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@105960 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/warn/main-2.C [new file with mode: 0644]

index fed864d..81da122 100644 (file)
@@ -1,3 +1,9 @@
+2005-10-28  Andrew Pinski  <pinskia@physics.uc.edu>
+
+       PR C++/23229
+       * decl.c (grokfndecl): Create a new function type
+       after erroring out about main not returning int.
+
 2005-10-28  Josh Conner  <jconner@apple.com>
 
        PR c++/22153
index ef61d17..07278ff 100644 (file)
@@ -5716,7 +5716,12 @@ grokfndecl (tree ctype,
       if (!same_type_p (TREE_TYPE (TREE_TYPE (decl)),
                        integer_type_node))
        {
+         tree oldtypeargs = TYPE_ARG_TYPES (TREE_TYPE (decl));
+         tree newtype;
          error ("%<::main%> must return %<int%>");
+         newtype =  build_function_type (integer_type_node,
+                                         oldtypeargs);
+         TREE_TYPE (decl) = newtype;
          TREE_TYPE (TREE_TYPE (decl)) = integer_type_node;
        }
       inlinep = 0;
index 35e9694..66577ef 100644 (file)
@@ -1,3 +1,8 @@
+2005-10-28  Andrew Pinski  <pinskia@physics.uc.edu>
+
+       PR C++/23229
+       * g++.dg/warn/main-2.C: New test.
+
 2005-10-28  Steven G. Kargl  <kargls@comcast.net>
 
        PR fortran/24545
diff --git a/gcc/testsuite/g++.dg/warn/main-2.C b/gcc/testsuite/g++.dg/warn/main-2.C
new file mode 100644 (file)
index 0000000..d38ef8e
--- /dev/null
@@ -0,0 +1,19 @@
+// { dg-do compile }
+// Make sure that the type of f1 does not change 
+// after the error of main about not returning 
+// int.
+// From Pekka Vuorela <pvuorela@iki.fi> 
+// PR c++/23229
+
+void f1();  
+  
+void
+main()  /* { dg-error "must return" } */
+{     
+  f1();  
+}  
+  
+void f1()  
+{     
+}  
+