Author: Aaron Puchert
Date: 2020-02-01T00:06:03+01:00
New Revision: 27684ae66d5545f211c0ac4393d0ba2bf3b5b47c

URL: 
https://github.com/llvm/llvm-project/commit/27684ae66d5545f211c0ac4393d0ba2bf3b5b47c
DIFF: 
https://github.com/llvm/llvm-project/commit/27684ae66d5545f211c0ac4393d0ba2bf3b5b47c.diff

LOG: Don't warn about missing declarations for partial template specializations

Summary: Just like templates, they are excepted from the ODR rule.

Reviewed By: aaron.ballman, rsmith

Differential Revision: https://reviews.llvm.org/D68923

Added: 
    

Modified: 
    clang/lib/Sema/SemaDecl.cpp
    clang/test/SemaCXX/warn-missing-variable-declarations.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index e8589d3bcf44..2175361dab9a 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -12523,6 +12523,7 @@ void Sema::CheckCompleteVariableDeclaration(VarDecl 
*var) {
       var->getDeclContext()->getRedeclContext()->isFileContext() &&
       var->isExternallyVisible() && var->hasLinkage() &&
       !var->isInline() && !var->getDescribedVarTemplate() &&
+      !isa<VarTemplatePartialSpecializationDecl>(var) &&
       !isTemplateInstantiation(var->getTemplateSpecializationKind()) &&
       !getDiagnostics().isIgnored(diag::warn_missing_variable_declarations,
                                   var->getLocation())) {

diff  --git a/clang/test/SemaCXX/warn-missing-variable-declarations.cpp 
b/clang/test/SemaCXX/warn-missing-variable-declarations.cpp
index e2480fd663b0..b50eeed30e7a 100644
--- a/clang/test/SemaCXX/warn-missing-variable-declarations.cpp
+++ b/clang/test/SemaCXX/warn-missing-variable-declarations.cpp
@@ -70,6 +70,8 @@ template<typename> int var_template = 0;
 template<typename> constexpr int const_var_template = 0;
 template<typename> static int static_var_template = 0;
 
+template<typename T> int var_template<T*>;
+
 template int var_template<int[1]>;
 int use_var_template() { return var_template<int[2]>; }
 template int var_template<int[3]>;


        
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to