[cfe-dev] return statements without expressions in non-void functions revisited

Jack Howarth howarth at bromo.med.uc.edu
Fri Jul 15 17:56:34 PDT 2011

   In porting texlive under clang for fink, we have run into the same issue from this thread...


In that thread it was suggested that -std=c89 might be modified to convert the error into
a warning for...

[MacPro:~] howarth% clang -std=gnu89 -c type1_test.c -fno-strict-aliasing 
type1_test.c:24:8: error: non-void function 'PSFakePop' should return a value [-Wreturn-type]
  else Error0("PSFakePop: Stack empty\n");
type1_test.c:13:54: note: instantiated from:
#define Error0(errmsg) { CC; IfTrace0(TRUE, errmsg); Error;}
type1_test.c:11:32: note: instantiated from:
#define Error {errflag = TRUE; return;}
1 error generated.

This appears to never have been implemented however. Any suggestions on the best approach to
revise the following testcase to avoid the error under clang (which I also see under icc
but not gcc trunk even with -std=c90)?

-------------------- type1_test.c -----------------------
#define TRUE (1)
typedef double DOUBLE;         /* 64 bits */
int currentchar = -1; /* for error reporting */
static int errflag;

#define MAXPSFAKESTACK 32  /* Max depth of fake PostScript stack (local) */

#define CC IfTrace1(TRUE, "'%03o ", currentchar)

#define Error {errflag = TRUE; return;}

#define Error0(errmsg) { CC; IfTrace0(TRUE, errmsg); Error;}

#define Error1(errmsg,arg) { CC; IfTrace1(TRUE, errmsg, arg); Error;}

static DOUBLE PSFakePop(void);
static int PSFakeTop;

/* PSFakePop: Removes a number from the top of the fake PostScript stack */
static DOUBLE PSFakePop ()
  if (PSFakeTop >= 0) return(PSFakeStack[PSFakeTop--]);
  else Error0("PSFakePop: Stack empty\n");

More information about the cfe-dev mailing list