]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Backport:
authorVolker Reichelt <reichelt@igpm.rwth-aachen.de>
Thu, 1 Sep 2005 15:23:21 +0000 (15:23 +0000)
committerVolker Reichelt <reichelt@gcc.gnu.org>
Thu, 1 Sep 2005 15:23:21 +0000 (15:23 +0000)
2004-11-27  Mark Mitchell  <mark@codesourcery.com>
PR c++/18512
* parser.c (cp_parser_postfix_expression): Robustify.

* g++.dg/template/crash29.C: New test.

From-SVN: r103734

gcc/cp/ChangeLog
gcc/cp/parser.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/template/crash29.C

index b485511eaf4c3702f8f22f2bdad2a9c3fb418371..20484b9b84e6fb8fc694c9f4f491c49717a70b04 100644 (file)
@@ -1,3 +1,11 @@
+2005-09-01  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
+
+       Backport:
+
+       2004-11-27  Mark Mitchell  <mark@codesourcery.com>
+       PR c++/18512
+       * parser.c (cp_parser_postfix_expression): Robustify.
+
 2005-09-01  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
 
        Backport:
index 1edbafca7ccdf3b5dd7d9432841dd64bac2574fb..1ae93effd64bf61ea34a8bd6b4a86191c2a40095 100644 (file)
@@ -3966,20 +3966,29 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p)
                if (parser->scope)
                  idk = CP_ID_KIND_QUALIFIED;
 
-               if (name != error_mark_node 
-                   && !BASELINK_P (name)
-                   && parser->scope)
+               /* If the name is a template-id that names a type, we will
+                  get a TYPE_DECL here.  That is invalid code.  */
+               if (TREE_CODE (name) == TYPE_DECL)
                  {
-                   name = build_nt (SCOPE_REF, parser->scope, name);
-                   parser->scope = NULL_TREE;
-                   parser->qualifying_scope = NULL_TREE;
-                   parser->object_scope = NULL_TREE;
+                   error ("invalid use of `%D'", name);
+                   postfix_expression = error_mark_node;
+                 }
+               else
+                 {
+                   if (name != error_mark_node && !BASELINK_P (name)
+                       && parser->scope)
+                     {
+                       name = build_nt (SCOPE_REF, parser->scope, name);
+                       parser->scope = NULL_TREE;
+                       parser->qualifying_scope = NULL_TREE;
+                       parser->object_scope = NULL_TREE;
+                     }
+                   if (scope && name && BASELINK_P (name))
+                     adjust_result_of_qualified_name_lookup
+                       (name, BINFO_TYPE (BASELINK_BINFO (name)), scope);
+                   postfix_expression = finish_class_member_access_expr
+                                          (postfix_expression, name);
                  }
-               if (scope && name && BASELINK_P (name))
-                 adjust_result_of_qualified_name_lookup 
-                   (name, BINFO_TYPE (BASELINK_BINFO (name)), scope);
-               postfix_expression 
-                 = finish_class_member_access_expr (postfix_expression, name);
              }
 
            /* We no longer need to look up names in the scope of the
index 0bd2505f77345afbd62fde658f2b44b4179bb905..f77f197046655f2c4fd68aae756bb7dedb809b36 100644 (file)
@@ -1,3 +1,11 @@
+2005-09-01  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
+
+       Backport:
+
+       2004-11-27  Mark Mitchell  <mark@codesourcery.com>
+       PR c++/18512
+       * g++.dg/template/crash29.C: New test.
+
 2005-09-01  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
 
        Backport:
index 55953ed80100d559c5ff6f870f71313dc8e548cd..681d2ce38d6bcab8ad922cf7bcda139765a81dea 100644 (file)
@@ -4,5 +4,5 @@ template <int> struct A {};
 
 struct B : A<0>
 {
-  void foo() { this->A<0>; } // { dg-error "" }
+  void foo() { this->A<0>; } // { dg-error "invalid use" }
 };