Afghan clash 'kills 40 militants'