[PATCH] D135433: [clang][Interp] Implement while and do-while loops

Timm Bäder via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 7 23:29:53 PDT 2022


tbaeder added inline comments.


================
Comment at: clang/test/AST/Interp/loops.cpp:93
+  }
+  static_assert(f4() == 5, "");
+};
----------------
aaron.ballman wrote:
> Can you also add some tests that use nested loops with multiple levels of `break` and `continue` use?
> 
> Also, I think it might be useful to show the jump statements causing code to be an invalid constant expression, as in: 
> ```
> constexpr int foo() {
>   int i;
> 
>   do {
>     break;
>     i = 12;
>   } while (1);
> 
>   return i;
> }
> 
> constexpr int f = foo();
> ```
I can add a commented-out test case for that, //but// it is currently being rejected for the wrong reasons. I investigated that in another case already and it will simply be rejected because the variable declaration does not have an initializer. Not because we're reading an uninitialized variable.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D135433/new/

https://reviews.llvm.org/D135433



More information about the cfe-commits mailing list