Index: src/CodeGen/CodeGenerator.cpp
===================================================================
--- src/CodeGen/CodeGenerator.cpp	(revision 6f9f3384980c4780f6be1f9970473781bdfb327f)
+++ src/CodeGen/CodeGenerator.cpp	(revision e48aca8ae51f025285f95f19f58f543a0bfdec0b)
@@ -790,4 +790,16 @@
 }
 
+void CodeGenerator::postvisit( ast::CountofExpr const * expr ) {
+	assertf( !options.genC, "CountofExpr should not reach code generation." );
+	extension( expr );
+	output << "countof(";
+	if ( auto type = expr->type.as<ast::TypeofType>() ) {
+		type->expr->accept( *visitor );
+	} else {
+		output << genType( expr->type, "", options );
+	}
+	output << ")";
+}
+
 void CodeGenerator::postvisit( ast::UntypedOffsetofExpr const * expr ) {
 	assertf( !options.genC, "UntypedOffsetofExpr should not reach code generation." );
Index: src/CodeGen/CodeGenerator.hpp
===================================================================
--- src/CodeGen/CodeGenerator.hpp	(revision 6f9f3384980c4780f6be1f9970473781bdfb327f)
+++ src/CodeGen/CodeGenerator.hpp	(revision e48aca8ae51f025285f95f19f58f543a0bfdec0b)
@@ -42,8 +42,8 @@
 	void previsit( ast::Expr const * );
 
-	void postvisit( ast::StructDecl const * );
 	void postvisit( ast::FunctionDecl const * );
 	// Yes, there is one visit that does modify the ast.
 	ast::ObjectDecl const * postvisit( ast::ObjectDecl const * );
+	void postvisit( ast::StructDecl const * );
 	void postvisit( ast::UnionDecl const * );
 	void postvisit( ast::EnumDecl const * );
@@ -73,4 +73,5 @@
 	void postvisit( ast::SizeofExpr const * );
 	void postvisit( ast::AlignofExpr const * );
+	void postvisit( ast::CountofExpr const * );
 	void postvisit( ast::UntypedOffsetofExpr const * );
 	void postvisit( ast::OffsetofExpr const * );
