[comp.lang.c++] ambiguities in the declaration grammar for cfront

donn@utah-cs.UUCP (Donn Seeley) (08/30/88)

The following sort of code makes cfront 1.2.1 bomb out:

	typedef char ctype;
	typedef ctype (*cptrtype);

The errors typically look like this:

	"ctype.c", line 2: warning:  ctype  redefined
	"ctype.c", line 2: internal <<cfront 1.2.1 2/16/87>> error:  type::dcl(this==0)

Cfront works if the parentheses are omitted, but there are situations
in which parentheses are necessary:

	typedef ctype (*cptrarraytype)[10];

In this case, it's necessary to either drop the ctype typedef or to
declare the type in two steps like this, carefully avoiding parentheses:

	typedef ctype carraytype[10];
	typedef carraytype *cptrarraytype;

Our C compiler, of course, is perfectly happy with these typedefs
(although we might tell a different story if our C compiler supported
prototypes).  Is this fixed in AT&T C++ 2.0?  Is there a preferred
workaround?

This doesn't do much to increase my sympathy toward prototype syntax,

Donn Seeley    University of Utah CS Dept    donn@cs.utah.edu
40 46' 6"N 111 50' 34"W    (801) 581-5668    utah-cs!donn