]> granicus.if.org Git - clang/commitdiff
Weak references and variables that are not definitions are not required for early...
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Thu, 29 Jul 2010 20:07:52 +0000 (20:07 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Thu, 29 Jul 2010 20:07:52 +0000 (20:07 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@109796 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/ASTContext.cpp
test/PCH/cxx-templates.h

index af19e89fd9d0ebaeb169505cf8d5bde65f2bbaaa..633538f3129e06b33acce3405addcc06f90639ed 100644 (file)
@@ -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.
index 47fa11eb08051f24454fa16e2b2e3664d80b52a6..92932199fa825918b2c3712d71cdba90172efe1b 100644 (file)
@@ -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>;