Support casting pointer to short or _Bool (grischka-2005-09-25 bugfix 6.1). This patch was originally posted in grischka's 2005-09-25 email as a "required fix" 6 (subfix 6.1) to compile gcc 2.95. It was tweaked by David A. Wheeler to merge the test case into the standard tcc test suite, and the test case now uses the correct formats %hd and %hhd (not %d). diff -ru tinycc-rl-1.0.0/tcc.c tinycc-grishka6.1.patch/tcc.c --- tinycc-rl-1.0.0/tcc.c 2007-04-18 14:52:22.000000000 -0400 +++ tinycc-grishka6.1.patch/tcc.c 2007-05-01 20:34:45.000000000 -0400 @@ -5125,6 +5125,10 @@ gen_op(TOK_NE); } else if ((dbt & VT_BTYPE) == VT_BYTE || (dbt & VT_BTYPE) == VT_SHORT) { + if (sbt == VT_PTR) { + vtop->type.t = VT_INT; + warning("nonportable conversion from pointer to char/short"); + } force_charshort_cast(dbt); } else if ((dbt & VT_BTYPE) == VT_INT) { /* scalar to int */ diff -ru tinycc-rl-1.0.0/tests/tcctest.c tinycc-grishka6.1.patch/tests/tcctest.c --- tinycc-rl-1.0.0/tests/tcctest.c 2007-04-18 14:52:22.000000000 -0400 +++ tinycc-grishka6.1.patch/tests/tcctest.c 2007-05-01 20:36:37.000000000 -0400 @@ -1105,6 +1105,16 @@ d = (char)b; printf("((unsigned)(char)0x%08x) = 0x%08x\n", b, d); + /* Try casting pointer to short or _Bool (grishka case_6.1). This + * is lossy, so tcc will print a warning. This capability is needed + * to compile gcc 2.95 as well as other programs. */ + { + void *p = (void *) 3; + printf("Expect 3 1 -> %hd %hhd\n", + (short) p, (_Bool) p); /* Expect warning */ + } + + /* test implicit int casting for array accesses */ c = 0; tab[1] = 2;