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: Do not warn about non-virtual destructors for Java classes


Ranjit pointed out that (with -Wnon-virtual-dtor) we're warning about
Java classes, which is pointless since we don't allow destructors to
be declared for Java classes.

Tested on x86_64-unknown-linux-gnu, applied on the mainline and on the
4.0 branch.

--
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com

2005-03-07  Mark Mitchell  <mark@codesourcery.com>

	* class.c (finish_struct_1): Do not warn about non-virtual
	destructors in Java classes.

2005-03-07  Mark Mitchell  <mark@codesourcery.com>

	* g++.dg/warn/Wnvdtor.C: New test.

Index: cp/class.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/class.c,v
retrieving revision 1.708
diff -c -5 -p -r1.708 class.c
*** cp/class.c	1 Mar 2005 09:57:37 -0000	1.708
--- cp/class.c	7 Mar 2005 22:57:29 -0000
*************** finish_struct_1 (tree t)
*** 5027,5037 ****
    finish_vtbls (t);
    
    /* Build the VTT for T.  */
    build_vtt (t);
  
!   if (warn_nonvdtor && TYPE_POLYMORPHIC_P (t))
      {
        tree dtor;
  
        dtor = CLASSTYPE_DESTRUCTORS (t);
        /* Warn only if the dtor is non-private or the class has
--- 5027,5039 ----
    finish_vtbls (t);
    
    /* Build the VTT for T.  */
    build_vtt (t);
  
!   /* This warning does not make sense for Java classes, since they
!      cannot have destructors.  */
!   if (!TYPE_FOR_JAVA (t) && warn_nonvdtor && TYPE_POLYMORPHIC_P (t))
      {
        tree dtor;
  
        dtor = CLASSTYPE_DESTRUCTORS (t);
        /* Warn only if the dtor is non-private or the class has
Index: testsuite/g++.dg/warn/Wnvdtor.C
===================================================================
RCS file: testsuite/g++.dg/warn/Wnvdtor.C
diff -N testsuite/g++.dg/warn/Wnvdtor.C
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- testsuite/g++.dg/warn/Wnvdtor.C	7 Mar 2005 22:57:30 -0000
***************
*** 0 ****
--- 1,10 ----
+ // { dg-options "-Wnon-virtual-dtor" }
+ 
+ extern "Java"
+ {
+   class Foo
+   {
+   public:
+     virtual void bar( void);
+   };
+ }


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