X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=src%2Fld65%2Fasserts.c;h=d0902e924ea3619c92611f78500d5983a78ffcec;hb=4786caf496bd8e6989abee74017aa098df860c41;hp=56b546afbe54c1bfa596da6f07e1da304292df8c;hpb=5faea71a56230b27c5618489185f74daf4515f88;p=cc65 diff --git a/src/ld65/asserts.c b/src/ld65/asserts.c index 56b546afb..d0902e924 100644 --- a/src/ld65/asserts.c +++ b/src/ld65/asserts.c @@ -6,10 +6,10 @@ /* */ /* */ /* */ -/* (C) 2003 Ullrich von Bassewitz */ -/* Römerstrasse 52 */ -/* D-70794 Filderstadt */ -/* EMail: uz@cc65.org */ +/* (C) 2003-2009, Ullrich von Bassewitz */ +/* Roemerstrasse 52 */ +/* D-70794 Filderstadt */ +/* EMail: uz@cc65.org */ /* */ /* */ /* This software is provided 'as-is', without any expressed or implied */ @@ -34,7 +34,7 @@ /* common */ -#include "assertdefs.h" +#include "assertion.h" #include "coll.h" #include "xmalloc.h" @@ -54,6 +54,15 @@ +/* Assertion struct decl */ +struct Assertion { + FilePos Pos; /* File position of assertion */ + ExprNode* Expr; /* Expression to evaluate */ + AssertAction Action; /* What to do */ + unsigned Msg; /* Message to print */ + ObjData* Obj; /* Object file containing the assertion */ +}; + /* List with all assertions */ static Collection Assertions = STATIC_COLLECTION_INITIALIZER; @@ -73,7 +82,7 @@ Assertion* ReadAssertion (FILE* F, struct ObjData* O) /* Read the fields from the file */ A->Expr = ReadExpr (F, O); - A->Action = ReadVar (F); + A->Action = (AssertAction) ReadVar (F); A->Msg = MakeGlobalStringId (O, ReadVar (F)); ReadFilePos (F, &A->Pos); @@ -100,6 +109,11 @@ void CheckAssertions (void) /* Get the assertion */ Assertion* A = CollAtUnchecked (&Assertions, I); + /* Ignore assertions that shouldn't be handled at link time */ + if (!AssertAtLinkTime (A->Action)) { + continue; + } + /* If the expression is not constant, we're not able to handle it */ if (!IsConstExpr (A->Expr)) { Warning ("Cannot evaluate assertion in module `%s', line %lu", @@ -113,10 +127,12 @@ void CheckAssertions (void) switch (A->Action) { case ASSERT_ACT_WARN: + case ASSERT_ACT_LDWARN: Warning ("%s(%lu): %s", Module, A->Pos.Line, Message); break; case ASSERT_ACT_ERROR: + case ASSERT_ACT_LDERROR: Error ("%s(%lu): %s", Module, A->Pos.Line, Message); break;