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.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67313 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index 18d55d9..a503811 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -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(),
diff --git a/test/Sema/function-redecl.c b/test/Sema/function-redecl.c
index 999aa49..8050066 100644
--- a/test/Sema/function-redecl.c
+++ b/test/Sema/function-redecl.c
@@ -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;