summaryrefslogtreecommitdiffstats
path: root/clang/test/CXX/stmt.stmt
Commit message (Collapse)AuthorAgeFilesLines
* Refactor the way we handle diagnosing unused expression results.Aaron Ballman2019-01-041-5/+4
| | | | | | | | 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. llvm-svn: 350404
* P0962R1: only use the member form of 'begin' and 'end' in a range-basedRichard Smith2018-09-241-2/+57
| | | | | | | | | | for loop if both members exist. This resolves a DR whereby an errant 'begin' or 'end' member in a base class could result in a derived class not being usable as a range with non-member 'begin' and 'end'. llvm-svn: 342925
* Clean up and simplify RequireCompleteType.Richard Smith2018-08-071-1/+1
| | | | | | | No functional change intended, except that we will now produce more "declared here" notes. llvm-svn: 339187
* [C++17] Allow an empty expression in an if init statementZhihao Yuan2018-03-171-1/+59
| | | | | | | | | | | | | | | | | | | Summary: This fixes [PR35381](https://llvm.org/pr35381) and an additional bug where clang didn't warn about the C++17 extension when having an expression in the init statement. Thanks Nicolas Lesser for contributing the patch. Reviewers: rsmith Reviewed By: rsmith Subscribers: erik.pilkington, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D40445 llvm-svn: 327782
* [Sema] Improve diagnostics for const- and ref-qualified member functionsJacob Bandes-Storch2017-12-311-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | (Re-submission of D39937 with fixed tests.) Adjust wording for const-qualification mismatch to be a little more clear. Also add another diagnostic for a ref qualifier mismatch, which previously produced a useless error (this error path is simply very old; see rL119336): Before: error: cannot initialize object parameter of type 'X0' with an expression of type 'X0' After: error: 'this' argument to member function 'rvalue' is an lvalue, but function has rvalue ref-qualifier Reviewers: aaron.ballman Reviewed By: aaron.ballman Subscribers: lebedev.ri, cfe-commits Differential Revision: https://reviews.llvm.org/D41646 llvm-svn: 321609
* Replace remaining user-visible mentions of C++1z with C++17.Richard Smith2017-08-131-2/+2
| | | | llvm-svn: 310804
* Try contextually converting condition of constexpr if to Boolean valueIsmail Pazarbasi2016-09-071-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: C++1z 6.4.1/p2: If the if statement is of the form if constexpr, the value of the condition shall be a contextually converted constant expression of type bool [...] C++1z 5.20/p4: [...] A contextually converted constant expression of type bool is an expression, contextually converted to bool (Clause4), where the converted expression is a constant expression and the conversion sequence contains only the conversions above. [...] Contextually converting result of an expression `e` to a Boolean value requires `bool t(e)` to be well-formed. An explicit conversion function is only considered as a user-defined conversion for direct-initialization, which is essentially what //contextually converted to bool// requires. Also, fixes PR28470. Reviewers: rsmith Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D24158 llvm-svn: 280838
* Implement p0292r2 (constexpr if), a likely C++1z feature.Richard Smith2016-06-231-0/+137
| | | | llvm-svn: 273602
* Lit C++11 Compatibility Patch #8Charles Li2016-04-141-2/+12
| | | | | | 24 tests have been updated for C++11 compatibility. llvm-svn: 266387
* P0184R0: Allow types of 'begin' and 'end' expressions in range-based for ↵Richard Smith2016-03-201-4/+11
| | | | | | loops to differ. llvm-svn: 263895
* Sema: Allow 'constexpr' variables in range loopsMeador Inge2015-02-181-1/+13
| | | | | | | | This fixes PR22492, which is in response to CWG issue #1204. Per the CWG issue 'contexpr' variables are now allowed in for range loops. llvm-svn: 229716
* Revert r229543.Meador Inge2015-02-171-1/+1
| | | | | | Reverting this while build bot failures are investigated. llvm-svn: 229550
* Sema: Allow 'constexpr' variables in range loopsMeador Inge2015-02-171-1/+1
| | | | | | | | This fixes PR22492, which is in response to CWG issue #1204. Per the CWG issue 'contexpr' variables are now allowed in for range loops. llvm-svn: 229543
* Reword switch/goto diagnostics "protected scope" diagnostics. Making up a termRichard Smith2014-09-062-4/+4
| | | | | | | | "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 -Wdeprecated warnings and fixits for things deprecated in C++11:Richard Smith2013-06-131-1/+1
| | | | | | | | | - 'register' storage class - dynamic exception specifications Only the former check is enabled by default for now (the latter might be quite noisy). llvm-svn: 183881
* Fix crasher when the range in a C++ range-for loop has an ill-formed ↵Douglas Gregor2013-05-021-0/+10
| | | | | | | | initializer. Fixes <rdar://problem/13712739>. llvm-svn: 180937
* The 'constexpr implies const' rule for non-static member functions is gone inRichard Smith2013-04-211-2/+2
| | | | | | | | | C++1y, so stop adding the 'const' there. Provide a compatibility warning for code relying on this in C++11, with a fix-it hint. Update our lazily-written tests to add the const, except for those ones which were testing our implementation of this rule. llvm-svn: 179969
* Prior to adding the new "expected-no-diagnostics" directive to ↵Andy Gibbs2012-10-191-0/+1
| | | | | | VerifyDiagnosticConsumer, make the necessary adjustment to 580 test-cases which will henceforth require this new directive. llvm-svn: 166280
* DR1442: In a range-based for statement, namespace 'std' is not an associatedRichard Smith2012-10-181-30/+43
| | | | | | namespace. llvm-svn: 166194
* Clarified diagnostics for range-based for loops with invalid rangesSam Panzer2012-09-061-3/+16
| | | | llvm-svn: 163350
* Better diagnostics for range-based for loops with bad range types.Sam Panzer2012-08-211-9/+9
| | | | | | | | | | | | | The old error message stating that 'begin' was an undeclared identifier is replaced with a new message explaining that the error is in the range expression, along with which of the begin() and end() functions was problematic if relevant. Additionally, if the range was a pointer type or defines operator*, attempt to dereference the range, and offer a FixIt if the modified range works. llvm-svn: 162248
* Fix PR12960 by not attempting to correct cases when we're not actually ↵David Blaikie2012-05-281-0/+9
| | | | | | | | | | instantiatiating a template. This comes up in the begin/end calls of a range-for (see the included test case). Other suggestions are welcome, though this seems to do the trick without regressing anything. llvm-svn: 157553
* Support decltype as a simple-type-specifier.David Blaikie2012-01-241-0/+40
| | | | | | | This makes all sorts of fun examples work with decltype. Reviewed by Richard Smith. llvm-svn: 148787
* constexpr: converted constant expression handling for enumerator values, caseRichard Smith2012-01-181-0/+39
| | | | | | | | | | values and non-type template arguments of integral and enumeration types. This change causes some legal C++98 code to no longer compile in C++11 mode, by enforcing the C++11 rule that narrowing integral conversions are not permitted in the final implicit conversion sequence for the above cases. llvm-svn: 148439
* 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
* Add -Wc++98-compat diagnostics for jumps which bypass initialization of non-PODRichard Smith2011-10-201-2/+2
| | | | | | | | but trivially constructible and destructible variables in C++11 mode. Also incidentally improve the precision of the wording for jump diagnostics in C++98 mode. llvm-svn: 142619
* Update all tests other than Driver/std.cpp to use -std=c++11 rather thanRichard Smith2011-10-132-2/+2
| | | | | | -std=c++0x. Patch by Ahmed Charles! llvm-svn: 141900
* constexpr: semantic checking for constexpr variables.Richard Smith2011-09-291-2/+1
| | | | | | We had an extension which allowed const static class members of floating-point type to have in-class initializers, 'as a C++0x extension'. However, C++0x does not allow this. The extension has been kept, and extended to all literal types in C++0x mode (with a fixit to add the 'constexpr' specifier). llvm-svn: 140801
* Declare and define implicit move constructor and assignment operator.Sebastian Redl2011-08-301-1/+1
| | | | | | | | | This makes the code duplication of implicit special member handling even worse, but the cleanup will have to come later. For now, this works. Follow-up with tests for explicit defaulting and enabling the __has_feature flag to come. llvm-svn: 138821
* Factor out (some of) the checking for invalid forms of pointerChandler Carruth2011-06-271-1/+1
| | | | | | | | | | | | | | | | | | | arithmetic into a couple of common routines. Use these to make the messages more consistent in the various contexts, especially in terms of consistently diagnosing binary operators with invalid types on both the left- and right-hand side. Also, improve the grammar and wording of the messages some, handling both two pointers and two (different) types. The wording of function pointer arithmetic diagnostics still strikes me as poorly phrased, and I worry this makes them slightly more awkward if more consistent. I'm hoping to fix that with a follow-on patch and test case that will also make them more helpful when a typedef or template type parameter makes the type completely opaque. Suggestions on better wording are very welcome, thanks to Richard Smith for some initial help on that front. llvm-svn: 133906
* Properly implement C++0x [stmt.dcl]p3, which requires a scope to beDouglas Gregor2011-06-151-4/+4
| | | | | | | protected in the case where a variable is being initialized by a trivial default constructor but has a non-trivial destructor. llvm-svn: 133037
* Clean up my changes to jump-diagnostic handling for local variables ofDouglas Gregor2011-05-272-2/+78
| | | | | | | | class type (or array thereof), eliminating some redundant checks (thanks Eli!) and adding some tests where the behavior differs in C++98/03 vs. C++0x. llvm-svn: 132218
* Update the jump-scope checker for local variables with initializers,Douglas Gregor2011-05-271-0/+26
| | | | | | | | so that it looks at the initializer of a local variable of class type (or array thereof) to determine whether it's just an implicit invocation of the trivial default constructor. Fixes PR10034. llvm-svn: 132191
* It's considered poor form to create references to the overloadedDouglas Gregor2011-05-211-3/+3
| | | | | | | function type. Educate template argument deduction thusly, fixing PR9974 / <rdar://problem/9479155>. llvm-svn: 131811
* Add support for C++0x's range-based for loops, as specified by the C++11 ↵Richard Smith2011-04-141-0/+210
| | | | | | draft standard (N3291). llvm-svn: 129541
* Step #1/N of implementing support for __label__: split labels intoChris Lattner2011-02-171-1/+1
| | | | | | | | | | | | | | | | | | | LabelDecl and LabelStmt. There is a 1-1 correspondence between the two, but this simplifies a bunch of code by itself. This is because labels are the only place where we previously had references to random other statements, causing grief for AST serialization and other stuff. This does cause one regression (attr(unused) doesn't silence unused label warnings) which I'll address next. This does fix some minor bugs: 1. "The only valid attribute " diagnostic was capitalized. 2. Various diagnostics printed as ''labelname'' instead of 'labelname' 3. This reduces duplication of label checking between functions and blocks. Review appreciated, particularly for the cindex and template bits. llvm-svn: 125733
* add missing newlines at end of file.Chris Lattner2010-12-211-1/+1
| | | | llvm-svn: 122309
* Add a test for C++ [stmt.label]p1, from Sashan!Douglas Gregor2010-11-291-0/+25
| | | | llvm-svn: 120291
* change Scope::WithinElse to be a normal scope flag, widen theChris Lattner2010-04-121-0/+8
| | | | | | fields to two 16-bit values instead of using bitfields. llvm-svn: 101020
* Add a test for C++ [stmt.select]p3, which specifies that redeclaring aDouglas Gregor2010-03-301-0/+11
name in the outermost block of a if/else that declares the same name is ill-formed. Turns out that Clang and MSVC were right about PR6739; GCC is too lax. llvm-svn: 99937
OpenPOWER on IntegriCloud