Hello, In the example accompanying this patch, check_instantiated_arg tries to ensure that a non-type template argument should be a constant if it has integral or enumeration type.
The problem is that an alias template which type-id is, e.g, an integer, looks like an argument that has integral/enumeration type: its TREE_TYPE is an integer type. So check_instantiated_arg mistenkaly barks that this integral non-type argument is not a constant. I am proposing to tighten the test in check_instantiated_arg to allow type template (and thus aliast template) arguments. Bootstrapped and tested on x86_64-unknown-linux-gnu against trunk. gcc/cp/ PR c++/52343 * pt.c (check_instantiated_arg): Allow type template arguments. gcc/testsuite/ PR c++/52343 * g++.dg/cpp0x/alias-decl-29.C: New test. --- gcc/cp/pt.c | 4 +++- gcc/testsuite/g++.dg/cpp0x/alias-decl-29.C | 10 ++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/alias-decl-29.C diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 1b3f039..e2e8311 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -14425,7 +14425,9 @@ check_instantiated_arg (tree tmpl, tree t, tsubst_flags_t complain) constant. */ else if (TREE_TYPE (t) && INTEGRAL_OR_ENUMERATION_TYPE_P (TREE_TYPE (t)) - && !TREE_CONSTANT (t)) + && !TREE_CONSTANT (t) + /* Class template and alias template arguments should be OK. */ + && !DECL_TYPE_TEMPLATE_P (t)) { if (complain & tf_error) error ("integral expression %qE is not constant", t); diff --git a/gcc/testsuite/g++.dg/cpp0x/alias-decl-29.C b/gcc/testsuite/g++.dg/cpp0x/alias-decl-29.C new file mode 100644 index 0000000..f6cc695 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/alias-decl-29.C @@ -0,0 +1,10 @@ +// Origin: PR c++/52343 +// { dg-do compile { target c++11 } } + +template<typename> +using A = int; + +template<template<class> class> +struct B {}; + +B<A> b; -- Dodji