This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch] PR c++/18512: backport to 3.4 branch


Title says it all.

The patch is mostly whitespace change. The only thing that really
changes is the additional check

   if (TREE_CODE (name) == TYPE_DECL)
     {
       error ("invalid use of `%D'", name);
       postfix_expression = error_mark_node;
     }
   else
     {
        ....
     }

Bootstrapped and regtested on i686-pc-linux-gnu.
Ok for the 3.4 branch?

Regards,
Volker


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.

===================================================================
*** gcc/gcc/cp/parser.c	31 Aug 2005 10:16:00 -0000	1.157.2.59
--- gcc/gcc/cp/parser.c	1 Sep 2005 14:43:50 -0000
*************** cp_parser_postfix_expression (cp_parser 
*** 3966,3985 ****
  		if (parser->scope)
  		  idk = CP_ID_KIND_QUALIFIED;
  
! 		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);
  	      }
  
  	    /* We no longer need to look up names in the scope of the
--- 3966,3994 ----
  		if (parser->scope)
  		  idk = CP_ID_KIND_QUALIFIED;
  
! 		/* 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)
  		  {
! 		    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);
  		  }
  	      }
  
  	    /* We no longer need to look up names in the scope of the
===================================================================


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.

===================================================================
--- gcc/gcc/testsuite/g++.dg/template/crash29.C
+++ gcc/gcc/testsuite/g++.dg/template/crash29.C	2005-09-01 09:40:29 +0000
@@ -0,0 +1,8 @@
+// PR c++/18512
+
+template <int> struct A {};
+
+struct B : A<0>
+{
+  void foo() { this->A<0>; } // { dg-error "" }
+};
===================================================================



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]