]> granicus.if.org Git - clang/commitdiff
Tighten up the determination of whether a function declaration has a
authorDouglas Gregor <dgregor@apple.com>
Mon, 23 Mar 2009 16:26:51 +0000 (16:26 +0000)
committerDouglas Gregor <dgregor@apple.com>
Mon, 23 Mar 2009 16:26:51 +0000 (16:26 +0000)
prototype. Thanks Eli!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67533 91177308-0d34-0410-b5e6-96231b3b80d8

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

index 62b9bff3defa12001d96508956c7f38b8f58ee69..89375d7066e7af5fc743c2243dc396aa6cbf895e 100644 (file)
@@ -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(),
index 80500664af338ac249501ca45a8f06d50b6025ef..fc2e1995f26f15248654e55e358a310535dab1c8 100644 (file)
@@ -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 *'}}
+}