OSDN Git Service

2011-12-06 Richard Guenther <rguenther@suse.de>
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 6 Dec 2011 12:17:31 +0000 (12:17 +0000)
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 6 Dec 2011 12:17:31 +0000 (12:17 +0000)
PR middle-end/51436
* gimple-fold.c (gimplify_and_update_call_from_tree): Guard
vdef check for the fact we do not have virtual operands when
not optimizing.

* g++.dg/torture/pr51436.C: New testcase.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@182045 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/gimple-fold.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/torture/pr51436.C [new file with mode: 0644]

index 1268439..76c8b18 100644 (file)
@@ -1,5 +1,12 @@
 2011-12-06  Richard Guenther  <rguenther@suse.de>
 
+       PR middle-end/51436
+       * gimple-fold.c (gimplify_and_update_call_from_tree): Guard
+       vdef check for the fact we do not have virtual operands when
+       not optimizing.
+
+2011-12-06  Richard Guenther  <rguenther@suse.de>
+
        PR tree-optimization/51245
        * tree-ssa-sccvn.c (vn_reference_lookup_or_insert_constant_for_pieces):
        New function.
index 3297f11..5da9be3 100644 (file)
@@ -600,7 +600,7 @@ gimplify_and_update_call_from_tree (gimple_stmt_iterator *si_p, tree expr)
          else
            vdef = make_ssa_name (gimple_vop (cfun), new_stmt);
          gimple_set_vdef (new_stmt, vdef);
-         if (TREE_CODE (vdef) == SSA_NAME)
+         if (vdef && TREE_CODE (vdef) == SSA_NAME)
            SSA_NAME_DEF_STMT (vdef) = new_stmt;
          laststore = new_stmt;
        }
index 248b284..5668927 100644 (file)
@@ -1,5 +1,10 @@
 2011-12-06  Richard Guenther  <rguenther@suse.de>
 
+       PR middle-end/51436
+       * g++.dg/torture/pr51436.C: New testcase.
+
+2011-12-06  Richard Guenther  <rguenther@suse.de>
+
        PR tree-optimization/51245
        * gcc.dg/torture/pr51245.c: New testcase.
 
diff --git a/gcc/testsuite/g++.dg/torture/pr51436.C b/gcc/testsuite/g++.dg/torture/pr51436.C
new file mode 100644 (file)
index 0000000..43d6c73
--- /dev/null
@@ -0,0 +1,60 @@
+/* { dg-do compile } */
+
+typedef __SIZE_TYPE__ size_t;
+extern "C" void *memcpy (void *, __const void *, size_t);
+template < class Dest, class Source > struct BitCastHelper {
+    static Dest cast (const Source & source) __attribute__ ((always_inline)) {
+       Dest dest;
+       memcpy (0, &source, sizeof dest);
+    }
+};
+template < class Dest, class Source > Dest BitCast (Source)
+{
+  BitCastHelper < Dest, Source >::cast (0);
+}
+
+class MaybeObject
+{
+};
+class Object:MaybeObject
+{
+public:
+    static Object *cast (Object *) {
+    }
+};
+class HeapObject:public Object
+{
+};
+class String:public HeapObject
+{
+};
+class ExternalString:public String
+{
+};
+class ExternalTwoByteString:public ExternalString
+{
+};
+
+template < typename T > class Handle
+{
+public:
+    Handle () {
+    }
+    T *operator* () const;
+    template < class S > static Handle < T > cast (Handle < S > that) {
+       T::cast (*that);
+    }
+    T **location_;
+};
+
+template < typename T > T * Handle < T >::operator* () const
+{
+  *BitCast < T ** >(location_);
+}
+
+void
+TestCharacterStream ()
+{
+  Handle < String > uc16_string;
+  Handle < ExternalTwoByteString >::cast (uc16_string);
+}