Re: [PATCH 1/2] Add ::verify for cgraph_node::origin/nested/next_nested.

2019-08-14 Thread Jeff Law
On 8/14/19 5:15 AM, Martin Liska wrote:
> 
> gcc/ChangeLog:
> 
> 2019-08-14  Martin Liska  
> 
>   * cgraph.c (cgraph_node::verify_node): Verify origin, nested
>   and next_nested.
> ---
>  gcc/cgraph.c | 24 
>  1 file changed, 24 insertions(+)
> 
OK.
Jeff


[PATCH 1/2] Add ::verify for cgraph_node::origin/nested/next_nested.

2019-08-14 Thread Martin Liska

gcc/ChangeLog:

2019-08-14  Martin Liska  

* cgraph.c (cgraph_node::verify_node): Verify origin, nested
and next_nested.
---
 gcc/cgraph.c | 24 
 1 file changed, 24 insertions(+)

diff --git a/gcc/cgraph.c b/gcc/cgraph.c
index ed46d81a513..eb38b905879 100644
--- a/gcc/cgraph.c
+++ b/gcc/cgraph.c
@@ -3464,6 +3464,30 @@ cgraph_node::verify_node (void)
 	  e->aux = 0;
 	}
 }
+
+  if (nested != NULL)
+{
+  for (cgraph_node *n = nested; n != NULL; n = n->next_nested)
+	{
+	  if (n->origin == NULL)
+	{
+	  error ("missing origin for a node in a nested list");
+	  error_found = true;
+	}
+	  else if (n->origin != this)
+	{
+	  error ("origin points to a different parent");
+	  error_found = true;
+	  break;
+	}
+	}
+}
+  if (next_nested != NULL && origin == NULL)
+{
+  error ("missing origin for a node in a nested list");
+  error_found = true;
+}
+
   if (error_found)
 {
   dump (stderr);