[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#490644: Acknowledgement (gcc: -finline-small-functions is overzealous)



On Sun, Jul 13, 2008 at 10:27:42AM +0000, Debian Bug Tracking System wrote:
> 
> Thank you for filing a new Bug report with Debian.

Here is the test file.

Cheers,
-- 
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
#include <stdlib.h>

enum token {
	EOI,
	FILRD,
	FILWR,
	FILEX,
	FILEXIST,
	FILREG,
	FILDIR,
	FILCDEV,
	FILBDEV,
	FILFIFO,
	FILSOCK,
	FILSYM,
	FILGZ,
	FILTT,
	FILSUID,
	FILSGID,
	FILSTCK,
	FILNT,
	FILOT,
	FILEQ,
	FILUID,
	FILGID,
	STREZ,
	STRNZ,
	STREQ,
	STRNE,
	STRLT,
	STRGT,
	INTEQ,
	INTNE,
	INTGE,
	INTGT,
	INTLE,
	INTLT,
	UNOT,
	BAND,
	BOR,
	LPAREN,
	RPAREN,
	OPERAND
};

enum token_types {
	UNOP,
	BINOP,
	BUNOP,
	BBINOP,
	PAREN
};

static struct t_op {
	const char *op_text;
	short op_num, op_type;
} const ops [] = {
	{"-r",	FILRD,	UNOP},
	{"-w",	FILWR,	UNOP},
	{"-x",	FILEX,	UNOP},
	{"-e",	FILEXIST,UNOP},
	{"-f",	FILREG,	UNOP},
	{"-d",	FILDIR,	UNOP},
	{"-c",	FILCDEV,UNOP},
	{"-b",	FILBDEV,UNOP},
	{"-p",	FILFIFO,UNOP},
	{"-u",	FILSUID,UNOP},
	{"-g",	FILSGID,UNOP},
	{"-k",	FILSTCK,UNOP},
	{"-s",	FILGZ,	UNOP},
	{"-t",	FILTT,	UNOP},
	{"-z",	STREZ,	UNOP},
	{"-n",	STRNZ,	UNOP},
	{"-h",	FILSYM,	UNOP},		/* for backwards compat */
	{"-O",	FILUID,	UNOP},
	{"-G",	FILGID,	UNOP},
	{"-L",	FILSYM,	UNOP},
	{"-S",	FILSOCK,UNOP},
	{"=",	STREQ,	BINOP},
	{"!=",	STRNE,	BINOP},
	{"<",	STRLT,	BINOP},
	{">",	STRGT,	BINOP},
	{"-eq",	INTEQ,	BINOP},
	{"-ne",	INTNE,	BINOP},
	{"-ge",	INTGE,	BINOP},
	{"-gt",	INTGT,	BINOP},
	{"-le",	INTLE,	BINOP},
	{"-lt",	INTLT,	BINOP},
	{"-nt",	FILNT,	BINOP},
	{"-ot",	FILOT,	BINOP},
	{"-ef",	FILEQ,	BINOP},
	{"!",	UNOT,	BUNOP},
	{"-a",	BAND,	BBINOP},
	{"-o",	BOR,	BBINOP},
	{"(",	LPAREN,	PAREN},
	{")",	RPAREN,	PAREN},
	{0,	0,	0}
};

static char **t_wp;
static struct t_op const *t_wp_op;

static const struct t_op *getop(const char *s)
{
	const struct t_op *op;

	for (op = ops; op->op_text; op++) {
		if (strcmp(s, op->op_text) == 0)
			return op;
	}

	return NULL;
}

static int
isoperand(void)
{
	struct t_op const *op;
	char *s, *t;

	if ((s  = *(t_wp+1)) == 0)
		return 1;
	if ((t = *(t_wp+2)) == 0)
		return 0;

	op = getop(s);
	return op && op->op_type == BINOP;
}

static enum token
t_lex(char *s)
{
	struct t_op const *op;

	if (s == 0) {
		t_wp_op = (struct t_op *)0;
		return EOI;
	}

	op = getop(s);
	if (op && !(op->op_type == UNOP && isoperand()) &&
	    !(op->op_num == LPAREN && *(t_wp+1) == 0)) {
		t_wp_op = op;
		return op->op_num;
	}

	t_wp_op = (struct t_op *)0;
	return OPERAND;
}

int
testcmd(int argc, char **argv)
{
	const struct t_op *op;
	int res;

	if (*argv[0] == '[') {
		if (*argv[--argc] != ']')
			error("missing ]");
		argv[argc] = NULL;
	}

	if (argc < 2)
		return 1;

	t_wp = &argv[1];

	/*
	 * POSIX prescriptions: he who wrote this deserves the Nobel
	 * peace prize.
	 */
	if (argc == 4) {
		op = getop(t_wp[1]);
		if (op && op->op_type == BINOP) {
			res = binop();
			goto done;
		}
	}

	if (argc >= 4 || argc <= 5) {
		if (!strcmp(*t_wp, "(") && !strcmp(argv[argc - 1], ")")) {
			argv[--argc] = NULL;
			t_wp++;
		}
	}

	res = oexpr(t_lex(*t_wp));

	if (*t_wp != NULL && *++t_wp != NULL)
		syntax(*t_wp, "unexpected operator");

done:
	return !res;
}

Reply to: