diff options
-rw-r--r-- | lib/AST/ASTContext.cpp | 7 | ||||
-rw-r--r-- | test/PCH/cxx-templates.h | 7 |
2 files changed, 14 insertions, 0 deletions
diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp index af19e89fd9..633538f312 100644 --- a/lib/AST/ASTContext.cpp +++ b/lib/AST/ASTContext.cpp @@ -5550,6 +5550,10 @@ bool ASTContext::DeclIsRequiredFunctionOrFileScopedVar(const Decl *D) { } else if (!isa<FunctionDecl>(D)) return false; + // Weak references don't produce any output by themselves. + if (D->hasAttr<WeakRefAttr>()) + return false; + // Aliases and used decls are required. if (D->hasAttr<AliasAttr>() || D->hasAttr<UsedAttr>()) return true; @@ -5587,6 +5591,9 @@ bool ASTContext::DeclIsRequiredFunctionOrFileScopedVar(const Decl *D) { const VarDecl *VD = cast<VarDecl>(D); assert(VD->isFileVarDecl() && "Expected file scoped var"); + if (VD->isThisDeclarationADefinition() == VarDecl::DeclarationOnly) + return false; + // Structs that have non-trivial constructors or destructors are required. // FIXME: Handle references. diff --git a/test/PCH/cxx-templates.h b/test/PCH/cxx-templates.h index 47fa11eb08..92932199fa 100644 --- a/test/PCH/cxx-templates.h +++ b/test/PCH/cxx-templates.h @@ -109,3 +109,10 @@ template<typename T> struct S_PR7660 { void g(void (*)(T)); }; template<typename> class C_PR7670; template<> class C_PR7670<int>; template<> class C_PR7670<int>; + +template <bool B> +struct S2 { + static bool V; +}; + +extern template class S2<true>; |