Refactor checking of switch conditions and case values.
authorRichard Smith <richard-llvm@metafoo.co.uk>
Thu, 26 Jul 2018 18:41:30 +0000 (18:41 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Thu, 26 Jul 2018 18:41:30 +0000 (18:41 +0000)
commitef6c43dc0cb2b05ec9b8500dfb934ac70664d591
tree79a32edb31114f4d7b90a3e3f3a040bd4c7204d3
parentc5982fb6343110969c2bdcbc19559b299071b8b1
Refactor checking of switch conditions and case values.

Check each case value in turn while parsing it, performing the
conversion to the switch type within the context of the expression
itself. This will become necessary in order to properly handle cleanups
for temporaries created as part of the case label (in an upcoming
patch). For now it's just good hygiene.

This necessitates moving the checking for the switch condition itself to
earlier, so that the destination type is available when checking the
case labels.

As a nice side-effect, we get slightly improved diagnostic quality and
error recovery by separating the case expression checking from the case
statement checking and from tracking whether there are discarded case
labels.

llvm-svn: 338056
14 files changed:
clang/include/clang/Parse/Parser.h
clang/include/clang/Sema/ScopeInfo.h
clang/include/clang/Sema/Sema.h
clang/lib/Parse/ParseExpr.cpp
clang/lib/Parse/ParseStmt.cpp
clang/lib/Sema/SemaCodeComplete.cpp
clang/lib/Sema/SemaStmt.cpp
clang/lib/Sema/TreeTransform.h
clang/test/Parser/switch-recovery.cpp
clang/test/Sema/complex-int.c
clang/test/Sema/switch.c
clang/test/SemaCXX/i-c-e-cxx.cpp
clang/test/SemaCXX/scope-check.cpp
clang/test/SemaCXX/typo-correction.cpp