AArch64/ARM64: make NEON vector list parsing a bit more robust
authorTim Northover <tnorthover@apple.com>
Tue, 6 May 2014 12:50:51 +0000 (12:50 +0000)
committerTim Northover <tnorthover@apple.com>
Tue, 6 May 2014 12:50:51 +0000 (12:50 +0000)
It doesn't change the results, but it seems silly not to diagnose obvious
problems early on.

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

lib/Target/ARM64/AsmParser/ARM64AsmParser.cpp
test/MC/ARM64/vector-lists.s

index 9ba1b73986bcf97a8e9b1fce89d83f73b65865c6..c5fb364a61ae7825dfa5244279fc770edd88e5a8 100644 (file)
@@ -3131,10 +3131,13 @@ bool ARM64AsmParser::parseVectorList(OperandVector &Operands) {
     }
   }
 
-  if (Parser.getTok().is(AsmToken::EndOfStatement))
-    Error(getLoc(), "'}' expected");
+  if (Parser.getTok().isNot(AsmToken::RCurly))
+    return Error(getLoc(), "'}' expected");
   Parser.Lex(); // Eat the '}' token.
 
+  if (Count > 4)
+    return Error(S, "invalid number of vectors");
+
   unsigned NumElements = 0;
   char ElementKind = 0;
   if (!Kind.empty())
index 0d026022375ea60be9ce6277cb17b2878878cf4d..a9b2d198e8686771af811e2cad9f206c02754112 100644 (file)
@@ -14,7 +14,7 @@
     ST4     {v0.8B-},[x0]
 
 // CHECK-ERRORS: error: invalid number of vectors
-// CHECK-ERRORS: error: unexpected token in argument list
+// CHECK-ERRORS: error: '}' expected
 // CHECK-ERRORS: error: mismatched register size suffix
 // CHECK-ERRORS: error: mismatched register size suffix
 // CHECK-ERRORS: error: vector register expected