summaryrefslogtreecommitdiff
path: root/src/parser/antlr_input.h
diff options
context:
space:
mode:
authorMorgan Deters <mdeters@cs.nyu.edu>2013-02-22 16:48:13 -0500
committerMorgan Deters <mdeters@cs.nyu.edu>2013-03-08 19:30:49 -0500
commit56b7a4f494dfe069fc4cbdb1dcd05c23c9b59a1d (patch)
treea8dc4d5d2e1ecaba112fa67c9a61e27e5ef07c80 /src/parser/antlr_input.h
parent9817df56827b4ee0ee67a33361f8619c5d1df6ed (diff)
Disallow overflow in bitvector literals (parser only)
* For example, (_ bv5 1) is now an error instead of being silently truncated. * Probably inappropriate for 1.0.x because it changes exception specifications.
Diffstat (limited to 'src/parser/antlr_input.h')
-rw-r--r--src/parser/antlr_input.h9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/parser/antlr_input.h b/src/parser/antlr_input.h
index 68a62274d..a2fe99f52 100644
--- a/src/parser/antlr_input.h
+++ b/src/parser/antlr_input.h
@@ -285,7 +285,14 @@ inline Rational AntlrInput::tokenToRational(pANTLR3_COMMON_TOKEN token) {
inline BitVector AntlrInput::tokenToBitvector(pANTLR3_COMMON_TOKEN number, pANTLR3_COMMON_TOKEN size) {
std::string number_str = tokenTextSubstr(number, 2);
- return BitVector(tokenToUnsigned(size), Integer(number_str));
+ unsigned sz = tokenToUnsigned(size);
+ Integer val(number_str);
+ if(val.modByPow2(sz) != val) {
+ std::stringstream ss;
+ ss << "Overflow in bitvector construction (specified bitvector size " << sz << " too small to hold value " << tokenText(number) << ")";
+ throw std::invalid_argument(ss.str());
+ }
+ return BitVector(sz, val);
}
}/* CVC4::parser namespace */
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback