]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/29735 (ICE on "main" returning vector)
authorJakub Jelinek <jakub@redhat.com>
Tue, 28 Nov 2006 12:56:53 +0000 (13:56 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 28 Nov 2006 12:56:53 +0000 (13:56 +0100)
PR c++/29735
* decl.c (grokfndecl): Check main's type after applying
attributes, not before.

* g++.dg/warn/main-3.C: New test.

From-SVN: r119287

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

index 076abeaf30497c87c69c6e00370587f770c333d6..361d6f734ee6c3944f60aed8669a712205b7e926 100644 (file)
@@ -1,3 +1,9 @@
+2006-11-28  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/29735
+       * decl.c (grokfndecl): Check main's type after applying
+       attributes, not before.
+
 2006-11-27  Mark Mitchell  <mark@codesourcery.com>
 
        * class.c (build_vcall_offset_vtbl_entries): Do not add vcall
index d10c3a2f0482801db80a40ef5c41992a1d8f2423..f50866832f6bad00ea5ad558facb1f453e60baec 100644 (file)
@@ -6026,17 +6026,6 @@ grokfndecl (tree ctype,
        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))
-       {
-         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;
-       }
-      check_main_parameter_types (decl);
       inlinep = 0;
       publicp = 1;
     }
@@ -6143,6 +6132,21 @@ grokfndecl (tree ctype,
       *attrlist = NULL_TREE;
     }
 
+  /* Check main's type after attributes have been applied.  */
+  if (ctype == NULL_TREE && DECL_MAIN_P (decl))
+    {
+      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;
+       }
+      check_main_parameter_types (decl);
+    }
+
   if (ctype != NULL_TREE
       && (! TYPE_FOR_JAVA (ctype) || check_java_method (decl))
       && check)
index e2a6284c54642b55f45e9c1e318d6d35b9741922..b08954b2f5eeaaecbbea42e6ba7c1bc37e18aa15 100644 (file)
@@ -1,3 +1,8 @@
+2006-11-28  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/29735
+       * g++.dg/warn/main-3.C: New test.
+
 2006-11-28  Jan Hubicka  <jh@suse.cz>
 
        * gcc.dg/winline-1.c: New test.
diff --git a/gcc/testsuite/g++.dg/warn/main-3.C b/gcc/testsuite/g++.dg/warn/main-3.C
new file mode 100644 (file)
index 0000000..eb462f4
--- /dev/null
@@ -0,0 +1,7 @@
+// PR c++/29735
+// { dg-do compile }
+
+int __attribute__ ((vector_size (8))) main () // { dg-error "must return" }
+{
+  return 0;
+}