Fix ICE on invalid variable template instantiation (PR c++/72759)
authorPatrick Palka <ppalka@gcc.gnu.org>
Thu, 4 Aug 2016 19:14:32 +0000 (19:14 +0000)
committerPatrick Palka <ppalka@gcc.gnu.org>
Thu, 4 Aug 2016 19:14:32 +0000 (19:14 +0000)
gcc/cp/ChangeLog:

PR c++/72759
* pt.c (tsubst_qualified_id): Return error_mark_node if
template_args is error_mark_node.

gcc/testsuite/ChangeLog:

PR c++/72759
* g++.dg/cpp1y/pr72759.C: New test.

From-SVN: r239147

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

index 573ece8bbad7fdbee6fdaa0b15cd600ab6d1980d..5ec690d6e2e6993d9082c2f0e95b9c015caa8d77 100644 (file)
@@ -1,3 +1,9 @@
+2016-08-04  Patrick Palka  <ppalka@gcc.gnu.org>
+
+       PR c++/72759
+       * pt.c (tsubst_qualified_id): Return error_mark_node if
+       template_args is error_mark_node.
+
 2016-08-04  Jason Merrill  <jason@redhat.com>
 
        PR c++/72415
index 60c87e001c05c8a7e2438994e6d32568b1de83ab..2f40700538ec03f9b1f99cf9e729ad2bd9601ef9 100644 (file)
@@ -13832,6 +13832,8 @@ tsubst_qualified_id (tree qualified_id, tree args,
       if (template_args)
        template_args = tsubst_template_args (template_args, args,
                                              complain, in_decl);
+      if (template_args == error_mark_node)
+       return error_mark_node;
       name = TREE_OPERAND (name, 0);
     }
   else
index 58672ba83a05c8f7cfdb04f67a8eb15ffb1a2f5a..c456b1886deee45a0b7d3892e2ef1b0e379c32df 100644 (file)
@@ -1,3 +1,8 @@
+2016-08-04  Patrick Palka  <ppalka@gcc.gnu.org>
+
+       PR c++/72759
+       * g++.dg/cpp1y/pr72759.C: New test.
+
 2016-08-04  Patrick Palka  <ppalka@gcc.gnu.org>
 
        * gcc.dg/switch-10.c: New test.
diff --git a/gcc/testsuite/g++.dg/cpp1y/pr72759.C b/gcc/testsuite/g++.dg/cpp1y/pr72759.C
new file mode 100644 (file)
index 0000000..4af6ea4
--- /dev/null
@@ -0,0 +1,18 @@
+// PR c++/72759
+// { dg-do compile { target c++14 } }
+
+template <typename> struct SpecPerType;
+class Specializer {
+  public:  template <bool> static void MbrFnTempl();
+  template <unsigned> struct A { static void InnerMemberFn(); };
+  void Trigger() { A<0>::InnerMemberFn; }
+};
+template <> struct SpecPerType<Specializer> {
+  using FnType = void *;
+  template <bool P>
+  static constexpr FnType SpecMbrFnPtr = Specializer::MbrFnTempl<P>;
+};
+template <unsigned X> void Specializer::A<X>::InnerMemberFn() {
+  using Spec = SpecPerType<Specializer>;
+  Spec ErrorSite = Spec::SpecMbrFnPtr<SpecMbrFnPtr>;  // { dg-error "not declared" }
+}