Permalink
Browse files

Added PARROT_ASSERT_MSG macro, which does an assertion with a custom …

…error message. Added PARROT_FAILURE which does an unconditonal assertion failure with a custom error message. PARROT_ASSERT was used (abused) to provide these two functions, but ICC gets very unhappy about it. No changes to functionality, but a lot fewer warnings on ICC"

git-svn-id: https://svn.parrot.org/parrot/branches/fix_icc_failures@44819 d31e2699-5ff4-0310-a27c-f18f2fbe73fe
  • Loading branch information...
whiteknight
whiteknight committed Mar 9, 2010
1 parent 954772e commit 71445c4a2146b88488c50549237dca2782362ce9
Showing with 18 additions and 14 deletions.
  1. +4 −0 include/parrot/exceptions.h
  2. +10 −10 src/call/args.c
  3. +1 −1 src/call/context.c
  4. +1 −1 src/pmc/callcontext.pmc
  5. +1 −1 src/pmc/hashiteratorkey.pmc
  6. +1 −1 src/pmc/iterator.pmc
@@ -272,10 +272,14 @@ void Parrot_print_backtrace(void);
#ifdef NDEBUG
# define PARROT_ASSERT(x) /*@-noeffect@*/((void)0)/*@=noeffect@*/
# define PARROT_ASSERT_ARG(x) (0)
+# define PARROT_FAILURE(x) /*@-noeffect@*/((void)0)/*@=noeffect@*/
+# define PARROT_ASSERT_MSG(x, s) /*@-noeffect@*/((void)0)/*@=noeffect@*/
# define ASSERT_ARGS(a)
#else
# define PARROT_ASSERT(x) (x) ? ((void)0) : Parrot_confess(#x, __FILE__, __LINE__)
# define PARROT_ASSERT_ARG(x) ((x) ? (0) : (Parrot_confess(#x, __FILE__, __LINE__), 0))
+# define PARROT_FAILURE(x) Parrot_confess(x, __FILE__, __LINE__)
+# define PARROT_ASSERT_MSG(x, s) ((x) ? (0) : (Parrot_confess(s, __FILE__, __LINE__), 0))
# ifdef __GNUC__
# define ASSERT_ARGS(a) ASSERT_ARGS_ ## a ;
View
@@ -2740,15 +2740,15 @@ static INTVAL
intval_constant_from_varargs(PARROT_INTERP, ARGIN(void *data), INTVAL index)
{
ASSERT_ARGS(intval_constant_from_varargs)
- PARROT_ASSERT(!"Wrong call");
+ PARROT_FAILURE("Wrong call");
return 0;
}
static FLOATVAL
numval_constant_from_varargs(PARROT_INTERP, ARGIN(void *data), INTVAL index)
{
ASSERT_ARGS(numval_constant_from_varargs)
- PARROT_ASSERT(!"Wrong call");
+ PARROT_FAILURE("Wrong call");
return 0.0;
}
@@ -2757,7 +2757,7 @@ static STRING*
string_constant_from_varargs(PARROT_INTERP, ARGIN(void *data), INTVAL index)
{
ASSERT_ARGS(string_constant_from_varargs)
- PARROT_ASSERT(!"Wrong call");
+ PARROT_FAILURE("Wrong call");
return NULL;
}
@@ -2766,7 +2766,7 @@ static PMC*
pmc_constant_from_varargs(PARROT_INTERP, ARGIN(void *data), INTVAL index)
{
ASSERT_ARGS(pmc_constant_from_varargs)
- PARROT_ASSERT(!"Wrong call");
+ PARROT_FAILURE("Wrong call");
return PMCNULL;
}
@@ -2927,7 +2927,7 @@ csr_push_pointer(PARROT_INTERP, ARGIN(PMC *self), ARGIN_NULLOK(void *value), INT
void **values;
INTVAL size;
- PARROT_ASSERT((type >= 0 && type < 4) || !"Wrong pointer type");
+ PARROT_ASSERT_MSG((type >= 0 && type < 4), "Wrong pointer type");
GETATTR_CallContext_returns_size(interp, self, size);
values = csr_reallocate_return_values(interp, self, size + 1);
@@ -2979,7 +2979,7 @@ csr_fill_integer(PARROT_INTERP, ARGIN(PMC *self), INTVAL key, INTVAL value)
*(PMC **)ptr = get_integer_pmc(interp, value);
break;
default:
- PARROT_ASSERT(!"Impossible type");
+ PARROT_FAILURE("Impossible type");
}
}
@@ -3004,7 +3004,7 @@ csr_fill_number(PARROT_INTERP, ARGIN(PMC *self), INTVAL key, FLOATVAL value)
*(PMC **)ptr = get_number_pmc(interp, value);
break;
default:
- PARROT_ASSERT(!"Impossible type");
+ PARROT_FAILURE("Impossible type");
}
}
@@ -3031,7 +3031,7 @@ csr_fill_string(PARROT_INTERP, ARGIN(PMC *self), INTVAL key, ARGIN_NULLOK(STRING
get_string_pmc(interp, value);
break;
default:
- PARROT_ASSERT(!"Impossible type");
+ PARROT_FAILURE("Impossible type");
}
}
@@ -3056,7 +3056,7 @@ csr_fill_pmc(PARROT_INTERP, ARGIN(PMC *self), INTVAL key, ARGIN_NULLOK(PMC *valu
*(PMC **)ptr = value;
break;
default:
- PARROT_ASSERT(!"Impossible type");
+ PARROT_FAILURE(!"Impossible type");
}
}
@@ -3102,7 +3102,7 @@ csr_get_pointer_keyed_int(PARROT_INTERP, ARGIN(PMC *self), INTVAL key)
INTVAL size;
GETATTR_CallContext_returns_size(interp, self, size);
- PARROT_ASSERT((key < size) || !"Wrong index");
+ PARROT_ASSERT_MSG(key < size, "Wrong index");
GETATTR_CallContext_returns_values(interp, self, values);
return values[key];
View
@@ -306,7 +306,7 @@ init_context(PARROT_INTERP, ARGMOD(PMC *pmcctx), ARGIN_NULLOK(PMC *pmcold))
? NULL
: get_context_struct_fast(interp, pmcold);
- PARROT_ASSERT(!PMC_IS_NULL(pmcctx) || !"Can't initialise Null CallContext");
+ PARROT_ASSERT_MSG(!PMC_IS_NULL(pmcctx), "Can't initialise Null CallContext");
/*
* FIXME Invoking corotine shouldn't initialise context. So just
View
@@ -655,7 +655,7 @@ Returns the short signature for the CallContext.
res = Parrot_str_append(INTERP, res, CONST_STRING(INTERP, "P"));
break;
default:
- PARROT_ASSERT(!"Impossible flag");
+ PARROT_FAILURE("Impossible flag");
break;
}
c = NEXT_CELL(c);
@@ -84,7 +84,7 @@ Set pointers to Hash and HashBucket. Not really part of public API.
Parrot_HashIteratorKey_attributes *attrs =
PARROT_HASHITERATORKEY(SELF);
- PARROT_ASSERT(value || !"Can't set NULL pointer into HashIteratorKey");
+ PARROT_ASSERT_MSG(value, "Can't set NULL pointer into HashIteratorKey");
if (key == 0) {
attrs->parrot_hash = (Hash*)value;
View
@@ -204,7 +204,7 @@ Restart iterator
*/
VTABLE void set_integer_native(INTVAL value) {
PMC *self = SELF;
- PARROT_ASSERT(!"Iterator: implementation have to override this method");
+ PARROT_FAILURE("Iterator: implementation have to override this method");
Parrot_ex_throw_from_c_args(INTERP, NULL, EXCEPTION_UNIMPLEMENTED,
"Iterator: unimplemented method");

0 comments on commit 71445c4

Please sign in to comment.