Index: src/Parser/TypeData.cc
===================================================================
--- src/Parser/TypeData.cc	(revision 28307be7d2cda5127601e285d00fb951c75f442f)
+++ src/Parser/TypeData.cc	(revision 12bc63ab6d1bb10cdf0105eb5df31eab3153a60b)
@@ -10,6 +10,6 @@
 // Created On       : Sat May 16 15:12:51 2015
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Mon Aug 29 22:31:53 2016
-// Update Count     : 277
+// Last Modified On : Mon Sep 12 21:11:22 2016
+// Update Count     : 377
 //
 
@@ -178,6 +178,8 @@
 		break;
 	  case Basic:
-		newtype->basic.typeSpec = basic.typeSpec;
-		newtype->basic.modifiers = basic.modifiers;
+		newtype->basictype = basictype;
+		newtype->complextype = complextype;
+		newtype->signedness = signedness;
+		newtype->length = length;
 		break;
 	  case Array:
@@ -247,5 +249,5 @@
 	using std::string;
 
-	for ( int i = 0; i < DeclarationNode::NoOfQualifier; i += 1 ) {
+	for ( int i = 0; i < DeclarationNode::NoQualifier; i += 1 ) {
 		if ( qualifiers[i] ) os << DeclarationNode::qualifierName[ i ] << ' ';
 	} // for
@@ -271,6 +273,9 @@
 		break;
 	  case Basic:
-		printEnums( basic.modifiers.begin(), basic.modifiers.end(), DeclarationNode::modifierName, os );
-		printEnums( basic.typeSpec.begin(), basic.typeSpec.end(), DeclarationNode::basicTypeName, os );
+		if ( signedness != DeclarationNode::NoSignedness ) os << DeclarationNode::signednessName[ signedness ] << " ";
+		if ( length != DeclarationNode::NoLength ) os << DeclarationNode::lengthName[ length ] << " ";
+		assert( basictype != DeclarationNode::NoBasicType );
+		os << DeclarationNode::basicTypeName[ basictype ] << " ";
+		if ( complextype != DeclarationNode::NoComplexType ) os << DeclarationNode::complexTypeName[ complextype ] << " ";
 		break;
 	  case Array:
@@ -418,5 +423,5 @@
 		break;
 	  default:
-		os << "internal error: TypeData::print " << kind  << endl;
+		os << "internal error: TypeData::print " << kind << endl;
 		assert( false );
 	} // switch
