]> granicus.if.org Git - clang/commitdiff
If a function is declared as, e.g.,
authorDouglas Gregor <dgregor@apple.com>
Thu, 19 Mar 2009 18:14:46 +0000 (18:14 +0000)
committerDouglas Gregor <dgregor@apple.com>
Thu, 19 Mar 2009 18:14:46 +0000 (18:14 +0000)
  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

lib/Sema/SemaDecl.cpp
test/Sema/function-redecl.c

index 18d55d92f47aff6f38eb38bc5a2eb5a9d6f5246d..a50381123c3452f3e336ee95eaaffa3e9c253f57 100644 (file)
@@ -1864,9 +1864,10 @@ Sema::ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC,
 
     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(),
index 999aa49189485b3ad2b67fcb6c0a8f21306eba1f..80500664af338ac249501ca45a8f06d50b6025ef 100644 (file)
@@ -106,3 +106,13 @@ int isroot(x, y)
 {
   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;