Skip to content

Commit 6f8bf69

Browse files
chqrliebvdberg
authored andcommitted
Compiler: fix Value.castAs for pointer conversions
Fixes #317
1 parent 69add01 commit 6f8bf69

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

analyser_utils/ctv_analyser.c2

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,13 @@ const Limit[] Limits = {
4343
{ -9223372036854775807-1, 9223372036854775807 },
4444
// 64 - UInt64
4545
{ 0, 18446744073709551615 },
46+
// 0 - Void
47+
{ 1, 0 },
4648
}
4749

4850
fn const Limit* getLimit(u32 width) {
4951
switch (width) {
52+
case 0: return &Limits[9];
5053
case 1: return &Limits[0];
5154
case 7: return &Limits[1];
5255
case 8: return &Limits[2];

ast/value.c2

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -751,6 +751,8 @@ fn Value Value.castAs(const Value* v, QualType qt) {
751751
qt = qt.getCanonicalType();
752752
if (qt.isEnum())
753753
qt = qt.getEnum().getImplType();
754+
if (qt.isPointer())
755+
return result;
754756
assert(qt.isBuiltin());
755757
BuiltinType* bi = qt.getBuiltin();
756758
switch (result.kind) { // @@@

0 commit comments

Comments
 (0)