]> granicus.if.org Git - clang/commitdiff
Merging r195556:
authorBill Wendling <isanbard@gmail.com>
Mon, 25 Nov 2013 07:42:52 +0000 (07:42 +0000)
committerBill Wendling <isanbard@gmail.com>
Mon, 25 Nov 2013 07:42:52 +0000 (07:42 +0000)
------------------------------------------------------------------------
r195556 | akirtzidis | 2013-11-23 10:41:35 -0800 (Sat, 23 Nov 2013) | 3 lines

[CodeGen] If there is a function definition with duplicate mangled name, emit an error instead of asserting.

rdar://15522601 & http://llvm.org/PR18031
------------------------------------------------------------------------

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

include/clang/Basic/DiagnosticSemaKinds.td
lib/CodeGen/CodeGenModule.cpp

index 43ecec533d826ebfb7cc2209a63f85263429cda0..6c7cb001808a8c375affc67cf33bcda53193e976 100644 (file)
@@ -2030,6 +2030,8 @@ def err_alias_not_supported_on_darwin : Error <
   "only weak aliases are supported on darwin">;
 def err_alias_to_undefined : Error<
   "alias must point to a defined variable or function">;
+def err_duplicate_mangled_name : Error<
+  "definition with same mangled name as another definition">;
 def err_cyclic_alias : Error<
   "alias definition is part of a cycle">;
 def warn_attribute_wrong_decl_type : Warning<
index 4d51fb02bb4d50d657caea05ebaf0d6fb4c2a73a..72f909fd53cd3e10efdfd132390ba596debbf0df 100644 (file)
@@ -2095,6 +2095,10 @@ void CodeGenModule::EmitGlobalFunctionDefinition(GlobalDecl GD) {
     Entry = CE->getOperand(0);
   }
 
+  if (!cast<llvm::GlobalValue>(Entry)->isDeclaration()) {
+    getDiags().Report(D->getLocation(), diag::err_duplicate_mangled_name);
+    return;
+  }
 
   if (cast<llvm::GlobalValue>(Entry)->getType()->getElementType() != Ty) {
     llvm::GlobalValue *OldFn = cast<llvm::GlobalValue>(Entry);