This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix PR86124
- From: Richard Biener <rguenther at suse dot de>
- To: gcc-patches at gcc dot gnu dot org
- Date: Thu, 14 Jun 2018 12:52:35 +0200 (CEST)
- Subject: [PATCH] Fix PR86124
Bootstrapped and tested on x86_64-unknown-linux-gnu, applied.
Richard.
>From ea6f08c8ce3de4d517d37faed5e2c9e4bf48f8bb Mon Sep 17 00:00:00 2001
From: Richard Guenther <rguenther@suse.de>
Date: Thu, 14 Jun 2018 10:20:06 +0200
Subject: [PATCH] fix-pr86124
2018-06-14 Richard Biener <rguenther@suse.de>
PR ipa/86124
* tree-ssa-struct-alias.c (create_variable_info_for): Handle
NULL cgraph_node.
* gcc.dg/pr86124.c: New testcase.
diff --git a/gcc/testsuite/gcc.dg/pr86124.c b/gcc/testsuite/gcc.dg/pr86124.c
new file mode 100644
index 00000000000..218b48295f7
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr86124.c
@@ -0,0 +1,11 @@
+/* { dg-do compile } */
+/* { dg-options "-O -fipa-pta" } */
+
+extern void a (void);
+
+void b (void)
+{
+ void *c;
+ c = a;
+ *(char *)c = 1;
+}
diff --git a/gcc/tree-ssa-structalias.c b/gcc/tree-ssa-structalias.c
index 73e500bb616..ac5d4bc93fe 100644
--- a/gcc/tree-ssa-structalias.c
+++ b/gcc/tree-ssa-structalias.c
@@ -6120,7 +6120,8 @@ create_variable_info_for (tree decl, const char *name, bool add_id)
cgraph_node *node;
if (in_ipa_mode
&& TREE_CODE (decl) == FUNCTION_DECL
- && (node = cgraph_node::get (decl))->ifunc_resolver)
+ && (node = cgraph_node::get (decl))
+ && node->ifunc_resolver)
{
varinfo_t fi = get_vi_for_tree (node->get_alias_target ()->decl);
constraint_expr rhs