aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdmund Grimley Evans <Edmund.Grimley.Evans@gmail.com>2015-11-26 12:24:34 +0000
committerEdmund Grimley Evans <Edmund.Grimley.Evans@gmail.com>2015-11-26 12:28:42 +0000
commit99372bb1d399005824d1148431888a9b5b9d462b (patch)
tree95984e6dcbdc3bd1f6788239f827d33e01a521fc
parent51c3465a49858d07c54684dec45c9ad8f2b0f8a0 (diff)
downloadtinycc-99372bb1d399005824d1148431888a9b5b9d462b.tar.gz
tinycc-99372bb1d399005824d1148431888a9b5b9d462b.tar.bz2
tccgen.c: Give error if statement expression found when const wanted.
Some test cases: #define SE ({ switch (0) { } 0; }) // Should give error: int x = SE; void f(void) { static int x = SE; } void f(void) { enum e { a = SE }; } void f(void) { switch (0) { case SE: break; } } // Correct: int f(void) { return SE; } int f(void) { return sizeof(SE); }
-rw-r--r--tccgen.c8
1 files changed, 2 insertions, 6 deletions
diff --git a/tccgen.c b/tccgen.c
index 72e892c..b085c65 100644
--- a/tccgen.c
+++ b/tccgen.c
@@ -3831,12 +3831,8 @@ ST_FUNC void unary(void)
gen_cast(&type);
}
} else if (tok == '{') {
- /*
- if (nocode_wanted)
- tcc_error("statement expression in global scope"); */
- /* this check breaks compilation of the linux 2.4.26 with the meesage:
- linux/include/net/tcp.h:945: error: statement expression in global scope */
-
+ if (const_wanted)
+ tcc_error("expected constant");
/* save all registers */
save_regs(0);
/* statement expression : we do not accept break/continue