~mpu/qbe

check that data alignment is in range and a power of two v1 PROPOSED

Michael Forney: 1
 check that data alignment is in range and a power of two

 1 files changed, 2 insertions(+), 0 deletions(-)
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~mpu/qbe/patches/50464/mbox | git am -3
Learn more about email & git

[PATCH] check that data alignment is in range and a power of two Export this patch

Otherwise, the alignment gets truncated to fit in char, so
`align 256` is handled as no alignment requirement.
---
I noticed this when trying to figure out what alignment values were
supported in gcc, as, and qbe.

The power-of-two is a requirement of gas, so maybe doesn't need to
be done here, but I think it's better to produce an error in qbe
than in as.

 parse.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/parse.c b/parse.c
index 738ec5b..08625c8 100644
--- a/parse.c
+++ b/parse.c
@@ -1091,6 +1091,8 @@ parsedat(void cb(Dat *), Lnk *lnk)
	if (t == Talign) {
		if (nextnl() != Tint)
			err("alignment expected");
		if (tokval.num <= 0 || tokval.num > CHAR_MAX || tokval.num & tokval.num - 1)
			err("invalid alignment");
		lnk->align = tokval.num;
		t = nextnl();
	}
-- 
2.44.0