[llvm-branch-commits] [cfe-branch] r195815 - Merging r195303:
Bill Wendling
isanbard at gmail.com
Tue Nov 26 21:27:22 PST 2013
Author: void
Date: Tue Nov 26 23:27:22 2013
New Revision: 195815
URL: http://llvm.org/viewvc/llvm-project?rev=195815&view=rev
Log:
Merging r195303:
------------------------------------------------------------------------
r195303 | rsmith | 2013-11-20 17:53:02 -0800 (Wed, 20 Nov 2013) | 4 lines
PR10837: Warn if a null pointer constant is formed by a zero integer constant
expression that is not a zero literal, in C. This is a different, and more
targeted, approach than that in r194540.
------------------------------------------------------------------------
Added:
cfe/branches/release_34/test/Sema/warn-null.c
- copied unchanged from r195303, cfe/trunk/test/Sema/warn-null.c
Modified:
cfe/branches/release_34/ (props changed)
cfe/branches/release_34/lib/Sema/SemaExpr.cpp
cfe/branches/release_34/test/SemaTemplate/dependent-expr.cpp
Propchange: cfe/branches/release_34/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Nov 26 23:27:22 2013
@@ -1,4 +1,4 @@
/cfe/branches/type-system-rewrite:134693-134817
-/cfe/trunk:195126,195128,195135-195136,195146,195149,195154,195158,195163,195168,195174,195268,195283,195326,195329,195367,195384,195409,195420,195422,195501,195547,195556,195558,195587,195620,195669,195687,195693,195710,195716,195760
+/cfe/trunk:195126,195128,195135-195136,195146,195149,195154,195158,195163,195168,195174,195268,195283,195303,195326,195329,195367,195384,195409,195420,195422,195501,195547,195556,195558,195587,195620,195669,195687,195693,195710,195716,195760
/cfe/trunk/test:170344
/cfe/trunk/test/SemaTemplate:126920
Modified: cfe/branches/release_34/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_34/lib/Sema/SemaExpr.cpp?rev=195815&r1=195814&r2=195815&view=diff
==============================================================================
--- cfe/branches/release_34/lib/Sema/SemaExpr.cpp (original)
+++ cfe/branches/release_34/lib/Sema/SemaExpr.cpp Tue Nov 26 23:27:22 2013
@@ -6564,12 +6564,14 @@ Sema::CheckSingleAssignmentConstraints(Q
// C99 6.5.16.1p1: the left operand is a pointer and the right is
// a null pointer constant.
- if ((LHSType->isPointerType() ||
- LHSType->isObjCObjectPointerType() ||
- LHSType->isBlockPointerType())
- && RHS.get()->isNullPointerConstant(Context,
- Expr::NPC_ValueDependentIsNull)) {
- RHS = ImpCastExprToType(RHS.take(), LHSType, CK_NullToPointer);
+ if ((LHSType->isPointerType() || LHSType->isObjCObjectPointerType() ||
+ LHSType->isBlockPointerType()) &&
+ RHS.get()->isNullPointerConstant(Context,
+ Expr::NPC_ValueDependentIsNull)) {
+ CastKind Kind;
+ CXXCastPath Path;
+ CheckPointerConversion(RHS.get(), LHSType, Kind, Path, false);
+ RHS = ImpCastExprToType(RHS.take(), LHSType, Kind, VK_RValue, &Path);
return Compatible;
}
Modified: cfe/branches/release_34/test/SemaTemplate/dependent-expr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_34/test/SemaTemplate/dependent-expr.cpp?rev=195815&r1=195814&r2=195815&view=diff
==============================================================================
--- cfe/branches/release_34/test/SemaTemplate/dependent-expr.cpp (original)
+++ cfe/branches/release_34/test/SemaTemplate/dependent-expr.cpp Tue Nov 26 23:27:22 2013
@@ -79,3 +79,17 @@ template<typename T> struct CastDependen
return ((void*)(((unsigned long)(x)|0x1ul)));
}
};
+
+// Regression test for crasher in r194540.
+namespace PR10837 {
+ typedef void t(int);
+ template<typename> struct A {
+ void f();
+ static t g;
+ };
+ t *p;
+ template<typename T> void A<T>::f() {
+ p = g;
+ }
+ template struct A<int>;
+}
More information about the llvm-branch-commits
mailing list