re PR c++/9120 (miscompilation of function with references to undeclared objects...
authorMark Mitchell <mark@codesourcery.com>
Fri, 10 Jan 2003 22:57:04 +0000 (22:57 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Fri, 10 Jan 2003 22:57:04 +0000 (22:57 +0000)
PR c++/9120
* parser.c (cp_parser_scope_through_which_access_occurs): Handle
an object_type which is not a class type.

PR c++/9120
* g++.dg/parse/dtor1.C: New file.

From-SVN: r61174

gcc/cp/ChangeLog
gcc/cp/parser.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/parse/dtor1.C [new file with mode: 0644]

index 0c73ca27836709537eef92e638f0afe246db2947..0764979fcd75bdfc12518a3a5843320db2664e23 100644 (file)
@@ -1,3 +1,9 @@
+2003-01-10  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/9120
+       * parser.c (cp_parser_scope_through_which_access_occurs): Handle
+       an object_type which is not a class type.
+
 2003-01-10  Geoffrey Keating  <geoffk@apple.com>
 
        * parser.c (cp_parser_late_parsing_for_member): Don't cast to void.
index 7c7d49b7c4e8358792a33569f183e552043eed8d..ebd919d970f561e79d6a814a4e4c6ae6b7eb5b43 100644 (file)
@@ -2230,7 +2230,17 @@ cp_parser_scope_through_which_access_occurs (decl,
   if (!TYPE_P (scope))
     return NULL_TREE;
   /* Figure out the type through which DECL is being accessed.  */
-  if (object_type && DERIVED_FROM_P (scope, object_type))
+  if (object_type 
+      /* OBJECT_TYPE might not be a class type; consider:
+
+          class A { typedef int I; };
+          I *p;
+          p->A::I::~I();
+
+         In this case, we will have "A::I" as the DECL, but "I" as the
+        OBJECT_TYPE.  */
+      && CLASS_TYPE_P (object_type)
+      && DERIVED_FROM_P (scope, object_type))
     /* If we are processing a `->' or `.' expression, use the type of the
        left-hand side.  */
     qualifying_type = object_type;
index e642d44faa571b309d3f57999c47a9a2d4a16f01..b6f1d50da8410e42e595b8043c8a204e04a4c2eb 100644 (file)
@@ -1,5 +1,8 @@
 2003-01-10  Mark Mitchell  <mark@codesourcery.com>
 
+       PR c++/9120
+       * g++.dg/parse/dtor1.C: New file.
+
        PR c++/9128
        * g++.dg/rtti/typeid1.C: New file.
 
diff --git a/gcc/testsuite/g++.dg/parse/dtor1.C b/gcc/testsuite/g++.dg/parse/dtor1.C
new file mode 100644 (file)
index 0000000..08d070e
--- /dev/null
@@ -0,0 +1,6 @@
+struct A { typedef int I; };
+int main(void)
+{
+        int * p;
+        p->A::I::~I();
+}