diff options
author | Douglas Gregor <dgregor@apple.com> | 2009-09-13 07:46:26 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2009-09-13 07:46:26 +0000 |
commit | 1fc09a92d0bffda20e06fa882388c01e192e2069 (patch) | |
tree | 0a0e14c1cd9a145db8c4c5b306836d20e2eab1c0 /lib/Sema/SemaDecl.cpp | |
parent | 0a2329a48095e7067b509eed82675cc2893045c8 (diff) |
Rework the way we determine whether an externally visible symbol is
generated for an inline function definition, taking into account C99
and GNU inline/extern inline semantics. This solution is simpler,
cleaner, and fixes PR4536.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81670 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaDecl.cpp')
-rw-r--r-- | lib/Sema/SemaDecl.cpp | 37 |
1 files changed, 2 insertions, 35 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 40ef66306b..002372aa90 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -917,25 +917,10 @@ bool Sema::MergeCompatibleFunctionDecls(FunctionDecl *New, FunctionDecl *Old) { MergeAttributes(New, Old, Context); // Merge the storage class. - if (Old->getStorageClass() != FunctionDecl::Extern) + if (Old->getStorageClass() != FunctionDecl::Extern && + Old->getStorageClass() != FunctionDecl::None) New->setStorageClass(Old->getStorageClass()); - // Merge "inline" - if (Old->isInline()) - New->setInline(true); - - // If this function declaration by itself qualifies as a C99 inline - // definition (C99 6.7.4p6), but the previous definition did not, - // then the function is not a C99 inline definition. - if (New->isC99InlineDefinition() && !Old->isC99InlineDefinition()) - New->setC99InlineDefinition(false); - else if (Old->isC99InlineDefinition() && !New->isC99InlineDefinition()) { - // Mark all preceding definitions as not being C99 inline definitions. - for (const FunctionDecl *Prev = Old; Prev; - Prev = Prev->getPreviousDeclaration()) - const_cast<FunctionDecl *>(Prev)->setC99InlineDefinition(false); - } - // Merge "pure" flag. if (Old->isPure()) New->setPure(); @@ -2859,24 +2844,6 @@ void Sema::CheckFunctionDeclaration(FunctionDecl *NewFD, NamedDecl *&PrevDecl, return NewFD->setInvalidDecl(); } - // C99 6.7.4p6: - // [... ] For a function with external linkage, the following - // restrictions apply: [...] If all of the file scope declarations - // for a function in a translation unit include the inline - // function specifier without extern, then the definition in that - // translation unit is an inline definition. An inline definition - // does not provide an external definition for the function, and - // does not forbid an external definition in another translation - // unit. - // - // Here we determine whether this function, in isolation, would be a - // C99 inline definition. MergeCompatibleFunctionDecls looks at - // previous declarations. - if (NewFD->isInline() && getLangOptions().C99 && - NewFD->getStorageClass() == FunctionDecl::None && - NewFD->getDeclContext()->getLookupContext()->isTranslationUnit()) - NewFD->setC99InlineDefinition(true); - // Check for a previous declaration of this name. if (!PrevDecl && NewFD->isExternC()) { // Since we did not find anything by this name and we're declaring |