Fix ternary operator in for loop argument, it was by mistake not set as CanBeForRangeDecl and led to incorrect codegen. It fixes https://bugs.llvm.org/show_bug.cgi?id=50038. I don't have commit rights. Danila Kutenin. kutdanila@yandex.ru
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
This should have codegen, and maybe AST, tests.
| clang/test/Parser/cxx2a-init-statement.cpp | ||
|---|---|---|
| 18 | This isn't cxx2a-specific isn't it? | |
Done
| clang/test/Parser/cxx2a-init-statement.cpp | ||
|---|---|---|
| 18 | clang even in C++11 versions go to this branch and produce warning that this feature is c++2a, so it fails currently for everything but the culprit was https://github.com/llvm/llvm-project/commit/8baa50013c86c34a58d8327c5d1a043898b86398 | |
Thanks, nice catch!
Can we also add an assert when parsing a for statement that we actually find a range if the tentative parse said we were expecting one?
| clang/test/CodeGenCXX/for-loop-init-ternary-operator-statement.cpp | ||
|---|---|---|
| 2 | We don't use -O3 tests for this kind of thing, to avoid depending on the behaviour of the optimizer; instead you should test that the (unoptimized) IR generated by clang is correct. | |
| clang/test/PCH/for-loop-init-ternary-operator-statement.cpp | ||
| 6 | This ast-print output looks wrong; I assume that's an unrelated bug? | |
| clang/lib/Parse/ParseExprCXX.cpp | ||
|---|---|---|
| 2036 | If parsing failed, I don't think this assertion should be expected to hold: error recovery after the parse error might not have interpreted the : as the start of the range expression. | |
If parsing failed, I don't think this assertion should be expected to hold: error recovery after the parse error might not have interpreted the : as the start of the range expression.