Don't build a call expression referring to a function which we're not allowed
to use. This makes very little difference right now (other than suppressing
follow-on errors in some cases), but will matter more once we support deduced
return types (we don't want expressions with undeduced return types in the
AST).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181107 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp
index 8d6924d..dcc7ad7 100644
--- a/lib/Sema/SemaExprCXX.cpp
+++ b/lib/Sema/SemaExprCXX.cpp
@@ -684,7 +684,8 @@
MarkFunctionReferenced(E->getExprLoc(), Destructor);
CheckDestructorAccess(E->getExprLoc(), Destructor,
PDiag(diag::err_access_dtor_exception) << Ty);
- DiagnoseUseOfDecl(Destructor, E->getExprLoc());
+ if (DiagnoseUseOfDecl(Destructor, E->getExprLoc()))
+ return ExprError();
return Owned(E);
}
@@ -1426,11 +1427,13 @@
// Mark the new and delete operators as referenced.
if (OperatorNew) {
- DiagnoseUseOfDecl(OperatorNew, StartLoc);
+ if (DiagnoseUseOfDecl(OperatorNew, StartLoc))
+ return ExprError();
MarkFunctionReferenced(StartLoc, OperatorNew);
}
if (OperatorDelete) {
- DiagnoseUseOfDecl(OperatorDelete, StartLoc);
+ if (DiagnoseUseOfDecl(OperatorDelete, StartLoc))
+ return ExprError();
MarkFunctionReferenced(StartLoc, OperatorDelete);
}
@@ -1446,7 +1449,8 @@
CheckDestructorAccess(StartLoc, dtor,
PDiag(diag::err_access_dtor)
<< BaseAllocType);
- DiagnoseUseOfDecl(dtor, StartLoc);
+ if (DiagnoseUseOfDecl(dtor, StartLoc))
+ return ExprError();
}
}
}
@@ -2204,7 +2208,8 @@
if (CXXDestructorDecl *Dtor = LookupDestructor(PointeeRD)) {
MarkFunctionReferenced(StartLoc,
const_cast<CXXDestructorDecl*>(Dtor));
- DiagnoseUseOfDecl(Dtor, StartLoc);
+ if (DiagnoseUseOfDecl(Dtor, StartLoc))
+ return ExprError();
}
// C++ [expr.delete]p3:
@@ -4819,7 +4824,8 @@
CheckDestructorAccess(E->getExprLoc(), Destructor,
PDiag(diag::err_access_dtor_temp)
<< E->getType());
- DiagnoseUseOfDecl(Destructor, E->getExprLoc());
+ if (DiagnoseUseOfDecl(Destructor, E->getExprLoc()))
+ return ExprError();
// If destructor is trivial, we can avoid the extra copy.
if (Destructor->isTrivial())
@@ -4974,7 +4980,8 @@
CheckDestructorAccess(Bind->getExprLoc(), Destructor,
PDiag(diag::err_access_dtor_temp)
<< Bind->getType());
- DiagnoseUseOfDecl(Destructor, Bind->getExprLoc());
+ if (DiagnoseUseOfDecl(Destructor, Bind->getExprLoc()))
+ return ExprError();
// We need a cleanup, but we don't need to remember the temporary.
ExprNeedsCleanups = true;