summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorprathamesh3492 <prathamesh3492@138bc75d-0d04-0410-961f-82ee72b054a4>2018-05-15 04:44:33 +0000
committerprathamesh3492 <prathamesh3492@138bc75d-0d04-0410-961f-82ee72b054a4>2018-05-15 04:44:33 +0000
commit9deb0d0954c6776cf07b260b14f7c62726da667f (patch)
tree8f4a374e2fe65e6e08730920207a99968ad8fe0c
parentbb547959cfa74f1d74d9ddc9f12f03bdc97ea073 (diff)
2018-05-15 Prathamesh Kulkarni <prathamesh.kulkarni@linaro.org>
PR ipa/85734 * ipa-pure-const.c (warn_function_malloc): Pass value of known_finite param as true in call to suggest_attribute. testsuite/ * gcc.dg/ipa/pr85734.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@260249 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/ipa-pure-const.c2
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/ipa/pr85734.c19
4 files changed, 31 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 9e54758cf091..294a937327ae 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2018-05-15 Prathamesh Kulkarni <prathamesh.kulkarni@linaro.org>
+
+ PR ipa/85734
+ * ipa-pure-const.c (warn_function_malloc): Pass value of known_finite param
+ as true in call to suggest_attribute.
+
2018-05-14 Segher Boessenkool <segher@kernel.crashing.org>
* doc/invoke.texi (RS/6000 and PowerPC Options): Delete @itemx for
diff --git a/gcc/ipa-pure-const.c b/gcc/ipa-pure-const.c
index a80b6845633e..7665358a9a51 100644
--- a/gcc/ipa-pure-const.c
+++ b/gcc/ipa-pure-const.c
@@ -249,7 +249,7 @@ warn_function_malloc (tree decl)
static hash_set<tree> *warned_about;
warned_about
= suggest_attribute (OPT_Wsuggest_attribute_malloc, decl,
- false, warned_about, "malloc");
+ true, warned_about, "malloc");
}
/* Emit suggestion about __attribute__((noreturn)) for DECL. */
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 4a0b371cecc5..452e6a276a51 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2018-05-14 Prathamesh Kulkarni <prathamesh.kulkarni@linaro.org>
+
+ PR ipa/85734
+ * gcc.dg/ipa/pr85734.c: New test.
+
2018-05-14 Eric Botcazou <ebotcazou@adacore.com>
PR target/85756
diff --git a/gcc/testsuite/gcc.dg/ipa/pr85734.c b/gcc/testsuite/gcc.dg/ipa/pr85734.c
new file mode 100644
index 000000000000..e5fa21f05483
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/ipa/pr85734.c
@@ -0,0 +1,19 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -Wsuggest-attribute=malloc" } */
+
+__attribute__((noinline))
+static void *f1(__SIZE_TYPE__ sz) /* { dg-bogus "function might be candidate for attribute 'malloc'" } */
+{
+ return __builtin_malloc (sz);
+}
+
+__attribute__((noinline))
+static void *f2(__SIZE_TYPE__ sz) /* { dg-bogus "function might be candidate for attribute 'malloc'" } */
+{
+ return f1 (sz);
+}
+
+void *f3(__SIZE_TYPE__ sz) /* { dg-warning "function might be candidate for attribute 'malloc'" } */
+{
+ return f2(sz);
+}