Bugfix
[libfirm] / ir / tr / trvrfy.c
index c254f76..6d9076f 100644 (file)
@@ -10,19 +10,22 @@ static int check_class(type *tp) {
   int i, j, k;
   int found;
 
-  //printf("\n"); DDMT(tp);
+  /*printf("\n"); DDMT(tp);*/
 
   for (i = 0; i < get_class_n_members(tp); i++) {
 
     entity *mem = get_class_member(tp, i);
     assert(mem && "NULL members not allowed");
-    //printf(" %d, %d", get_entity_n_overwrites(mem), get_class_n_supertypes(tp)); DDME(mem);
+    /*printf(" %d, %d", get_entity_n_overwrites(mem), get_class_n_supertypes(tp)); DDME(mem);*/
     if (!mem) return error_null_mem;
 
-    assert(get_entity_n_overwrites(mem) <= get_class_n_supertypes(tp));
+    if (get_entity_n_overwrites(mem) > get_class_n_supertypes(tp)) {
+      DDMT(tp); DDME(mem);
+      assert(get_entity_n_overwrites(mem) <= get_class_n_supertypes(tp));
+    }
     for (j = 0; j < get_entity_n_overwrites(mem); j++) {
       entity *ovw = get_entity_overwrites(mem, j);
-      //printf(" overwrites: "); DDME(ovw);
+      /*printf(" overwrites: "); DDME(ovw);*/
       /* Check whether ovw is member of one of tp's supertypes. If so,
         the representation is correct. */
       found = false;
@@ -72,6 +75,10 @@ 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.");
 }
 
 /**
@@ -101,7 +108,13 @@ static int constants_on_wrong_irg(entity *ent) {
        return 1;
     }
   } else {
-    return constant_on_wrong_irg(get_atomic_ent_value(ent));
+    /* Might not be set if entity belongs to a description. */
+    if (get_atomic_ent_value(ent))
+      return constant_on_wrong_irg(get_atomic_ent_value(ent));
+    else
+      assert((is_class_type(get_entity_owner(ent)) &&
+             get_class_peculiarity(get_entity_owner(ent)) == description) &&
+            "Value in constant atomic entity not set.");
   }
   return 0;
 }
@@ -115,6 +128,7 @@ static int constants_on_wrong_irg(entity *ent) {
  *     != 0    else
  */
 static int check_entity(entity *ent) {
+  current_ir_graph =  get_const_code_irg();
   if (constants_on_wrong_irg(ent)) {
     assert(0 && "Contants placed on wrong IRG");
     return error_const_on_wrong_irg;
@@ -127,6 +141,7 @@ static int check_entity(entity *ent) {
  */
 static void check_tore(type_or_ent *tore, void *env) {
   int *res = env;
+  assert(tore);
   if (is_type(tore)) {
     *res = check_type((type *)tore);
   } else {