LLParser.cpp (193574) | LLParser.cpp (193630) |
---|---|
1//===-- LLParser.cpp - Parser Class ---------------------------------------===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// --- 1029 unchanged lines hidden (view full) --- 1038 default: return false; 1039 1040 // TypeRec ::= TypeRec '*' 1041 case lltok::star: 1042 if (Result.get() == Type::LabelTy) 1043 return TokError("basic block pointers are invalid"); 1044 if (Result.get() == Type::VoidTy) 1045 return TokError("pointers to void are invalid; use i8* instead"); | 1//===-- LLParser.cpp - Parser Class ---------------------------------------===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// --- 1029 unchanged lines hidden (view full) --- 1038 default: return false; 1039 1040 // TypeRec ::= TypeRec '*' 1041 case lltok::star: 1042 if (Result.get() == Type::LabelTy) 1043 return TokError("basic block pointers are invalid"); 1044 if (Result.get() == Type::VoidTy) 1045 return TokError("pointers to void are invalid; use i8* instead"); |
1046 if (!PointerType::isValidElementType(Result.get())) 1047 return TokError("pointer to this type is invalid"); |
|
1046 Result = HandleUpRefs(PointerType::getUnqual(Result.get())); 1047 Lex.Lex(); 1048 break; 1049 1050 // TypeRec ::= TypeRec 'addrspace' '(' uint32 ')' '*' 1051 case lltok::kw_addrspace: { 1052 if (Result.get() == Type::LabelTy) 1053 return TokError("basic block pointers are invalid"); 1054 if (Result.get() == Type::VoidTy) 1055 return TokError("pointers to void are invalid; use i8* instead"); | 1048 Result = HandleUpRefs(PointerType::getUnqual(Result.get())); 1049 Lex.Lex(); 1050 break; 1051 1052 // TypeRec ::= TypeRec 'addrspace' '(' uint32 ')' '*' 1053 case lltok::kw_addrspace: { 1054 if (Result.get() == Type::LabelTy) 1055 return TokError("basic block pointers are invalid"); 1056 if (Result.get() == Type::VoidTy) 1057 return TokError("pointers to void are invalid; use i8* instead"); |
1058 if (!PointerType::isValidElementType(Result.get())) 1059 return TokError("pointer to this type is invalid"); |
|
1056 unsigned AddrSpace; 1057 if (ParseOptionalAddrSpace(AddrSpace) || 1058 ParseToken(lltok::star, "expected '*' in address space")) 1059 return true; 1060 1061 Result = HandleUpRefs(PointerType::get(Result.get(), AddrSpace)); 1062 break; 1063 } --- 80 unchanged lines hidden (view full) --- 1144 return Error(TypeLoc, "argument can not have void type"); 1145 1146 if (Lex.getKind() == lltok::LocalVar || 1147 Lex.getKind() == lltok::StringConstant) { // FIXME: REMOVE IN LLVM 3.0 1148 Name = Lex.getStrVal(); 1149 Lex.Lex(); 1150 } 1151 | 1060 unsigned AddrSpace; 1061 if (ParseOptionalAddrSpace(AddrSpace) || 1062 ParseToken(lltok::star, "expected '*' in address space")) 1063 return true; 1064 1065 Result = HandleUpRefs(PointerType::get(Result.get(), AddrSpace)); 1066 break; 1067 } --- 80 unchanged lines hidden (view full) --- 1148 return Error(TypeLoc, "argument can not have void type"); 1149 1150 if (Lex.getKind() == lltok::LocalVar || 1151 Lex.getKind() == lltok::StringConstant) { // FIXME: REMOVE IN LLVM 3.0 1152 Name = Lex.getStrVal(); 1153 Lex.Lex(); 1154 } 1155 |
1152 if (!ArgTy->isFirstClassType() && !isa<OpaqueType>(ArgTy)) | 1156 if (!FunctionType::isValidArgumentType(ArgTy)) |
1153 return Error(TypeLoc, "invalid type for function argument"); 1154 1155 ArgList.push_back(ArgInfo(TypeLoc, ArgTy, Attrs, Name)); 1156 1157 while (EatIfPresent(lltok::comma)) { 1158 // Handle ... at end of arg list. 1159 if (EatIfPresent(lltok::dotdotdot)) { 1160 isVarArg = true; --- 79 unchanged lines hidden (view full) --- 1240 1241 std::vector<PATypeHolder> ParamsList; 1242 LocTy EltTyLoc = Lex.getLoc(); 1243 if (ParseTypeRec(Result)) return true; 1244 ParamsList.push_back(Result); 1245 1246 if (Result == Type::VoidTy) 1247 return Error(EltTyLoc, "struct element can not have void type"); | 1157 return Error(TypeLoc, "invalid type for function argument"); 1158 1159 ArgList.push_back(ArgInfo(TypeLoc, ArgTy, Attrs, Name)); 1160 1161 while (EatIfPresent(lltok::comma)) { 1162 // Handle ... at end of arg list. 1163 if (EatIfPresent(lltok::dotdotdot)) { 1164 isVarArg = true; --- 79 unchanged lines hidden (view full) --- 1244 1245 std::vector<PATypeHolder> ParamsList; 1246 LocTy EltTyLoc = Lex.getLoc(); 1247 if (ParseTypeRec(Result)) return true; 1248 ParamsList.push_back(Result); 1249 1250 if (Result == Type::VoidTy) 1251 return Error(EltTyLoc, "struct element can not have void type"); |
1252 if (!StructType::isValidElementType(Result)) 1253 return Error(EltTyLoc, "invalid element type for struct"); |
|
1248 1249 while (EatIfPresent(lltok::comma)) { 1250 EltTyLoc = Lex.getLoc(); 1251 if (ParseTypeRec(Result)) return true; 1252 1253 if (Result == Type::VoidTy) 1254 return Error(EltTyLoc, "struct element can not have void type"); | 1254 1255 while (EatIfPresent(lltok::comma)) { 1256 EltTyLoc = Lex.getLoc(); 1257 if (ParseTypeRec(Result)) return true; 1258 1259 if (Result == Type::VoidTy) 1260 return Error(EltTyLoc, "struct element can not have void type"); |
1261 if (!StructType::isValidElementType(Result)) 1262 return Error(EltTyLoc, "invalid element type for struct"); |
|
1255 1256 ParamsList.push_back(Result); 1257 } 1258 1259 if (ParseToken(lltok::rbrace, "expected '}' at end of struct")) 1260 return true; 1261 1262 std::vector<const Type*> ParamsListTy; --- 31 unchanged lines hidden (view full) --- 1294 "expected end of sequential type")) 1295 return true; 1296 1297 if (isVector) { 1298 if (Size == 0) 1299 return Error(SizeLoc, "zero element vector is illegal"); 1300 if ((unsigned)Size != Size) 1301 return Error(SizeLoc, "size too large for vector"); | 1263 1264 ParamsList.push_back(Result); 1265 } 1266 1267 if (ParseToken(lltok::rbrace, "expected '}' at end of struct")) 1268 return true; 1269 1270 std::vector<const Type*> ParamsListTy; --- 31 unchanged lines hidden (view full) --- 1302 "expected end of sequential type")) 1303 return true; 1304 1305 if (isVector) { 1306 if (Size == 0) 1307 return Error(SizeLoc, "zero element vector is illegal"); 1308 if ((unsigned)Size != Size) 1309 return Error(SizeLoc, "size too large for vector"); |
1302 if (!EltTy->isFloatingPoint() && !EltTy->isInteger()) | 1310 if (!VectorType::isValidElementType(EltTy)) |
1303 return Error(TypeLoc, "vector element type must be fp or integer"); 1304 Result = VectorType::get(EltTy, unsigned(Size)); 1305 } else { | 1311 return Error(TypeLoc, "vector element type must be fp or integer"); 1312 Result = VectorType::get(EltTy, unsigned(Size)); 1313 } else { |
1306 if (!EltTy->isFirstClassType() && !isa<OpaqueType>(EltTy)) | 1314 if (!ArrayType::isValidElementType(EltTy)) |
1307 return Error(TypeLoc, "invalid array element type"); 1308 Result = HandleUpRefs(ArrayType::get(EltTy, Size)); 1309 } 1310 return false; 1311} 1312 1313//===----------------------------------------------------------------------===// 1314// Function Semantic Analysis. --- 1974 unchanged lines hidden --- | 1315 return Error(TypeLoc, "invalid array element type"); 1316 Result = HandleUpRefs(ArrayType::get(EltTy, Size)); 1317 } 1318 return false; 1319} 1320 1321//===----------------------------------------------------------------------===// 1322// Function Semantic Analysis. --- 1974 unchanged lines hidden --- |