}
setAttribute(n, TypeAttr(), typeNode);
- setAttribute(n, TypeCheckedAttr(),
+ setAttribute(n, TypeCheckedAttr(),
check || getAttribute(n, TypeCheckedAttr()));
-
+
return typeNode;
}
bool readyToCompute = true;
- for( TNode::iterator it = m.begin(), end = m.end() ; it != end; ++it ) {
- if( !hasAttribute(*it, TypeAttr())
+ for( TNode::iterator it = m.begin(), end = m.end();
+ it != end;
+ ++it ) {
+ if( !hasAttribute(*it, TypeAttr())
|| (check && !getAttribute(*it, TypeCheckedAttr())) ) {
readyToCompute = false;
worklist.push(*it);
if( readyToCompute ) {
/* All the children have types, time to compute */
- typeNode = computeType(m,check);
+ typeNode = computeType(m, check);
worklist.pop();
- }
+ }
} // end while
/* Last type computed in loop should be the type of n */
- Assert( typeNode == getAttribute(n,TypeAttr()) );
+ Assert( typeNode == getAttribute(n, TypeAttr()) );
} else if( !hasType || needsCheck ) {
/* We can compute the type top-down, without worrying about
deep recursion. */
- typeNode = computeType(n,check);
+ typeNode = computeType(n, check);
}
/* The type should be have been computed and stored. */
Assert( hasAttribute(n, TypeAttr()) );
/* The check should have happened, if we asked for it. */
- Assert( !check || hasAttribute(n, TypeCheckedAttr()) );
+ Assert( !check || getAttribute(n, TypeCheckedAttr()) );
Debug("getType") << "type of " << n << " is " << typeNode << std::endl;
return typeNode;
// copy constructors. The advantage is that with CVC4_UNDEFINED,
// if something _does_ try to call the function, you get an error
// at the point of the call (rather than a link error later).
+
+// CVC4_UNUSED is to mark something (e.g. local variable, function)
+// as being _possibly_ unused, so that the compiler generates no
+// warning about it. This might be the case for e.g. a variable
+// only used in DEBUG builds.
+
#ifdef __GNUC__
-# define CVC4_UNDEFINED __attribute__((error("this function intentionally undefined")))
+# if __GNUC__ > 4 || ( __GNUC__ == 4 && __GNUC_MINOR__ >= 3 )
+ /* error function attribute only exists in GCC >= 4.3.0 */
+# define CVC4_UNDEFINED __attribute__((error("this function intentionally undefined")))
+# else /* GCC < 4.3.0 */
+# define CVC4_UNDEFINED
+# endif /* GCC >= 4.3.0 */
#else /* ! __GNUC__ */
# define CVC4_UNDEFINED
#endif /* __GNUC__ */
+#ifdef __GNUC__
+# define CVC4_UNUSED __attribute__((unused))
+#else /* ! __GNUC__ */
+# define CVC4_UNUSED
+#endif /* __GNUC__ */
+
#define EXPECT_TRUE(x) __builtin_expect( (x), true )
#define EXPECT_FALSE(x) __builtin_expect( (x), false )
-#define NORETURN __attribute__ ((noreturn))
+#define CVC4_NORETURN __attribute__ ((noreturn))
#ifndef NULL
# define NULL ((void*) 0)