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]

Re: ICE: malformed code gives ICE for &(C::m)


Jason Merrill <jason@redhat.com> writes:

| Hmm...we might be trying to support that in order to be bug-compatible with
| VC++; I know it allows a lot of sloppiness with pointers to members.  But
| that should only happen with -fms-extensions anyway; let's give your patch
| a try.

I committed the below to fix Mike's testcase and PR/2521, along with
your suggestion

Thanks,

-- Gaby
Index: testsuite/ChangeLog
===================================================================
RCS file: /cvs/gcc/egcs/gcc/testsuite/ChangeLog,v
retrieving revision 1.2017
diff -p -r1.2017 ChangeLog
*** testsuite/ChangeLog	6 Aug 2002 20:35:46 -0000	1.2017
--- testsuite/ChangeLog	6 Aug 2002 23:04:14 -0000
***************
*** 1,3 ****
--- 1,8 ----
+ 2002-08-07  Gabriel Dos Reis  <gdr@nerim.net>
+ 
+ 	* g++.dg/README (Subdirectories): Document new subdir expr.
+ 	* g++.dg/expr/pmf-1.C: New test.
+ 
  2002-08-06  Neil Booth  <neil@daikokuya.co.uk>
  
  	* gcc.dg/cpp/vararg3.c, gcc.dg/cpp/vararg4.c: New tests.
Index: testsuite/g++.dg/README
===================================================================
RCS file: /cvs/gcc/egcs/gcc/testsuite/g++.dg/README,v
retrieving revision 1.2
diff -p -r1.2 README
*** testsuite/g++.dg/README	9 Oct 2001 15:44:25 -0000	1.2
--- testsuite/g++.dg/README	6 Aug 2002 23:04:15 -0000
*************** Subdirectories:
*** 2,7 ****
--- 2,8 ----
  
  abi	 Tests for ABI compatibility -- mangling, object layout, etc.
  eh	 Tests for exception handling.
+ expr     Tests for expressions.
  ext	 Tests for GNU language extensions.
  inherit	 Tests for inheritance -- virtual functions, multiple inheritance, etc.
  init	 Tests for initialization semantics, constructors/destructors, etc.
Index: cp/ChangeLog
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/ChangeLog,v
retrieving revision 1.2920
diff -p -r1.2920 ChangeLog
*** cp/ChangeLog	5 Aug 2002 18:46:34 -0000	1.2920
--- cp/ChangeLog	6 Aug 2002 23:04:24 -0000
***************
*** 1,3 ****
--- 1,7 ----
+ 2002-08-06  Gabriel Dos Reis  <gdr@nerim.net>
+ 
+ 	* typeck.c (build_x_unary_op): Handle pointer-to-member.
+ 
  2002-08-05  Geoffrey Keating  <geoffk@redhat.com>
  
  	* class.c: Don't include obstack.h.
Index: cp/typeck.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/typeck.c,v
retrieving revision 1.415
diff -p -r1.415 typeck.c
*** cp/typeck.c	2 Aug 2002 11:57:22 -0000	1.415
--- cp/typeck.c	6 Aug 2002 23:04:27 -0000
*************** build_x_unary_op (code, xarg)
*** 3794,3799 ****
--- 3794,3818 ----
      }
    if (code == ADDR_EXPR)
      {
+       /*  A pointer to member-function can be formed only by saying
+ 	  &X::mf.  */
+       if (!flag_ms_extensions && TREE_CODE (TREE_TYPE (xarg)) == METHOD_TYPE
+ 	  && (TREE_CODE (xarg) != OFFSET_REF || !PTRMEM_OK_P (xarg)))
+ 	{
+ 	  if (TREE_CODE (xarg) != OFFSET_REF)
+ 	    {
+ 	      error ("invalid use of '%E' to form a pointer-to-member-function.  Use a qualified-id.",
+ 		     xarg);
+ 	      return error_mark_node;
+ 	    }
+ 	  else
+ 	    {
+ 	      error ("parenthesis around '%E' cannot be used to form a pointer-to-member-function",
+ 		     xarg);
+ 	      PTRMEM_OK_P (xarg) = 1;
+ 	    }
+ 	}
+       
        if (TREE_CODE (xarg) == OFFSET_REF)
          {
            ptrmem = PTRMEM_OK_P (xarg);


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