[PATCH] D40445: [C++17] Allow an empty expression in an if init statement

Erik Pilkington via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Nov 24 11:41:49 PST 2017


erik.pilkington added a comment.

Hi, thanks for working on this!
Can you add tests to make sure that this also works with switch statements (which also have this bug), and not with while?  Also, it makes it a lot easier to review these patches if you add context lines to the diff.
Thanks,
Erik



================
Comment at: lib/Parse/ParseExprCXX.cpp:1750
+    //   if (; true);
+    if (TryConsumeToken(tok::semi))
+      return ParseCXXCondition(nullptr, Loc, CK);
----------------
We should only be doing this if InitStmt != nullptr, right? I think this would lead us to be too permissive with while statements, which don't have this feature. Also, it would be nice to emit a c++14-compat warning here, like below.


https://reviews.llvm.org/D40445





More information about the cfe-commits mailing list