Skip to content

Commit 3a85829

Browse files
committed
Sema: DeclChecker::visitFuncDecl() does everything in the 'first pass'
1 parent f250bdb commit 3a85829

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

lib/Sema/TypeCheckDecl.cpp

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4771,22 +4771,20 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
47714771
}
47724772

47734773
void visitFuncDecl(FuncDecl *FD) {
4774-
if (!IsFirstPass) {
4775-
if (FD->hasBody()) {
4776-
// Record the body.
4777-
TC.definedFunctions.push_back(FD);
4778-
} else if (requiresDefinition(FD)) {
4779-
// Complain if we should have a body.
4780-
TC.diagnose(FD->getLoc(), diag::func_decl_without_brace);
4781-
}
4782-
4774+
if (!IsFirstPass)
47834775
return;
4784-
}
47854776

47864777
TC.validateDecl(FD);
47874778
checkAccessControl(TC, FD);
4788-
}
47894779

4780+
if (FD->hasBody()) {
4781+
// Record the body.
4782+
TC.definedFunctions.push_back(FD);
4783+
} else if (requiresDefinition(FD)) {
4784+
// Complain if we should have a body.
4785+
TC.diagnose(FD->getLoc(), diag::func_decl_without_brace);
4786+
}
4787+
}
47904788

47914789
void visitModuleDecl(ModuleDecl *) { }
47924790

test/decl/overload.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,9 @@ struct X6<T> {
219219

220220
extension X6 {
221221
var k: Int { return 0 } // expected-note{{previously declared here}}
222-
func k() // expected-error{{invalid redeclaration of 'k()'}}
222+
func k()
223+
// expected-error@-1{{invalid redeclaration of 'k()'}}
224+
// expected-error@-2{{expected '{' in body of function declaration}}
223225
}
224226

225227
// Subscripting

0 commit comments

Comments
 (0)