LRDE Tiger Compiler
1.34a $Id: 7fef12e1f5fa43449d667a0eec1d837c40fc1202 $
Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
contract.hh
Go to the documentation of this file.
1
6
#ifndef MISC_CONTRACT_HH
7
# define MISC_CONTRACT_HH
8
9
10
// Use GCC magic bits to specify we cannot return from these functions
11
12
#ifndef __attribute__
13
# if !defined __GNUC__
14
# define __attribute__(Spec)
/* empty */
15
# endif
16
#endif
17
18
#ifndef ATTRIBUTE_NORETURN
19
# define ATTRIBUTE_NORETURN __attribute__((__noreturn__))
20
#endif
21
22
23
void
__Terminate
(
const
char
*,
int
,
const
char
*)
ATTRIBUTE_NORETURN
;
24
25
# define die(reason) __Terminate(__FILE__, __LINE__, reason)
26
# define unreached() die("unreachable code reached")
27
28
# ifdef NDEBUG
29
30
# define assertion(expr) ((void) 0)
31
# define invariant(expr) ((void) 0)
32
# define precondition(expr) ((void) 0)
33
# define postcondition(expr) ((void) 0)
34
35
# else // NDEBUG
36
37
void
__FailedCondition
(
const
char
* condType,
38
const
char
* condText,
39
const
char
* fileName,
40
int
fileLine)
ATTRIBUTE_NORETURN
;
41
42
# define __TestCondition(condType,expr) \
43
((void) ((expr) ? 0 : (__FailedCondition( #condType, #expr, \
44
__FILE__, __LINE__ ), 0)))
45
46
# define assertion(expr) __TestCondition(Assertion,expr)
47
# define invariant(expr) __TestCondition(Invariant,expr)
48
# define precondition(expr) __TestCondition(Precondition,expr)
49
# define postcondition(expr) __TestCondition(Postcondition,expr)
50
51
# endif // ! NDEBUG
52
53
#endif // !MISC_CONTRACT_HH
misc
contract.hh
Generated on Wed Mar 5 2014 15:47:36 for LRDE Tiger Compiler by
1.8.1.2