[cfe-commits] r67533 - in /cfe/trunk: lib/Sema/SemaDecl.cpp test/Sema/function-redecl.c

Douglas Gregor dgregor at apple.com
Mon Mar 23 09:26:51 PDT 2009


Author: dgregor
Date: Mon Mar 23 11:26:51 2009
New Revision: 67533

URL: http://llvm.org/viewvc/llvm-project?rev=67533&view=rev
Log:
Tighten up the determination of whether a function declaration has a
prototype. Thanks Eli!

Modified:
    cfe/trunk/lib/Sema/SemaDecl.cpp
    cfe/trunk/test/Sema/function-redecl.c

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=67533&r1=67532&r2=67533&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Mon Mar 23 11:26:51 2009
@@ -1895,7 +1895,7 @@
     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(),

Modified: cfe/trunk/test/Sema/function-redecl.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/function-redecl.c?rev=67533&r1=67532&r2=67533&view=diff

==============================================================================
--- cfe/trunk/test/Sema/function-redecl.c (original)
+++ cfe/trunk/test/Sema/function-redecl.c Mon Mar 23 11:26:51 2009
@@ -116,3 +116,12 @@
 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 *'}}
+}





More information about the cfe-commits mailing list