cproc

Unnamed repository; edit this file 'description' to name the repository.
git clone git://git.nihaljere.xyz/cproc
Log | Files | Refs | Submodules | README | LICENSE

commit 3411746ee9e93981ad0a9c28fc6e33d5d4c9bfd4
parent 6380b5cd6643bc0101e81c4da46d244466cda141
Author: Michael Forney <mforney@mforney.org>
Date:   Fri,  5 Apr 2019 11:24:08 -0700

Fix _Alignas with type specifier

Diffstat:
Mdecl.c | 8++++----
Atests/alignas.c | 1+
Atests/alignas.qbe | 1+
3 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/decl.c b/decl.c @@ -228,7 +228,7 @@ tagspec(struct scope *s) static struct type * declspecs(struct scope *s, enum storageclass *sc, enum funcspec *fs, int *align) { - struct type *t; + struct type *t, *other; struct decl *d; enum typespec ts = SPECNONE; enum typequal tq = QUALNONE; @@ -341,9 +341,9 @@ declspecs(struct scope *s, enum storageclass *sc, enum funcspec *fs, int *align) error(&tok.loc, "alignment specifier not allowed in this declaration"); next(); expect(TLPAREN, "after '_Alignas'"); - t = typename(s); - if (t) { - *align = t->align; + other = typename(s); + if (other) { + *align = other->align; } else { i = intconstexpr(s, false); if (!i || i & (i - 1) || i > 16) diff --git a/tests/alignas.c b/tests/alignas.c @@ -0,0 +1 @@ +_Alignas(int) char x[4]; diff --git a/tests/alignas.qbe b/tests/alignas.qbe @@ -0,0 +1 @@ +export data $x = align 4 { z 4 }