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 implicit typename warning regression


Hi

In GCC 3.3, we have a problem issuing warning for implicit
typename.  It affects friend class declaration like

	friend class T::X;

where 'T' is template parameter dependent.  The syntax forbids
'typename' keyword here so implicit typename warning should
not apply.  However GCC 3.3 outputs a warning for such code.
This patch disables such diagnostic.  The mainline does not
have such problem so it does not need any fix.

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

--Kriang


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

	PR c++/11039
	* decl.c (grokdeclarator): Don't issue implicit typename
	diagnostics when processing friend class declaration.

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

	PR c++/11039
	* g++.dg/warn/implicit-typename2.C: New test.
	* g++.dg/warn/implicit-typename3.C: New test.


diff -cprN gcc-33-save/gcc/cp/decl.c gcc-33-new/gcc/cp/decl.c
*** gcc-33-save/gcc/cp/decl.c	Sat May 31 18:38:57 2003
--- gcc-33-new/gcc/cp/decl.c	Fri Jun  6 22:06:15 2003
*************** grokdeclarator (declarator, declspecs, d
*** 10895,10906 ****
        type = integer_type_node;
      }
    
    if (type && IMPLICIT_TYPENAME_P (type))
      {
!       /* The implicit typename extension is deprecated and will be
! 	 removed.  Warn about its use now.  */
!       warning ("`%T' is implicitly a typename", type);
!       cp_deprecated ("implicit typename");
  
        /* Now remove its implicitness, so that we don't warn again.
           For instance this might be a typedef, and we do not want to
--- 10895,10923 ----
        type = integer_type_node;
      }
    
+   friendp = RIDBIT_SETP (RID_FRIEND, specbits);
+   RIDBIT_RESET (RID_FRIEND, specbits);
+ 
    if (type && IMPLICIT_TYPENAME_P (type))
      {
! 
!       /* In friend declaration, typename keyword is not allowed.
! 	 So don't issue warning when a declaration like
! 
! 	   friend class T::x;
! 
! 	 is encountered.  Here `T' is a template parameter.  Note
! 	 that we still want to issue a warning for
! 
! 	   friend T::x f();  */
! 
!       if (!(friendp && innermost_code != CALL_EXPR))
! 	{
! 	  /* The implicit typename extension is deprecated and will be
! 	     removed.  Warn about its use now.  */
! 	  warning ("`%T' is implicitly a typename", type);
! 	  cp_deprecated ("implicit typename");
! 	}
  
        /* Now remove its implicitness, so that we don't warn again.
           For instance this might be a typedef, and we do not want to
*************** grokdeclarator (declarator, declspecs, d
*** 11086,11093 ****
  		dname);
        staticp = 0;
      }
-   friendp = RIDBIT_SETP (RID_FRIEND, specbits);
-   RIDBIT_RESET (RID_FRIEND, specbits);
  
    if (dependant_name && !friendp)
      {
--- 11103,11108 ----
diff -cprN gcc-33-save/gcc/testsuite/g++.dg/warn/implicit-typename2.C gcc-33-new/gcc/testsuite/g++.dg/warn/implicit-typename2.C
*** gcc-33-save/gcc/testsuite/g++.dg/warn/implicit-typename2.C	Thu Jan  1 07:00:00 1970
--- gcc-33-new/gcc/testsuite/g++.dg/warn/implicit-typename2.C	Fri Jun  6 21:02:50 2003
***************
*** 0 ****
--- 1,12 ----
+ // { dg-do compile }
+ 
+ // Origin: Wolfgang Bangerth <bangerth@ticam.utexas.edu>
+ 
+ // PR c++/11039: Implicit typename warning in friend class declaration.
+ 
+ template <typename T> struct X {
+   struct Y {
+     struct Z {};
+   };
+   friend struct Y::Z;
+ };
diff -cprN gcc-33-save/gcc/testsuite/g++.dg/warn/implicit-typename3.C gcc-33-new/gcc/testsuite/g++.dg/warn/implicit-typename3.C
*** gcc-33-save/gcc/testsuite/g++.dg/warn/implicit-typename3.C	Thu Jan  1 07:00:00 1970
--- gcc-33-new/gcc/testsuite/g++.dg/warn/implicit-typename3.C	Fri Jun  6 22:19:01 2003
***************
*** 0 ****
--- 1,12 ----
+ // { dg-do compile }
+ 
+ // Origin: Wolfgang Bangerth <bangerth@ticam.utexas.edu>
+ 
+ // PR c++/11039: Implicit typename warning in friend class declaration.
+ 
+ template <typename T> struct X {
+   struct Y {
+     struct Z {};
+   };
+   template <typename U> friend struct Y::Z f(U); // { dg-warning "implicit" }
+ };


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