Skip to content

Clang warning with -Wdeprecated in MATCHER_P generated matchers #1305

@estan

Description

@estan

As reported by @francoechea in google/googlemock#211 , in the expansion of MATCHER_P there's a -Wdeprecated warning by Clang because the class defines a copy assignment operator (to make it private), but does not define a copy constructor, and implicit copy constructor generation is deprecated in such cases in C++11:

 definition of implicit copy constructor for 'FooMatcherP2<double, double>' is deprecated because it has a user-declared copy assignment operator [-Werror,-Wdeprecated]

When I bumped into this myself, I tried simply adding a copy constructor like:

name##MatcherP(const name##MatcherP &other) : p0(other.p0) {\
}\

to the MATCHER_P macro I was using, and it seemed to work.

Should perhaps whatever code generates these MATCHER_P macros make sure they have explicitly defined copy constructors like this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions