]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Backport:
authorVolker Reichelt <reichelt@igpm.rwth-aachen.de>
Tue, 6 Sep 2005 15:25:11 +0000 (15:25 +0000)
committerVolker Reichelt <reichelt@gcc.gnu.org>
Tue, 6 Sep 2005 15:25:11 +0000 (15:25 +0000)
2004-12-14  Mark Mitchell  <mark@codesourcery.com>
PR c++/18738
* decl.c (make_typename_type): Do not handle namespace-scoped
names here.
(tag_name): Handle typename_type.
(check_elaborated_type_specifier): Handle typenames.
* parser.c (cp_parser_diagnose_invalid_type_name): Do not call
make_typename_type for namespace-scoped names here.
(cp_parser_elaborated_type_specifier): Use
cp_parser_diagnose_invalid_type_name.

* g++.dg/template/typename8.C: New test.
* g++.dg/parse/friend2.C: Tweak error message.

From-SVN: r103951

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/cp/parser.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/parse/friend2.C

index bc4cfb3a82ac9ed9ed37e422c8ffaac4b13b046b..dcbd0f7cd0af09e5f1ad779f8d1e6a87ca2dfcf9 100644 (file)
@@ -1,3 +1,18 @@
+2005-09-06  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
+
+       Backport:
+
+       2004-12-14  Mark Mitchell  <mark@codesourcery.com>
+       PR c++/18738
+       * decl.c (make_typename_type): Do not handle namespace-scoped
+       names here.
+       (tag_name): Handle typename_type.
+       (check_elaborated_type_specifier): Handle typenames.
+       * parser.c (cp_parser_diagnose_invalid_type_name): Do not call
+       make_typename_type for namespace-scoped names here.
+       (cp_parser_elaborated_type_specifier): Use
+       cp_parser_diagnose_invalid_type_name.
+
 2005-09-03  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
 
        Backport:
index 7381ae321228ace12163c372064cd8388691ba00..b9199da3169f409c3c3cac58e8010f12aafe32cf 100644 (file)
@@ -2647,16 +2647,7 @@ make_typename_type (tree context, tree name, tsubst_flags_t complain)
       return error_mark_node;
     }
   my_friendly_assert (TREE_CODE (name) == IDENTIFIER_NODE, 20030802);
-  
-  if (TREE_CODE (context) == NAMESPACE_DECL)
-    {
-      /* We can get here from typename_sub0 in the explicit_template_type
-        expansion.  Just fail.  */
-      if (complain & tf_error)
-       error ("no class template named `%#T' in `%#T'",
-                 name, context);
-      return error_mark_node;
-    }
+  my_friendly_assert (TYPE_P (context), 20050905);
 
   if (!dependent_type_p (context)
       || currently_open_class (context))
@@ -9344,9 +9335,11 @@ tag_name (enum tag_types code)
     case class_type:
       return "class";
     case union_type:
-      return "union ";
+      return "union";
     case enum_type:
       return "enum";
+    case typename_type:
+      return "typename";
     default:
       abort ();
     }
@@ -9384,7 +9377,8 @@ check_elaborated_type_specifier (enum tag_types tag_code,
      In other words, the only legitimate declaration to use in the
      elaborated type specifier is the implicit typedef created when
      the type is declared.  */
-  if (!DECL_IMPLICIT_TYPEDEF_P (decl))
+  if (!DECL_IMPLICIT_TYPEDEF_P (decl)
+      && tag_code != typename_type)
     {
       error ("using typedef-name `%D' after `%s'", decl, tag_name (tag_code));
       return IS_AGGR_TYPE (type) ? type : error_mark_node;
@@ -9398,7 +9392,8 @@ check_elaborated_type_specifier (enum tag_types tag_code,
     }
   else if (TREE_CODE (type) != RECORD_TYPE
           && TREE_CODE (type) != UNION_TYPE
-          && tag_code != enum_type)
+          && tag_code != enum_type
+          && tag_code != typename_type)
     {
       error ("`%T' referred to as `%s'", type, tag_name (tag_code));
       return error_mark_node;
index 1ae93effd64bf61ea34a8bd6b4a86191c2a40095..a9589bd0cb6ead6a104385bf6c69e842349d7d50 100644 (file)
@@ -9245,7 +9245,8 @@ cp_parser_elaborated_type_specifier (cp_parser* parser,
        }
 
       /* For a `typename', we needn't call xref_tag.  */
-      if (tag_type == typename_type)
+      if (tag_type == typename_type
+         && TREE_CODE (parser->scope) != NAMESPACE_DECL)
        return make_typename_type (parser->scope, identifier, 
                                   /*complain=*/1);
       /* Look up a qualified name in the usual way.  */
@@ -9289,7 +9290,7 @@ cp_parser_elaborated_type_specifier (cp_parser* parser,
 
          if (TREE_CODE (decl) != TYPE_DECL)
            {
-             error ("expected type-name");
+             cp_parser_diagnose_invalid_type_name (parser);
              return error_mark_node;
            }
 
index 092acae2ff3c6c8e6420c06f0f904889da55ffce..6788ff16b9257e0df17f4a1b2ff3dac7d661fe3a 100644 (file)
@@ -1,3 +1,12 @@
+2005-09-06  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
+
+       Backport:
+
+       2004-12-14  Mark Mitchell  <mark@codesourcery.com>
+       PR c++/18738
+       * g++.dg/template/typename8.C: New test.
+       * g++.dg/parse/friend2.C: Tweak error message.
+
 2005-09-03  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
 
        Backport:
index 2e88845cceb0ede102b18be448b189fb4e6fa5b8..1a2ad8bfad9280cf187154c6f972ae39d8324e91 100644 (file)
@@ -10,7 +10,7 @@ namespace NS {
 }
 
 template <class T> class X {
-  friend class NS::C;  // { dg-error "expected|friend" }
+  friend class NS::C;  // { dg-error "template|friend" }
 };
 
 X<int> c;