aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2015-09-29 13:02:42 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2015-09-29 13:02:42 +0000
commiteada851cc9fb2822989d3ef81bb5b4b08dcc81a7 (patch)
tree622acbfaa22ecaaa95a141f7bf10c0291f7cd7af
parentce535a9685b11c846560cc0f9f4dded1ca558efc (diff)
downloadgcc-eada851cc9fb2822989d3ef81bb5b4b08dcc81a7.zip
gcc-eada851cc9fb2822989d3ef81bb5b4b08dcc81a7.tar.gz
gcc-eada851cc9fb2822989d3ef81bb5b4b08dcc81a7.tar.bz2
re PR tree-optimization/67741 (Invalid built-in usage should not cause segmentation fault in compiler)
2015-09-29 Richard Biener <rguenther@suse.de> PR tree-optimization/67741 * tree-ssa-math-opts.c (pass_cse_sincos::execute): Only recognize builtin calls with correct signature. * gcc.dg/torture/pr67741.c: New testcase. From-SVN: r228243
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr67741.c13
-rw-r--r--gcc/tree-ssa-math-opts.c7
4 files changed, 27 insertions, 4 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 12de2e1..8fc37ce 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2015-09-29 Richard Biener <rguenther@suse.de>
+
+ PR tree-optimization/67741
+ * tree-ssa-math-opts.c (pass_cse_sincos::execute): Only recognize
+ builtin calls with correct signature.
+
2015-09-29 Ilya Enkovich <enkovich.gnu@gmail.com>
PR target/65105
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 09a72d9..6582172 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2015-09-29 Richard Biener <rguenther@suse.de>
+
+ PR tree-optimization/67741
+ * gcc.dg/torture/pr67741.c: New testcase.
+
2015-09-29 Uros Bizjak <ubizjak@gmail.com>
* gcc.dg/tg-tests.h (foo_1) [UNSAFE]: Also check if f and ld are
diff --git a/gcc/testsuite/gcc.dg/torture/pr67741.c b/gcc/testsuite/gcc.dg/torture/pr67741.c
new file mode 100644
index 0000000..1ffc707
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr67741.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+
+struct singlecomplex { float real, imag ; } ;
+struct doublecomplex { double real, imag ; } ;
+struct extendedcomplex { long double real, imag ; } ;
+extern double cabs();
+float cabsf(fc)
+ struct singlecomplex fc; /* { dg-warning "doesn't match" } */
+{
+ struct doublecomplex dc ;
+ dc.real=fc.real; dc.imag=fc.imag;
+ return (float) cabs(dc);
+}
diff --git a/gcc/tree-ssa-math-opts.c b/gcc/tree-ssa-math-opts.c
index 42708ee..9747739 100644
--- a/gcc/tree-ssa-math-opts.c
+++ b/gcc/tree-ssa-math-opts.c
@@ -1738,15 +1738,14 @@ pass_cse_sincos::execute (function *fun)
of a basic block. */
cleanup_eh = false;
- if (is_gimple_call (stmt)
- && gimple_call_lhs (stmt)
- && (fndecl = gimple_call_fndecl (stmt))
- && DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL)
+ if (gimple_call_builtin_p (stmt, BUILT_IN_NORMAL)
+ && gimple_call_lhs (stmt))
{
tree arg, arg0, arg1, result;
HOST_WIDE_INT n;
location_t loc;
+ fndecl = gimple_call_fndecl (stmt);
switch (DECL_FUNCTION_CODE (fndecl))
{
CASE_FLT_FN (BUILT_IN_COS):