aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-01-12 21:30:55 +0000
committerChris Lattner <sabre@nondot.org>2010-01-12 21:30:55 +0000
commitcb329c506d0e041b9523618158ac925d620c24ac (patch)
treec01bbca9054e23c8810d399bab725570e92819b0
parent84d0a19828599e8623223632d59447fd498999cf (diff)
use DiagRuntimeBehavior to silence the div/rem by zero warning when
not in an evaluated context. This removes some bogus warnings. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93258 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Sema/SemaExpr.cpp6
-rw-r--r--test/Sema/exprs.c2
-rw-r--r--test/SemaTemplate/instantiate-expr-1.cpp3
-rw-r--r--test/SemaTemplate/instantiate-static-var.cpp2
4 files changed, 8 insertions, 5 deletions
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index 7dc13c4ad8..26c2e176cf 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -4868,7 +4868,8 @@ QualType Sema::CheckMultiplyDivideOperands(
// Check for division by zero.
if (isDiv &&
rex->isNullPointerConstant(Context, Expr::NPC_ValueDependentIsNotNull))
- Diag(Loc, diag::warn_division_by_zero) << rex->getSourceRange();
+ DiagRuntimeBehavior(Loc, PDiag(diag::warn_division_by_zero)
+ << rex->getSourceRange());
return compType;
}
@@ -4888,7 +4889,8 @@ QualType Sema::CheckRemainderOperands(
// Check for remainder by zero.
if (rex->isNullPointerConstant(Context, Expr::NPC_ValueDependentIsNotNull))
- Diag(Loc, diag::warn_remainder_by_zero) << rex->getSourceRange();
+ DiagRuntimeBehavior(Loc, PDiag(diag::warn_remainder_by_zero)
+ << rex->getSourceRange());
return compType;
}
diff --git a/test/Sema/exprs.c b/test/Sema/exprs.c
index b2f92e2c01..9059cac22e 100644
--- a/test/Sema/exprs.c
+++ b/test/Sema/exprs.c
@@ -120,5 +120,7 @@ void test17(int x) {
x = x % 0; // expected-warning {{remainder by zero is undefined}}
x /= 0; // expected-warning {{division by zero is undefined}}
x %= 0; // expected-warning {{remainder by zero is undefined}}
+
+ x = sizeof(x/0); // no warning.
}
diff --git a/test/SemaTemplate/instantiate-expr-1.cpp b/test/SemaTemplate/instantiate-expr-1.cpp
index 5752033fbd..663749ddce 100644
--- a/test/SemaTemplate/instantiate-expr-1.cpp
+++ b/test/SemaTemplate/instantiate-expr-1.cpp
@@ -35,8 +35,7 @@ void test_BitfieldMinus() {
template<int I, int J>
struct BitfieldDivide {
int bitfield : I / J; // expected-error{{expression is not an integer constant expression}} \
- // expected-note{{division by zero}} \
- // expected-warning {{division by zero is undefined}}
+ // expected-note{{division by zero}}
};
void test_BitfieldDivide() {
diff --git a/test/SemaTemplate/instantiate-static-var.cpp b/test/SemaTemplate/instantiate-static-var.cpp
index 1fcc36b43c..789fe3db87 100644
--- a/test/SemaTemplate/instantiate-static-var.cpp
+++ b/test/SemaTemplate/instantiate-static-var.cpp
@@ -2,7 +2,7 @@
template<typename T, T Divisor>
class X {
public:
- static const T value = 10 / Divisor; // expected-error{{in-class initializer is not an integral constant expression}} expected-warning {{division by zero is undefined}}
+ static const T value = 10 / Divisor; // expected-error{{in-class initializer is not an integral constant expression}}
};
int array1[X<int, 2>::value == 5? 1 : -1];