Clang currently crashes for switch statements inside a template when the condition is a non-integer field member because contextual implicit conversion is skipped when parsing the condition. This conversion is however later checked in an assert when the case statement is handled.
The conversion is skipped when parsing the condition because the field member is set as type-dependent based on its containing class. This patch sets the type dependency based on the field's type instead. A few lit tests started to fail once I applied this patch because errors are now diagnosed earlier (does not wait till instantiation). I've modified these tests.
This patch fixes Bug 40982. Please note my earlier attempt at fixing this bug delayed checks for dependent expressions till instantiation. I changed the approach after feedback from Richard and cpplearner (ensadc) - https://bugs.llvm.org/show_bug.cgi?id=40982