[llvm-commits] CVS: llvm-gcc/gcc/cp/class.c
Chris Lattner
lattner at cs.uiuc.edu
Thu Jul 21 14:56:14 PDT 2005
Changes in directory llvm-gcc/gcc/cp:
class.c updated: 1.1.1.2 -> 1.2
---
Log message:
Fix PR602: http://llvm.cs.uiuc.edu/PR602 and Regression/C++Frontend/2005-07-21-VirtualBaseAccess.cpp,
by forcing GCC to be more careful about the way it emits its unsafe pointer
casts.
---
Diffs of the changes: (+15 -1)
class.c | 16 +++++++++++++++-
1 files changed, 15 insertions(+), 1 deletion(-)
Index: llvm-gcc/gcc/cp/class.c
diff -u llvm-gcc/gcc/cp/class.c:1.1.1.2 llvm-gcc/gcc/cp/class.c:1.2
--- llvm-gcc/gcc/cp/class.c:1.1.1.2 Tue Jan 13 10:49:36 2004
+++ llvm-gcc/gcc/cp/class.c Thu Jul 21 16:56:03 2005
@@ -36,6 +36,7 @@
#include "lex.h"
#include "target.h"
#include "convert.h"
+#include "llvm-out.h"
/* The number of nested classes being processed. If we are not in the
scope of any class, this is zero. */
@@ -356,12 +357,25 @@
if (want_pointer)
target_type = ptr_target_type;
- expr = build1 (NOP_EXPR, ptr_target_type, expr);
+ /* To go from a derived class to a base member, do NOT first cast from
+ * derived* to base* then add an offset. This sort of evil behavior results
+ * in invalid getelementptr instructions.
+ */
+#ifdef EMIT_LLVM
+ if (!integer_zerop (offset))
+ expr = build (code, ptr_target_type, expr, offset);
+ else
+ null_test = NULL;
+ expr = build1 (NOP_EXPR, ptr_target_type, expr);
+#else
+ expr = build1 (NOP_EXPR, ptr_target_type, expr);
+
if (!integer_zerop (offset))
expr = build (code, ptr_target_type, expr, offset);
else
null_test = NULL;
+#endif
if (!want_pointer)
expr = build_indirect_ref (expr, NULL);
More information about the llvm-commits
mailing list