diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-05-24 14:24:44 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-05-24 14:24:57 -0700 |
commit | bf8c659ebc868649ceb570d780a8b3de9b6d18b9 (patch) | |
tree | 21136633a5818b74e0d76d5d22744f377722cf30 | |
parent | c5732b99a69d611d3fb7fa9cd94ebb9b1f2497a5 (diff) |
handle globals with no value and no zeroinit
-rw-r--r-- | src/intertyper.js | 15 | ||||
-rw-r--r-- | tests/cases/emptystruct.ll | 2 |
2 files changed, 12 insertions, 5 deletions
diff --git a/src/intertyper.js b/src/intertyper.js index 445c37f4..6da30ae8 100644 --- a/src/intertyper.js +++ b/src/intertyper.js @@ -537,12 +537,17 @@ function intertyper(data, sidePass, baseLineNums) { }); } } else if (!external) { - if (item.tokens[3].text == 'c') - item.tokens.splice(3, 1); - if (item.tokens[3].text in PARSABLE_LLVM_FUNCTIONS) { - ret.value = parseLLVMFunctionCall(item.tokens.slice(2)); + if (item.tokens[3] && item.tokens[3].text != ';') { + if (item.tokens[3].text == 'c') { + item.tokens.splice(3, 1); + } + if (item.tokens[3].text in PARSABLE_LLVM_FUNCTIONS) { + ret.value = parseLLVMFunctionCall(item.tokens.slice(2)); + } else { + ret.value = scanConst(item.tokens[3], ret.type); + } } else { - ret.value = scanConst(item.tokens[3], ret.type); + ret.value = { intertype: 'value', ident: '0', value: '0', type: ret.type }; } } return [ret]; diff --git a/tests/cases/emptystruct.ll b/tests/cases/emptystruct.ll index 67967e65..ecf0e295 100644 --- a/tests/cases/emptystruct.ll +++ b/tests/cases/emptystruct.ll @@ -6,6 +6,8 @@ target triple = "i386-pc-linux-gnu" @.str = private constant [14 x i8] c"hello, world!\00", align 1 ; [#uses=1] +@.waka = extern_weak global i8* ; no initializer! + define i32 @main() nounwind { entry: %z = alloca %struct.s, align 4 |