Added C++ Krempel :-)
[libfirm] / ir / tr / trvrfy.c
index 1c4744f..30d3cea 100644 (file)
@@ -1,3 +1,17 @@
+/*
+ * Project:     libFIRM
+ * File name:   ir/tr/trvrfy.c
+ * Purpose:     Check types and entities for correctness.
+ * Author:      Michael Beck, Goetz Lindenmaier
+ * Modified by:
+ * Created:     29.1.2003
+ * CVS-ID:      $Id$
+ * Copyright:   (c) 2003 Universität Karlsruhe
+ * Licence:     This file protected by GPL -  GNU GENERAL PUBLIC LICENSE.
+ */
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
 
 #include "trvrfy.h"
 #include "irgraph_t.h"  /* for checking whether constant code is allocated
@@ -19,7 +33,10 @@ static int check_class(type *tp) {
     /*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);*/
@@ -72,6 +89,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.");
 }
 
 /**
@@ -92,7 +113,7 @@ static int constant_on_wrong_irg(ir_node *n) {
  * Check if constants node are NOT on the constant IR graph.
  */
 static int constants_on_wrong_irg(entity *ent) {
-  if (get_entity_variability(ent) == uninitialized) return 0;
+  if (get_entity_variability(ent) == variability_uninitialized) return 0;
 
   if (is_compound_entity(ent)) {
     int i;
@@ -106,7 +127,7 @@ static int constants_on_wrong_irg(entity *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) &&
+             get_class_peculiarity(get_entity_owner(ent)) == peculiarity_description) &&
             "Value in constant atomic entity not set.");
   }
   return 0;
@@ -121,10 +142,20 @@ 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;
   }
+
+  if ((get_entity_peculiarity(ent) == peculiarity_existent) &&
+      (get_entity_visibility(ent) != visibility_external_allocated) &&
+      (is_method_type(get_entity_type(ent)))                &&
+      (!get_entity_irg(ent) || !(is_ir_graph(get_entity_irg(ent))))) {
+    assert(0 && "Method ents with pec_exist must have an irg");
+    return error_existent_entity_without_irg;
+  }
+
   return 0;
 }
 
@@ -133,6 +164,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 {