]> granicus.if.org Git - clang/commitdiff
PR14284: crash on ext-valid returning NULL from a void function
authorDavid Blaikie <dblaikie@gmail.com>
Thu, 8 Nov 2012 00:41:20 +0000 (00:41 +0000)
committerDavid Blaikie <dblaikie@gmail.com>
Thu, 8 Nov 2012 00:41:20 +0000 (00:41 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@167565 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaChecking.cpp
test/SemaCXX/null_in_arithmetic_ops.cpp

index a434425db868bce97d4a5a5358dc22db6b53bac3..692a210ef304af733cdfe1d4b6082d8e5a5f9925 100644 (file)
@@ -4799,7 +4799,8 @@ void CheckImplicitConversion(Sema &S, Expr *E, QualType T,
 
   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;
index a6c0dbfc6560e5cb7d36a121ca1ef1b9305fabdc..a919213fb208501b00d7c20830ff911f70873a72 100644 (file)
@@ -90,4 +90,6 @@ void f() {
   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}}
 }