C++ PATCH: Fix PR 288
Mark Mitchell
mark@codesourcery.com
Sat Feb 17 21:53:00 GMT 2001
It's unclear whether this code
struct S
{
int i;
__typeof( S::i ) f ();
};
should be considered legal. On the one hand, you could argue that
S::i has type `int'. However, in most places, you can't talk about
the type of a non-static data member without an object. Once again,
we see the problem with language extensions...
Anyhow, we used to crash on this code. With this change, we issue an
error message, which is certainly an improvement.
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>
* semantics.c (finish_typeof): Resolve OFFSET_REFs.
Index: testsuite/g++.old-deja/g++.ext/typeof2.C
===================================================================
RCS file: typeof2.C
diff -N typeof2.C
*** /dev/null Tue May 5 13:32:27 1998
--- typeof2.C Sat Feb 17 21:47:19 2001
***************
*** 0 ****
--- 1,8 ----
+ // Build don't link:
+ // Origin: Mark Mitchell <mark@codesourcery.com>
+
+ struct S
+ {
+ int i; // ERROR - non-static data member
+ __typeof( S::i ) f (); // ERROR - referenced here
+ };
Index: cp/semantics.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/semantics.c,v
retrieving revision 1.190
diff -c -p -r1.190 semantics.c
*** semantics.c 2001/02/16 08:03:23 1.190
--- semantics.c 2001/02/18 05:47:17
*************** finish_typeof (expr)
*** 2152,2157 ****
--- 2152,2160 ----
return t;
}
+ if (TREE_CODE (expr) == OFFSET_REF)
+ expr = resolve_offset_ref (expr);
+
return TREE_TYPE (expr);
}
More information about the Gcc-patches
mailing list