re PR c++/12486 (Accepts IMHO invalid C++ code)
authorMark Mitchell <mark@codesourcery.com>
Thu, 2 Oct 2003 23:14:01 +0000 (23:14 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Thu, 2 Oct 2003 23:14:01 +0000 (23:14 +0000)
PR c++/12486
* typeck.c (finish_class_member_access_expr): Issue diagnostic
on erroneous use of qualified name.

PR c++/12486
* g++.dg/inherit/error1.C: New test.

From-SVN: r72052

gcc/cp/ChangeLog
gcc/cp/typeck.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/inherit/error1.C [new file with mode: 0644]

index b6fe158a6c0f17162d660f6a84784069f0da1d7f..1661e4170c5ff5f2ac790ca5b9956630fcc4844d 100644 (file)
@@ -1,3 +1,9 @@
+2003-10-02  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/12486
+       * typeck.c (finish_class_member_access_expr): Issue diagnostic
+       on erroneous use of qualified name.
+
 2003-09-30  Richard Henderson  <rth@redhat.com>
 
        * decl.c (duplicate_decls): Copy DECL_SAVED_INSNS too.
index 5c45976bffe42c66129b55b34241faf19294479a..25d6ac4ef466a7d5487c1dee0276eddefa12061d 100644 (file)
@@ -1888,8 +1888,13 @@ finish_class_member_access_expr (tree object, tree name)
 
          /* Find the base of OBJECT_TYPE corresponding to SCOPE.  */
          access_path = lookup_base (object_type, scope, ba_check, NULL);
-         if (!access_path || access_path == error_mark_node)
+         if (access_path == error_mark_node)
            return error_mark_node;
+         if (!access_path)
+           {
+             error ("`%T' is not a base of `%T'", scope, object_type);
+             return error_mark_node;
+           }
        }
       else
        {
index f69251bd9887ae0db685640fca5866a0ae800f6d..5d992b1896ff7d42b30a551cd15bac449e809dce 100644 (file)
@@ -1,3 +1,8 @@
+2003-10-02  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/12486
+       * g++.dg/inherit/error1.C: New test.
+
 2003-10-02  Chris Demetriou  <cgd@broadcom.com>
 
        * lib/f-torture.exp (search_for): Rename to...
diff --git a/gcc/testsuite/g++.dg/inherit/error1.C b/gcc/testsuite/g++.dg/inherit/error1.C
new file mode 100644 (file)
index 0000000..1570bf1
--- /dev/null
@@ -0,0 +1,10 @@
+// PR 12486
+
+struct A { int ma; }; 
+struct B { }; 
+void foo() 
+{ 
+  B *b; 
+  b->A::ma=0; // { dg-error "" }
+}