re PR ipa/86271 (ICE due to size mismatch when inlining)
authorRichard Biener <rguenther@suse.de>
Tue, 26 Jun 2018 06:40:43 +0000 (06:40 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Tue, 26 Jun 2018 06:40:43 +0000 (06:40 +0000)
2018-06-26  Richard Biener  <rguenther@suse.de>

PR middle-end/86271
* fold-const.c (fold_convertible_p): Pointer extension
isn't valid.

* gcc.dg/pr86271.c: New testcase.

From-SVN: r262131

gcc/ChangeLog
gcc/fold-const.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr86271.c [new file with mode: 0644]

index d420310..342c69b 100644 (file)
@@ -1,3 +1,9 @@
+2018-06-26  Richard Biener  <rguenther@suse.de>
+
+       PR middle-end/86271
+       * fold-const.c (fold_convertible_p): Pointer extension
+       isn't valid.
+
 2018-06-26  Alexandre Oliva <aoliva@redhat.com>
 
        PR debug/86064
index 4568e1e..8476c22 100644 (file)
@@ -2358,7 +2358,9 @@ fold_convertible_p (const_tree type, const_tree arg)
     case INTEGER_TYPE: case ENUMERAL_TYPE: case BOOLEAN_TYPE:
     case POINTER_TYPE: case REFERENCE_TYPE:
     case OFFSET_TYPE:
-      return (INTEGRAL_TYPE_P (orig) || POINTER_TYPE_P (orig)
+      return (INTEGRAL_TYPE_P (orig)
+             || (POINTER_TYPE_P (orig)
+                 && TYPE_PRECISION (type) <= TYPE_PRECISION (orig))
              || TREE_CODE (orig) == OFFSET_TYPE);
 
     case REAL_TYPE:
index 5d5ed66..eb782ff 100644 (file)
@@ -1,3 +1,8 @@
+2018-06-26  Richard Biener  <rguenther@suse.de>
+
+       PR middle-end/86271
+       * gcc.dg/pr86271.c: New testcase.
+
 2018-06-26  Alexandre Oliva <aoliva@redhat.com>
 
        PR debug/86064
diff --git a/gcc/testsuite/gcc.dg/pr86271.c b/gcc/testsuite/gcc.dg/pr86271.c
new file mode 100644 (file)
index 0000000..1200533
--- /dev/null
@@ -0,0 +1,17 @@
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+int main ()
+{
+  int i;
+  foobar (i, &i); /* { dg-warning "implicit declaration" } */
+}
+
+int foobar (int a, long long b)
+{
+  int c;
+
+  c = a % b;
+  a = a / b;
+  return a + b;
+}