* pt.c (do_decl_instantiation): Detect type mismatches in explicit
instantiations for variables.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@121864
138bc75d-0d04-0410-961f-
82ee72b054a4
+2007-02-12 Simon Martin <simartin@users.sourceforge.net>
+ Mark Mitchell <mark@codesourcery.com>
+
+ PR c++/14622
+ * pt.c (do_decl_instantiation): Detect type mismatches in explicit
+ instantiations for variables.
+
2007-02-12 Manuel Lopez-Ibanez <manu@gcc.gnu.org>
PR middle-end/7651
error ("no matching template for %qD found", decl);
return;
}
+ if (!same_type_p (TREE_TYPE (result), TREE_TYPE (decl)))
+ {
+ error ("type %qT for explicit instantiation %qD does not match "
+ "declared type %qT", TREE_TYPE (result), decl,
+ TREE_TYPE (decl));
+ return;
+ }
}
else if (TREE_CODE (decl) != FUNCTION_DECL)
{
+2007-02-12 Simon Martin <simartin@users.sourceforge.net>
+
+ PR c++/14622
+ * g++.dg/template/instantiate9.C: New test.
+ * g++.old-deja/g++.pt/instantiate12.C: Fixed type mismatches in explicit
+ instantiations.
+
2007-02-12 Uros Bizjak <ubizjak@gmail.com>
* gcc.target/i386/parity-1.c: New test.
--- /dev/null
+/* PR c++/14622. The invalid explicit instantiation was not reported. */
+/* { dg-do "compile" } */
+template<class T>
+class A
+{
+ static T a;
+};
+
+template<class T>
+T A<T>::a;
+
+struct B {};
+
+template B A<int>::a; /* { dg-error "does not match declared type" } */
+template float A<float>::a;
// const-ness should allow the compiler to elide references to the
// actual variables.
template const bool X<int>::cflag;
-template const bool X<int>::flag;
+template bool X<int>::flag;
template const bool X<float>::cflag;
-template const bool X<float>::flag;
+template bool X<float>::flag;