aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2019-03-05 09:43:16 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2019-03-05 09:43:16 +0100
commitd6f7829a1fa2577bac1bd8815acd31730affcb92 (patch)
tree8002b8c05a197626eed6b4dcc4b741aa9980a0ed /gcc
parentda7382442e127e54ba65edeab4d9444e786ffd73 (diff)
downloadgcc-d6f7829a1fa2577bac1bd8815acd31730affcb92.zip
gcc-d6f7829a1fa2577bac1bd8815acd31730affcb92.tar.gz
gcc-d6f7829a1fa2577bac1bd8815acd31730affcb92.tar.bz2
re PR tree-optimization/89566 (ICE on compilable C++ code: in gimple_call_arg, at gimple.h:3166)
PR tree-optimization/89566 * gimple-ssa-sprintf.c (sprintf_dom_walker::handle_gimple_call): Set info.fncode to BUILT_IN_NONE if gimple_call_builtin_p failed. Punt if get_user_idx_format succeeds, but idx_format argument is not provided or doesn't have pointer type, or if idx_args is above number of provided arguments. * c-c++-common/pr89566.c: New test. From-SVN: r269384
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog9
-rw-r--r--gcc/gimple-ssa-sprintf.c13
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/c-c++-common/pr89566.c15
4 files changed, 38 insertions, 4 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 38858fa..22ce364 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,12 @@
+2019-03-05 Jakub Jelinek <jakub@redhat.com>
+
+ PR tree-optimization/89566
+ * gimple-ssa-sprintf.c (sprintf_dom_walker::handle_gimple_call):
+ Set info.fncode to BUILT_IN_NONE if gimple_call_builtin_p failed.
+ Punt if get_user_idx_format succeeds, but idx_format argument is
+ not provided or doesn't have pointer type, or if idx_args is above
+ number of provided arguments.
+
2019-03-04 Wilco Dijkstra <wdijkstr@arm.com>
PR tree-optimization/89437
diff --git a/gcc/gimple-ssa-sprintf.c b/gcc/gimple-ssa-sprintf.c
index 4fe206a..ced1c4c 100644
--- a/gcc/gimple-ssa-sprintf.c
+++ b/gcc/gimple-ssa-sprintf.c
@@ -3858,16 +3858,21 @@ sprintf_dom_walker::handle_gimple_call (gimple_stmt_iterator *gsi)
if (!info.func)
return false;
- info.fncode = DECL_FUNCTION_CODE (info.func);
-
/* Format string argument number (valid for all functions). */
unsigned idx_format = UINT_MAX;
- if (!gimple_call_builtin_p (info.callstmt, BUILT_IN_NORMAL))
+ if (gimple_call_builtin_p (info.callstmt, BUILT_IN_NORMAL))
+ info.fncode = DECL_FUNCTION_CODE (info.func);
+ else
{
unsigned idx_args;
idx_format = get_user_idx_format (info.func, &idx_args);
- if (idx_format == UINT_MAX)
+ if (idx_format == UINT_MAX
+ || idx_format >= gimple_call_num_args (info.callstmt)
+ || idx_args > gimple_call_num_args (info.callstmt)
+ || !POINTER_TYPE_P (TREE_TYPE (gimple_call_arg (info.callstmt,
+ idx_format))))
return false;
+ info.fncode = BUILT_IN_NONE;
info.argidx = idx_args;
}
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index c06d63a..a5e25c3 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2019-03-05 Jakub Jelinek <jakub@redhat.com>
+
+ PR tree-optimization/89566
+ * c-c++-common/pr89566.c: New test.
+
2019-03-04 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/84605
diff --git a/gcc/testsuite/c-c++-common/pr89566.c b/gcc/testsuite/c-c++-common/pr89566.c
new file mode 100644
index 0000000..d967656
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/pr89566.c
@@ -0,0 +1,15 @@
+/* PR tree-optimization/89566 */
+/* { dg-do compile } */
+
+typedef struct FILE { int i; } FILE;
+#ifdef __cplusplus
+extern "C"
+#endif
+int fprintf (FILE *, const char *, ...);
+
+int
+main ()
+{
+ ((void (*)()) fprintf) (); // { dg-warning "function called through a non-compatible type" "" { target c } }
+ return 0;
+}