re PR c++/29735 (ICE on "main" returning vector)
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
This commit is contained in:
parent
f464d80f27
commit
da33778420
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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.
|
||||
|
7
gcc/testsuite/g++.dg/warn/main-3.C
Normal file
7
gcc/testsuite/g++.dg/warn/main-3.C
Normal file
@ -0,0 +1,7 @@
|
||||
// PR c++/29735
|
||||
// { dg-do compile }
|
||||
|
||||
int __attribute__ ((vector_size (8))) main () // { dg-error "must return" }
|
||||
{
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user