+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
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;
}
*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)
+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.