[PATCH] ipa/126930 - defend against non-pointers in ptr_deref_may_alias_global_p

Richard Biener <[email protected]>
Newsgroups gmane.comp.gcc.patches
Message-ID <[email protected]>
The following for consistency reasons defends against accessing
SSA_NAME_PTR_INFO on non-pointers which might then instead
access range info.

Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed.

	PR ipa/126930
	* tree-ssa-alias.cc (ptr_deref_may_alias_global_p): Guard
	against non-pointers.
	(ptr_deref_may_alias_auto_p): Likewise.
---
 gcc/tree-ssa-alias.cc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gcc/tree-ssa-alias.cc b/gcc/tree-ssa-alias.cc
index 1d10f6dbd97..7fc87b3b944 100644
--- a/gcc/tree-ssa-alias.cc
+++ b/gcc/tree-ssa-alias.cc
@@ -224,7 +224,7 @@ ptr_deref_may_alias_global_p (tree ptr, bool escaped_local_p)
 
   /* If we end up with a pointer constant here that may point
      to global memory.  */
-  if (TREE_CODE (ptr) != SSA_NAME)
+  if (TREE_CODE (ptr) != SSA_NAME || !POINTER_TYPE_P (TREE_TYPE (ptr)))
     return true;
 
   pi = SSA_NAME_PTR_INFO (ptr);
@@ -248,7 +248,7 @@ ptr_deref_may_alias_auto_p (tree ptr)
 
   /* If we end up with a pointer constant here that may point
      to local stack memory.  */
-  if (TREE_CODE (ptr) != SSA_NAME)
+  if (TREE_CODE (ptr) != SSA_NAME || !POINTER_TYPE_P (TREE_TYPE (ptr)))
     return true;
 
   pi = SSA_NAME_PTR_INFO (ptr);
-- 
2.51.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.