[cfe-commits] r167565 - in /cfe/trunk: lib/Sema/SemaChecking.cpp test/SemaCXX/null_in_arithmetic_ops.cpp
David Blaikie
dblaikie at gmail.com
Wed Nov 7 16:41:20 PST 2012
Author: dblaikie
Date: Wed Nov 7 18:41:20 2012
New Revision: 167565
URL: http://llvm.org/viewvc/llvm-project?rev=167565&view=rev
Log:
PR14284: crash on ext-valid returning NULL from a void function
Modified:
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/test/SemaCXX/null_in_arithmetic_ops.cpp
Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=167565&r1=167564&r2=167565&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Wed Nov 7 18:41:20 2012
@@ -4799,7 +4799,8 @@
if ((E->isNullPointerConstant(S.Context, Expr::NPC_ValueDependentIsNotNull)
== Expr::NPCK_GNUNull) && !Target->isAnyPointerType()
- && !Target->isBlockPointerType() && !Target->isMemberPointerType()) {
+ && !Target->isBlockPointerType() && !Target->isMemberPointerType()
+ && Target->isScalarType()) {
SourceLocation Loc = E->getSourceRange().getBegin();
if (Loc.isMacroID())
Loc = S.SourceMgr.getImmediateExpansionRange(Loc).first;
Modified: cfe/trunk/test/SemaCXX/null_in_arithmetic_ops.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/null_in_arithmetic_ops.cpp?rev=167565&r1=167564&r2=167565&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/null_in_arithmetic_ops.cpp (original)
+++ cfe/trunk/test/SemaCXX/null_in_arithmetic_ops.cpp Wed Nov 7 18:41:20 2012
@@ -90,4 +90,6 @@
b = e == NULL || NULL == e || e != NULL || NULL != e;
b = f == NULL || NULL == f || f != NULL || NULL != f;
b = "f" == NULL || NULL == "f" || "f" != NULL || NULL != "f";
+
+ return NULL; // expected-error{{void function 'f' should not return a value}}
}
More information about the cfe-commits
mailing list