+/*
+ * Copyright (C) 1995-2008 University of Karlsruhe. All right reserved.
+ *
+ * This file is part of libFirm.
+ *
+ * This file may be distributed and/or modified under the terms of the
+ * GNU General Public License version 2 as published by the Free Software
+ * Foundation and appearing in the file LICENSE.GPL included in the
+ * packaging of this file.
+ *
+ * Licensees holding valid libFirm Professional Edition licenses may use
+ * this file in accordance with the libFirm Commercial License.
+ * Agreement provided with the Software.
+ *
+ * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+ * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE.
+ */
+
+/**
+ * @file tr_inheritance.c
+ * @brief Check types and entities for correctness.
+ * @date 29.1.2003
+ * @author Michael Beck, Goetz Lindenmaier
+ * @version $Id$
+ */
+#include "config.h"
+
+#include "irgraph_t.h"
+#include "irflag_t.h"
+#include "irprintf.h"
+#include "irgwalk.h"
+#include "error.h"
+#include "tv.h"
+
+#ifdef NDEBUG
+/*
+ * in RELEASE mode, returns ret if the expression expr evaluates to zero
+ * in ASSERT mode, asserts the expression expr (and the string string).
+ */
+#define ASSERT_AND_RET(expr, string, ret) if (!(expr)) return (ret)
+
+/*
+ * in RELEASE mode, returns ret if the expression expr evaluates to zero
+ * in ASSERT mode, executes blk if the expression expr evaluates to zero and asserts expr
+ */
+#define ASSERT_AND_RET_DBG(expr, string, ret, blk) if (!(expr)) return (ret)
+#else
+#define ASSERT_AND_RET(expr, string, ret) \
+do { \
+ if (opt_do_node_verification == FIRM_VERIFICATION_ON) {\
+ assert((expr) && string); } \
+ if (!(expr)) { \
+ if (opt_do_node_verification == FIRM_VERIFICATION_REPORT) \
+ fprintf(stderr, #expr " : " string "\n"); \
+ firm_vrfy_failure_msg = #expr " && " string; \
+ return (ret); \
+ } \
+} while (0)
+
+#define ASSERT_AND_RET_DBG(expr, string, ret, blk) \
+do { \
+ if (!(expr)) { \
+ firm_vrfy_failure_msg = #expr " && " string; \
+ if (opt_do_node_verification != FIRM_VERIFICATION_ERROR_ONLY) { blk; } \
+ if (opt_do_node_verification == FIRM_VERIFICATION_REPORT) \
+ fprintf(stderr, #expr " : " string "\n"); \
+ else if (opt_do_node_verification == FIRM_VERIFICATION_ON) { \
+ assert((expr) && string); \
+ } \
+ return (ret); \
+ } \
+} while (0)
+
+#endif /* NDEBUG */
+
+#ifndef NDEBUG
+
+static const char *firm_vrfy_failure_msg;
+
+/**
+ * Show diagnostic if an entity overwrites another one not
+ * in direct superclasses.
+ */
+static void show_ent_not_supertp(ir_entity *ent, ir_entity *ovw)
+{
+ ir_type *owner = get_entity_owner(ent);
+ ir_type *ov_own = get_entity_owner(ovw);
+ int i;
+
+ fprintf(stderr, "Type verification error:\n");
+ ir_fprintf(stderr, "Entity %+F::%+e owerwrites ", owner, ent);
+ ir_fprintf(stderr, "Entity %+F::%+e\n", ov_own, ovw);