Probable bugs in egcs-19981220 and autoconf 2.12
Manfred Hollstein
manfred@s-direktnet.de
Wed Dec 30 09:03:00 GMT 1998
On Tue, 22 December 1998, 21:24:25, bagnara@di.unipi.it wrote:
> N8TM@aol.com wrote:
> >
> > In a message dated 12/22/98 3:57:22 AM Pacific Standard Time,
> > bagnara@di.unipi.it writes:
> >
> > << I discovered the following while using autoconf 2.12
> > together with egcs-19981220/g++. Autoconf uses the following
> > program to check whether the C++ compiler works:
> >
> > #line 894 "configure"
> > #include "confdefs.h"
> > main(){return(0);}
> >
> > If the -Wall option is used, then egcs-19981220 rejects it >>
> > This could be useful information. egcs expects a newer version of autoconf,
> > but I have had to fall back on autoconf 2.12 for systems where the newer
> > version refuses to install. Maybe this change and the change of the version
> > report are all that are required. However, this test string appears on first
> > glance to appear in acspecific.m4.
>
> Perhaps my message was not clear enough, sorry about that.
> The bugs do not show up building egcs (the problem I reported previously
> with the egcs configuration mechanism expecting a non-released version of
> autoconf seems to have been fixed). I have discovered them building
> an application of mine.
>
> As far as egcs-19981220 is concerned: -Wall should not cause the rejection
> of a C++ program just because it omits the return type of `main'.
> IMHO, either the program is rejected regardless of -Wall, or the
> program is compiled.
I posted a small patch for this with the subject ``CVS-19981219: New
PATCH for actually fixing the "main(){}" case'' some days ago (please
see the appended copy).
Jason (Merrill): I haven't heard anything from you so far, is it OK to
install?
A Happy New Year to everybody out there!
manfred
>
> As far as autoconf 2.12 is concerned: testing whether the C++ compiler
> works should be done with a program not omitting the return type of `main'.
>
> The combination of these two bugs makes autoconfiguration of C++ programs
> impossible if the user has specified CFLAGS so as to contain -Wall.
> I am one of those users ;)
>
> Cheers,
>
> Roberto
On Sat, 19 December 1998, 20:14:43, manfred@s-direktnet.de wrote:
> On nil, 17 December 1998, 09:48:15, jason@cygnus.com wrote:
>
> > No; we want -Wreturn-type to warn about this case. It ought to be a plain
> > warning, though.
> >
> > Jason
>
> OK. How about this, then?
>
> 1998-12-19 Manfred Hollstein <manfred@s-direktnet.de>
>
> * decl.c (user_wants_pedantic_errors): Define new variable.
> (init_decl_processing): Record the current value of flag_pedantic_errors.
> (grokdeclarator): Define new helper variable `is_main'; decide based on
> `user_wants_pedantic_errors' if "main () { ... }" should be flagged with
> an error message or with a warning only.
>
> diff -rup -x CVS -x RCS -x *.o -x *.info* -x *.html* -x *.elc -x *.dvi -x *.orig -x *~ -x version.el egcs-19981219.orig/gcc/cp/decl.c egcs-19981219/gcc/cp/decl.c
> --- egcs-19981219.orig/gcc/cp/decl.c Sat Dec 19 10:24:37 1998
> +++ egcs-19981219/gcc/cp/decl.c Sat Dec 19 19:16:52 1998
> @@ -435,6 +435,9 @@ static struct named_label_list *named_la
> in the TREE_PURPOSE slot. */
> tree static_aggregates;
>
> +/* Record if the user specified -pedantic-errors. */
> +static int user_wants_pedantic_errors = 0;
> +
> /* -- end of C++ */
>
> /* Two expressions that are constants with value zero.
> @@ -5830,6 +5833,10 @@ init_decl_processing ()
>
> if (flag_strict_prototype == 2)
> flag_strict_prototype = pedantic;
> + /* Record if the user gave the -pedantic-errors flag; we will need this
> + later to decide, if "main () { ... }" should be flagged with an error
> + or with a warning only. */
> + user_wants_pedantic_errors = flag_pedantic_errors;
> if (! flag_permissive && ! pedantic)
> flag_pedantic_errors = 1;
>
> @@ -9353,16 +9360,24 @@ grokdeclarator (declarator, declspecs, d
> }
> else
> {
> - if (! pedantic && ! warn_return_type
> - && funcdef_flag
> - && MAIN_NAME_P (dname)
> - && ctype == NULL_TREE
> - && in_namespace == NULL_TREE
> - && current_namespace == global_namespace)
> + int is_main = funcdef_flag
> + && MAIN_NAME_P (dname)
> + && ctype == NULL_TREE
> + && in_namespace == NULL_TREE
> + && current_namespace == global_namespace;
> +
> + if (! pedantic && ! warn_return_type && is_main)
> /* Let `main () { }' slide, since it's so common. */;
> else
> - cp_pedwarn ("ANSI C++ forbids declaration `%D' with no type",
> - dname);
> + {
> + int old_flag_pedantic_errors = flag_pedantic_errors;
> +
> + if (is_main)
> + flag_pedantic_errors = 0;
> + cp_pedwarn ("ANSI C++ forbids declaration `%D' with no type",
> + dname);
> + flag_pedantic_errors = old_flag_pedantic_errors;
> + }
> type = integer_type_node;
> }
> }
>
More information about the Gcc-bugs
mailing list