scc

simple C compiler
git clone git://git.2f30.org/scc
Log | Files | Refs | README | LICENSE

commit c8abdfe1b720a9d786ea3fd840d48b744ef07e06
parent 1dacb7932abe8799f3d0106d24c2615781dfe3a0
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Fri, 11 Jul 2014 09:50:31 +0200

Allow labels with same name that a previous typedef

Labels have a separate namespace, so it is correct this combination,
but the problem is the lexer returns a different token for an
identifier after a typedef for it. For example:

	main()
	{
		typedef int pepe;

	pepe:	return 0;
	}

The easier solution is a hack, where we modify the grammar to
accept an IDEN or a TYPE when creating labels.

Diffstat:
Mcc1/stmt.c | 2+-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/cc1/stmt.c b/cc1/stmt.c @@ -303,7 +303,7 @@ compound(Symbol *lbreak, Symbol *lcont, Caselist *lswitch) next(); return; case TYPE: - if (ahead() == ':') + if (yylval.token == TYPENAME && ahead() == ':') goto statement; /* pass through */ case SCLASS: case TQUALIFIER: