[cfe-commits] r39256 - in /cfe/cfe/trunk: AST/SemaDecl.cpp Sema/SemaDecl.cpp

sabre at cs.uiuc.edu sabre at cs.uiuc.edu
Wed Jul 11 09:42:02 PDT 2007


Author: sabre
Date: Wed Jul 11 11:42:02 2007
New Revision: 39256

URL: http://llvm.org/viewvc/llvm-project?rev=39256&view=rev
Log:
Handle C99 6.7.5.3p10, fixing test/Parser/attributes.c

Modified:
    cfe/cfe/trunk/AST/SemaDecl.cpp
    cfe/cfe/trunk/Sema/SemaDecl.cpp

Modified: cfe/cfe/trunk/AST/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/AST/SemaDecl.cpp?rev=39256&r1=39255&r2=39256&view=diff

==============================================================================
--- cfe/cfe/trunk/AST/SemaDecl.cpp (original)
+++ cfe/cfe/trunk/AST/SemaDecl.cpp Wed Jul 11 11:42:02 2007
@@ -163,8 +163,16 @@
   
   // Create Decl objects for each parameter, adding them to the FunctionDecl.
   SmallVector<VarDecl*, 16> Params;
-  for (unsigned i = 0, e = FTI.NumArgs; i != e; ++i)
-    Params.push_back(ParseParamDeclarator(D.getTypeObject(0), i, FnBodyScope));
+  
+  // Check for C99 6.7.5.3p10 - foo(void) is a non-varargs function that takes
+  // no arguments, not a function that takes a single void argument.
+  if (FTI.NumArgs == 1 && !FTI.isVariadic && FTI.ArgInfo[0].Ident == 0 &&
+      FTI.ArgInfo[0].TypeInfo == Context.VoidTy.getAsOpaquePtr()) {
+    
+  } else {
+    for (unsigned i = 0, e = FTI.NumArgs; i != e; ++i)
+      Params.push_back(ParseParamDeclarator(D.getTypeObject(0), i,FnBodyScope));
+  }
   
   FD->setParams(&Params[0], Params.size());
   

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

==============================================================================
--- cfe/cfe/trunk/Sema/SemaDecl.cpp (original)
+++ cfe/cfe/trunk/Sema/SemaDecl.cpp Wed Jul 11 11:42:02 2007
@@ -163,8 +163,16 @@
   
   // Create Decl objects for each parameter, adding them to the FunctionDecl.
   SmallVector<VarDecl*, 16> Params;
-  for (unsigned i = 0, e = FTI.NumArgs; i != e; ++i)
-    Params.push_back(ParseParamDeclarator(D.getTypeObject(0), i, FnBodyScope));
+  
+  // Check for C99 6.7.5.3p10 - foo(void) is a non-varargs function that takes
+  // no arguments, not a function that takes a single void argument.
+  if (FTI.NumArgs == 1 && !FTI.isVariadic && FTI.ArgInfo[0].Ident == 0 &&
+      FTI.ArgInfo[0].TypeInfo == Context.VoidTy.getAsOpaquePtr()) {
+    
+  } else {
+    for (unsigned i = 0, e = FTI.NumArgs; i != e; ++i)
+      Params.push_back(ParseParamDeclarator(D.getTypeObject(0), i,FnBodyScope));
+  }
   
   FD->setParams(&Params[0], Params.size());
   





More information about the cfe-commits mailing list