Check dflags for language extensions when deciding if "foreign " and "deriving "
look like prefixes of valid declarations (fixes #9915)