From 426b5cf16ae97e1cb9c4b459861e35c88908d50e Mon Sep 17 00:00:00 2001 From: Daniel Dunbar Date: Thu, 16 Apr 2009 15:34:14 +0000 Subject: Ensure that the most recent declaration of a tentative definition wins when generating a common definition. llvm-svn: 69287 --- clang/lib/CodeGen/CodeGenModule.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'clang/lib/CodeGen/CodeGenModule.cpp') diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 81bff667fb9..d1d67a11b8a 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -424,9 +424,11 @@ void CodeGenModule::EmitDeferred() { EmitGlobalDefinition(D); } - // Emit any tentative definitions. - for (std::vector::iterator it = TentativeDefinitions.begin(), - ie = TentativeDefinitions.end(); it != ie; ++it) + // Emit any tentative definitions, in reverse order so the most + // important (merged) decl will be seen and emitted first. + for (std::vector::reverse_iterator + it = TentativeDefinitions.rbegin(), ie = TentativeDefinitions.rend(); + it != ie; ++it) EmitTentativeDefinition(*it); } -- cgit v1.2.3