Skip to content

[clang-format] attribute on constructor causes -> to be incorrectly inferred as trailing return type in base class argument list #86559

Closed
@joelhock

Description

@joelhock

version 17.0.1 correctly formats this:

// --dump-config has
// AttributeMacros:
//  - _COLD
#define _COLD __attribute__((cold))

class C {
  public:
    __attribute__((cold)) C() : Base(obj->func()) {}  // OK
    _COLD C() : Base(obj->func()) {}  // OK
    C() : Base(obj->func()) {}  // OK
};

whereas 18.1 and HEAD (d99cfa0) incorrectly think -> is introducing a trailing return type when the constructor has an attribute attached to it:

// --dump-config has
// AttributeMacros:
//  - _COLD
#define _COLD __attribute__((cold))

class C {
  public:
    __attribute__((cold)) C() : Base(obj -> func()) {}  // WRONG
    _COLD C() : Base(obj -> func()) {}  // WRONG
    C() : Base(obj->func()) {}  // OK
};

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions