From: Douglas Gregor Date: Mon, 23 Mar 2009 16:26:51 +0000 (+0000) Subject: Tighten up the determination of whether a function declaration has a X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d1659a6bd96132ffab70613b23f5716424fa364f;p=clang Tighten up the determination of whether a function declaration has a prototype. Thanks Eli! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67533 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 62b9bff3de..89375d7066 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -1895,7 +1895,7 @@ Sema::ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC, bool HasPrototype = getLangOptions().CPlusPlus || (D.getNumTypeObjects() && D.getTypeObject(0).Fun.hasPrototype) || - !isa(R.getTypePtr()); + (!isa(R.getTypePtr()) && R->isFunctionProtoType()); NewFD = FunctionDecl::Create(Context, DC, D.getIdentifierLoc(), diff --git a/test/Sema/function-redecl.c b/test/Sema/function-redecl.c index 80500664af..fc2e1995f2 100644 --- a/test/Sema/function-redecl.c +++ b/test/Sema/function-redecl.c @@ -116,3 +116,12 @@ extern __typeof (h1) h1 __attribute__((__sentinel__)); void i0 (unsigned short a0); extern __typeof (i0) i1; extern __typeof (i1) i1; + +typedef int a(); +typedef int a2(int*); +a x; +a2 x2; +void test_x() { + x(5); + x2(5); // expected-warning{{incompatible integer to pointer conversion passing 'int', expected 'int *'}} +}