Commit 8ea6dfae by Simon Martin Committed by Simon Martin

re PR c++/14622 (type mismatch in explicit template instantiation not detected)

PR c++/14622
* pt.c (do_decl_instantiation): Detect type mismatches in explicit
instantiations for variables.

Co-Authored-By: Mark Mitchell <mark@codesourcery.com>

From-SVN: r121864
parent 0f7b6776
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
......
......@@ -11728,6 +11728,13 @@ do_decl_instantiation (tree decl, tree storage)
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.
/* 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;
......@@ -56,6 +56,6 @@ int main ()
// 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;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment