Commit 41eff652 by Jason Merrill Committed by Jason Merrill

decl.c (grokdeclarator): Don't make 'main(){}' an error with only -Wreturn-type.

	* decl.c (grokdeclarator): Don't make 'main(){}' an error with only
	-Wreturn-type.

Co-Authored-By: Manfred Hollstein <manfred@s-direktnet.de>

From-SVN: r24704
parent db838bb8
1999-01-16 Jason Merrill <jason@yorick.cygnus.com>
Manfred Hollstein <manfred@s-direktnet.de>
* decl.c (grokdeclarator): Don't make 'main(){}' an error with only
-Wreturn-type.
1999-01-16 Nathan Sidwell <nathan@acm.org> 1999-01-16 Nathan Sidwell <nathan@acm.org>
* cp-tree.h (struct lang_type): Added has_mutable flag. * cp-tree.h (struct lang_type): Added has_mutable flag.
......
...@@ -9356,16 +9356,22 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist) ...@@ -9356,16 +9356,22 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist)
} }
else else
{ {
if (! pedantic && ! warn_return_type /* We handle `main' specially here, because 'main () { }' is so
&& funcdef_flag common. With no options, it is allowed. With -Wreturn-type,
&& MAIN_NAME_P (dname) it is a warning. It is only an error with -pedantic-errors. */
&& ctype == NULL_TREE int is_main = (funcdef_flag
&& in_namespace == NULL_TREE && MAIN_NAME_P (dname)
&& current_namespace == global_namespace) && ctype == NULL_TREE
/* Let `main () { }' slide, since it's so common. */; && in_namespace == NULL_TREE
else && current_namespace == global_namespace);
if (pedantic || ! is_main)
cp_pedwarn ("ANSI C++ forbids declaration `%D' with no type", cp_pedwarn ("ANSI C++ forbids declaration `%D' with no type",
dname); dname);
else if (warn_return_type)
cp_warning ("ANSI C++ forbids declaration `%D' with no type",
dname);
type = integer_type_node; type = integer_type_node;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment