[cfe-commits] r146580 - in /cfe/trunk: lib/Parse/ParseDecl.cpp test/SemaCXX/warn-thread-safety-parsing.cpp

DeLesley Hutchins delesley at google.com
Wed Dec 14 11:36:06 PST 2011


Author: delesley
Date: Wed Dec 14 13:36:06 2011
New Revision: 146580

URL: http://llvm.org/viewvc/llvm-project?rev=146580&view=rev
Log:
Allow empty argument lists in thread safety attributes

Modified:
    cfe/trunk/lib/Parse/ParseDecl.cpp
    cfe/trunk/test/SemaCXX/warn-thread-safety-parsing.cpp

Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=146580&r1=146579&r2=146580&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Wed Dec 14 13:36:06 2011
@@ -843,7 +843,7 @@
   bool ArgExprsOk = true;
   
   // now parse the list of expressions
-  while (1) {
+  while (Tok.isNot(tok::r_paren)) {
     ExprResult ArgExpr(ParseAssignmentExpression());
     if (ArgExpr.isInvalid()) {
       ArgExprsOk = false;
@@ -857,7 +857,7 @@
     ConsumeToken(); // Eat the comma, move to the next argument
   }
   // Match the ')'.
-  if (ArgExprsOk && !T.consumeClose()) {
+  if (ArgExprsOk && !T.consumeClose() && ArgExprs.size() > 0) {
     Attrs.addNew(&AttrName, AttrNameLoc, 0, AttrNameLoc, 0, SourceLocation(),
                  ArgExprs.take(), ArgExprs.size());
   }

Modified: cfe/trunk/test/SemaCXX/warn-thread-safety-parsing.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-thread-safety-parsing.cpp?rev=146580&r1=146579&r2=146580&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/warn-thread-safety-parsing.cpp (original)
+++ cfe/trunk/test/SemaCXX/warn-thread-safety-parsing.cpp Wed Dec 14 13:36:06 2011
@@ -1253,3 +1253,12 @@
   Mu mu;
 };
 
+//-------------------------
+// Empty argument lists
+//-------------------------
+
+class __attribute__((lockable)) EmptyArgListsTest {
+  void lock() __attribute__((exclusive_lock_function())) { }
+  void unlock() __attribute__((unlock_function())) { }
+};
+





More information about the cfe-commits mailing list