parse.y (base_class.1): Produce a _TYPE not a _DECL.
authorNathan Sidwell <nathan@codesourcery.com>
Tue, 28 Nov 2000 10:31:09 +0000 (10:31 +0000)
committerNathan Sidwell <nathan@gcc.gnu.org>
Tue, 28 Nov 2000 10:31:09 +0000 (10:31 +0000)
cp:
* parse.y (base_class.1): Produce a _TYPE not a _DECL.
* semantics.c (finish_base_specifier): Accept a _TYPE not a
_DECL.
testsuite:
* g++.old-deja/g++.other/base1.C: New test.

From-SVN: r37817

gcc/cp/ChangeLog
gcc/cp/parse.y
gcc/cp/semantics.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.old-deja/g++.other/base1.C [new file with mode: 0644]

index 9d486f6a59cc473b76780221e9d24a2236f160da..e0c75484634f9da28b8765de390ef2a8eb781305 100644 (file)
@@ -1,3 +1,9 @@
+2000-11-28  Nathan Sidwell  <nathan@codesourcery.com>
+
+       * parse.y (base_class.1): Produce a _TYPE not a _DECL.
+       * semantics.c (finish_base_specifier): Accept a _TYPE not a
+       _DECL.
+
 2000-11-28  Nathan Sidwell  <nathan@codesourcery.com>
 
        * spew.c (yyerror): Cope if yylval.ttype is NULL.
index 9e32911058f9d3538e019f414202935ef5465325..4c03dc74c03023dee59dc44ba3db68861caa35f1 100644 (file)
@@ -2460,13 +2460,10 @@ base_class:
 
 base_class.1:
          typename_sub
-               { if ($$ == error_mark_node)
-                   ;
-                  else if (!TYPE_P ($$))
-                   $$ = error_mark_node;
-                 else 
-                   $$ = TYPE_MAIN_DECL ($1); }
+               { if (!TYPE_P ($$))
+                   $$ = error_mark_node; }
        | nonnested_type
+               { $$ = TREE_TYPE ($$); }
        ;
 
 base_class_access_list:
index 8d22ce2e70ea70574f8f0b0f89f600f64bd01c13..8502eeff1021a7678dd9a1b9cdfea3d9a7f04d13 100644 (file)
@@ -2068,21 +2068,19 @@ finish_base_specifier (access_specifier, base_class)
      tree access_specifier;
      tree base_class;
 {
-  tree type;
   tree result;
 
-  if (base_class == NULL_TREE)
-    {
-      error ("invalid base class");
-      type = error_mark_node;
-    }
-  else
-    type = TREE_TYPE (base_class);
-
-  if (! is_aggr_type (type, 1))
+  if (! is_aggr_type (base_class, 1))
     result = NULL_TREE;
   else
-    result = build_tree_list (access_specifier, type);
+    {
+      if (CP_TYPE_QUALS (base_class) != 0)
+        {
+          cp_error ("base class `%T' has cv qualifiers", base_class);
+          base_class = TYPE_MAIN_VARIANT (base_class);
+        }
+      result = build_tree_list (access_specifier, base_class);
+    }
 
   return result;
 }
index 06f689b708377d3ceb0e1bb4d83501ec89009be6..f60af3fdc8203ff9e4287f26c90592d5b3846782 100644 (file)
@@ -1,3 +1,7 @@
+2000-11-28  Nathan Sidwell  <nathan@codesourcery.com>
+
+       * g++.old-deja/g++.other/base1.C: New test.
+
 2000-11-28  Nathan Sidwell  <nathan@codesourcery.com>
 
        * g++.old-deja/g++.other/parse2.C: New test.
diff --git a/gcc/testsuite/g++.old-deja/g++.other/base1.C b/gcc/testsuite/g++.old-deja/g++.other/base1.C
new file mode 100644 (file)
index 0000000..ace821c
--- /dev/null
@@ -0,0 +1,20 @@
+// Build don't link:
+
+// Copyright (C) 2000 Free Software Foundation, Inc.
+// Contributed by Nathan Sidwell 25 Nov 2000 <nathan@codesourcery.com>
+
+// We lost information about which base wasn't an aggregate type, plus we
+// allowed cv qualifed bases via typedefs.
+
+typedef int I;
+typedef int cI;
+
+struct A {};
+
+typedef const A cA;
+typedef A pA;
+
+struct B : I {};  // ERROR - not an aggregate
+struct C : cI {}; // ERROR - not an aggregate
+struct D : cA {}; // ERROR - cv qualified
+struct E : pA {};