Fix PR1577, a crash on invalid bug.
authorChris Lattner <sabre@nondot.org>
Mon, 6 Aug 2007 21:00:37 +0000 (21:00 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 6 Aug 2007 21:00:37 +0000 (21:00 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@40874 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AsmParser/llvmAsmParser.y
test/Assembler/2007-08-06-AliasInvalid.ll [new file with mode: 0644]

index 9d7b063d0c30f4c362346340da7b3ad1a1e3365e..adf6eadc7c7786f9f1775c5283439a99098b1a22 100644 (file)
@@ -1980,6 +1980,7 @@ ThreadLocal : THREAD_LOCAL { $$ = true; } | { $$ = false; };
 AliaseeRef : ResultTypes SymbolicValueRef {
     const Type* VTy = $1->get();
     Value *V = getVal(VTy, $2);
+    CHECK_FOR_ERROR
     GlobalValue* Aliasee = dyn_cast<GlobalValue>(V);
     if (!Aliasee)
       GEN_ERROR("Aliases can be created only to global values");
diff --git a/test/Assembler/2007-08-06-AliasInvalid.ll b/test/Assembler/2007-08-06-AliasInvalid.ll
new file mode 100644 (file)
index 0000000..0711e03
--- /dev/null
@@ -0,0 +1,7 @@
+; RUN: llvm-as < %s > /dev/null |& grep {Invalid type for reference to global}
+; PR1577
+
+@anInt = global i32 1 alias i32 @anAlias
+define i32 @main() {
+   ret i32 0 
+}