summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaCXX/scope-check.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Refactor checking of switch conditions and case values.Richard Smith2018-07-261-1/+2
| | | | | | | | | | | | | | | | | | | 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
* Fix Sema tests using __try by adding tripleReid Kleckner2015-04-281-2/+2
| | | | llvm-svn: 236057
* Warn when jumping out of a __finally block via goto.Nico Weber2015-03-091-10/+8
| | | | | | | | | | | | | | This only warns on direct gotos and indirect gotos with a unique label (`goto *&&label;`). Jumping out ith a true indirect goto is already an error. This isn't O(1), but goto statements are less common than continue, break, and return. Also, the GetDeepestCommonScope() call in the same function does the same amount of work, so this isn't worse than what's there in a complexity sense, and it should be pretty fast in practice. This is the last piece that was missing in r231623. llvm-svn: 231628
* Implement jump scope SEHmantic analysis.Nico Weber2015-02-031-2/+191
| | | | | | | | | | | | | | | | | | | Thou shall not jump into SEH blocks. Jumping out of SEH __try and __excepts is A-ok. Jumping out of __finally blocks is B-ok (msvc doesn't error about it, but warns that it has undefined behavior). I've checked that clang's behavior with this patch matches msvc's behavior. We don't have the warning on jumping out of a __finally yet, see the FIXME in the test. clang also currently crashes on codegen for a jump out of a __finally block, see PR22414 comment 7. I also added a few tests for the interaction of indirect jumps and SEH blocks. MSVC doesn't support indirect jumps, so there's no way to know if clang behave the same way as msvc here. clang's behavior with this patch does make sense to me, but maybe it could be argued that it should be more permissive (see FIXME in the indirect jump tests -- shout if you have an opinion on this). llvm-svn: 227982
* Reword switch/goto diagnostics "protected scope" diagnostics. Making up a termRichard Smith2014-09-061-19/+19
| | | | | | | | "protected scope" is very unhelpful here and actively confuses users. Instead, simply state the nature of the problem in the diagnostic: we cannot jump from here to there. The notes explain nicely why not. llvm-svn: 217293
* Add support for partial jump scope checkingAlp Toker2014-05-091-11/+31
| | | | | | | | | | This lets us diagnose and perform more complete semantic analysis when faced with errors in the function body or declaration. By recovering here we provide more consistent diagnostics, particularly during interactive editing. llvm-svn: 208394
* PR18217: Rewrite JumpDiagnostics' handling of temporaries, to correctly handleRichard Smith2013-12-121-2/+116
| | | | | | | | | declarations that might lifetime-extend multiple temporaries. In passing, fix a crasher (PR18217) if an initializer was dependent and exactly the wrong shape, and remove a bogus function (Expr::findMaterializedTemporary) now its last use is gone. llvm-svn: 197103
* Fix a couple of bugs where jump diagnostics would not notice that a variableRichard Smith2013-06-031-0/+21
| | | | | | has an initializer. llvm-svn: 183092
* When a statement is dropped from the AST because it was invalid, make sureArgyrios Kyrtzidis2013-02-151-0/+12
| | | | | | | we don't do the scope checks otherwise we are going to hit assertion checks since a label may not have been actually added. llvm-svn: 175281
* Correctly reject gotos in function-level try blocks. PR14225.Eli Friedman2012-10-311-2/+16
| | | | llvm-svn: 167184
* Fix invalid jump scopes again. This time without trying to find out if anRafael Espindola2012-10-281-0/+58
| | | | | | incomplete type has a destructor or not. llvm-svn: 166895
* Revert 166876 while I debug a bootstrap problem.Rafael Espindola2012-10-271-58/+0
| | | | llvm-svn: 166878
* Reapply 166855 with an early exit on null QualTypes.Rafael Espindola2012-10-271-0/+58
| | | | llvm-svn: 166876
* Revert r166855. I can reproduce the bootstrap failure and have a testcaseRafael Espindola2012-10-271-58/+0
| | | | | | to reduce. llvm-svn: 166863
* Fix cases where we were not producing an error when a computed goto couldRafael Espindola2012-10-271-0/+58
| | | | | | | jump over destructor calls. Fixes pr13812. llvm-svn: 166855
* Fix namespace nesting and remove windows line endings.Rafael Espindola2012-09-111-21/+16
| | | | llvm-svn: 163620
* Modify how the -verify flag works. Currently, the verification string andRichard Trieu2011-12-151-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | diagnostic message are compared. If either is a substring of the other, then no error is given. This gives rise to an unexpected case: // expect-error{{candidate function has different number of parameters}} will match the following error messages from Clang: candidate function has different number of parameters (expected 1 but has 2) candidate function has different number of parameters It will also match these other error messages: candidate function function has different number of parameters number of parameters This patch will change so that the verification string must be a substring of the diagnostic message before accepting. Also, all the failing tests from this change have been corrected. Some stats from this cleanup: 87 - removed extra spaces around verification strings 70 - wording updates to diagnostics 40 - extra leading or trailing characters (typos, unmatched parens or quotes) 35 - diagnostic level was included (error:, warning:, or note:) 18 - flag name put in the warning (-Wprotocol) llvm-svn: 146619
* Update all tests other than Driver/std.cpp to use -std=c++11 rather thanRichard Smith2011-10-131-1/+1
| | | | | | -std=c++0x. Patch by Ahmed Charles! llvm-svn: 141900
* In Microsoft mode, warn if an indirect goto jump over a variable initialization.Francois Pichet2011-09-161-0/+15
| | | | | | Also add a test case for the non Microsoft case because such test didn't exist. llvm-svn: 139971
* Make DiagnosticErrorTrap keep a count of the errors that occurred so multipleArgyrios Kyrtzidis2011-07-291-0/+21
| | | | | | | | DiagnosticErrorTraps can be composed (e.g. a trap inside another trap). Fixes http://llvm.org/PR10462 & rdar://9852007. llvm-svn: 136447
* I concur with DPG here. This does indeed apply in 0x mode. Added testChandler Carruth2011-04-221-0/+20
| | | | | | | | | cases that demonstrates exactly why this does indeed apply in 0x mode. If isPOD is currently broken in 0x mode, we should fix that directly rather than papering over it here. llvm-svn: 130007
* Implement an indirect-goto optimization for goto *&&lbl and respect thisJohn McCall2010-10-281-2/+2
| | | | | | | | | | | | | | in the scope checker. With that done, turn an indirect goto into a protected scope into a hard error; otherwise IR generation has to start worrying about declarations not dominating their scopes, as exemplified in PR8473. If this really affects anyone, I can probably adjust this to only hard-error on possible indirect gotos into VLA scopes rather than arbitrary scopes. But we'll see how people cope with the aggressive change on the marginal feature. llvm-svn: 117539
* Labels (and case statement) don't create independent scope parents for theJohn McCall2010-08-021-0/+18
| | | | | | | | purposes of the jump checker. Also extend Ted's iteration fix to labels. Fixes PR7789. llvm-svn: 110082
* Don't consider all local variables in C++ to mandate scope-checking, justJohn McCall2010-08-011-0/+12
| | | | | | those with initializers. llvm-svn: 109964
* When checking scopes for indirect goto, be more permissive (but still safe)John McCall2010-05-121-0/+123
about the permitted scopes. Specifically: 1) Permit labels and gotos to appear after a prologue of variable initializations. 2) Permit indirect gotos to jump out of scopes that don't require cleanup. 3) Diagnose possible attempts to indirect-jump out of scopes that do require cleanup. This requires a substantial reinvention of the algorithm for checking indirect goto. The current algorithm is Omega(M*N), with M = the number of unique scopes being jumped from and N = the number of unique scopes being jumped to, with an additional factor that is probably (worst-case) linear in the depth of scopes. Thus the entire thing is likely cubic given some truly bizarre ill-formed code; on well-formed code the additional factor collapses to an amortized constant (when amortized over the entire function) and so the algorithm is quadratic. Even this requires every label to appear in its own scope, which would be very unusual for indirect-goto code (and extremely unlikely for well-formed code); it is far more likely that all labels will be in the same scope and so the algorithm becomes linear. For such a marginal feature, I am fairly happy with this result. (this is using JumpDiagnostic's definition of scope, where successive variables in a block appear in their own scope) llvm-svn: 103536
OpenPOWER on IntegriCloud