[cfe-commits] r39324 - in /cfe/cfe/trunk: AST/SemaDecl.cpp Sema/SemaDecl.cpp

sabre at cs.uiuc.edu sabre at cs.uiuc.edu
Wed Jul 11 09:43:06 PDT 2007


Author: sabre
Date: Wed Jul 11 11:43:06 2007
New Revision: 39324

URL: http://llvm.org/viewvc/llvm-project?rev=39324&view=rev
Log:
Start doing trivial merging of function prototypes.  If we have a function
proto, then a function body, and they have the same type, don't emit an error.
This reduces #errors from 654->616

Modified:
    cfe/cfe/trunk/AST/SemaDecl.cpp
    cfe/cfe/trunk/Sema/SemaDecl.cpp

Modified: cfe/cfe/trunk/AST/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/AST/SemaDecl.cpp?rev=39324&r1=39323&r2=39324&view=diff

==============================================================================
--- cfe/cfe/trunk/AST/SemaDecl.cpp (original)
+++ cfe/cfe/trunk/AST/SemaDecl.cpp Wed Jul 11 11:43:06 2007
@@ -127,8 +127,12 @@
     return New;
   }
   
-  // This is not right, but it's a start.  If 'Old' is a 
-  
+  // This is not right, but it's a start.  If 'Old' is a function prototype with
+  // the same type as 'New', silently allow this.  FIXME: We should link up decl
+  // objects here.
+  if (Old->getBody() == 0 && Old->getType() == New->getType()) {
+    return New;
+  }
   
   // TODO: CHECK FOR CONFLICTS, multiple decls with same name in one scope.
   // TODO: This is totally simplistic.  It should handle merging functions

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

==============================================================================
--- cfe/cfe/trunk/Sema/SemaDecl.cpp (original)
+++ cfe/cfe/trunk/Sema/SemaDecl.cpp Wed Jul 11 11:43:06 2007
@@ -127,8 +127,12 @@
     return New;
   }
   
-  // This is not right, but it's a start.  If 'Old' is a 
-  
+  // This is not right, but it's a start.  If 'Old' is a function prototype with
+  // the same type as 'New', silently allow this.  FIXME: We should link up decl
+  // objects here.
+  if (Old->getBody() == 0 && Old->getType() == New->getType()) {
+    return New;
+  }
   
   // TODO: CHECK FOR CONFLICTS, multiple decls with same name in one scope.
   // TODO: This is totally simplistic.  It should handle merging functions





More information about the cfe-commits mailing list