[clang] [clang][diagnostics] Fix fix-it hint parenthesis placement for fold expressions (PR #151790)

Yanzuo Liu via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 1 21:58:15 PDT 2025


================
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -verify -std=c++17 -pedantic-errors %s
+// RUN: cp %s %t
+// RUN: not %clang_cc1 -x c++ -std=c++17 -fixit %t
+// RUN: %clang_cc1 -Wall -pedantic-errors -x c++ -std=c++17 %t
+
+/* This is a test of the various code modification hints that only
+   apply in C++17. */
+template<int... args>
+int foo() {
+    return (args + 1 + ...); // expected-error {{expression not permitted as operand of fold expression}}
----------------
zwuis wrote:

Can you add these test cases?
```cpp
(args + 123 + ...); // long number
(... + args + 1); // left fold
```

https://github.com/llvm/llvm-project/pull/151790


More information about the cfe-commits mailing list