aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMichael Forney <mforney@mforney.org>2021-09-17 21:30:15 -0700
committerMichael Forney <mforney@mforney.org>2021-10-20 14:42:42 -0700
commit77cc546cba247149a0beec7fae66521a61fdecfe (patch)
tree761f8d3be1381e19a0ac99df671b18e945f43175 /test
parente7cbbfbd5a8c8fdbbec30e4b78d2e21ade637fad (diff)
expr: Add support for wide string literals
Thanks to Nihal Jere for his initial patches implementing this feature. Fixes #35.
Diffstat (limited to 'test')
-rw-r--r--test/initializer-replace-local-string-wide.c22
-rw-r--r--test/initializer-replace-local-string-wide.qbe61
-rw-r--r--test/initializer-replace-static-string-wide.c20
-rw-r--r--test/initializer-replace-static-string-wide.qbe3
-rw-r--r--test/initializer-string-wide.c13
-rw-r--r--test/initializer-string-wide.qbe122
6 files changed, 241 insertions, 0 deletions
diff --git a/test/initializer-replace-local-string-wide.c b/test/initializer-replace-local-string-wide.c
new file mode 100644
index 0000000..366020f
--- /dev/null
+++ b/test/initializer-replace-local-string-wide.c
@@ -0,0 +1,22 @@
+void f(void) {
+ struct {
+ unsigned short u[6];
+ unsigned U[6];
+ __typeof__(L' ') L[6];
+ } x = {
+ .u[0] = u'x',
+ .u[4] = u'y',
+ .u = u"hello",
+ .u[1] = u'a',
+
+ .U[0] = U'x',
+ .U[4] = U'y',
+ .U = U"hello",
+ .U[1] = U'a',
+
+ .L[0] = L'x',
+ .L[4] = L'y',
+ .L = L"hello",
+ .L[1] = L'a',
+ };
+}
diff --git a/test/initializer-replace-local-string-wide.qbe b/test/initializer-replace-local-string-wide.qbe
new file mode 100644
index 0000000..97ac914
--- /dev/null
+++ b/test/initializer-replace-local-string-wide.qbe
@@ -0,0 +1,61 @@
+export
+function $f() {
+@start.1
+ %.1 =l alloc4 60
+@body.2
+ %.2 =l add %.1, 0
+ storeh 104, %.2
+ %.3 =l add %.1, 2
+ storeh 101, %.3
+ %.4 =l add %.1, 4
+ storeh 108, %.4
+ %.5 =l add %.1, 6
+ storeh 108, %.5
+ %.6 =l add %.1, 8
+ storeh 111, %.6
+ %.7 =l add %.1, 10
+ storeh 0, %.7
+ %.8 =l add %.1, 2
+ storeh 97, %.8
+ %.9 =l add %.1, 4
+ storew 0, %.9
+ %.10 =l add %.1, 8
+ storew 0, %.10
+ %.11 =l add %.1, 12
+ storew 104, %.11
+ %.12 =l add %.1, 16
+ storew 101, %.12
+ %.13 =l add %.1, 20
+ storew 108, %.13
+ %.14 =l add %.1, 24
+ storew 108, %.14
+ %.15 =l add %.1, 28
+ storew 111, %.15
+ %.16 =l add %.1, 32
+ storew 0, %.16
+ %.17 =l add %.1, 16
+ storew 97, %.17
+ %.18 =l add %.1, 20
+ storew 0, %.18
+ %.19 =l add %.1, 24
+ storew 0, %.19
+ %.20 =l add %.1, 28
+ storew 0, %.20
+ %.21 =l add %.1, 32
+ storew 0, %.21
+ %.22 =l add %.1, 36
+ storew 104, %.22
+ %.23 =l add %.1, 40
+ storew 101, %.23
+ %.24 =l add %.1, 44
+ storew 108, %.24
+ %.25 =l add %.1, 48
+ storew 108, %.25
+ %.26 =l add %.1, 52
+ storew 111, %.26
+ %.27 =l add %.1, 56
+ storew 0, %.27
+ %.28 =l add %.1, 40
+ storew 97, %.28
+ ret
+}
diff --git a/test/initializer-replace-static-string-wide.c b/test/initializer-replace-static-string-wide.c
new file mode 100644
index 0000000..b6c348a
--- /dev/null
+++ b/test/initializer-replace-static-string-wide.c
@@ -0,0 +1,20 @@
+struct {
+ unsigned short s[6];
+} u = {
+ .s = u"aα€😐",
+ .s[2] = u'£',
+};
+
+struct {
+ unsigned s[5];
+} U = {
+ .s = U"aα€😐",
+ .s[3] = U'😃',
+};
+
+struct {
+ __typeof__(L' ') s[5];
+} L = {
+ .s = L"aα€😐",
+ .s[3] = L'😃',
+};
diff --git a/test/initializer-replace-static-string-wide.qbe b/test/initializer-replace-static-string-wide.qbe
new file mode 100644
index 0000000..ab42886
--- /dev/null
+++ b/test/initializer-replace-static-string-wide.qbe
@@ -0,0 +1,3 @@
+export data $u = align 2 { h 97 945 163 55357 56848 0 , }
+export data $U = align 4 { w 97 945 8364 128515 0 , }
+export data $L = align 4 { w 97 945 8364 128515 0 , }
diff --git a/test/initializer-string-wide.c b/test/initializer-string-wide.c
new file mode 100644
index 0000000..85b8019
--- /dev/null
+++ b/test/initializer-string-wide.c
@@ -0,0 +1,13 @@
+char s[] = "aα€😀\xAA\xBBBB\xCCCCCCCC";
+char u8[] = u8"aα€😀\xAA\xBBBB\xCCCCCCCC";
+unsigned short u[] = u"aα€😀\xAA\xBBBB\xCCCCCCCC";
+unsigned U[] = U"aα€😀\xAA\xBBBB\xCCCCCCCC";
+__typeof__(L' ') L[] = L"aα€😀\xAA\xBBBB\xCCCCCCCC";
+
+void f(void) {
+ char s[] = "aα€😀\xAA\xBBBB\xCCCCCCCC";
+ char u8[] = u8"aα€😀\xAA\xBBBB\xCCCCCCCC";
+ unsigned short u[] = u"aα€😀\xAA\xBBBB\xCCCCCCCC";
+ unsigned U[] = U"aα€😀\xAA\xBBBB\xCCCCCCCC";
+ __typeof__(L' ') L[] = L"aα€😀\xAA\xBBBB\xCCCCCCCC";
+}
diff --git a/test/initializer-string-wide.qbe b/test/initializer-string-wide.qbe
new file mode 100644
index 0000000..dc784d4
--- /dev/null
+++ b/test/initializer-string-wide.qbe
@@ -0,0 +1,122 @@
+export data $s = align 1 { b "a\316\261\342\202\254\360\237\230\200\252\273\314\000", }
+export data $u8 = align 1 { b "a\316\261\342\202\254\360\237\230\200\252\273\314\000", }
+export data $u = align 2 { h 97 945 8364 55357 56832 170 48059 52428 0 , }
+export data $U = align 4 { w 97 945 8364 128512 170 48059 3435973836 0 , }
+export data $L = align 4 { w 97 945 8364 128512 170 48059 3435973836 0 , }
+export
+function $f() {
+@start.1
+ %.1 =l alloc4 14
+ %.16 =l alloc4 14
+ %.31 =l alloc4 18
+ %.41 =l alloc4 32
+ %.50 =l alloc4 32
+@body.2
+ %.2 =l add %.1, 0
+ storeb 97, %.2
+ %.3 =l add %.1, 1
+ storeb 206, %.3
+ %.4 =l add %.1, 2
+ storeb 177, %.4
+ %.5 =l add %.1, 3
+ storeb 226, %.5
+ %.6 =l add %.1, 4
+ storeb 130, %.6
+ %.7 =l add %.1, 5
+ storeb 172, %.7
+ %.8 =l add %.1, 6
+ storeb 240, %.8
+ %.9 =l add %.1, 7
+ storeb 159, %.9
+ %.10 =l add %.1, 8
+ storeb 152, %.10
+ %.11 =l add %.1, 9
+ storeb 128, %.11
+ %.12 =l add %.1, 10
+ storeb 170, %.12
+ %.13 =l add %.1, 11
+ storeb 187, %.13
+ %.14 =l add %.1, 12
+ storeb 204, %.14
+ %.15 =l add %.1, 13
+ storeb 0, %.15
+ %.17 =l add %.16, 0
+ storeb 97, %.17
+ %.18 =l add %.16, 1
+ storeb 206, %.18
+ %.19 =l add %.16, 2
+ storeb 177, %.19
+ %.20 =l add %.16, 3
+ storeb 226, %.20
+ %.21 =l add %.16, 4
+ storeb 130, %.21
+ %.22 =l add %.16, 5
+ storeb 172, %.22
+ %.23 =l add %.16, 6
+ storeb 240, %.23
+ %.24 =l add %.16, 7
+ storeb 159, %.24
+ %.25 =l add %.16, 8
+ storeb 152, %.25
+ %.26 =l add %.16, 9
+ storeb 128, %.26
+ %.27 =l add %.16, 10
+ storeb 170, %.27
+ %.28 =l add %.16, 11
+ storeb 187, %.28
+ %.29 =l add %.16, 12
+ storeb 204, %.29
+ %.30 =l add %.16, 13
+ storeb 0, %.30
+ %.32 =l add %.31, 0
+ storeh 97, %.32
+ %.33 =l add %.31, 2
+ storeh 945, %.33
+ %.34 =l add %.31, 4
+ storeh 8364, %.34
+ %.35 =l add %.31, 6
+ storeh 55357, %.35
+ %.36 =l add %.31, 8
+ storeh 56832, %.36
+ %.37 =l add %.31, 10
+ storeh 170, %.37
+ %.38 =l add %.31, 12
+ storeh 48059, %.38
+ %.39 =l add %.31, 14
+ storeh 52428, %.39
+ %.40 =l add %.31, 16
+ storeh 0, %.40
+ %.42 =l add %.41, 0
+ storew 97, %.42
+ %.43 =l add %.41, 4
+ storew 945, %.43
+ %.44 =l add %.41, 8
+ storew 8364, %.44
+ %.45 =l add %.41, 12
+ storew 128512, %.45
+ %.46 =l add %.41, 16
+ storew 170, %.46
+ %.47 =l add %.41, 20
+ storew 48059, %.47
+ %.48 =l add %.41, 24
+ storew 3435973836, %.48
+ %.49 =l add %.41, 28
+ storew 0, %.49
+ %.51 =l add %.50, 0
+ storew 97, %.51
+ %.52 =l add %.50, 4
+ storew 945, %.52
+ %.53 =l add %.50, 8
+ storew 8364, %.53
+ %.54 =l add %.50, 12
+ storew 128512, %.54
+ %.55 =l add %.50, 16
+ storew 170, %.55
+ %.56 =l add %.50, 20
+ storew 48059, %.56
+ %.57 =l add %.50, 24
+ storew 3435973836, %.57
+ %.58 =l add %.50, 28
+ storew 0, %.58
+ ret
+}