[cfe-commits] r93258 - in /cfe/trunk: lib/Sema/SemaExpr.cpp test/Sema/exprs.c test/SemaTemplate/instantiate-expr-1.cpp test/SemaTemplate/instantiate-static-var.cpp
Chris Lattner
sabre at nondot.org
Tue Jan 12 13:30:55 PST 2010
Author: lattner
Date: Tue Jan 12 15:30:55 2010
New Revision: 93258
URL: http://llvm.org/viewvc/llvm-project?rev=93258&view=rev
Log:
use DiagRuntimeBehavior to silence the div/rem by zero warning when
not in an evaluated context. This removes some bogus warnings.
Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/Sema/exprs.c
cfe/trunk/test/SemaTemplate/instantiate-expr-1.cpp
cfe/trunk/test/SemaTemplate/instantiate-static-var.cpp
Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=93258&r1=93257&r2=93258&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Tue Jan 12 15:30:55 2010
@@ -4868,7 +4868,8 @@
// 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 @@
// 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;
}
Modified: cfe/trunk/test/Sema/exprs.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/exprs.c?rev=93258&r1=93257&r2=93258&view=diff
==============================================================================
--- cfe/trunk/test/Sema/exprs.c (original)
+++ cfe/trunk/test/Sema/exprs.c Tue Jan 12 15:30:55 2010
@@ -120,5 +120,7 @@
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.
}
Modified: cfe/trunk/test/SemaTemplate/instantiate-expr-1.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/instantiate-expr-1.cpp?rev=93258&r1=93257&r2=93258&view=diff
==============================================================================
--- cfe/trunk/test/SemaTemplate/instantiate-expr-1.cpp (original)
+++ cfe/trunk/test/SemaTemplate/instantiate-expr-1.cpp Tue Jan 12 15:30:55 2010
@@ -35,8 +35,7 @@
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() {
Modified: cfe/trunk/test/SemaTemplate/instantiate-static-var.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/instantiate-static-var.cpp?rev=93258&r1=93257&r2=93258&view=diff
==============================================================================
--- cfe/trunk/test/SemaTemplate/instantiate-static-var.cpp (original)
+++ cfe/trunk/test/SemaTemplate/instantiate-static-var.cpp Tue Jan 12 15:30:55 2010
@@ -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];
More information about the cfe-commits
mailing list