[PATCH] D102502: [clang] Fix ternary operator in the second for loop statement

Danila Kutenin via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri May 14 13:02:57 PDT 2021


danlark added inline comments.


================
Comment at: clang/test/CodeGenCXX/for-loop-init-ternary-operator-statement.cpp:1
+// RUN: %clang_cc1 -triple i386-unknown-unknown -O3 -emit-llvm -o - %s | FileCheck %s
+
----------------
rsmith wrote:
> 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.
Done.


================
Comment at: clang/test/PCH/for-loop-init-ternary-operator-statement.cpp:5
+int f() {
+  // CHECK: for (int i = 0; x; i++) {
+  for (int i = 0; int x = i < 2 ? 1 : 0; i++) {
----------------
rsmith wrote:
> This ast-print output looks wrong; I assume that's an unrelated bug?
Yes, I think so, in a buggy version `x` as a second parameter is missing so at least it tests correctly


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102502



More information about the cfe-commits mailing list