Skip to content

Commit c77f7ef

Browse files
authored
Require type arguments for generic functions in checked scopes. (#589)
We previously added code to allow type arguments to be omitted at some calls to generic function calls. When type arguments are omitted, void is used as the value for each type argument instead. We allowed type arguments to be omitted at calls in unchecked scopes and checked bounds_only scopes. I think the difference in behavior between different forms of checked scopes will likely be confusing, so require type arguments for all checked scopes. Testing: - Added tests to the Checked C repo that check this behavior. - Passed automated testing for Linux. - Passed local testing for Windows.
1 parent 18a77c6 commit c77f7ef

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lib/Sema/SemaExpr.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5486,13 +5486,13 @@ ExprResult Sema::ActOnCallExpr(Scope *Scope, Expr *Fn, SourceLocation LParenLoc,
54865486
// where no type arguments have been specified.
54875487
if (Fn->getType()->isItypeGenericFunctionType()) {
54885488
// It is an error in a checked scope.
5489-
if (GetCheckedScopeInfo() == CSS_BoundsAndTypes) {
5489+
CheckedScopeSpecifier CSS = GetCheckedScopeInfo();
5490+
if (CSS == CSS_BoundsAndTypes || CSS == CSS_Bounds) {
54905491
Diag(Fn->getLocEnd(),
54915492
diag::err_expected_type_argument_list_for_itype_generic_call);
54925493
return ExprError();
54935494
}
5494-
// In an unchecked or checked bounds-only scope, pass void types
5495-
// as the type arguments.
5495+
// In an unchecked scope, pass void types as the type arguments.
54965496
if (DeclRefExpr *DR = dyn_cast<DeclRefExpr>(Fn)) {
54975497
SmallVector<DeclRefExpr::GenericInstInfo::TypeArgument, 4>
54985498
typeArgumentInfos;
@@ -5507,7 +5507,7 @@ ExprResult Sema::ActOnCallExpr(Scope *Scope, Expr *Fn, SourceLocation LParenLoc,
55075507
// a type application node.
55085508
DR->SetGenericInstInfo(Context, typeArgumentInfos);
55095509

5510-
// Substitute Type Variables of Function Type in DeclRefExpr
5510+
// Substitute type arguments into function type in DeclRefExpr
55115511
QualType NewTy =
55125512
SubstituteTypeArgs(DR->getType(), typeArgumentInfos);
55135513
DR->setType(NewTy);

0 commit comments

Comments
 (0)