[comp.sys.apollo] SR10.1 BUG/MISFEATURE: typedefs

jfinger@apolling (Jeff Finger) (11/16/89)

################################################################

Following is an example of a legal use of ANSI C function 
prototypes -- a typedef specifying a class of functions
of identical type (including argument types).

Unfortunately, this program cannot be compiled under SR10.1.

Although Apollo's support of ANSI C is admittedly only partial, I
believe that giving an error on the program below is either a serious
bug or serious misfeature. At the worst, the compiler should give an
incorrect warning message rather than claim a type mismatch.

-- Jeff Finger --
jfinger@imagen.com
jfinger@neon.stanford.edu

################################################################
% cat fred.c
typedef short fred_fp( long );

extern fred_fp fred;

extern void main( void );

short
fred( nbytes )
     long  nbytes;
{
    return( 37 );
}

void main()
{
    short   x;
    x = fred( 43 );
}

#####################################################################
#
#   Note that gcc 1.33 compiles it ok, but Apollo SR10.1 CC does not.
#   Apollo CC's  handling of typedefs does not seem to have remembered
#   the formal parameter types.
#
#####################################################################
% gcc -ansi -Wall -c fred.c
% cc -v -c fred.c -g-W0,-info 1

 (0009)      long  nbytes;

******** Line 8 of "fred.c": [Error #258]  Multiple declaration of "fred".

 (0017)     x = fred( 43 );

******** Line 17 of "fred.c": [Warning #078]  Incompatible pointer and integer operands
         [x, fred] to the "=" operator.