diff mbox

[C++] PR53055

Message ID alpine.DEB.2.02.1210112355090.23017@stedding.saclay.inria.fr
State New
Headers show

Commit Message

Marc Glisse Oct. 11, 2012, 10:24 p.m. UTC
Hello,

this is an old patch that Paolo dug out of bugzilla and where I only 
changed the error message. It fixes an ICE on invalid code.

Note that the code uses error() like the nearby code so the caret appears 
on the RHS while the message is about the LHS. Paolo offered to look into 
it as a follow-up (the LHS doesn't have a location attached to it, so it 
isn't just a matter of using error_at).

bootstrap+testsuite ok.

2012-10-12  Marc Glisse  <marc.glisse@inria.fr>

 	PR c++/53055

gcc/c-family/
 	* c-common.h (enum ref_operator) [RO_ARROW_PM]: New.

gcc/cp/
 	* call.c (build_new_op_1): Pass RO_ARROW_PM to cp_build_indirect_ref.
 	* typeck.c (cp_build_indirect_ref): Handle RO_ARROW_PM.

gcc/testsuite/
 	* g++.dg/pr53055.C: New testcase.

Comments

Jason Merrill Oct. 12, 2012, 1:43 p.m. UTC | #1
Let's use RO_ARROW_STAR to be more readable.  OK with that change.

Jason
Marc Glisse Oct. 12, 2012, 1:46 p.m. UTC | #2
On Fri, 12 Oct 2012, Jason Merrill wrote:

> Let's use RO_ARROW_STAR to be more readable.

I now realize that I have no idea what RO_ARROW_PM was supposed to stand 
for (Pointer to Member?), which proves that it was a bad name ;-)

> OK with that change.

Thanks.
diff mbox

Patch

Index: cp/typeck.c
===================================================================
--- cp/typeck.c	(revision 192378)
+++ cp/typeck.c	(working copy)
@@ -2901,20 +2901,24 @@  cp_build_indirect_ref (tree ptr, ref_ope
       {
          case RO_ARRAY_INDEXING:
            error ("invalid use of array indexing on pointer to member");
            break;
          case RO_UNARY_STAR:
            error ("invalid use of unary %<*%> on pointer to member");
            break;
          case RO_IMPLICIT_CONVERSION:
            error ("invalid use of implicit conversion on pointer to member");
            break;
+         case RO_ARROW_PM:
+           error ("left hand operand of %<->*%> must be a pointer to class, "
+		  "but is a pointer to member of type %qT", type);
+           break;
          default:
            gcc_unreachable ();
       }
   else if (pointer != error_mark_node)
     invalid_indirection_error (input_location, type, errorstring);
 
   return error_mark_node;
 }
 
 /* This handles expressions of the form "a[i]", which denotes
Index: cp/call.c
===================================================================
--- cp/call.c	(revision 192378)
+++ cp/call.c	(working copy)
@@ -5302,21 +5302,21 @@  build_new_op_1 (location_t loc, enum tre
     case POSTDECREMENT_EXPR:
     case REALPART_EXPR:
     case IMAGPART_EXPR:
     case ABS_EXPR:
       return cp_build_unary_op (code, arg1, candidates != 0, complain);
 
     case ARRAY_REF:
       return cp_build_array_ref (input_location, arg1, arg2, complain);
 
     case MEMBER_REF:
-      return build_m_component_ref (cp_build_indirect_ref (arg1, RO_NULL, 
+      return build_m_component_ref (cp_build_indirect_ref (arg1, RO_ARROW_PM, 
                                                            complain), 
                                     arg2, complain);
 
       /* The caller will deal with these.  */
     case ADDR_EXPR:
     case COMPONENT_REF:
     case COMPOUND_EXPR:
       return NULL_TREE;
 
     default:
Index: c-family/c-common.h
===================================================================
--- c-family/c-common.h	(revision 192378)
+++ c-family/c-common.h	(working copy)
@@ -470,21 +470,23 @@  extern c_language_kind c_language;
 typedef enum ref_operator {
   /* NULL */
   RO_NULL,
   /* array indexing */
   RO_ARRAY_INDEXING,
   /* unary * */
   RO_UNARY_STAR,
   /* -> */
   RO_ARROW,
   /* implicit conversion */
-  RO_IMPLICIT_CONVERSION
+  RO_IMPLICIT_CONVERSION,
+  /* ->* */
+  RO_ARROW_PM
 } ref_operator;
 
 /* Information about a statement tree.  */
 
 struct GTY(()) stmt_tree_s {
   /* A stack of statement lists being collected.  */
   VEC(tree,gc) *x_cur_stmt_list;
 
   /* In C++, Nonzero if we should treat statements as full
      expressions.  In particular, this variable is non-zero if at the
Index: testsuite/g++.dg/pr53055.C
===================================================================
--- testsuite/g++.dg/pr53055.C	(revision 0)
+++ testsuite/g++.dg/pr53055.C	(revision 0)
@@ -0,0 +1,5 @@ 
+// PR c++/53055
+// { dg-do compile }
+
+struct A A :: * p ;
+int i = p ->* p ; // { dg-error "" }