+/**
+ * called by the walker
+ */
+static void on_irg_storage(ir_node *n, void *env) {
+ struct myenv * myenv = env;
+
+ myenv->res = node_is_in_irgs_storage(myenv->irg, n);
+
+ /* We also test whether the setting of the visited flag is legal. */
+ assert(get_irn_visited(n) <= get_irg_visited(myenv->irg) &&
+ "Visited flag of node is larger than that of corresponding irg.");
+}
+
+/**
+ * checks wheater a given constant IR node is NOT on the
+ * constant IR graph.
+ */
+static int constant_on_wrong_irg(ir_node *n) {
+ struct myenv env;
+
+ env.res = 1; /* on right obstack */
+ env.irg = get_const_code_irg();
+
+ irg_walk(n, on_irg_storage, NULL, (void *)&env);
+ return ! env.res;
+}
+
+/*
+ * Check if constants node are NOT on the constant IR graph.
+ */
+static int constants_on_wrong_irg(entity *ent) {
+ if (get_entity_variability(ent) == variability_uninitialized) return 0;
+
+ if (is_compound_entity(ent)) {
+ int i;
+ for (i = 0; i < get_compound_ent_n_values(ent); i++) {
+ if (constant_on_wrong_irg(get_compound_ent_value(ent, i)))
+ return 1;
+ }
+ } else {
+ /* Might not be set if entity belongs to a description or is external allocated. */
+ if (get_atomic_ent_value(ent))
+ return constant_on_wrong_irg(get_atomic_ent_value(ent));
+ else if (get_entity_visibility(ent) != visibility_external_allocated)
+ assert((is_class_type(get_entity_owner(ent)) &&
+ get_class_peculiarity(get_entity_owner(ent)) == peculiarity_description) &&
+ "Value in constant atomic entity not set.");
+ }