diff options
author | Douglas Gregor <dgregor@apple.com> | 2009-03-23 16:26:51 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2009-03-23 16:26:51 +0000 |
commit | d1659a6bd96132ffab70613b23f5716424fa364f (patch) | |
tree | 93870abc50652582ad1eff831df729904eb7468d | |
parent | d9cd4c947d9dc50907d7c318def665362955c38a (diff) |
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
-rw-r--r-- | lib/Sema/SemaDecl.cpp | 2 | ||||
-rw-r--r-- | test/Sema/function-redecl.c | 9 |
2 files changed, 10 insertions, 1 deletions
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<FunctionType>(R.getTypePtr()); + (!isa<FunctionType>(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 *'}} +} |