Refactored the thread role checking code into something that can be shared between declarations and statements; moved some test cases around based on what part of the compiler emits the diagnostic.