Fix crash on switch conditions of non-integer types in templates
authorElizabeth Andrews <elizabeth.andrews@intel.com>
Tue, 13 Aug 2019 15:53:19 +0000 (15:53 +0000)
committerElizabeth Andrews <elizabeth.andrews@intel.com>
Tue, 13 Aug 2019 15:53:19 +0000 (15:53 +0000)
commit76945821b9cad3baebad5c36ae00ab173f8529c6
treea3e44347cfdaf3a2cabe88257f51328504c15971
parent0a04a062500e2c6d5b92b59c545db3f45e9daffe
Fix crash on switch conditions of non-integer types in templates

Clang currently crashes for switch statements inside a template when
the condition is a non-integer field. The crash is due to incorrect
type-dependency of field. Type-dependency of member expressions is
currently set based on the containing class. This patch changes this for
'members of the current instantiation' to set the type dependency based
on the member'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 in this patch as well.

Patch fixes PR#40982

Differential Revision: https://reviews.llvm.org/D61027

llvm-svn: 368706
clang/lib/AST/Expr.cpp
clang/lib/Sema/SemaChecking.cpp
clang/test/SemaTemplate/dependent-names.cpp
clang/test/SemaTemplate/enum-argument.cpp
clang/test/SemaTemplate/member-access-expr.cpp
clang/test/SemaTemplate/non-integral-switch-cond.cpp [new file with mode: 0644]