diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2010-02-12 21:53:14 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2010-02-12 21:53:14 +0000 |
commit | 9a66c303c7024967a48877106384bf315c84e80e (patch) | |
tree | 7a7c617e2528e541332be0a6ae6ab18f4147918a | |
parent | f4aed5f8a30e39e169dcdef1c315f0f7a5699738 (diff) |
Complain if block-literal expression's parameter name is
missing (in c/objc mode). Fixes radar 7528255.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96017 91177308-0d34-0410-b5e6-96231b3b80d8
-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}} +} |