]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
PR c++/78906 - ICE with member variable template
authorJason Merrill <jason@redhat.com>
Thu, 22 Dec 2016 20:29:07 +0000 (15:29 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Thu, 22 Dec 2016 20:29:07 +0000 (15:29 -0500)
* pt.c (finish_template_variable): Use most_general_template.

From-SVN: r243897

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/g++.dg/cpp1y/var-templ54.C [new file with mode: 0644]

index 6f193c4e2dba5e569ebb0cbd2e2eafb01ec6fe2c..2969762844fc876af59578470585e7b1fd2a972c 100644 (file)
@@ -1,5 +1,8 @@
 2016-12-22  Jason Merrill  <jason@redhat.com>
 
+       PR c++/78906
+       * pt.c (finish_template_variable): Use most_general_template.
+
        PR c++/78898
        PR c++/42329
        * pt.c (unify): Don't look for a class template from a non-class.
index 7711546f7b79ae464aa16083d4ae97f62e815dd2..3fa2ce9df6712c450265d0eac014f58b26b0dfa3 100644 (file)
@@ -9000,6 +9000,7 @@ finish_template_variable (tree var, tsubst_flags_t complain)
   tree tmpl_args = DECL_TI_ARGS (DECL_TEMPLATE_RESULT (templ));
   arglist = add_outermost_template_args (tmpl_args, arglist);
 
+  templ = most_general_template (templ);
   tree parms = DECL_TEMPLATE_PARMS (templ);
   arglist = coerce_innermost_template_parms (parms, arglist, templ, complain,
                                             /*req_all*/true,
diff --git a/gcc/testsuite/g++.dg/cpp1y/var-templ54.C b/gcc/testsuite/g++.dg/cpp1y/var-templ54.C
new file mode 100644 (file)
index 0000000..f52f764
--- /dev/null
@@ -0,0 +1,13 @@
+// PR c++/78906
+// { dg-do compile { target c++14 } }
+
+template <typename> struct A { static constexpr int digits = 0; };
+template <typename> struct B {
+  template <int, typename MaskInt = int, int = A<MaskInt>::digits>
+  static constexpr int XBitMask = 0;
+};
+struct C {
+  using ReferenceHost = B<int>;
+  template <int> static decltype(ReferenceHost::XBitMask<0>) XBitMask;
+};
+int main() { C::XBitMask<0>; }