Skip to content

[clang] Hints for fold_expression_bad_operand insert parentheses at incorrect ___location #151787

@el-ev

Description

@el-ev
template<int... args>
int foo() {
    return (args + 1 + ...);
}

Actual behaviour:

The right parenthesis is inserted before 1

/tmp/test.cpp:3:18: error: expression not permitted as operand
      of fold expression
    3 |     return (args + 1 + ...);
      |             ~~~~~^~~
      |             (      )
1 error generated.

-->
return ((args + )1 + ...);

Expected behaviour:

The right parenthesis should be inserted after 1

/tmp/test.cpp:3:18: error: expression not permitted as operand
      of fold expression
    3 |     return (args + 1 + ...);
      |             ~~~~~^~~
      |             (       )
1 error generated.

-->
return ((args + 1) + ...);

Metadata

Metadata

Assignees

Labels

clang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzer

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions