Index: src/AST/Bitfield.hpp
===================================================================
--- src/AST/Bitfield.hpp	(revision 360b2e13b0a6890e0332ced51cb4d18245ed79ae)
+++ src/AST/Bitfield.hpp	(revision b96d7c198e371dbd361b72116c33fa18df27ef5a)
@@ -22,44 +22,53 @@
 /// does not allow it. Requires type to have `unsigned val` field
 /// @param BFType  Name of containing type
-#define MakeBitfield( BFType )                                         \
-	constexpr BFType() : val( 0 ) {}                                   \
-	constexpr BFType( unsigned int v ) : val( v ) {}                   \
-	bool operator[]( unsigned int i ) const { return val & (1 << i); } \
-	bool any() const { return val != 0; }                              \
-	void reset() { val = 0; }                                          \
-	int ffs() { return ::ffs( val ) - 1; }                             \
-	BFType operator&=( BFType other ) {                                \
-		val &= other.val; return *this;                                \
-	}                                                                  \
-	BFType operator&( BFType other ) const {                           \
-		BFType q = other;                                              \
-		q &= *this;                                                    \
-		return q;                                                      \
-	}                                                                  \
-	BFType operator|=( BFType other ) {                                \
-		val |= other.val; return *this;                                \
-	}                                                                  \
-	BFType operator|( BFType other ) const {                           \
-		BFType q = other;                                              \
-		q |= *this;                                                    \
-		return q;                                                      \
-	}                                                                  \
-	BFType operator-=( BFType other ) {                                \
-		val &= ~other.val; return *this;                               \
+template<typename T>
+struct bitfield : public T {
+	static_assert(sizeof(T) == sizeof(unsigned int), "Type has incorrect size");
+	using T::val;
+	using val_t = decltype(val);
+
+	constexpr bitfield() : T( 0 ) {}
+	constexpr bitfield( val_t v ) : T( v ) {}
+
+	bool operator[]( val_t i ) const { return val & (1 << i); }
+	bool any() const { return val != 0; }
+	void reset() { val = 0; }
+	int ffs() { return ::ffs( val ) - 1; }
+
+	bitfield operator&=( bitfield other ) {
+		val &= other.val; return *this;
 	}
+	bitfield operator&( bitfield other ) const {
+		bitfield q = other;
+		q &= *this;
+		return q;
+	}
+	bitfield operator|=( bitfield other ) {
+		val |= other.val; return *this;
+	}
+	bitfield operator|( bitfield other ) const {
+		bitfield q = other;
+		q |= *this;
+		return q;
+	}
+	bitfield operator-=( bitfield other ) {
+		val &= ~other.val; return *this;
+	}
+};
 
 /// Adds default printing operator to a bitfield type.
 /// Include in definition to add print function, requires other bitfield operators.
 /// @param N  Number of bits in bitfield
-#define MakeBitfieldPrint( N )                                         \
-	static const char* Names[];                                        \
-	void print( std::ostream & os ) const {                            \
-		if ( (*this).any() ) {                                         \
-			for ( unsigned int i = 0; i < N; i += 1 ) {                \
-				if ( (*this)[i] ) {                                    \
-					os << Names[i] << ' ';                             \
-				}                                                      \
-			}                                                          \
-		}                                                              \
+#define MakeBitfieldPrint( N ) \
+	static const char* Names[]; \
+ \
+	void print( std::ostream & os ) const { \
+		if ( (*this).any() ) { \
+			for ( unsigned int i = 0; i < N; i += 1 ) { \
+				if ( (*this)[i] ) { \
+					os << Names[i] << ' '; \
+				} \
+			} \
+		} \
 	}
 
