* C++ PATCH for c++/78906 (ICE with member template variable)
@ 2016-12-22 20:28 Jason Merrill
0 siblings, 0 replies; only message in thread
From: Jason Merrill @ 2016-12-22 20:28 UTC (permalink / raw)
To: gcc-patches List
[-- Attachment #1: Type: text/plain, Size: 157 bytes --]
If we're adding the enclosing template args, we also need to switch to
looking at the most general template.
Tested x86_64-pc-linux-gnu, applying to trunk.
[-- Attachment #2: 78906.diff --]
[-- Type: text/plain, Size: 1422 bytes --]
commit 35fe583ade362f018f095435980424f1244ab92f
Author: Jason Merrill <jason@redhat.com>
Date: Thu Dec 22 13:27:26 2016 -0500
PR c++/78906 - ICE with member variable template
* pt.c (finish_template_variable): Use most_general_template.
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 7711546..3fa2ce9 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -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
index 0000000..f52f764
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1y/var-templ54.C
@@ -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>; }
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2016-12-22 20:27 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-22 20:28 C++ PATCH for c++/78906 (ICE with member template variable) 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).