aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJason Merrill <jason@yorick.cygnus.com>1999-01-16 16:44:35 +0000
committerJason Merrill <jason@gcc.gnu.org>1999-01-16 11:44:35 -0500
commit41eff652935a9cbeb7d26a7742dcf2040c78e431 (patch)
tree91f852ffee6c0f09aeed47783bad1e998988a1f4 /gcc
parentdb838bb85b280d924ff9967471871739c129ff73 (diff)
downloadgcc-41eff652935a9cbeb7d26a7742dcf2040c78e431.zip
gcc-41eff652935a9cbeb7d26a7742dcf2040c78e431.tar.gz
gcc-41eff652935a9cbeb7d26a7742dcf2040c78e431.tar.bz2
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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/decl.c22
2 files changed, 20 insertions, 8 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 32f5df1..554d85f 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+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>
* cp-tree.h (struct lang_type): Added has_mutable flag.
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index b15cec5..13c11bf 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -9356,16 +9356,22 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist)
}
else
{
- if (! pedantic && ! warn_return_type
- && funcdef_flag
- && MAIN_NAME_P (dname)
- && ctype == NULL_TREE
- && in_namespace == NULL_TREE
- && current_namespace == global_namespace)
- /* Let `main () { }' slide, since it's so common. */;
- else
+ /* We handle `main' specially here, because 'main () { }' is so
+ common. With no options, it is allowed. With -Wreturn-type,
+ it is a warning. It is only an error with -pedantic-errors. */
+ int is_main = (funcdef_flag
+ && MAIN_NAME_P (dname)
+ && ctype == NULL_TREE
+ && in_namespace == NULL_TREE
+ && current_namespace == global_namespace);
+
+ if (pedantic || ! is_main)
cp_pedwarn ("ANSI C++ forbids declaration `%D' with no type",
dname);
+ else if (warn_return_type)
+ cp_warning ("ANSI C++ forbids declaration `%D' with no type",
+ dname);
+
type = integer_type_node;
}
}