]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR sanitizer/59437 (ICE in for g++ -S -fvtable-verify=std -fsanitize=null)
authorMarek Polacek <polacek@redhat.com>
Tue, 10 Dec 2013 10:49:39 +0000 (10:49 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Tue, 10 Dec 2013 10:49:39 +0000 (10:49 +0000)
PR sanitizer/59437
* vtable-verify.c (var_is_used_for_virtual_call_p): Check the
return value of gimple_call_fn.  Use is_gimple_call/is_gimple_assign
instead of gimple_code.
testsuite/
* g++.dg/ubsan/pr59437.C: New test.

From-SVN: r205854

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/ubsan/pr59437.C [new file with mode: 0644]
gcc/vtable-verify.c

index 0f34fb242d7317214282f28c561690483e1fbe10..110c0a033e9213b0e27b7686f38011b34c00bc77 100644 (file)
@@ -1,3 +1,10 @@
+2013-12-10  Marek Polacek  <polacek@redhat.com>
+
+       PR sanitizer/59437
+       * vtable-verify.c (var_is_used_for_virtual_call_p): Check the
+       return value of gimple_call_fn.  Use is_gimple_call/is_gimple_assign
+       instead of gimple_code.
+
 2013-12-10  Maxim Kuvyrkov  <maxim@kugelworks.com>
 
        * config.gcc (mips*-mti-linux*, mips64*-*-linux*):
index 404569ed7435b210407c540cf3ab1db9afdd72e1..09a1323ca184bbeeaa487dde7ab7fec094240ce5 100644 (file)
@@ -1,3 +1,8 @@
+2013-12-09  Marek Polacek  <polacek@redhat.com>
+
+       PR sanitizer/59437
+       * g++.dg/ubsan/pr59437.C: New test.
+
 2013-12-10  Max Ostapenko  <m.ostapenko@partner.samsung.com>
 
        * c-c++-common/tsan/thread_leak2.c: `dg-skip-if' removed.
diff --git a/gcc/testsuite/g++.dg/ubsan/pr59437.C b/gcc/testsuite/g++.dg/ubsan/pr59437.C
new file mode 100644 (file)
index 0000000..0e77ccd
--- /dev/null
@@ -0,0 +1,24 @@
+// { dg-do compile }
+// { dg-options "-fsanitize=null -fvtable-verify=std" }
+// { dg-skip-if "" { *-*-* } { "-flto" } { "" } }
+
+template < typename T > struct A
+{
+  T foo ();
+};
+template < typename T > struct C: virtual public A < T >
+{
+  C & operator<< (C & (C &));
+};
+template < typename T >
+C < T > &endl (C < int > &c)
+{
+  c.foo ();
+  return c;
+}
+C < int > cout;
+void
+fn ()
+{
+  cout << endl;
+}
index dabb77b9d106d7a63eed208a7aab21e053f667d7..af61e930b205eb504cf7201a5b45fbfea933725a 100644 (file)
@@ -513,10 +513,10 @@ var_is_used_for_virtual_call_p (tree lhs, int *mem_ref_depth)
     {
       gimple stmt2 = USE_STMT (use_p);
 
-      if (gimple_code (stmt2) == GIMPLE_CALL)
+      if (is_gimple_call (stmt2))
         {
           tree fncall = gimple_call_fn (stmt2);
-          if (TREE_CODE (fncall) == OBJ_TYPE_REF)
+          if (fncall && TREE_CODE (fncall) == OBJ_TYPE_REF)
             found_vcall = true;
          else
            return false;
@@ -527,7 +527,7 @@ var_is_used_for_virtual_call_p (tree lhs, int *mem_ref_depth)
                                                    (gimple_phi_result (stmt2),
                                                     mem_ref_depth);
         }
-      else if (gimple_code (stmt2) == GIMPLE_ASSIGN)
+      else if (is_gimple_assign (stmt2))
         {
          tree rhs = gimple_assign_rhs1 (stmt2);
          if (TREE_CODE (rhs) == ADDR_EXPR