http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53470
--- Comment #12 from Richard Guenther <rguenth at gcc dot gnu.org> 2012-06-11 12:54:50 UTC --- It seems we never come along with a DECL_CONTEXT that is a BLOCK (nor does the C++ frontend do that ...). Replacing the TYPE_CONTEXT clearing with if (TYPE_CONTEXT (type) && TREE_CODE (TYPE_CONTEXT (type)) == BLOCK) { tree ctx = TYPE_CONTEXT (type); do { ctx = BLOCK_SUPERCONTEXT (ctx); } while (ctx && TREE_CODE (ctx) == BLOCK); TYPE_CONTEXT (type) = ctx; } thus, replace a BLOCK context with the first non-BLOCK context, works.