aboutsummaryrefslogtreecommitdiff
path: root/tests/tcctest.c
diff options
context:
space:
mode:
authorMichael Matz <matz@suse.de>2017-03-06 21:45:41 +0100
committerMichael Matz <matz@suse.de>2017-05-02 03:07:37 +0200
commit8ca98e23c4e54b1552c819425890584e6357f46a (patch)
tree726ade8adcde484eaec9f1c1161ea78a7ed86481 /tests/tcctest.c
parent21b12ea10d3c04d66c81633b67be29c42d5dcb3a (diff)
downloadtinycc-8ca98e23c4e54b1552c819425890584e6357f46a.tar.gz
tinycc-8ca98e23c4e54b1552c819425890584e6357f46a.tar.bz2
Tidy unary() a bit
factor code a bit for transforming tokens into SValues. This revealed a bug in TOK_GET (see testcase), which happened to be harmless before. So fix that as well.
Diffstat (limited to 'tests/tcctest.c')
-rw-r--r--tests/tcctest.c23
1 files changed, 21 insertions, 2 deletions
diff --git a/tests/tcctest.c b/tests/tcctest.c
index aee0120..e86a2a6 100644
--- a/tests/tcctest.c
+++ b/tests/tcctest.c
@@ -3720,8 +3720,6 @@ typedef struct __attribute__((__packed__)) {
int c;
} Spacked2;
Spacked2 spacked2;
-/* This doesn't work for now. Requires adjusting field offsets/sizes
- after parsing the struct members. */
typedef struct Spacked3_s {
char a;
short b;
@@ -3754,3 +3752,24 @@ void * __attribute__((__unused__)) get_void_ptr (void *a)
{
return a;
}
+
+/* This part checks for a bug in TOK_GET (used for inline expansion),
+ where the large long long constant left the the high bits set for
+ the integer constant token. */
+static inline
+int __get_order(unsigned long long size)
+{
+ int order;
+ size -= 0xffff880000000000ULL; // this const left high bits set in the token
+ {
+ struct S { int i : 1; } s; // constructed for this '1'
+ }
+ order = size;
+ return order;
+}
+
+/* This just forces the above inline function to be actually emitted. */
+int force_get_order(unsigned long s)
+{
+ return __get_order(s);
+}