Index: src/SymTab/Validate.cc
===================================================================
--- src/SymTab/Validate.cc	(revision ac3362c49d6542b7d8c8fb775ea7b0215120bdbd)
+++ src/SymTab/Validate.cc	(revision 2b79a705ea7fc9439579f72a887d080e6387f0d5)
@@ -62,4 +62,5 @@
 #include "ResolvExpr/typeops.h"        // for typesCompatible
 #include "ResolvExpr/Resolver.h"       // for findSingleExpression
+#include "ResolvExpr/ResolveTypeof.h"  // for resolveTypeof
 #include "SymTab/Autogen.h"            // for SizeType
 #include "SynTree/Attribute.h"         // for noAttributes, Attribute
@@ -247,4 +248,13 @@
 		void previsit( StructInstType * inst );
 		void previsit( UnionInstType * inst );
+	};
+
+	struct FixObjectType : public WithIndexer {
+		/// resolves typeof type in object, function, and type declarations
+		static void fix( std::list< Declaration * > & translationUnit );
+
+		void previsit( ObjectDecl * );
+		void previsit( FunctionDecl * );
+		void previsit( TypeDecl * );
 	};
 
@@ -312,4 +322,5 @@
 		Concurrency::implementThreadStarter( translationUnit );
 		mutateAll( translationUnit, compoundliteral );
+		FixObjectType::fix( translationUnit );
 		ArrayLength::computeLength( translationUnit );
 		acceptAll( translationUnit, finder ); // xxx - remove this pass soon
@@ -1238,4 +1249,29 @@
 	}
 
+	void FixObjectType::fix( std::list< Declaration * > & translationUnit ) {
+		PassVisitor<FixObjectType> fixer;
+		acceptAll( translationUnit, fixer );
+	}
+
+	void FixObjectType::previsit( ObjectDecl * objDecl ) {
+		Type *new_type = ResolvExpr::resolveTypeof( objDecl->get_type(), indexer );
+		new_type->get_qualifiers() -= Type::Lvalue; // even if typeof is lvalue, variable can never have lvalue-qualified type
+		objDecl->set_type( new_type );
+	}
+
+	void FixObjectType::previsit( FunctionDecl * funcDecl ) {
+		Type *new_type = ResolvExpr::resolveTypeof( funcDecl->type, indexer );
+		new_type->get_qualifiers() -= Type::Lvalue; // even if typeof is lvalue, variable can never have lvalue-qualified type
+		funcDecl->set_type( new_type );
+	}
+
+	void FixObjectType::previsit( TypeDecl *typeDecl ) {
+		if ( typeDecl->get_base() ) {
+			Type *new_type = ResolvExpr::resolveTypeof( typeDecl->get_base(), indexer );
+			new_type->get_qualifiers() -= Type::Lvalue; // even if typeof is lvalue, variable can never have lvalue-qualified type
+			typeDecl->set_base( new_type );
+		} // if
+	}
+
 	void ArrayLength::computeLength( std::list< Declaration * > & translationUnit ) {
 		PassVisitor<ArrayLength> len;
