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]

C++ PATCH: Fix PR 200



We did not correct diagnose the error in:

  template <class T> struct S { ~S(); };
  int i;

  void f () 
  {
    i.~S(); // ERROR - invalid destructor call.
  }

which resulted in a subsequent compiler crash.

Tested on i686-pc-linux-gnu, applied on the mainline.

--
Mark Mitchell                   mark@codesourcery.com
CodeSourcery, LLC               http://www.codesourcery.com

2001-02-17  Mark Mitchell  <mark@codesourcery.com>

	* call.c (check_dtor_name): Handle template names correctly.

Index: cp/call.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/call.c,v
retrieving revision 1.256
diff -c -p -r1.256 call.c
*** call.c	2001/02/14 06:32:14	1.256
--- call.c	2001/02/17 23:43:13
*************** check_dtor_name (basetype, name)
*** 192,197 ****
--- 192,206 ----
        else
  	name = get_type_value (name);
      }
+   /* In the case of:
+       
+        template <class T> struct S { ~S(); };
+        int i;
+        i.~S();
+ 
+      NAME will be a class template.  */
+   else if (DECL_CLASS_TEMPLATE_P (name))
+     return 0;
    else
      my_friendly_abort (980605);
  
Index: testsuite/g++.old-deja/g++.other/dtor13.C
===================================================================
RCS file: dtor13.C
diff -N dtor13.C
*** /dev/null	Tue May  5 13:32:27 1998
--- dtor13.C	Sat Feb 17 15:43:24 2001
***************
*** 0 ****
--- 1,10 ----
+ // Build don't link:
+ // Origin: Mark Mitchell <mark@codesourcery.com>
+ 
+ template <class T> struct S { ~S(); };
+ int i;
+ 
+ void f () 
+ {
+   i.~S(); // ERROR - invalid destructor call.
+ }


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