reject void pointers with a nice error:
authorChris Lattner <sabre@nondot.org>
Sun, 8 Feb 2009 19:56:22 +0000 (19:56 +0000)
committerChris Lattner <sabre@nondot.org>
Sun, 8 Feb 2009 19:56:22 +0000 (19:56 +0000)
llvm-as: t.ll:2:15: pointers to void are invalid, use i8* instead
%X = type void*
              ^

instead of asserting and dying.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@64089 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AsmParser/LLParser.cpp

index 60e863c53ed069d33e9e739f864c1f109930f6e2..3201e9887ce41779517a25e3294dcfe35cdbec9f 100644 (file)
@@ -465,7 +465,7 @@ bool LLParser::ParseGlobal(const std::string &Name, LocTy NameLoc,
       return true;
   }
 
-  if (isa<FunctionType>(Ty) || Ty == Type::LabelTy)
+  if (isa<FunctionType>(Ty) || Ty == Type::LabelTy || Ty == Type::VoidTy)
     return Error(TyLoc, "invald type for global variable");
   
   GlobalVariable *GV = 0;
@@ -1024,6 +1024,8 @@ bool LLParser::ParseTypeRec(PATypeHolder &Result) {
     case lltok::star:
       if (Result.get() == Type::LabelTy)
         return TokError("basic block pointers are invalid");
+      if (Result.get() == Type::VoidTy)
+        return TokError("pointers to void are invalid, use i8* instead");
       Result = HandleUpRefs(PointerType::getUnqual(Result.get()));
       Lex.Lex();
       break;
@@ -1032,6 +1034,8 @@ bool LLParser::ParseTypeRec(PATypeHolder &Result) {
     case lltok::kw_addrspace: {
       if (Result.get() == Type::LabelTy)
         return TokError("basic block pointers are invalid");
+      if (Result.get() == Type::VoidTy)
+        return TokError("pointers to void are invalid, use i8* instead");
       unsigned AddrSpace;
       if (ParseOptionalAddrSpace(AddrSpace) ||
           ParseToken(lltok::star, "expected '*' in address space"))