Index: src/SynTree/Type.h
===================================================================
--- src/SynTree/Type.h	(revision 4a9ccc35f7b5fed64bf53eee245fc9caa37f687d)
+++ src/SynTree/Type.h	(revision c0aa3360803b4a312708b494a8067a91f03e9e8f)
@@ -10,6 +10,6 @@
 // Created On       : Mon May 18 07:44:20 2015
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Wed Jul 13 11:46:54 2016
-// Update Count     : 23
+// Last Modified On : Thu Feb  2 17:43:01 2017
+// Update Count     : 33
 //
 
@@ -25,6 +25,6 @@
   public:
 	struct Qualifiers {
-		Qualifiers(): isConst( false ), isVolatile( false ), isRestrict( false ), isLvalue( false ), isAtomic( false ), isAttribute( false ) {}
-		Qualifiers( bool isConst, bool isVolatile, bool isRestrict, bool isLvalue, bool isAtomic, bool isAttribute ): isConst( isConst ), isVolatile( isVolatile ), isRestrict( isRestrict ), isLvalue( isLvalue ), isAtomic( isAtomic ), isAttribute( isAttribute ) {}
+		Qualifiers(): isConst( false ), isVolatile( false ), isRestrict( false ), isLvalue( false ), isAtomic( false ) {}
+		Qualifiers( bool isConst, bool isVolatile, bool isRestrict, bool isLvalue, bool isAtomic ): isConst( isConst ), isVolatile( isVolatile ), isRestrict( isRestrict ), isLvalue( isLvalue ), isAtomic( isAtomic ) {}
 
 		Qualifiers &operator&=( const Qualifiers &other );
@@ -45,8 +45,7 @@
 		bool isLvalue;
 		bool isAtomic;
-		bool isAttribute;
 	};
 
-	Type( const Qualifiers &tq );
+	Type( const Qualifiers &tq, const std::list< Attribute * > & attributes );
 	Type( const Type &other );
 	virtual ~Type();
@@ -58,5 +57,4 @@
 	bool get_isLvalue() { return tq.isLvalue; }
 	bool get_isAtomic() { return tq.isAtomic; }
-	bool get_isAttribute() { return tq.isAttribute; }
 	void set_isConst( bool newValue ) { tq.isConst = newValue; }
 	void set_isVolatile( bool newValue ) { tq.isVolatile = newValue; }
@@ -64,8 +62,10 @@
 	void set_isLvalue( bool newValue ) { tq.isLvalue = newValue; }
 	void set_isAtomic( bool newValue ) { tq.isAtomic = newValue; }
-	void set_isAttribute( bool newValue ) { tq.isAttribute = newValue; }
 
 	typedef std::list<TypeDecl *> ForallList;
 	ForallList& get_forall() { return forall; }
+
+	std::list< Attribute * >& get_attributes() { return attributes; }
+	const std::list< Attribute * >& get_attributes() const { return attributes; }
 
 	/// How many elemental types are represented by this type
@@ -83,4 +83,5 @@
 	Qualifiers tq;
 	ForallList forall;
+	std::list< Attribute * > attributes;
 };
 
