diff options
author | Nick Lewycky <nicholas@mxc.ca> | 2011-07-07 20:25:10 +0000 |
---|---|---|
committer | Nick Lewycky <nicholas@mxc.ca> | 2011-07-07 20:25:10 +0000 |
commit | d755e6ac4828d6de90afca6eb64a7f90a33f603c (patch) | |
tree | 542db1ece629529322f3f0ab67dd11aee223ead4 /clang/lib/AST/Decl.cpp | |
parent | 77a9e6e7df7f38b9f0509c570df6fe3f7fa0eb7c (diff) | |
download | llvm-d755e6ac4828d6de90afca6eb64a7f90a33f603c.zip llvm-d755e6ac4828d6de90afca6eb64a7f90a33f603c.tar.gz llvm-d755e6ac4828d6de90afca6eb64a7f90a33f603c.tar.bz2 |
A redeclaration of an inline method in C99 mode should trigger emission of that
function. Fixes PR10233!
llvm-svn: 134634
Diffstat (limited to 'clang/lib/AST/Decl.cpp')
-rw-r--r-- | clang/lib/AST/Decl.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp index 9b507cf..9feec9d 100644 --- a/clang/lib/AST/Decl.cpp +++ b/clang/lib/AST/Decl.cpp @@ -1762,6 +1762,32 @@ bool FunctionDecl::isInlined() const { return false; } +/// \brief For a function declaration in C or C++, determine whether this +/// declaration causes the definition to be externally visible. +/// +/// Determines whether this is the first non-inline redeclaration of an inline +/// function in a language where "inline" does not normally require an +/// externally visible definition. +bool FunctionDecl::doesDeclarationForceExternallyVisibleDefinition() const { + assert(!doesThisDeclarationHaveABody() && + "Must have a declaration without a body."); + + ASTContext &Context = getASTContext(); + + // In C99 mode, a function may have an inline definition (causing it to + // be deferred) then redeclared later. As a special case, "extern inline" + // is not required to produce an external symbol. + if (Context.getLangOptions().GNUInline || !Context.getLangOptions().C99 || + Context.getLangOptions().CPlusPlus) + return false; + if (getLinkage() != ExternalLinkage || isInlineSpecified()) + return false; + const FunctionDecl *InlineDefinition = 0; + if (hasBody(InlineDefinition)) + return InlineDefinition->isInlineDefinitionExternallyVisible(); + return false; +} + /// \brief For an inline function definition in C or C++, determine whether the /// definition will be externally visible. /// |