]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
PR c++/21008, DR 515
authorJason Merrill <jason@redhat.com>
Fri, 13 Nov 2009 15:37:29 +0000 (10:37 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Fri, 13 Nov 2009 15:37:29 +0000 (10:37 -0500)
PR c++/21008, DR 515
* semantics.c (finish_non_static_data_member): Don't check
derivation in a template.

From-SVN: r154153

gcc/cp/ChangeLog
gcc/cp/semantics.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/lookup/scoped8.C
gcc/testsuite/g++.dg/template/inherit4.C [new file with mode: 0644]

index 0990ca687e01fe1b122fcebca1de7d765b4d1688..c81318730048ac05fbe274eba61de61bb694ce3c 100644 (file)
@@ -1,3 +1,9 @@
+2009-11-13  Jason Merrill  <jason@redhat.com>
+
+       PR c++/21008, DR 515
+       * semantics.c (finish_non_static_data_member): Don't check
+       derivation in a template.
+
 2009-11-12  Jason Merrill  <jason@redhat.com>
 
        PR c++/37037
index fc6469689a99934bea24900aa4a2805c820cd8bc..70dd353b8bb238abadd5133922916e29dc75fb52 100644 (file)
@@ -1449,6 +1449,14 @@ finish_non_static_data_member (tree decl, tree object, tree qualifying_scope)
 
       return build_min (COMPONENT_REF, type, object, decl, NULL_TREE);
     }
+  /* If PROCESSING_TEMPLATE_DECL is nonzero here, then
+     QUALIFYING_SCOPE is also non-null.  Wrap this in a SCOPE_REF
+     for now.  */
+  else if (processing_template_decl)
+    return build_qualified_name (TREE_TYPE (decl),
+                                qualifying_scope,
+                                DECL_NAME (decl),
+                                /*template_p=*/false);
   else
     {
       tree access_type = TREE_TYPE (object);
@@ -1468,15 +1476,6 @@ finish_non_static_data_member (tree decl, tree object, tree qualifying_scope)
            }
        }
 
-      /* If PROCESSING_TEMPLATE_DECL is nonzero here, then
-        QUALIFYING_SCOPE is also non-null.  Wrap this in a SCOPE_REF
-        for now.  */
-      if (processing_template_decl)
-       return build_qualified_name (TREE_TYPE (decl),
-                                    qualifying_scope,
-                                    DECL_NAME (decl),
-                                    /*template_p=*/false);
-
       perform_or_defer_access_check (TYPE_BINFO (access_type), decl,
                                     decl);
 
index ef66c3ee5f074520441bc1ff7d31cbbd20d78fad..077763691d72e8ab5af75100fe4c72db00169f8b 100644 (file)
@@ -1,3 +1,9 @@
+2009-11-13  Jason Merrill  <jason@redhat.com>
+
+       PR c++/21008, DR 515
+       * g++.dg/template/inherit4.C: New.
+       * g++.dg/lookup/scoped8.C: Adjust.
+
 2009-11-12  Jason Merrill  <jason@redhat.com>
 
        PR c++/37037
index 1c3030456085d32e32a1a5354e59ea73d275aa8a..2ba28a6941b2773f9cdaf7ac2b55435a901b46b5 100644 (file)
@@ -14,3 +14,5 @@ template <int> struct B
 {
     int foo() { return A::i; } // { dg-error "this location" }
 };
+
+template struct B<0>;
diff --git a/gcc/testsuite/g++.dg/template/inherit4.C b/gcc/testsuite/g++.dg/template/inherit4.C
new file mode 100644 (file)
index 0000000..511c9e6
--- /dev/null
@@ -0,0 +1,14 @@
+// PR c++/21008, DR 515
+
+struct A {
+  int foo_;
+};
+template <typename T> struct B: public A { };
+template <typename T> struct C: B<T> {
+  int foo() {
+    return A::foo_;  // #1
+  }
+};
+int f(C<int>* p) {
+  return p->foo();
+}