Fix newly-introduced 4.3 warnings
[oota-llvm.git] / lib / AsmParser / llvmAsmParser.y.cvs
index 9674bba4d53bbfa3e7777a133c0e75c89116dba7..9e9da4723dca3eae625704cde6eb4893b6470fdc 100644 (file)
@@ -378,7 +378,8 @@ static Value *getExistingVal(const Type *Ty, const ValID &D) {
   // Check to make sure that "Ty" is an integral type, and that our
   // value will fit into the specified type...
   case ValID::ConstSIntVal:    // Is it a constant pool reference??
-    if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
+    if (!isa<IntegerType>(Ty) ||
+        !ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
       GenerateError("Signed integral constant '" +
                      itostr(D.ConstPool64) + "' is invalid for type '" +
                      Ty->getDescription() + "'");
@@ -387,20 +388,23 @@ static Value *getExistingVal(const Type *Ty, const ValID &D) {
     return ConstantInt::get(Ty, D.ConstPool64, true);
 
   case ValID::ConstUIntVal:     // Is it an unsigned const pool reference?
-    if (!ConstantInt::isValueValidForType(Ty, D.UConstPool64)) {
-      if (!ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
-        GenerateError("Integral constant '" + utostr(D.UConstPool64) +
-                       "' is invalid or out of range");
-        return 0;
-      } else {     // This is really a signed reference.  Transmogrify.
-        return ConstantInt::get(Ty, D.ConstPool64, true);
-      }
-    } else {
+    if (isa<IntegerType>(Ty) &&
+        ConstantInt::isValueValidForType(Ty, D.UConstPool64))
       return ConstantInt::get(Ty, D.UConstPool64);
+
+    if (!isa<IntegerType>(Ty) ||
+        !ConstantInt::isValueValidForType(Ty, D.ConstPool64)) {
+      GenerateError("Integral constant '" + utostr(D.UConstPool64) +
+                    "' is invalid or out of range for type '" +
+                    Ty->getDescription() + "'");
+      return 0;
     }
+    // This is really a signed reference.  Transmogrify.
+    return ConstantInt::get(Ty, D.ConstPool64, true);
 
   case ValID::ConstFPVal:        // Is it a floating point const pool reference?
-    if (!ConstantFP::isValueValidForType(Ty, *D.ConstPoolFP)) {
+    if (!Ty->isFloatingPoint() ||
+        !ConstantFP::isValueValidForType(Ty, *D.ConstPoolFP)) {
       GenerateError("FP constant invalid for type");
       return 0;
     }
@@ -574,12 +578,13 @@ static BasicBlock *getBBVal(const ValID &ID) {
   } if (ID.Type == ValID::LocalName) {
     std::string Name = ID.getName();
     Value *N = CurFun.CurrentFunction->getValueSymbolTable().lookup(Name);
-    if (N)
+    if (N) {
       if (N->getType()->getTypeID() == Type::LabelTyID)
         BB = cast<BasicBlock>(N);
       else
         GenerateError("Reference to label '" + Name + "' is actually of type '"+
           N->getType()->getDescription() + "'");
+    }
   } else if (ID.Type == ValID::LocalID) {
     if (ID.Num < CurFun.NextValNum && ID.Num < CurFun.Values.size()) {
       if (CurFun.Values[ID.Num]->getType()->getTypeID() == Type::LabelTyID)
@@ -970,7 +975,7 @@ Module *llvm::RunVMAsmParser(llvm::MemoryBuffer *MB) {
 
   llvm::GlobalValue::LinkageTypes         Linkage;
   llvm::GlobalValue::VisibilityTypes      Visibility;
-  uint16_t                          ParamAttrs;
+  llvm::ParameterAttributes         ParamAttrs;
   llvm::APInt                       *APIntVal;
   int64_t                           SInt64Val;
   uint64_t                          UInt64Val;
@@ -1089,6 +1094,7 @@ Module *llvm::RunVMAsmParser(llvm::MemoryBuffer *MB) {
 // Other Operators
 %token <OtherOpVal> PHI_TOK SELECT VAARG
 %token <OtherOpVal> EXTRACTELEMENT INSERTELEMENT SHUFFLEVECTOR
+%token <OtherOpVal> GETRESULT
 
 // Function Attributes
 %token SIGNEXT ZEROEXT NORETURN INREG SRET NOUNWIND NOALIAS BYVAL NEST
@@ -1729,7 +1735,7 @@ ConstVal: Types '[' ConstVector ']' { // Nonempty unsized arr
       GEN_ERROR("Invalid upreference in type: " + (*$1)->getDescription());
     const PointerType *Ty = dyn_cast<PointerType>($1->get());
     if (Ty == 0)
-      GEN_ERROR("Global const reference must be a pointer type");
+      GEN_ERROR("Global const reference must be a pointer type " + (*$1)->getDescription());
 
     // ConstExprs can exist in the body of a function, thus creating
     // GlobalValues whenever they refer to a variable.  Because we are in
@@ -3126,6 +3132,14 @@ MemoryInst : MALLOC Types OptCAlign {
     $$ = new StoreInst($3, tmpVal, $1, $7);
     delete $5;
   }
+| GETRESULT Types LocalName ',' ConstVal  {
+  ValID TmpVID = ValID::createLocalName(*$3);
+  Value *TmpVal = getVal($2->get(), TmpVID);
+  if (!GetResultInst::isValidOperands(TmpVal, $5))
+      GEN_ERROR("Invalid getresult operands");
+    $$ = new GetResultInst(TmpVal, $5);
+    CHECK_FOR_ERROR
+  }
   | GETELEMENTPTR Types ValueRef IndexList {
     if (!UpRefs.empty())
       GEN_ERROR("Invalid upreference in type: " + (*$2)->getDescription());