This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Patch: fix regression in 4.0

As discussed on gcc list, this accepts
   int use() { int foo(); }   /* implicit int */
  void foo() {}
  extern void foo();
with a warning instead of an error, as earlier versions did.
Testing in progress, OK if it passes?

Please refer to test case. The first patch line causes case 8 to get a
type mismatch error, not a warning (of course it got another error later).
The rest causes cases 9 and 10 to be accepted as in earlier compilers.

Case 5 still behaves differently; it is a warning not an error as in earlier
compilers. This is due to Zack's code
/* Permit void foo (...) to match int foo (...) if the latter is
the definition and implicit int was used. See
c-torture/compile/920625-2.c. */
However, the example in 920625-2.c is not quite the same, it is
int use() { extern void foo(); }
foo() {}
I would not expect that example to get into this code at all, since the
declarations are not visible in the same scope. But accepting that mismatch
here means accepting case 5 as well.

2004-13-12 Dale Johannesen <>

        * c-decl.c (diagnose_mismatched_decls):  Accept mismatched
        function types: void with previous implicit int.

Index: c-decl.c
RCS file: /cvs/gcc/gcc/gcc/c-decl.c,v
retrieving revision 1.612
diff -r1.612 c-decl.c
> && C_FUNCTION_IMPLICIT_INT (newdecl) && !DECL_INITIAL (olddecl))
> /* Permit void foo (...) to match an earlier int foo (...) if
> implicit int was used. */
> else if (TREE_CODE (newdecl) == FUNCTION_DECL
> && TYPE_MAIN_VARIANT (TREE_TYPE (newtype)) == void_type_node
> && TYPE_MAIN_VARIANT (TREE_TYPE (oldtype)) == integer_type_node
> && C_DECL_IMPLICIT (olddecl) && !DECL_INITIAL (olddecl))
> {
> pedwarn ("%Jconflicting types for %qD", newdecl, newdecl);
> /* Make sure we keep void as the return type. */
> TREE_TYPE (olddecl) = *oldtypep = oldtype = newtype;
> C_FUNCTION_IMPLICIT_INT (olddecl) = 0;
> pedwarned = true;
> }

Attachment: 20041213-1.c
Description: Text document

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]