re PR c++/89512 (ICE in get_expr_operands, at tree-ssa-operands.c:882)
authorJakub Jelinek <jakub@redhat.com>
Thu, 14 Mar 2019 08:14:48 +0000 (09:14 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Thu, 14 Mar 2019 08:14:48 +0000 (09:14 +0100)
PR c++/89512
* semantics.c (finish_qualified_id_expr): Reject variable templates.

* g++.dg/cpp1y/var-templ61.C: New test.

From-SVN: r269672

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

index 7c0b4f47322686b5c9d76561077e26534451d05b..054a891bcef374a69643d7709b33978dcb9c0474 100644 (file)
@@ -1,5 +1,8 @@
 2019-03-14  Jakub Jelinek  <jakub@redhat.com>
 
+       PR c++/89512
+       * semantics.c (finish_qualified_id_expr): Reject variable templates.
+
        PR c++/89652
        * constexpr.c (struct constexpr_ctx): Change save_exprs type from
        hash_set<tree> to vec<tree>.
index 798a2b3bb30f70d8ad830904cfd4c50908b5244b..fcf06061bc724963b33ffc1c6686aee81d50c5bd 100644 (file)
@@ -2112,6 +2112,14 @@ finish_qualified_id_expr (tree qualifying_class,
        expr = build_offset_ref (qualifying_class, expr, /*address_p=*/false,
                                 complain);
     }
+  else if (!template_p
+          && TREE_CODE (expr) == TEMPLATE_DECL
+          && !DECL_FUNCTION_TEMPLATE_P (expr))
+    {
+      if (complain & tf_error)
+       error ("%qE missing template arguments", expr);
+      return error_mark_node;
+    }
   else
     {
       /* In a template, return a SCOPE_REF for most qualified-ids
index 73ac51a8bbde76cdc3e34e4fe24547f3380cfe52..dbd918c6ca4cca12fdb3331a10eae41a32b2c497 100644 (file)
@@ -1,5 +1,8 @@
 2019-03-14  Jakub Jelinek  <jakub@redhat.com>
 
+       PR c++/89512
+       * g++.dg/cpp1y/var-templ61.C: New test.
+
        PR c++/89652
        * g++.dg/cpp1y/constexpr-89652.C: New test.
 
diff --git a/gcc/testsuite/g++.dg/cpp1y/var-templ61.C b/gcc/testsuite/g++.dg/cpp1y/var-templ61.C
new file mode 100644 (file)
index 0000000..be2fe0f
--- /dev/null
@@ -0,0 +1,20 @@
+// PR c++/89512
+// { dg-do compile { target c++14 } }
+
+struct A {
+  template <typename T>
+  static const int a = 0;
+};
+
+struct B {
+  template <typename T>
+  static int foo ()
+  {
+    return T::a;               // { dg-error "missing template arguments" }
+  }
+};
+
+int bar ()
+{
+  return B::foo<A> ();         // { dg-message "required from here" }
+}