summaryrefslogtreecommitdiffstats
path: root/Source/LexerParser/cmExprParser.y
diff options
context:
space:
mode:
authorDaniel Franke <franke@edf-online.de>2018-05-18 19:59:46 (GMT)
committerBrad King <brad.king@kitware.com>2018-06-26 18:21:18 (GMT)
commit8661e7052c4f711f13e7168231276e23c4c0defd (patch)
treeeddefa9320ae82c187179b9e9664a9c12008e172 /Source/LexerParser/cmExprParser.y
parent7c4c13ffef87d748b896e2c762ad0b2c00afcd31 (diff)
downloadCMake-8661e7052c4f711f13e7168231276e23c4c0defd.zip
CMake-8661e7052c4f711f13e7168231276e23c4c0defd.tar.gz
CMake-8661e7052c4f711f13e7168231276e23c4c0defd.tar.bz2
math: Diagnose divide-by-zero
Diffstat (limited to 'Source/LexerParser/cmExprParser.y')
-rw-r--r--Source/LexerParser/cmExprParser.y4
1 files changed, 4 insertions, 0 deletions
diff --git a/Source/LexerParser/cmExprParser.y b/Source/LexerParser/cmExprParser.y
index 575ffa7..510daaa 100644
--- a/Source/LexerParser/cmExprParser.y
+++ b/Source/LexerParser/cmExprParser.y
@@ -18,6 +18,7 @@ Modify cmExprParser.cxx:
#include <stdlib.h>
#include <string.h>
+#include <stdexcept>
/*-------------------------------------------------------------------------*/
#define YYDEBUG 1
@@ -129,6 +130,9 @@ term:
$<Number>$ = $<Number>1 * $<Number>3;
}
| term exp_DIVIDE unary {
+ if (yyvsp[0].Number == 0) {
+ throw std::overflow_error("divide by zero");
+ }
$<Number>$ = $<Number>1 / $<Number>3;
}
| term exp_MOD unary {