зеркало из https://github.com/microsoft/clang.git
Instantiate return statements.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71825 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
fd0e628aa8
Коммит
03d77760a5
|
@ -823,7 +823,7 @@ Sema::ActOnReturnStmt(SourceLocation ReturnLoc, ExprArg rex) {
|
|||
return Owned(new (Context) ReturnStmt(ReturnLoc, RetValExp));
|
||||
}
|
||||
|
||||
if (!RetValExp) {
|
||||
if (!RetValExp && !FnRetType->isDependentType()) {
|
||||
unsigned DiagID = diag::warn_return_missing_expr; // C90 6.6.6.4p4
|
||||
// C99 6.8.6.4p1 (ext_ since GCC warns)
|
||||
if (getLangOptions().C99) DiagID = diag::ext_return_missing_expr;
|
||||
|
|
|
@ -447,6 +447,7 @@ namespace {
|
|||
OwningStmtResult VisitExpr(Expr *E);
|
||||
OwningStmtResult VisitLabelStmt(LabelStmt *S);
|
||||
OwningStmtResult VisitGotoStmt(GotoStmt *S);
|
||||
OwningStmtResult VisitReturnStmt(ReturnStmt *S);
|
||||
|
||||
// Base case. I'm supposed to ignore this.
|
||||
OwningStmtResult VisitStmt(Stmt *S) {
|
||||
|
@ -499,6 +500,19 @@ Sema::OwningStmtResult TemplateStmtInstantiator::VisitGotoStmt(GotoStmt *S) {
|
|||
S->getLabel()->getID());
|
||||
}
|
||||
|
||||
Sema::OwningStmtResult
|
||||
TemplateStmtInstantiator::VisitReturnStmt(ReturnStmt *S) {
|
||||
Sema::OwningExprResult Result = SemaRef.ExprEmpty();
|
||||
if (Expr *E = S->getRetValue()) {
|
||||
Result = SemaRef.InstantiateExpr(E, TemplateArgs);
|
||||
|
||||
if (Result.isInvalid())
|
||||
return SemaRef.StmtError();
|
||||
}
|
||||
|
||||
return SemaRef.ActOnReturnStmt(S->getReturnLoc(), move(Result));
|
||||
}
|
||||
|
||||
Sema::OwningStmtResult
|
||||
TemplateStmtInstantiator::VisitCompoundStmt(CompoundStmt *S) {
|
||||
// FIXME: We need an *easy* RAII way to delete these statements if
|
||||
|
|
|
@ -37,3 +37,16 @@ struct X3 {
|
|||
};
|
||||
|
||||
template struct X3<int>;
|
||||
|
||||
template <typename T> struct X4 {
|
||||
T f() const {
|
||||
return; // expected-warning{{non-void function 'f' should return a value}}
|
||||
}
|
||||
|
||||
T g() const {
|
||||
return 1; // expected-warning{{void function 'g' should not return a value}}
|
||||
}
|
||||
};
|
||||
|
||||
template struct X4<void>; // expected-note{{in instantiation of template class 'X4<void>' requested here}}
|
||||
template struct X4<int>; // expected-note{{in instantiation of template class 'X4<int>' requested here}}
|
||||
|
|
Загрузка…
Ссылка в новой задаче