diff mbox

C++ PATCH for c++/67021 (dependent alias template specialization)

Message ID 55B9B5AF.8020601@redhat.com
State New
Headers show

Commit Message

Jason Merrill July 30, 2015, 5:27 a.m. UTC
In this testcase, having previously determined that "int" is not 
dependent was confusing us into thinking that ValueType<I> was not 
dependent.  But under DR 1558, it is.

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

Patch

commit 4f4b8497f404ab8f8d641878ee03ee91e6dcf6fb
Author: Jason Merrill <jason@redhat.com>
Date:   Thu Jul 30 00:45:44 2015 -0400

    	DR 1558
    	PR c++/67021
    	* pt.c (tsubst_decl) [TYPE_DECL]: Clear TYPE_DEPENDENT_P_VALID.

diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index e92fefb..6bf3d23 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -11570,6 +11570,10 @@  tsubst_decl (tree t, tree args, tsubst_flags_t complain)
 	  {
 	    DECL_ORIGINAL_TYPE (r) = NULL_TREE;
 	    set_underlying_type (r);
+	    if (TYPE_DECL_ALIAS_P (r) && type != error_mark_node)
+	      /* An alias template specialization can be dependent
+		 even if its underlying type is not.  */
+	      TYPE_DEPENDENT_P_VALID (TREE_TYPE (r)) = false;
 	  }
 
 	layout_decl (r, 0);
diff --git a/gcc/testsuite/g++.dg/cpp0x/alias-decl-52.C b/gcc/testsuite/g++.dg/cpp0x/alias-decl-52.C
new file mode 100644
index 0000000..2734075
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/alias-decl-52.C
@@ -0,0 +1,24 @@ 
+// PR c++/67021
+// { dg-do compile { target c++11 } }
+
+template<typename> struct Dummy;
+template<> struct Dummy<int> {};
+
+template <class...>
+struct all_same { static constexpr bool value = true; };
+template <class T, class...Rest>
+struct all_same<T, T, Rest...> : all_same<T, Rest...> {};
+template <class T, class U, class...Rest>
+struct all_same<T, U, Rest...> { static constexpr bool value = false; };
+
+template <class R>
+using ValueType = int;
+
+template <class I>
+constexpr bool A(I i) {
+  return all_same<ValueType<I>, ValueType<decltype(i++)>>::value;
+}
+
+int main() {
+  static_assert(A(42), "");
+}