re PR c++/20172 (Invalid non-type template parameters not diagnosed)

cp:
	PR c++/20172
	* pt.c (tsubst_template_parms): Check for invalid non-type
	parameters.
testsuite:
	PR c++/20172
	* g++.dg/template/nontype12.C : New test.

Co-Authored-By: Nathan Sidwell <nathan@codesourcery.com>

From-SVN: r101928
This commit is contained in:
Volker Reichelt 2005-07-12 16:07:38 +00:00 committed by Nathan Sidwell
parent cac50d9410
commit a207780f9b
4 changed files with 50 additions and 0 deletions

View file

@ -1,3 +1,10 @@
2005-07-12 Volker Reichelt <reichelt@igpm.rwth-aachen.de>
Nathan Sidwell <nathan@codesourcery.com>
PR c++/20172
* pt.c (tsubst_template_parms): Check for invalid non-type
parameters.
2005-07-09 Andrew Pinski <pinskia@physics.uc.edu>
* cp-lang.c (shadowed_var_for_decl, decl_shadowed_for_var_lookup,

View file

@ -5987,6 +5987,9 @@ tsubst_template_parms (tree parms, tree args, tsubst_flags_t complain)
tree parm_decl = TREE_VALUE (tuple);
parm_decl = tsubst (parm_decl, args, complain, NULL_TREE);
if (TREE_CODE (parm_decl) == PARM_DECL
&& invalid_nontype_parm_type_p (TREE_TYPE (parm_decl), complain))
parm_decl = error_mark_node;
default_value = tsubst_template_arg (default_value, args,
complain, NULL_TREE);

View file

@ -1,3 +1,8 @@
2005-07-12 Volker Reichelt <reichelt@igpm.rwth-aachen.de>
PR c++/20172
* g++.dg/template/nontype12.C : New test.
2005-07-12 Zdenek Dvorak <dvorakz@suse.cz>
* gcc.dg/tree-ssa/loop-10.c: New test.

View file

@ -0,0 +1,35 @@
// PR c++/20172
// Origin: Volker Reichelt <reichelt@igpm.rwth-aachen.de>
template<typename T> struct A
{
template<T> int foo(); // { dg-error "double" }
template<template<T> class> int bar(); // { dg-error "double" }
template<T> struct X; // { dg-error "double" }
};
A<char> a1;
A<double> a2; // { dg-error "instantiated" }
template<typename T> struct B
{
template<double> int foo(); // { dg-error "double" }
template<template<double> class> int bar(); // { dg-error "double" }
template<double> struct X; // { dg-error "double" }
};
template<void> int foo(); // { dg-error "void" }
template<template<void> class> int bar(); // { dg-error "void" }
template<void> struct X; // { dg-error "void" }
template<typename T> struct C
{
template<T> int foo(); // { dg-error "double" }
};
template<typename T> int baz(T) { C<T> c; } // { dg-error "instantiated" }
void foobar()
{
baz(1.2); // { dg-error "instantiated" }
}