Don't warn about missing declarations for partial template specializations
authorAaron Puchert <aaronpuchert@alice-dsl.net>
Fri, 31 Jan 2020 23:05:36 +0000 (00:05 +0100)
committerAaron Puchert <aaronpuchert@alice-dsl.net>
Fri, 31 Jan 2020 23:06:03 +0000 (00:06 +0100)
Summary: Just like templates, they are excepted from the ODR rule.

Reviewed By: aaron.ballman, rsmith

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

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

index e8589d3..2175361 100644 (file)
@@ -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())) {
index e2480fd..b50eeed 100644 (file)
@@ -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]>;