aboutsummaryrefslogtreecommitdiff
path: root/lib/ubsan/lit_tests/Integer/div-zero.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/ubsan/lit_tests/Integer/div-zero.cpp')
-rw-r--r--lib/ubsan/lit_tests/Integer/div-zero.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/ubsan/lit_tests/Integer/div-zero.cpp b/lib/ubsan/lit_tests/Integer/div-zero.cpp
new file mode 100644
index 000000000000..b2a839566c5f
--- /dev/null
+++ b/lib/ubsan/lit_tests/Integer/div-zero.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang -fsanitize=integer-divide-by-zero -DDIVIDEND=0 %s -o %t && %t 2>&1 | FileCheck %s
+// RUN: %clang -fsanitize=integer-divide-by-zero -DDIVIDEND=1U %s -o %t && %t 2>&1 | FileCheck %s
+// RUN: %clang -fsanitize=float-divide-by-zero -DDIVIDEND=1.5 %s -o %t && %t 2>&1 | FileCheck %s
+// RUN: %clang -fsanitize=integer-divide-by-zero -DDIVIDEND='intmax(123)' %s -o %t && %t 2>&1 | FileCheck %s
+
+#ifdef __SIZEOF_INT128__
+typedef __int128 intmax;
+#else
+typedef long long intmax;
+#endif
+
+int main() {
+ // CHECK: div-zero.cpp:[[@LINE+1]]:12: runtime error: division by zero
+ DIVIDEND / 0;
+}