summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaCXX/for-range-examples.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Fix 32-bit buildbots.Richard Smith2018-05-161-1/+1
| | | | llvm-svn: 332425
* PR37450: Fix bug that disabled some type checks for variables with deduced ↵Richard Smith2018-05-141-6/+2
| | | | | | | | types. Also improve diagnostic for the case where a type is non-literal because it's a lambda. llvm-svn: 332286
* Fix PR32933: crash on lambda capture of VLAFaisal Vali2017-05-151-0/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | https://bugs.llvm.org/show_bug.cgi?id=32933 Turns out clang wasn't really handling vla's (*) in C++11's for-range entirely correctly. For e.g. This would lead to generation of buggy IR: void foo(int b) { int vla[b]; b = -1; // This store would affect the '__end = vla + b' for (int &c : vla) c = 0; } Additionally, code-gen would get confused when VLA's were reference-captured by lambdas, and then used in a for-range, which would result in an attempt to generate IR for '__end = vla + b' within the lambda's body - without any capture of 'b' - hence the assertion. This patch modifies clang, so that for VLA's it translates the end pointer approximately into: __end = __begin + sizeof(vla)/sizeof(vla->getElementType()) As opposed to the __end = __begin + b; I considered passing a magic value into codegen - or having codegen special case the '__end' variable when it referred to a variably-modified type, but I decided against that approach, because it smelled like I would be increasing a complicated form of coupling, that I think would be even harder to maintain than the above approach (which can easily be optimized (-O1) to refer to the run-time bound that was calculated upon array's creation or copied into the lambda's closure object). (*) why oh why gcc would you enable this by default?! ;) llvm-svn: 303026
* Re-commit r273548, reverted in r273589, with a fix to not produceRichard Smith2016-06-231-2/+2
| | | | | | | | | | | | | | | | -Wfor-loop-analysis warnings for a for-loop with a condition variable. In such a case, the loop condition variable is modified on each iteration of the loop by definition. Original commit message: Rearrange condition handling so that semantic checks on a condition variable are performed before the other substatements of the construct are parsed, rather than deferring them until the end. This allows better error recovery from semantic errors in the condition, improves diagnostic order, and is a prerequisite for C++17 constexpr if. llvm-svn: 273600
* Revert r273548, "Rearrange condition handling so that semantic checks on a ↵Peter Collingbourne2016-06-231-2/+2
| | | | | | | | condition variable" as it caused a regression in -Wfor-loop-analysis. llvm-svn: 273589
* Rearrange condition handling so that semantic checks on a condition variableRichard Smith2016-06-231-2/+2
| | | | | | | | | are performed before the other substatements of the construct are parsed, rather than deferring them until the end. This allows better error recovery from semantic errors in the condition, improves diagnostic order, and is a prerequisite for C++17 constexpr if. llvm-svn: 273548
* P0188R1: add support for standard [[fallthrough]] attribute. This is almostRichard Smith2016-03-081-1/+1
| | | | | | | | | | | | | | exactly the same as clang's existing [[clang::fallthrough]] attribute, which has been updated to have the same semantics. The one significant difference is that [[fallthrough]] is ill-formed if it's not used immediately before a switch label (even when -Wimplicit-fallthrough is disabled). To support that, we now build a CFG of any function that uses a '[[fallthrough]];' statement to check. In passing, fix some bugs with our support for statement attributes -- in particular, diagnose their use on declarations, rather than asserting. llvm-svn: 262881
* Minor tweaks to r229447 to ensure the attribute is properly quoted when ↵Aaron Ballman2015-02-161-2/+2
| | | | | | diagnosed. llvm-svn: 229454
* Sema: diagnose use of unscoped deprecated prior to C++14Saleem Abdulrasool2015-02-161-1/+1
| | | | | | | | | The deprecated attribute was adopted as part of the C++14, however, there is a GNU version available in C++11. When using C++ earlier than C++14, diagnose the use of the attribute without the GNU scope, but only when using the generalised attribute syntax. llvm-svn: 229447
* [c++1z] Remove terse range-based for loops; they've been removed fromRichard Smith2014-11-271-9/+11
| | | | | | consideration for C++17 for now. Update C++ status page to match. llvm-svn: 222865
* Improve error recovery around colon.Serge Pavlov2014-07-161-0/+12
| | | | | | | | | | | | Recognize additional cases, when '::' is mistyped as ':'. This is a fix to RP18587 - colons have too much protection in member-declarations Review is tracked by http://reviews.llvm.org/D3653. This is an attempt to recommit the fix, initially committed as r212957 but then reverted in r212965 as it broke self-build. In the updated patch ParseDirectDeclarator turns on colon protection in for context as well. llvm-svn: 213120
* [c++1z] Implement N3994: a range-based for loop can declare a variable with ↵Richard Smith2014-06-191-2/+20
| | | | | | | | | | | | super-terse notation for (x : range) { ... } which is equivalent to for (auto &&x : range) { ... } llvm-svn: 211267
* Improve the error message for attempting to build a for range loop using aRichard Trieu2013-10-111-0/+18
| | | | | | | | | function parameter that has array type. Such a parameter will be treated as a pointer type instead, resulting in a missing begin function error is a suggestion to dereference the pointer. This provides a different, more informative diagnostic as well as point to the parameter declaration. llvm-svn: 192512
* If we find an error in the range expression in a range-based for loop, and theRichard Smith2013-08-211-0/+11
| | | | | | | loop variable has a type containing 'auto', set the declaration to be invalid (because we couldn't deduce its type) to prevent follow-on errors. llvm-svn: 188853
* Started implementing variable templates. Top level declarations should be ↵Larisse Voufo2013-08-061-1/+1
| | | | | | fully supported, up to some limitations documented as FIXMEs or TODO. Static data member templates work very partially. Static data member templates of class templates need particular attention... llvm-svn: 187762
* Fix test better way.Fariborz Jahanian2012-09-191-5/+5
| | | | llvm-svn: 164234
* c: warn when an integer value comparison with anFariborz Jahanian2012-09-181-4/+4
| | | | | | | | integral expression have the obvious result. Patch reviewed by John McCall off line. // rdar://12202422 llvm-svn: 164143
* Don't assume that a valid expression for the first part of a for-statementRichard Smith2012-02-211-0/+11
| | | | | | is non-null when diagnosing a broken attempt to write a for-range-statement. llvm-svn: 151081
* A couple minor fixes to template instantiation for for-range loops.Eli Friedman2012-01-311-0/+11
| | | | llvm-svn: 149440
* Be sure to emit delayed diagnostics after parsing the declarationJohn McCall2012-01-271-0/+10
| | | | | | of a for-range variable. Fixes PR11793. llvm-svn: 149109
* 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
* Add support for C++0x's range-based for loops, as specified by the C++11 ↵Richard Smith2011-04-141-0/+150
draft standard (N3291). llvm-svn: 129541
OpenPOWER on IntegriCloud