summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2018-03-08 06:56:59 +0000
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2018-03-08 06:56:59 +0000
commit8b84a61218a2dd83111889846d74005d8e727954 (patch)
treead47591876053c5ce660972384957cf9d2935ea7
parentdb4f7f88497d7a823854f87f6650bdc12b584372 (diff)
downloadgcc-8b84a61218a2dd83111889846d74005d8e727954.tar.gz
PR tree-optimization/84739
* tree-tailcall.c (find_tail_calls): Check call arguments against DECL_ARGUMENTS (current_function_decl) rather than DECL_ARGUMENTS (func) when checking for tail recursion. * gcc.dg/pr84739.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@258351 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog7
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/pr84739.c26
-rw-r--r--gcc/tree-tailcall.c2
4 files changed, 39 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 9c7dd744f02..c96e895c3d8 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,10 @@
+2018-03-08 Jakub Jelinek <jakub@redhat.com>
+
+ PR tree-optimization/84739
+ * tree-tailcall.c (find_tail_calls): Check call arguments against
+ DECL_ARGUMENTS (current_function_decl) rather than
+ DECL_ARGUMENTS (func) when checking for tail recursion.
+
2018-03-07 Jakub Jelinek <jakub@redhat.com>
* doc/contrib.texi: Add entries for Martin Liska, David Malcolm,
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index a6f89e15dcf..3f0ac96471a 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2018-03-08 Jakub Jelinek <jakub@redhat.com>
+
+ PR tree-optimization/84739
+ * gcc.dg/pr84739.c: New test.
+
2018-03-07 Martin Sebor <msebor@redhat.com>
PR tree-optimization/83519
diff --git a/gcc/testsuite/gcc.dg/pr84739.c b/gcc/testsuite/gcc.dg/pr84739.c
new file mode 100644
index 00000000000..6903425c5c4
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr84739.c
@@ -0,0 +1,26 @@
+/* PR tree-optimization/84739 */
+/* { dg-do compile } */
+/* { dg-require-weak "" } */
+/* { dg-options "-O2" } */
+
+static void baz (void) __attribute__((weakref("bar"))); /* { dg-warning "alias between functions of incompatible types" } */
+
+int
+foo (int x, int y)
+{
+ if (x)
+ y = 0;
+ if (y)
+ goto lab;
+ y = 0;
+lab:
+ return y;
+}
+
+void
+bar (int x, int y) /* { dg-message "aliased declaration here" } */
+{
+ y = foo (x, y);
+ if (y != 0)
+ baz ();
+}
diff --git a/gcc/tree-tailcall.c b/gcc/tree-tailcall.c
index 4e309cd9b41..9ebed9de524 100644
--- a/gcc/tree-tailcall.c
+++ b/gcc/tree-tailcall.c
@@ -481,7 +481,7 @@ find_tail_calls (basic_block bb, struct tailcall **ret)
{
tree arg;
- for (param = DECL_ARGUMENTS (func), idx = 0;
+ for (param = DECL_ARGUMENTS (current_function_decl), idx = 0;
param && idx < gimple_call_num_args (call);
param = DECL_CHAIN (param), idx ++)
{