PR c++/71710 - template using directive of field
authorNathan Sidwell <nathan@acm.org>
Mon, 23 Jan 2017 20:24:32 +0000 (20:24 +0000)
committerNathan Sidwell <nathan@gcc.gnu.org>
Mon, 23 Jan 2017 20:24:32 +0000 (20:24 +0000)
PR c++/71710 - template using directive of field
* pt.c (tsubst_copy_and_build [COMPONENT_REF]): Move FIELD_DECL
check earlier.

PR C++/71710
* g++.dg/template/pr71710.C: New.

From-SVN: r244833

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

index c56c84089f0e92b46463342d53c540ff87d0b803..66151e9b0a4c71cf489cd1fe05aa15747e161d8a 100644 (file)
@@ -1,5 +1,9 @@
 2017-01-23  Nathan Sidwell  <nathan@acm.org>
 
+       PR c++/71710 - template using directive of field
+       * pt.c (tsubst_copy_and_build [COMPONENT_REF]): Move FIELD_DECL
+       check earlier.
+
        PR c++/71406 - ICE with scope-ref'd template id exprs
        PR c++/77508
        * typeck.c (finish_class_member_access_expr): Break up SCOPE_REF
index 8c920c3644236517a8ee1dfb3b10f9f9c1da4838..537d1073fa0ce24964694ba3adde9bf3f2211d70 100644 (file)
@@ -17470,7 +17470,14 @@ tsubst_copy_and_build (tree t,
        if (member == error_mark_node)
          RETURN (error_mark_node);
 
-       if (type_dependent_expression_p (object))
+       if (TREE_CODE (member) == FIELD_DECL)
+         {
+           r = finish_non_static_data_member (member, object, NULL_TREE);
+           if (TREE_CODE (r) == COMPONENT_REF)
+             REF_PARENTHESIZED_P (r) = REF_PARENTHESIZED_P (t);
+           RETURN (r);
+         }
+       else if (type_dependent_expression_p (object))
          /* We can't do much here.  */;
        else if (!CLASS_TYPE_P (object_type))
          {
@@ -17535,13 +17542,6 @@ tsubst_copy_and_build (tree t,
              }
            RETURN (error_mark_node);
          }
-       else if (TREE_CODE (member) == FIELD_DECL)
-         {
-           r = finish_non_static_data_member (member, object, NULL_TREE);
-           if (TREE_CODE (r) == COMPONENT_REF)
-             REF_PARENTHESIZED_P (r) = REF_PARENTHESIZED_P (t);
-           RETURN (r);
-         }
 
        r = finish_class_member_access_expr (object, member,
                                             /*template_p=*/false,
index f3ac5e5bd5aba0cce84eb95c509ef51cb9407be2..ee1f19ce99316aa604af60560fc425c89513811f 100644 (file)
@@ -1,5 +1,8 @@
 2017-01-23  Nathan Sidwell  <nathan@acm.org>
 
+       PR C++/71710
+       * g++.dg/template/pr71710.C: New.
+
        PR c++/71406
        PR c++/77508
        * g++.dg/template/pr71406.C: New.
diff --git a/gcc/testsuite/g++.dg/template/pr71710.C b/gcc/testsuite/g++.dg/template/pr71710.C
new file mode 100644 (file)
index 0000000..7c394e7
--- /dev/null
@@ -0,0 +1,10 @@
+// { dg-do compile { target c++11 } }
+// PR C++/71710 ICE with decltype & using
+
+template < typename > struct A
+{
+  A a;
+  template < int > using B = decltype (a);
+  B < 0 > b;
+  template < int C > B < C > foo ();
+};