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]

[C++ PATCH for 3.3] Fix PR10849 (2nd approach)


Hi

This is another approach for fixing PR 10849, a regression in 3.3,
in case you guys prefer it this way.  This one reset 'type_lookups'
after parsing class head and before parsing base classes.  So
deferred access is no longer perform on such class head.

Tested on i686-pc-linux-gnu.  OK for 3.3 branch?

--Kriang


2003-07-09  Kriang Lerdsuwanakij  <lerdsuwa@users.sourceforge.net>

	PR c++/10849
	* parse.y (class_head_defn): Reset type_lookups for class head
	that is a template id.
	* search.c (type_access_control): Revert my 2003-05-25 change.

2003-07-09  Kriang Lerdsuwanakij  <lerdsuwa@users.sourceforge.net>

	PR c++/10849
	* g++.dg/template/access12.C: New test.


diff -cprN gcc-33-save/gcc/cp/parse.y gcc-33-new/gcc/cp/parse.y
*** gcc-33-save/gcc/cp/parse.y	Sun Jul  6 17:19:35 2003
--- gcc-33-new/gcc/cp/parse.y	Sun Jul  6 21:37:36 2003
*************** class_head_defn:
*** 2493,2498 ****
--- 2493,2501 ----
  		  yyungetc ('{', 1);
  		  $$.t = $1;
  		  $$.new_type_flag = 0;
+ 		  /* Don't check access for names that appeared in
+ 		     class_head_apparent_template.  */
+ 		  type_lookups = NULL_TREE;
  		  if (TREE_CODE (TREE_TYPE ($1)) == RECORD_TYPE)
  		    /* We might be specializing a template with a different
  		       class-key.  */
*************** class_head_defn:
*** 2504,2509 ****
--- 2507,2515 ----
  		  yyungetc (':', 1);
  		  $$.t = $1;
  		  $$.new_type_flag = 0;
+ 		  /* Don't check access for names that appeared in
+ 		     class_head_apparent_template.  */
+ 		  type_lookups = NULL_TREE;
  		  if (TREE_CODE (TREE_TYPE ($1)) == RECORD_TYPE)
  		    /* We might be specializing a template with a different
  		       class-key.  */
diff -cprN gcc-33-save/gcc/cp/search.c gcc-33-new/gcc/cp/search.c
*** gcc-33-save/gcc/cp/search.c	Sun Jul  6 17:19:35 2003
--- gcc-33-new/gcc/cp/search.c	Sun Jul  6 21:34:50 2003
*************** void
*** 1048,1062 ****
  type_access_control (type, val)
       tree type, val;
  {
-   /* The check processing_specialization is here because the parser in 3.3
-      does not set current_class_type while parsing class head of class
-      template specialization.  Access checking, if performed, will be
-      evaluated in the wrong context so we disable it here.  This doesn't
-      apply to the new parser in 3.4.  */
    if (val == NULL_TREE
        || (TREE_CODE (val) != TEMPLATE_DECL && TREE_CODE (val) != TYPE_DECL)
!       || ! DECL_CLASS_SCOPE_P (val)
!       || processing_specialization)
      return;
  
    if (type_lookups == error_mark_node)
--- 1048,1056 ----
  type_access_control (type, val)
       tree type, val;
  {
    if (val == NULL_TREE
        || (TREE_CODE (val) != TEMPLATE_DECL && TREE_CODE (val) != TYPE_DECL)
!       || ! DECL_CLASS_SCOPE_P (val))
      return;
  
    if (type_lookups == error_mark_node)
diff -cprN gcc-33-save/gcc/testsuite/g++.dg/template/access12.C gcc-33-new/gcc/testsuite/g++.dg/template/access12.C
*** gcc-33-save/gcc/testsuite/g++.dg/template/access12.C	Thu Jan  1 07:00:00 1970
--- gcc-33-new/gcc/testsuite/g++.dg/template/access12.C	Sun Jul  6 21:19:24 2003
***************
*** 0 ****
--- 1,13 ----
+ // { dg-do compile }
+ 
+ // Origin: Giovanni Bajo <giovannibajo@libero.it>
+ 
+ // PR c++/10849: Incorrect access checking on class template partial
+ // specialization.
+ 
+ class X {
+   private:
+     template <typename T> struct Y;
+ };
+ 
+ template <typename T> struct X::Y<T*> {};


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