public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] PR c++/52343 - error with alias template as template template argument
@ 2012-12-21 12:35 Dodji Seketeli
  2012-12-21 15:11 ` Gabriel Dos Reis
  2012-12-24  5:04 ` Jason Merrill
  0 siblings, 2 replies; 12+ messages in thread
From: Dodji Seketeli @ 2012-12-21 12:35 UTC (permalink / raw)
  To: GCC Patches; +Cc: Jason Merrill

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

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2012-12-26 18:55 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-12-21 12:35 [PATCH] PR c++/52343 - error with alias template as template template argument Dodji Seketeli
2012-12-21 15:11 ` Gabriel Dos Reis
2012-12-21 16:26   ` Dodji Seketeli
2012-12-21 23:21     ` Gabriel Dos Reis
2012-12-22 15:53       ` Dodji Seketeli
2012-12-22 16:43         ` Gabriel Dos Reis
2012-12-24  5:04 ` Jason Merrill
2012-12-24  5:38   ` Gabriel Dos Reis
2012-12-24 13:58     ` Dodji Seketeli
2012-12-24 20:18       ` Gabriel Dos Reis
2012-12-24 13:50   ` Dodji Seketeli
2012-12-26 18:55     ` Jason Merrill

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).