From 9f9bf258f8ebae30bfb70feb9d797d6eb67b0460 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Tue, 28 Apr 2009 06:37:30 +0000 Subject: Improve compatibility with GCC regarding inline semantics in GNU89 mode and in the presence of __gnu_inline__ attributes. This should fix both PR3989 and PR4069. As part of this, we now keep track of all of the attributes attached to each declaration even after we've performed declaration merging. This fixes PR3264. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70292 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CodeGenModule.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'lib/CodeGen/CodeGenModule.cpp') diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp index 378223e3a7..4e58d09360 100644 --- a/lib/CodeGen/CodeGenModule.cpp +++ b/lib/CodeGen/CodeGenModule.cpp @@ -240,9 +240,17 @@ GetLinkageForFunction(const FunctionDecl *FD, const LangOptions &Features) { // If the inline function explicitly has the GNU inline attribute on it, or if // this is C89 mode, we use to GNU semantics. - if (FD->hasAttr() || (!Features.C99 && !Features.CPlusPlus)) { + if (!Features.C99 && !Features.CPlusPlus) { // extern inline in GNU mode is like C99 inline. - if (FD->isC99InlineDefinition()) + if (FD->getStorageClass() == FunctionDecl::Extern) + return CodeGenModule::GVA_C99Inline; + // Normal inline is a strong symbol. + return CodeGenModule::GVA_StrongExternal; + } else if (FD->hasActiveGNUInlineAttribute()) { + // GCC in C99 mode seems to use a different decision-making + // process for extern inline, which factors in previous + // declarations. + if (FD->isExternGNUInline()) return CodeGenModule::GVA_C99Inline; // Normal inline is a strong symbol. return CodeGenModule::GVA_StrongExternal; -- cgit v1.2.3-18-g5258