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]

[PATCH, PR 40492] Pass zero offset to build_ref_for_offset in sra_modify_assign


Hi,

the patch  below fixes PR 40492.  The  problem is that when  we try to
avoid building a  V_C_E by creating a reference to an  only field in a
record we must obviously  pass zero offset to build_ref_for_offset and
not the offset of whatever the replacement stands for.

Bootstrapped and tested on x86_64-linux.  OK for trunk?

Thanks,

Martin



2009-06-19  Martin Jambor  <mjambor@suse.cz>

	PR tree-optimization/40492
	* tree-sra.c (sra_modify_assign): Pass zero offsets to
	build_ref_for_offset.

Index: mine/gcc/testsuite/g++.dg/torture/pr40492.C
===================================================================
--- /dev/null
+++ mine/gcc/testsuite/g++.dg/torture/pr40492.C
@@ -0,0 +1,26 @@
+typedef unsigned short ushort;
+class QChar {
+public:
+    QChar( const QChar& c );
+    ushort ucs;
+};
+inline QChar::QChar( const QChar& c ) : ucs( c.ucs ) { };
+class QString { };
+class KoAutoFormat {
+public:
+    struct TypographicQuotes     { QChar begin, end; };
+    TypographicQuotes getConfigTypographicDoubleQuotes() const     {
+        return m_typographicDoubleQuotes;
+    }
+    TypographicQuotes m_typographicDoubleQuotes;
+};
+class KoAutoFormatDia {
+    QChar oDoubleBegin, oDoubleEnd;
+    KoAutoFormat * m_docAutoFormat;
+    bool noSignal;
+    void changeAutoformatLanguage(void);
+};
+void KoAutoFormatDia::changeAutoformatLanguage(void)
+{
+  oDoubleEnd= m_docAutoFormat->getConfigTypographicDoubleQuotes().end;
+}
Index: mine/gcc/tree-sra.c
===================================================================
--- mine.orig/gcc/tree-sra.c
+++ mine/gcc/tree-sra.c
@@ -2119,7 +2119,7 @@ sra_modify_assign (gimple *stmt, gimple_
 	      && !access_has_children_p (lacc))
 	    {
 	      tree expr = unshare_expr (lhs);
-	      if (build_ref_for_offset (&expr, TREE_TYPE (lhs), racc->offset,
+	      if (build_ref_for_offset (&expr, TREE_TYPE (lhs), 0,
 					TREE_TYPE (rhs), false))
 		{
 		  lhs = expr;
@@ -2130,7 +2130,7 @@ sra_modify_assign (gimple *stmt, gimple_
 		   && !access_has_children_p (racc))
 	    {
 	      tree expr = unshare_expr (rhs);
-	      if (build_ref_for_offset (&expr, TREE_TYPE (rhs), lacc->offset,
+	      if (build_ref_for_offset (&expr, TREE_TYPE (rhs), 0,
 					TREE_TYPE (lhs), false))
 		rhs = expr;
 	    }


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