@@ -89,5 +90,5 @@
 class VoidType : public Type {
   public:
-	VoidType( const Type::Qualifiers &tq );
+	VoidType( const Type::Qualifiers &tq, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
 
 	virtual unsigned size() const { return 0; };
@@ -129,5 +130,5 @@
 	static const char *typeNames[];						// string names for basic types, MUST MATCH with Kind
 
-	BasicType( const Type::Qualifiers &tq, Kind bt );
+	BasicType( const Type::Qualifiers &tq, Kind bt, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
 
 	Kind get_kind() { return kind; }
@@ -146,6 +147,6 @@
 class PointerType : public Type {
   public:
-	PointerType( const Type::Qualifiers &tq, Type *base );
-	PointerType( const Type::Qualifiers &tq, Type *base, Expression *dimension, bool isVarLen, bool isStatic );
+	PointerType( const Type::Qualifiers &tq, Type *base, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
+	PointerType( const Type::Qualifiers &tq, Type *base, Expression *dimension, bool isVarLen, bool isStatic, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
 	PointerType( const PointerType& );
 	virtual ~PointerType();
@@ -175,5 +176,5 @@
 class ArrayType : public Type {
   public:
-	ArrayType( const Type::Qualifiers &tq, Type *base, Expression *dimension, bool isVarLen, bool isStatic );
+	ArrayType( const Type::Qualifiers &tq, Type *base, Expression *dimension, bool isVarLen, bool isStatic, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
 	ArrayType( const ArrayType& );
 	virtual ~ArrayType();
@@ -203,5 +204,5 @@
 class FunctionType : public Type {
   public:
-	FunctionType( const Type::Qualifiers &tq, bool isVarArgs );
+	FunctionType( const Type::Qualifiers &tq, bool isVarArgs, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
 	FunctionType( const FunctionType& );
 	virtual ~FunctionType();
@@ -231,5 +232,5 @@
 class ReferenceToType : public Type {
   public:
-	ReferenceToType( const Type::Qualifiers &tq, const std::string &name );
+	ReferenceToType( const Type::Qualifiers &tq, const std::string &name, const std::list< Attribute * > & attributes );
 	ReferenceToType( const ReferenceToType &other );
 	virtual ~ReferenceToType();
@@ -253,6 +254,6 @@
 	typedef ReferenceToType Parent;
   public:
-	StructInstType( const Type::Qualifiers &tq, const std::string &name ) : Parent( tq, name ), baseStruct( 0 ) {}
-	StructInstType( const Type::Qualifiers &tq, StructDecl * baseStruct );
+	StructInstType( const Type::Qualifiers &tq, const std::string &name, const std::list< Attribute * > & attributes = std::list< Attribute * >()  ) : Parent( tq, name, attributes ), baseStruct( 0 ) {}
+	StructInstType( const Type::Qualifiers &tq, StructDecl * baseStruct, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
 	StructInstType( const StructInstType &other ) : Parent( other ), baseStruct( other.baseStruct ) {}
 
@@ -285,12 +286,13 @@
 	typedef ReferenceToType Parent;
   public:
-	UnionInstType( const Type::Qualifiers &tq, const std::string &name ) : Parent( tq, name ), baseUnion( 0 ) {}
+	UnionInstType( const Type::Qualifiers &tq, const std::string &name, const std::list< Attribute * > & attributes = std::list< Attribute * >()  ) : Parent( tq, name, attributes ), baseUnion( 0 ) {}
+	UnionInstType( const Type::Qualifiers &tq, UnionDecl * baseUnion, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
 	UnionInstType( const UnionInstType &other ) : Parent( other ), baseUnion( other.baseUnion ) {}
 
 	UnionDecl *get_baseUnion() const { return baseUnion; }
-	void set_baseUnion( UnionDecl *newValue ) { baseUnion = newValue; }
+	void set_baseUnion( UnionDecl * newValue ) { baseUnion = newValue; }
 
 	/// Accesses generic parameters of base union (NULL if none such)
-	std::list<TypeDecl*> * get_baseParameters();
+	std::list< TypeDecl * > * get_baseParameters();
 
 	virtual bool isComplete() const;
@@ -316,9 +318,12 @@
 	typedef ReferenceToType Parent;
   public:
-	EnumInstType( const Type::Qualifiers &tq, const std::string &name ) : Parent( tq, name ) {}
-	EnumInstType( const EnumInstType &other ) : Parent( other ) {}
-
-	// xxx - enum inst does not currently contain a pointer to base, this should be fixed.
-	// virtual bool isComplete() const { return baseEnum()->hasBody(); }
+	EnumInstType( const Type::Qualifiers &tq, const std::string &name, const std::list< Attribute * > & attributes = std::list< Attribute * >()  ) : Parent( tq, name, attributes ) {}
+	EnumInstType( const Type::Qualifiers &tq, EnumDecl * baseEnum, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
+	EnumInstType( const EnumInstType &other ) : Parent( other ), baseEnum( other.baseEnum ) {}
+
+	EnumDecl *get_baseEnum() const { return baseEnum; }
+	void set_baseEnum( EnumDecl *newValue ) { baseEnum = newValue; }
+
+	virtual bool isComplete() const;
 
 	virtual EnumInstType *clone() const { return new EnumInstType( *this ); }
@@ -327,4 +332,8 @@
   private:
 	virtual std::string typeString() const;
+
+	// this decl is not "owned" by the union inst; it is merely a pointer to elsewhere in the tree,
+	// where the union used in this type is actually defined
+	EnumDecl *baseEnum = nullptr;
 };
 
@@ -332,5 +341,5 @@
 	typedef ReferenceToType Parent;
   public:
-	TraitInstType( const Type::Qualifiers &tq, const std::string &name ) : Parent( tq, name ) {}
+	TraitInstType( const Type::Qualifiers &tq, const std::string &name, const std::list< Attribute * > & attributes = std::list< Attribute * >()  ) : Parent( tq, name, attributes ) {}
 	TraitInstType( const TraitInstType &other );
 	~TraitInstType();
@@ -354,6 +363,6 @@
 	typedef ReferenceToType Parent;
   public:
-	TypeInstType( const Type::Qualifiers &tq, const std::string &name, TypeDecl *baseType );
-	TypeInstType( const Type::Qualifiers &tq, const std::string &name, bool isFtype );
+	TypeInstType( const Type::Qualifiers &tq, const std::string &name, TypeDecl *baseType, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
+	TypeInstType( const Type::Qualifiers &tq, const std::string &name, bool isFtype, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
 	TypeInstType( const TypeInstType &other );
 	~TypeInstType();
@@ -380,5 +389,5 @@
 class TupleType : public Type {
   public:
-	TupleType( const Type::Qualifiers &tq, const std::list< Type * > & types = std::list< Type * >() );
+	TupleType( const Type::Qualifiers &tq, const std::list< Type * > & types = std::list< Type * >(), const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
 	TupleType( const TupleType& );
 	virtual ~TupleType();
@@ -410,5 +419,5 @@
 class TypeofType : public Type {
   public:
-	TypeofType( const Type::Qualifiers &tq, Expression *expr );
+	TypeofType( const Type::Qualifiers &tq, Expression *expr, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
 	TypeofType( const TypeofType& );
 	virtual ~TypeofType();
@@ -429,6 +438,6 @@
 class AttrType : public Type {
   public:
-	AttrType( const Type::Qualifiers &tq, const std::string &name, Expression *expr );
-	AttrType( const Type::Qualifiers &tq, const std::string &name, Type *type );
+	AttrType( const Type::Qualifiers &tq, const std::string &name, Expression *expr, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
+	AttrType( const Type::Qualifiers &tq, const std::string &name, Type *type, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
 	AttrType( const AttrType& );
 	virtual ~AttrType();
@@ -460,5 +469,5 @@
   public:
 	VarArgsType();
-	VarArgsType( Type::Qualifiers tq );
+	VarArgsType( Type::Qualifiers tq, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
 
 	virtual bool isComplete() const{ return true; } // xxx - is this right?
@@ -474,5 +483,5 @@
   public:
 	ZeroType();
-	ZeroType( Type::Qualifiers tq );
+	ZeroType( Type::Qualifiers tq, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
 
 	virtual ZeroType *clone() const { return new ZeroType( *this ); }
@@ -486,5 +495,5 @@
   public:
 	OneType();
-	OneType( Type::Qualifiers tq );
+	OneType( Type::Qualifiers tq, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
 
 	virtual OneType *clone() const { return new OneType( *this ); }
