OSDN Git Service

PR c++/10230, c++/10481
authorlerdsuwa <lerdsuwa@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 11 May 2003 10:06:39 +0000 (10:06 +0000)
committerlerdsuwa <lerdsuwa@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 11 May 2003 10:06:39 +0000 (10:06 +0000)
* semantics.c (finish_non_static_data_member): Handle when the
non-static member is not from a base of the current class type.

* g++.dg/lookup/scoped5.C: New test.

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

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

index 9aa822b..a11a502 100644 (file)
@@ -1,5 +1,11 @@
 2003-05-11  Kriang Lerdsuwanakij  <lerdsuwa@users.sourceforge.net>
 
+       PR c++/10230, c++/10481
+       * semantics.c (finish_non_static_data_member): Handle when the
+       non-static member is not from a base of the current class type.
+
+2003-05-11  Kriang Lerdsuwanakij  <lerdsuwa@users.sourceforge.net>
+
        PR c++/10552
        * pt.c (tsubst_copy): Handle TEMPLATE_DECL that is a member class
        template and has dependent context.
index 62a900a..ab6a75c 100644 (file)
@@ -1276,13 +1276,22 @@ finish_non_static_data_member (tree decl, tree qualifying_scope)
       tree access_type = current_class_type;
       tree object = current_class_ref;
 
-      while (!DERIVED_FROM_P (context_for_name_lookup (decl), access_type))
+      while (access_type
+            && !DERIVED_FROM_P (context_for_name_lookup (decl), access_type))
        {
          access_type = TYPE_CONTEXT (access_type);
-         while (DECL_P (access_type))
+         while (access_type && DECL_P (access_type))
            access_type = DECL_CONTEXT (access_type);
        }
 
+      if (!access_type)
+       {
+         cp_error_at ("object missing in reference to `%D'",
+                      decl);
+         error ("from this location");
+         return error_mark_node;
+       }
+
       perform_or_defer_access_check (access_type, decl);
 
       /* If the data member was named `C::M', convert `*this' to `C'
index ade2507..5f37055 100644 (file)
@@ -1,5 +1,10 @@
 2003-05-11  Kriang Lerdsuwanakij  <lerdsuwa@users.sourceforge.net>
 
+       PR c++/10230, c++/10481
+       * g++.dg/lookup/scoped5.C: New test.
+
+2003-05-11  Kriang Lerdsuwanakij  <lerdsuwa@users.sourceforge.net>
+
        PR c++/10552
        * g++.dg/template/ttp6.C: New test.
 
diff --git a/gcc/testsuite/g++.dg/lookup/scoped5.C b/gcc/testsuite/g++.dg/lookup/scoped5.C
new file mode 100644 (file)
index 0000000..267bc60
--- /dev/null
@@ -0,0 +1,19 @@
+// { dg-do compile }
+
+// Origin: pepeaty@yahoo.com
+
+// PR c++/10230: ICE while determining if refered non-static member
+// is from a base type of the current class.
+
+class A {
+public:
+  class B {
+  public:
+    int a;                     // { dg-error "member of base" }
+  };
+};
+
+class C {
+public:
+  void f(void) { sizeof(A::B::a); } // { dg-error "this location" }
+};