aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMichael Forney <mforney@mforney.org>2019-07-11 13:56:26 -0700
committerMichael Forney <mforney@mforney.org>2019-07-11 13:56:26 -0700
commit1a38a5fc4844a0de8729be694a62ba0afce3ff52 (patch)
tree4d2bb39d6c27d0cbb0330d788a5eea9b43cb3fad /test
parent7d5d63cd2f7c49adaf2c97ccc0ba39063cf084a0 (diff)
downloadcproc-1a38a5fc4844a0de8729be694a62ba0afce3ff52.tar.xz
expr: Fix cast of same type
Diffstat (limited to 'test')
-rw-r--r--test/cast-same-type.c4
-rw-r--r--test/cast-same-type.qbe12
2 files changed, 16 insertions, 0 deletions
diff --git a/test/cast-same-type.c b/test/cast-same-type.c
new file mode 100644
index 0000000..5602057
--- /dev/null
+++ b/test/cast-same-type.c
@@ -0,0 +1,4 @@
+struct S {int x;} s;
+int main(void) {
+ return ((struct S)s).x;
+}
diff --git a/test/cast-same-type.qbe b/test/cast-same-type.qbe
new file mode 100644
index 0000000..625f937
--- /dev/null
+++ b/test/cast-same-type.qbe
@@ -0,0 +1,12 @@
+export
+function w $main() {
+@start.1
+@body.2
+ %.1 =l copy $s
+ %.2 =l mul 0, 1
+ %.3 =l add %.1, %.2
+ %.4 =l copy %.3
+ %.5 =w loadsw %.4
+ ret %.5
+}
+export data $s = align 4 { z 4 }