Index: src/Parser/TypeData.cc
===================================================================
--- src/Parser/TypeData.cc	(revision c45b3043143d32253a958105b5b97f4651100bd7)
+++ src/Parser/TypeData.cc	(revision f441c882023a95e64ef87d0bf8675cb0a49fbc9b)
@@ -522,46 +522,46 @@
 	switch ( td->kind ) {
 	  case TypeData::Unknown:
-		// fill in implicit int
-		return new BasicType( buildQualifiers( td ), BasicType::SignedInt );
+			// fill in implicit int
+			return new BasicType( buildQualifiers( td ), BasicType::SignedInt );
 	  case TypeData::Basic:
-		return buildBasicType( td );
+			return buildBasicType( td );
 	  case TypeData::Pointer:
-		return buildPointer( td );
+			return buildPointer( td );
 	  case TypeData::Array:
-		return buildArray( td );
+			return buildArray( td );
 	  case TypeData::Reference:
-		return buildReference( td );
+			return buildReference( td );
 	  case TypeData::Function:
-		return buildFunction( td );
+			return buildFunction( td );
 	  case TypeData::AggregateInst:
-		return buildAggInst( td );
+			return buildAggInst( td );
 	  case TypeData::EnumConstant:
-		// the name gets filled in later -- by SymTab::Validate
-		return new EnumInstType( buildQualifiers( td ), "" );
+			// the name gets filled in later -- by SymTab::Validate
+			return new EnumInstType( buildQualifiers( td ), "" );
 	  case TypeData::SymbolicInst:
-		return buildSymbolicInst( td );
+			return buildSymbolicInst( td );
 	  case TypeData::Tuple:
-		return buildTuple( td );
+			return buildTuple( td );
 	  case TypeData::Typeof:
 	  case TypeData::Basetypeof:
-		return buildTypeof( td );
+			return buildTypeof( td );
 	  case TypeData::Builtin:
-		if(td->builtintype == DeclarationNode::Zero) {
-			return new ZeroType( noQualifiers );
-		}
-		else if(td->builtintype == DeclarationNode::One) {
-			return new OneType( noQualifiers );
-		}
-		else {
-			return new VarArgsType( buildQualifiers( td ) );
-		}
+			if (td->builtintype == DeclarationNode::Zero) {
+				return new ZeroType( noQualifiers );
+			}
+			else if (td->builtintype == DeclarationNode::One) {
+				return new OneType( noQualifiers );
+			}
+			else {
+				return new VarArgsType( buildQualifiers( td ) );
+			}
 	  case TypeData::GlobalScope:
-		return new GlobalScopeType();
+			return new GlobalScopeType();
 		case TypeData::Qualified:
-		return new QualifiedType( buildQualifiers( td ), typebuild( td->qualified.parent ), typebuild( td->qualified.child ) );
+			return new QualifiedType( buildQualifiers( td ), typebuild( td->qualified.parent ), typebuild( td->qualified.child ) );
 	  case TypeData::Symbolic:
 	  case TypeData::Enum:
 	  case TypeData::Aggregate:
-		assert( false );
+			assert( false );
 	} // switch
 
@@ -942,5 +942,6 @@
 	assert( td->typeexpr );
 	// assert( td->typeexpr->expr );
-	return new TypeofType( td->kind == TypeData::Basetypeof ? Type::Qualifiers{} : buildQualifiers( td ), td->typeexpr->build() );
+	return new TypeofType{ 
+		buildQualifiers( td ), td->typeexpr->build(), td->kind == TypeData::Basetypeof };
 } // buildTypeof
 
Index: src/ResolvExpr/ResolveTypeof.cc
===================================================================
--- src/ResolvExpr/ResolveTypeof.cc	(revision c45b3043143d32253a958105b5b97f4651100bd7)
+++ src/ResolvExpr/ResolveTypeof.cc	(revision f441c882023a95e64ef87d0bf8675cb0a49fbc9b)
@@ -67,14 +67,35 @@
 		std::cerr << std::endl;
 #endif
