summaryrefslogtreecommitdiff
path: root/test/Parser/switch-recovery.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Refactor the way we handle diagnosing unused expression results.Aaron Ballman2019-01-041-1/+1
| | | | | | | | Rather than sprinkle calls to DiagnoseUnusedExprResult() around in places where we want diagnostics, we now diagnose unused expression statements and full expressions in a more generic way when acting on the final expression statement. This results in more appropriate diagnostics for [[nodiscard]] where we were previously lacking them, such as when the body of a for loop is not a compound statement. This patch fixes PR39837. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@350404 91177308-0d34-0410-b5e6-96231b3b80d8
* Refactor checking of switch conditions and case values.Richard Smith2018-07-261-3/+5
| | | | | | | | | | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338056 91177308-0d34-0410-b5e6-96231b3b80d8
* Sema: Don't leave switch stack inconsistent when recoveringDavid Majnemer2014-12-151-0/+9
| | | | | | | | | We would exit Sema::ActOnFinishSwitchStmt early if we didn't have a body. This would leave an extra SwitchStmt on the SwitchStack. This fixes PR21841. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@224237 91177308-0d34-0410-b5e6-96231b3b80d8
* Improved recovery of switch statementSerge Pavlov2014-05-211-0/+50
| | | | | | | | | | Make better diagnostic produced by erroneous switch statement. It fixes PR19022. Differential Revision: http://reviews.llvm.org/D3137 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@209302 91177308-0d34-0410-b5e6-96231b3b80d8
* Allow CorrectTypo to replace CXXScopeSpecifiers that refer to classes.Kaelyn Uhrain2013-10-191-3/+3
| | | | | | | | | | | Now that CorrectTypo knows how to correctly search classes for typo correction candidates, there is no good reason to only replace an existing CXXScopeSpecifier if it refers to a namespace. While the actual enablement was a matter of changing a single comparison, the fallout from enabling the functionality required a lot more code changes (including my two previous commits). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@193020 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove the last FIXMEs on -Wunused-comparison since it got moved toChandler Carruth2011-08-181-1/+1
| | | | | | | entirely use the existing -Wunused-value infrastructure. This also fixes a few missed cases for -Wunused in general. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137916 91177308-0d34-0410-b5e6-96231b3b80d8
* Improve the diagnostics generated for switch statements missing expressionsDavid Majnemer2011-06-131-0/+14
| | | | | | | | - Move the diagnostic to the case statement instead of at the end of the switch - Add a fix-it hint as to how to fix the compilation error git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132903 91177308-0d34-0410-b5e6-96231b3b80d8
* Add a fixit suggest for missing case keywords inside a switch scope. For ↵Richard Trieu2011-04-211-0/+124
| | | | | | | | | | | | | instance, in the following code, 'case ' will be suggested before the '1:' switch (x) { 1: return 0; default: return 1; } git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@129943 91177308-0d34-0410-b5e6-96231b3b80d8
* Improve our parse recovery on 'case blah;' and 'default;'.John McCall2011-01-221-0/+14
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@124025 91177308-0d34-0410-b5e6-96231b3b80d8
* Improve the diagnostic and recovery for missing colons after 'case'Douglas Gregor2010-12-231-1/+9
| | | | | | | | | | | | | | | | | and 'default' statements, including a Fix-It to add the colon: test/Parser/switch-recovery.cpp:13:12: error: expected ':' after 'case' case 17 // expected-error{{expected ':' after 'case'}} ^ : test/Parser/switch-recovery.cpp:16:12: error: expected ':' after 'default' default // expected-error{{expected ':' after 'default'}} ^ : git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@122522 91177308-0d34-0410-b5e6-96231b3b80d8
* Improve parser recovery when a switch condition is invalid; fixesDouglas Gregor2010-05-201-0/+12
<rdar://problem/7971948>. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@104291 91177308-0d34-0410-b5e6-96231b3b80d8