diff options
author | Reid Spencer <rspencer@reidspencer.com> | 2006-12-20 17:20:09 +0000 |
---|---|---|
committer | Reid Spencer <rspencer@reidspencer.com> | 2006-12-20 17:20:09 +0000 |
commit | 9ffad0a43f189bbc75139bf49cb0114882dc14a9 (patch) | |
tree | e5d8bea36ae7b48c2abeb16e9ff62b83a0480d9b | |
parent | 3bad2533bb18d45a811e56d9fd3a2d1e7b94be9e (diff) |
Allow negative constants for unsigned integers and unsigned constants
greater than MAX_INT64 for signed integers. This is now valid and is just
waiting for the distinction between signed and unsigned to go away.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32716 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/AsmParser/llvmAsmParser.y | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/lib/AsmParser/llvmAsmParser.y b/lib/AsmParser/llvmAsmParser.y index 05fc57d82c..41fcb28ba8 100644 --- a/lib/AsmParser/llvmAsmParser.y +++ b/lib/AsmParser/llvmAsmParser.y @@ -926,7 +926,6 @@ Module *llvm::RunVMAsmParser(const char * AsmString, Module * M) { // EUINT64VAL - A positive number within uns. long long range %token <UInt64Val> EUINT64VAL -%type <SInt64Val> EINT64VAL %token <SIntVal> SINTVAL // Signed 32 bit ints... %token <UIntVal> UINTVAL // Unsigned 32 bit ints... @@ -995,15 +994,6 @@ INTVAL : UINTVAL { CHECK_FOR_ERROR }; - -EINT64VAL : ESINT64VAL; // These have same type and can't cause problems... -EINT64VAL : EUINT64VAL { - if ($1 > (uint64_t)INT64_MAX) // Outside of my range! - GEN_ERROR("Value too large for type!"); - $$ = (int64_t)$1; - CHECK_FOR_ERROR -}; - // Operations that are notably excluded from this list include: // RET, BR, & SWITCH because they end basic blocks and are treated specially. // @@ -1486,7 +1476,13 @@ ConstVal: Types '[' ConstVector ']' { // Nonempty unsized arr delete $1; CHECK_FOR_ERROR } - | SIntType EINT64VAL { // integral constants + | SIntType ESINT64VAL { // integral constants + if (!ConstantInt::isValueValidForType($1, $2)) + GEN_ERROR("Constant value doesn't fit in type!"); + $$ = ConstantInt::get($1, $2); + CHECK_FOR_ERROR + } + | SIntType EUINT64VAL { // integral constants if (!ConstantInt::isValueValidForType($1, $2)) GEN_ERROR("Constant value doesn't fit in type!"); $$ = ConstantInt::get($1, $2); @@ -1498,6 +1494,12 @@ ConstVal: Types '[' ConstVector ']' { // Nonempty unsized arr $$ = ConstantInt::get($1, $2); CHECK_FOR_ERROR } + | UIntType ESINT64VAL { + if (!ConstantInt::isValueValidForType($1, $2)) + GEN_ERROR("Constant value doesn't fit in type!"); + $$ = ConstantInt::get($1, $2); + CHECK_FOR_ERROR + } | BOOL TRUETOK { // Boolean constants $$ = ConstantBool::getTrue(); CHECK_FOR_ERROR |