@@ -531,205 +536,90 @@
 
 Type * buildBasicType( const TypeData * td ) {
-	static const BasicType::Kind kindMap[] = { BasicType::Char, BasicType::SignedInt, BasicType::Float, BasicType::Double,
-											   BasicType::Char /* void */, BasicType::Bool, BasicType::DoubleComplex,
-											   BasicType::DoubleImaginary };
-	bool init = false;
-	bool sawDouble = false;
-	bool sawSigned = false;
 	BasicType::Kind ret;
 
-	for ( std::list< DeclarationNode::BasicType >::const_iterator i = td->basic.typeSpec.begin(); i != td->basic.typeSpec.end(); ++i ) {
-		if ( ! init ) {
-			init = true;
-			if ( *i == DeclarationNode::Void ) {
-				if ( td->basic.typeSpec.size() != 1 || ! td->basic.modifiers.empty() ) {
-					throw SemanticError( "invalid type specifier \"void\" in type: ", td );
-				} else {
-					return new VoidType( buildQualifiers( td ) );
-				} // if
-			} else {
-				ret = kindMap[ *i ];
-			} // if
-		} else {
-			switch ( *i ) {
-			  case DeclarationNode::Float:
-				if ( sawDouble ) {
-					throw SemanticError( "invalid type specifier \"float\" in type: ", td );
-				} else {
-					switch ( ret ) {
-					  case BasicType::DoubleComplex:
-						ret = BasicType::FloatComplex;
-						break;
-					  case BasicType::DoubleImaginary:
-						ret = BasicType::FloatImaginary;
-						break;
-					  default:
-						throw SemanticError( "invalid type specifier \"float\" in type: ", td );
-					} // switch
-				} // if
-				break;
-			  case DeclarationNode::Double:
-				if ( sawDouble ) {
-					throw SemanticError( "duplicate type specifier \"double\" in type: ", td );
-				} else {
-					switch ( ret ) {
-					  case BasicType::DoubleComplex:
-					  case BasicType::DoubleImaginary:
-						break;
-					  default:
-						throw SemanticError( "invalid type specifier \"double\" in type: ", td );
-					} // switch
-				} // if
-				break;
-			  case DeclarationNode::Complex:
-				switch ( ret ) {
-				  case BasicType::Float:
-					ret = BasicType::FloatComplex;
-					break;
-				  case BasicType::Double:
-					ret = BasicType::DoubleComplex;
-					break;
-				  default:
-					throw SemanticError( "invalid type specifier \"_Complex\" in type: ", td );
-				} // switch
-				break;
-			  case DeclarationNode::Imaginary:
-				switch ( ret ) {
-				  case BasicType::Float:
-					ret = BasicType::FloatImaginary;
-					break;
-				  case BasicType::Double:
-					ret = BasicType::DoubleImaginary;
-					break;
-				  default:
-					throw SemanticError( "invalid type specifier \"_Imaginary\" in type: ", td );
-				} // switch
-				break;
-			  default:
-				throw SemanticError( std::string( "invalid type specifier \"" ) + DeclarationNode::basicTypeName[ *i ] + "\" in type: ", td );
-			} // switch
-		} // if
-		if ( *i == DeclarationNode::Double ) {
-			sawDouble = true;
-		} // if
-	} // for
-
-	for ( std::list< DeclarationNode::Modifier >::const_iterator i = td->basic.modifiers.begin(); i != td->basic.modifiers.end(); ++i ) {
-		switch ( *i ) {
-		  case DeclarationNode::Long:
-			if ( ! init ) {
-				init = true;
-				ret = BasicType::LongSignedInt;
-			} else {
-				switch ( ret ) {
-				  case BasicType::SignedInt:
-					ret = BasicType::LongSignedInt;
-					break;
-				  case BasicType::UnsignedInt:
-					ret = BasicType::LongUnsignedInt;
-					break;
-				  case BasicType::LongSignedInt:
-					ret = BasicType::LongLongSignedInt;
-					break;
-				  case BasicType::LongUnsignedInt:
-					ret = BasicType::LongLongUnsignedInt;
-					break;
-				  case BasicType::Double:
-					ret = BasicType::LongDouble;
-					break;
-				  case BasicType::DoubleComplex:
-					ret = BasicType::LongDoubleComplex;
-					break;
-				  case BasicType::DoubleImaginary:
-					ret = BasicType::LongDoubleImaginary;
-					break;
-				  default:
-					throw SemanticError( "invalid type modifier \"long\" in type: ", td );
-				} // switch
-			} // if
-			break;
-		  case DeclarationNode::Short:
-			if ( ! init ) {
-				init = true;
-				ret = BasicType::ShortSignedInt;
-			} else {
-				switch ( ret ) {
-				  case BasicType::SignedInt:
-					ret = BasicType::ShortSignedInt;
-					break;
-				  case BasicType::UnsignedInt:
-					ret = BasicType::ShortUnsignedInt;
-					break;
-				  default:
-					throw SemanticError( "invalid type modifier \"short\" in type: ", td );
-				} // switch
-			} // if
-			break;
-		  case DeclarationNode::Signed:
-			if ( ! init ) {
-				init = true;
-				ret = BasicType::SignedInt;
-			} else if ( sawSigned ) {
-				throw SemanticError( "duplicate type modifer \"signed\" in type: ", td );
-			} else {
-				switch ( ret ) {
-				  case BasicType::LongLongSignedInt:
-					ret = BasicType::LongLongUnsignedInt;
-					break;
-				  case BasicType::LongSignedInt:
-					ret = BasicType::LongUnsignedInt;
-					break;
-				  case BasicType::SignedInt:
-				  case BasicType::ShortSignedInt:
-					break;
-				  case BasicType::Char:
-					ret = BasicType::SignedChar;
-					break;
-				  default:
-					throw SemanticError( "invalid type modifer \"signed\" in type: ", td );
-				} // switch
-			} // if
-			break;
-		  case DeclarationNode::Unsigned:
-			if ( ! init ) {
-				init = true;
-				ret = BasicType::UnsignedInt;
-			} else if ( sawSigned ) {
-				throw SemanticError( "invalid type modifer \"unsigned\" in type: ", td );
-			} else {
-				switch ( ret ) {
-				  case BasicType::LongLongSignedInt:
-					ret = BasicType::LongLongUnsignedInt;
-					break;
-				  case BasicType::LongSignedInt:
-					ret = BasicType::LongUnsignedInt;
-					break;
-				  case BasicType::SignedInt:
-					ret = BasicType::UnsignedInt;
-					break;
-				  case BasicType::ShortSignedInt:
-					ret = BasicType::ShortUnsignedInt;
-					break;
-				  case BasicType::Char:
-					ret = BasicType::UnsignedChar;
-					break;
-				  default:
-					throw SemanticError( "invalid type modifer \"unsigned\" in type: ", td );
-				} // switch
-			} // if
-			break;
-		} // switch
-
-		if ( *i == DeclarationNode::Signed ) {
-			sawSigned = true;
-		} // if
-	} // for
-
-	BasicType * bt;
-	if ( ! init ) {
-		bt = new BasicType( buildQualifiers( td ), BasicType::SignedInt );
-	} else {
-		bt = new BasicType( buildQualifiers( td ), ret );
-	} // if
+	switch ( td->basictype ) {
+	  case DeclarationNode::Void:
+		if ( td->signedness != DeclarationNode::NoSignedness && td->length != DeclarationNode::NoLength ) {
+			throw SemanticError( "invalid type specifier \"void\" in type: ", td );
+		} // if
+
+		return new VoidType( buildQualifiers( td ) );
+		break;
+
+	  case DeclarationNode::Bool:
+		if ( td->signedness != DeclarationNode::NoSignedness ) {
+			throw SemanticError( std::string( "invalid type specifier " ) + DeclarationNode::signednessName[ td->signedness ] + " in type: ", td );
+		} // if
+		if ( td->length != DeclarationNode::NoLength ) {
+			throw SemanticError( std::string( "invalid type specifier " ) + DeclarationNode::lengthName[ td->length ] + " in type: ", td );
+		} // if
+
+		ret = BasicType::Bool;
+		break;
+
+	  case DeclarationNode::Char:
+		// C11 Standard 6.2.5.15: The three types char, signed char, and unsigned char are collectively called the
+		// character types. The implementation shall define char to have the same range, representation, and behavior as
+		// either signed char or unsigned char.
+		static BasicType::Kind chartype[] = { BasicType::SignedChar, BasicType::UnsignedChar, BasicType::Char }; 
+
+		if ( td->length != DeclarationNode::NoLength ) {
+			throw SemanticError( std::string( "invalid type specifier " ) + DeclarationNode::lengthName[ td->length ] + " in type: ", td );
+		} // if
+
+		ret = chartype[ td->signedness ];
+		break;
+
+	  case DeclarationNode::Int:
+		static BasicType::Kind inttype[2][4] = {
+			{ BasicType::ShortSignedInt, BasicType::LongSignedInt, BasicType::LongLongSignedInt, BasicType::SignedInt },
+			{ BasicType::ShortUnsignedInt, BasicType::LongUnsignedInt, BasicType::LongLongUnsignedInt, BasicType::UnsignedInt },
+		};
+
+	  Integral: ;
+		if ( td->signedness == DeclarationNode::NoSignedness ) {
+			const_cast<TypeData *>(td)->signedness = DeclarationNode::Signed;
+		} // if
+		ret = inttype[ td->signedness ][ td->length ];
+		break;
+
+	  case DeclarationNode::Float:
+	  case DeclarationNode::Double:
+	  case DeclarationNode::LongDouble:					// not set until below
+		static BasicType::Kind floattype[3][3] = {
+			{ BasicType::FloatComplex, BasicType::DoubleComplex, BasicType::LongDoubleComplex },
+			{ BasicType::FloatImaginary, BasicType::DoubleImaginary, BasicType::LongDoubleImaginary },
+			{ BasicType::Float, BasicType::Double, BasicType::LongDouble },
+		};
+
+	  FloatingPoint: ;
+		if ( td->signedness != DeclarationNode::NoSignedness ) {
+			throw SemanticError( std::string( "invalid type specifier " ) + DeclarationNode::signednessName[ td->signedness ] + " in type: ", td );
+		} // if
+		if ( td->length == DeclarationNode::Short || td->length == DeclarationNode::LongLong ) {
+			throw SemanticError( std::string( "invalid type specifier " ) + DeclarationNode::lengthName[ td->length ] + " in type: ", td );
+		} // if
+		if ( td->basictype == DeclarationNode::Float && td->length == DeclarationNode::Long ) {
+			throw SemanticError( "invalid type specifier \"long\" in type: ", td );
+		} // if
+		if ( td->length == DeclarationNode::Long ) {
+			const_cast<TypeData *>(td)->basictype = DeclarationNode::LongDouble;
+		} // if
+
+		ret = floattype[ td->complextype ][ td->basictype - DeclarationNode::Float ];
+		break;
+
+	  case DeclarationNode::NoBasicType:
+		// No basic type in declaration => default double for Complex/Imaginary and int type for integral types
+		if ( td->complextype == DeclarationNode::Complex || td->complextype == DeclarationNode::Imaginary ) {
+			const_cast<TypeData *>(td)->basictype = DeclarationNode::Double;
+			goto FloatingPoint;
+		} // if
+
+		const_cast<TypeData *>(td)->basictype = DeclarationNode::Int;
+		goto Integral;
+	} // switch
+
+	BasicType * bt = new BasicType( buildQualifiers( td ), ret );
 	buildForall( td->forall, bt->get_forall() );
 	return bt;
