diff options
-rw-r--r-- | lib/Sema/SemaDecl.cpp | 1 | ||||
-rw-r--r-- | lib/Sema/SemaExpr.cpp | 11 | ||||
-rw-r--r-- | test/Sema/block-args.c | 6 |
3 files changed, 16 insertions, 2 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index feb9f8511c..1fc08ce031 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -3875,6 +3875,7 @@ Sema::ActOnParamDeclarator(Scope *S, Declarator &D) { // Recover by removing the name II = 0; D.SetIdentifier(0, D.getIdentifierLoc()); + D.setInvalidType(true); } } } diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index 940c3d3e7f..633884f673 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -6830,8 +6830,15 @@ void Sema::ActOnBlockArguments(Declarator &ParamInfo, Scope *CurScope) { // empty arg list, don't push any params. CurBlock->isVariadic = false; } else if (FTI.hasPrototype) { - for (unsigned i = 0, e = FTI.NumArgs; i != e; ++i) - CurBlock->Params.push_back(FTI.ArgInfo[i].Param.getAs<ParmVarDecl>()); + for (unsigned i = 0, e = FTI.NumArgs; i != e; ++i) { + ParmVarDecl *Param = FTI.ArgInfo[i].Param.getAs<ParmVarDecl>(); + if (Param->getIdentifier() == 0 && + !Param->isImplicit() && + !Param->isInvalidDecl() && + !getLangOptions().CPlusPlus) + Diag(Param->getLocation(), diag::err_parameter_name_omitted); + CurBlock->Params.push_back(Param); + } CurBlock->isVariadic = FTI.isVariadic; } CurBlock->TheDecl->setParams(CurBlock->Params.data(), diff --git a/test/Sema/block-args.c b/test/Sema/block-args.c index 08af9b3773..a07c82e75a 100644 --- a/test/Sema/block-args.c +++ b/test/Sema/block-args.c @@ -27,3 +27,9 @@ int main(int argc, char** argv) { argCount = 3; }(argc); } + +// radar 7528255 +void f0() { + ^(int, double d, char) {}(1, 1.34, 'a'); // expected-error {{parameter name omitted}} \ + // expected-error {{parameter name omitted}} +} |