Var->setReferenced();
TemplateSpecializationKind TSK = Var->getTemplateSpecializationKind();
+ bool MarkODRUsed = true;
// If the context is not potentially evaluated, this is not an odr-use and
// does not trigger instantiation.
if (!isTemplateInstantiation(TSK))
return;
+
+ // Instantiate, but do not mark as odr-used, variable templates.
+ MarkODRUsed = false;
}
VarTemplateSpecializationDecl *VarSpec =
}
}
+ if(!MarkODRUsed) return;
+
// Per C++11 [basic.def.odr], a variable is odr-used "unless it satisfies
// the requirements for appearing in a constant expression (5.19) and, if
// it is an object, the lvalue-to-rvalue conversion (4.1)
// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++1y -verify %s -DCXX1Y
+
+#ifndef CXX1Y
template<typename T, typename U, U> using alias_ref = T;
template<typename T, typename U, U> void func_ref() {}
(void)class_ref<int, int&, U<2>::a>(); // expected-note {{here}}
};
+
template<int N>
void fi() {
(void)alias_ref<int, int&, U<N>::a>(); // expected-note {{here}}
int j = f<int>();
}
+#else
+// expected-no-diagnostics
+
+namespace { template<typename> extern int n; }
+template<typename T> int g() { return n<int>; }
+
+#endif
+