public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* C++ PATCH for c++/66647 (ICE with alias templates)
@ 2015-06-24 20:08 Jason Merrill
  0 siblings, 0 replies; only message in thread
From: Jason Merrill @ 2015-06-24 20:08 UTC (permalink / raw)
  To: gcc-patches List

[-- Attachment #1: Type: text/plain, Size: 360 bytes --]

Another issue with dependent alias template specializations.  In this 
case, we were dealing with an alias template that expands to a function 
type; dependent_type_p_r was looking at the function type and never 
considering whether the alias specialization itself was dependent. 
Fixed by checking that sooner.

Tested x86_64-pc-linux-gnu, applying to trunk.

[-- Attachment #2: 66647.patch --]
[-- Type: text/x-patch, Size: 2846 bytes --]

commit c9afe9335ac08dcbbfbf4aeee747d76ad36e74d1
Author: Jason Merrill <jason@redhat.com>
Date:   Wed Jun 24 15:28:06 2015 -0400

    	PR c++/66647
    	* pt.c (dependent_type_p_r): Check for dependent alias template
    	specialization sooner.

diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 8800af8..b63c0d4 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -20992,6 +20992,12 @@ dependent_type_p_r (tree type)
 	names a dependent type.  */
   if (TREE_CODE (type) == TYPENAME_TYPE)
     return true;
+
+  /* An alias template specialization can be dependent even if the
+     resulting type is not.  */
+  if (dependent_alias_template_spec_p (type))
+    return true;
+
   /* -- a cv-qualified type where the cv-unqualified type is
 	dependent.
      No code is necessary for this bullet; the code below handles
@@ -21043,10 +21049,6 @@ dependent_type_p_r (tree type)
 	   && (any_dependent_template_arguments_p
 	       (INNERMOST_TEMPLATE_ARGS (CLASSTYPE_TI_ARGS (type)))))
     return true;
-  /* For an alias template specialization, check the arguments both to the
-     class template and the alias template.  */
-  else if (dependent_alias_template_spec_p (type))
-    return true;
 
   /* All TYPEOF_TYPEs, DECLTYPE_TYPEs, and UNDERLYING_TYPEs are
      dependent; if the argument of the `typeof' expression is not
diff --git a/gcc/testsuite/g++.dg/cpp0x/alias-decl-49.C b/gcc/testsuite/g++.dg/cpp0x/alias-decl-49.C
new file mode 100644
index 0000000..5fd3b65
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/alias-decl-49.C
@@ -0,0 +1,54 @@
+// PR c++/66647
+// { dg-do compile { target c++11 } }
+
+template <typename _Tp> struct A
+{
+  static constexpr _Tp value = 1;
+};
+template <typename> class B
+{
+public:
+  template <typename> struct rebind
+  {
+  };
+};
+
+template <typename _Alloc, typename _Tp> class C
+{
+  template <typename _Alloc2, typename _Tp2>
+  static A<int> _S_chk (typename _Alloc2::template rebind<_Tp2> *);
+
+public:
+  using __type = decltype (_S_chk<_Alloc, _Tp> (0));
+};
+
+template <typename _Alloc, typename _Tp, int = C<_Alloc, _Tp>::__type::value>
+struct D;
+template <typename _Alloc, typename _Tp> struct D<_Alloc, _Tp, 1>
+{
+  typedef typename _Alloc::template rebind<_Tp> __type;
+};
+template <typename _Alloc> struct F
+{
+  template <typename _Tp> using rebind_alloc = typename D<_Alloc, _Tp>::__type;
+};
+template <typename _Alloc> struct __alloc_traits
+{
+  template <typename> struct rebind
+  {
+    typedef typename F<_Alloc>::template rebind_alloc<int> other;
+  };
+};
+template <typename _Alloc> struct G
+{
+  typename __alloc_traits<_Alloc>::template rebind<int>::other _Tp_alloc_type;
+};
+template <typename _Tp, typename _Alloc = B<_Tp> > class vector : G<_Alloc>
+{
+};
+
+template <int> using tfuncptr = void();
+template <int d> struct H
+{
+  vector<tfuncptr<d> > funcs;
+};

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2015-06-24 19:59 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-24 20:08 C++ PATCH for c++/66647 (ICE with alias templates) 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).