From: Douglas Gregor Date: Thu, 19 Mar 2009 18:14:46 +0000 (+0000) Subject: If a function is declared as, e.g., X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=13d7a32774c51af4c314c9d1fa6229d0e1d099da;p=clang 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 18d55d92f4..a50381123c 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -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(R.getTypePtr()); NewFD = FunctionDecl::Create(Context, DC, D.getIdentifierLoc(), diff --git a/test/Sema/function-redecl.c b/test/Sema/function-redecl.c index 999aa49189..80500664af 100644 --- a/test/Sema/function-redecl.c +++ b/test/Sema/function-redecl.c @@ -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;