diff options
author | Chris Lattner <sabre@nondot.org> | 2009-04-22 00:03:30 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-04-22 00:03:30 +0000 |
commit | f8dc07369aa022314461ce15ab2aba51c87c54ad (patch) | |
tree | 1627000a6c1bddcfe58e837a0f15e7ed0f669c8b /clang/lib/CodeGen/CodeGenModule.cpp | |
parent | c3366a555b382af03e207ce72a0ab14f3a0f6988 (diff) | |
download | bcm5719-llvm-f8dc07369aa022314461ce15ab2aba51c87c54ad.tar.gz bcm5719-llvm-f8dc07369aa022314461ce15ab2aba51c87c54ad.zip |
Fix some mishandling of the attr(gnu_inline) mode when used with
extern. Previously we would warn about it and ignore the attribute.
This is incorrect, it should be handled as a c89 "extern inline"
function. Many thanks to Matthieu Castet for pointing this out and
beating me over the head until I got it.
PR3988: extern inline function are not externally visible
llvm-svn: 69756
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r-- | clang/lib/CodeGen/CodeGenModule.cpp | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 80e4bd9f9bb..ba0b28ac975 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -238,30 +238,27 @@ GetLinkageForFunction(const FunctionDecl *FD, const LangOptions &Features) { if (!FD->isInline()) return CodeGenModule::GVA_StrongExternal; - // If the inline function explicitly has the GNU inline attribute on it, then - // force to GNUC semantics (which is strong external), regardless of language. - if (FD->hasAttr<GNUInlineAttr>()) + // 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<GNUInlineAttr>() || (!Features.C99 && !Features.CPlusPlus)) { + // extern inline in GNU mode is like C99 inline. + if (FD->getStorageClass() == FunctionDecl::Extern) + return CodeGenModule::GVA_C99Inline; + // Normal inline is a strong symbol. return CodeGenModule::GVA_StrongExternal; + } // The definition of inline changes based on the language. Note that we // have already handled "static inline" above, with the GVA_Internal case. if (Features.CPlusPlus) // inline and extern inline. return CodeGenModule::GVA_CXXInline; - if (FD->getStorageClass() == FunctionDecl::Extern) { - // extern inline in C99 is a strong definition. In C89, it is extern inline. - if (Features.C99) - return CodeGenModule::GVA_StrongExternal; - - // In C89 mode, an 'extern inline' works like a C99 inline function. - return CodeGenModule::GVA_C99Inline; - } - - if (Features.C99) - return CodeGenModule::GVA_C99Inline; + assert(Features.C99 && "Must be in C99 mode if not in C89 or C++ mode"); + // extern inline in C99 is a strong definition. + if (FD->getStorageClass() == FunctionDecl::Extern) + return CodeGenModule::GVA_StrongExternal; - // Otherwise, this is the GNU inline extension in K&R and GNU C89 mode. - return CodeGenModule::GVA_StrongExternal; + return CodeGenModule::GVA_C99Inline; } /// SetFunctionDefinitionAttributes - Set attributes for a global. |