[cfe-commits] r96017 - in /cfe/trunk: lib/Sema/SemaDecl.cpp lib/Sema/SemaExpr.cpp test/Sema/block-args.c

Fariborz Jahanian fjahanian at apple.com
Fri Feb 12 13:53:15 PST 2010


Author: fjahanian
Date: Fri Feb 12 15:53:14 2010
New Revision: 96017

URL: http://llvm.org/viewvc/llvm-project?rev=96017&view=rev
Log:
Complain if block-literal expression's parameter name is
missing (in c/objc mode). Fixes radar 7528255.

Modified:
    cfe/trunk/lib/Sema/SemaDecl.cpp
    cfe/trunk/lib/Sema/SemaExpr.cpp
    cfe/trunk/test/Sema/block-args.c

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=96017&r1=96016&r2=96017&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Fri Feb 12 15:53:14 2010
@@ -3875,6 +3875,7 @@
         // Recover by removing the name
         II = 0;
         D.SetIdentifier(0, D.getIdentifierLoc());
+        D.setInvalidType(true);
       }
     }
   }

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=96017&r1=96016&r2=96017&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Fri Feb 12 15:53:14 2010
@@ -6830,8 +6830,15 @@
     // 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(),

Modified: cfe/trunk/test/Sema/block-args.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/block-args.c?rev=96017&r1=96016&r2=96017&view=diff

==============================================================================
--- cfe/trunk/test/Sema/block-args.c (original)
+++ cfe/trunk/test/Sema/block-args.c Fri Feb 12 15:53:14 2010
@@ -27,3 +27,9 @@
     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}}
+}





More information about the cfe-commits mailing list