[cfe-commits] r67313 - in /cfe/trunk: lib/Sema/SemaDecl.cpp test/Sema/function-redecl.c

Douglas Gregor dgregor at apple.com
Thu Mar 19 11:14:46 PDT 2009


Author: dgregor
Date: Thu Mar 19 13:14:46 2009
New Revision: 67313

URL: http://llvm.org/viewvc/llvm-project?rev=67313&view=rev
Log:
If a function is declared as, e.g.,

  F f;

where F is a typedef of a function type, then the function "f" has a
prototype. This is a slight tweak to Chris's suggested fix in
PR3817. Fixes PR3817 and PR3840.


Modified:
    cfe/trunk/lib/Sema/SemaDecl.cpp
    cfe/trunk/test/Sema/function-redecl.c

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

==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Thu Mar 19 13:14:46 2009
@@ -1864,9 +1864,10 @@
 
     isVirtualOkay = (SC != FunctionDecl::Static);
   } else {
-    bool HasPrototype =
+    bool HasPrototype = 
        getLangOptions().CPlusPlus ||
-       (D.getNumTypeObjects() && D.getTypeObject(0).Fun.hasPrototype);
+       (D.getNumTypeObjects() && D.getTypeObject(0).Fun.hasPrototype) ||
+      !isa<FunctionType>(R.getTypePtr());
     
     NewFD = FunctionDecl::Create(Context, DC,
                                  D.getIdentifierLoc(),

Modified: cfe/trunk/test/Sema/function-redecl.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/function-redecl.c?rev=67313&r1=67312&r2=67313&view=diff

==============================================================================
--- cfe/trunk/test/Sema/function-redecl.c (original)
+++ cfe/trunk/test/Sema/function-redecl.c Thu Mar 19 13:14:46 2009
@@ -106,3 +106,13 @@
 {
   return x == 1;
 }
+
+// PR3817
+void *h0(unsigned a0,     ...);
+extern __typeof (h0) h1 __attribute__((__sentinel__));
+extern __typeof (h1) h1 __attribute__((__sentinel__));
+
+// PR3840
+void i0 (unsigned short a0);
+extern __typeof (i0) i1;
+extern __typeof (i1) i1;





More information about the cfe-commits mailing list