OSDN Git Service

PR c++/21008, DR 515
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 13 Nov 2009 14:40:22 +0000 (14:40 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 13 Nov 2009 14:40:22 +0000 (14:40 +0000)
* semantics.c (finish_non_static_data_member): Don't check
derivation in a template.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@154150 138bc75d-0d04-0410-961f-82ee72b054a4

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 1ffa86a..b148d23 100644 (file)
@@ -1,5 +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.
+
        PR c++/11987
        * parser.c (cp_parser_direct_declarator): Give helpful error about
        trying to define member of a dependent typedef.
index e270a73..c1df24b 100644 (file)
@@ -1485,6 +1485,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);
@@ -1504,15 +1512,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 20f4686..82752b8 100644 (file)
@@ -1,5 +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.
+
        PR c++/11987
        * g++.dg/parse/typename11.C: New.
        * g++.dg/template/crash48.C: Adjust.
index 1c30304..2ba28a6 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();
+}