-		if ( typeofType->expr ) {
+		// pass on null expression
+		if ( ! typeofType->expr ) return typeofType;
+
+		bool isBasetypeof = typeofType->is_basetypeof;
+		auto oldQuals = typeofType->get_qualifiers().val;
+
+		Type* newType;
+		if ( TypeExpr* tyExpr = dynamic_cast<TypeExpr*>(typeofType->expr) ) {
+			// typeof wrapping type
+			newType = tyExpr->type;
+			tyExpr->type = nullptr;
+			delete tyExpr;
+		} else {
+			// typeof wrapping expression
 			Expression * newExpr = resolveInVoidContext( typeofType->expr, indexer );
 			assert( newExpr->result && ! newExpr->result->isVoid() );
-			Type * newType = newExpr->result;
+			newType = newExpr->result;
 			newExpr->result = nullptr;
 			delete typeofType;
 			delete newExpr;
-			return newType;
-		} // if
-		return typeofType;
+		}
+
+		// clear qualifiers for base, combine with typeoftype quals in any case
+		if ( isBasetypeof ) {
+			newType->get_qualifiers().val 
+				= ( newType->get_qualifiers().val & ~Type::Qualifiers::Mask ) | oldQuals;
+		} else {
+			newType->get_qualifiers().val |= oldQuals;
+		}
+		
+		return newType;
 	}
 } // namespace ResolvExpr
Index: src/SynTree/Type.h
===================================================================
--- src/SynTree/Type.h	(revision c45b3043143d32253a958105b5b97f4651100bd7)
+++ src/SynTree/Type.h	(revision f441c882023a95e64ef87d0bf8675cb0a49fbc9b)
@@ -598,7 +598,10 @@
 class TypeofType : public Type {
   public:
-	Expression *expr;
-
-	TypeofType( const Type::Qualifiers & tq, Expression *expr, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
+	Expression *expr;    ///< expression to take the type of
+	bool is_basetypeof;  ///< true iff is basetypeof type
+
+	TypeofType( const Type::Qualifiers & tq, Expression *expr, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
+	TypeofType( const Type::Qualifiers & tq, Expression *expr, bool is_basetypeof, 
+		const std::list< Attribute * > & attributes = std::list< Attribute * >() );
 	TypeofType( const TypeofType& );
 	virtual ~TypeofType();
Index: src/SynTree/TypeofType.cc
===================================================================
--- src/SynTree/TypeofType.cc	(revision c45b3043143d32253a958105b5b97f4651100bd7)
+++ src/SynTree/TypeofType.cc	(revision f441c882023a95e64ef87d0bf8675cb0a49fbc9b)
@@ -23,9 +23,14 @@
 class Attribute;
 
-TypeofType::TypeofType( const Type::Qualifiers &tq, Expression *expr, const std::list< Attribute * > & attributes ) : Type( tq, attributes ), expr( expr ) {
-}
+TypeofType::TypeofType( const Type::Qualifiers &tq, Expression *expr, 
+	const std::list< Attribute * > & attributes ) 
+: Type( tq, attributes ), expr( expr ), is_basetypeof(false) {}
 
-TypeofType::TypeofType( const TypeofType &other ) : Type( other ), expr( maybeClone( other.expr ) ) {
-}
+TypeofType::TypeofType( const Type::Qualifiers &tq, Expression *expr, bool is_basetypeof, 
+	const std::list< Attribute * > & attributes ) 
+: Type( tq, attributes ), expr( expr ), is_basetypeof( is_basetypeof ) {}
+
+TypeofType::TypeofType( const TypeofType &other )
+: Type( other ), expr( maybeClone( other.expr ) ), is_basetypeof( other.is_basetypeof ) {}
 
 TypeofType::~TypeofType() {
@@ -35,4 +40,5 @@
 void TypeofType::print( std::ostream &os, Indenter indent ) const {
 	Type::print( os, indent );
+	if ( is_basetypeof ) { os << "base-"; }
 	os << "type-of expression ";
 	if ( expr ) {
