Skip to content

cmAlgorithms: Fix -Wnon-c-typedef-for-linkage warnings

Raul Tambre requested to merge tambre/cmake:invalid_alias into master

C++ had a rule change whereby only C-compatible unnamed typedefs are allowed. Clang 11 warns about this by default. See https://reviews.llvm.org/D74103. The aliases don't seem to be necessary, so simply define as structs.

../Source/cmAlgorithms.h:142:22: warning: anonymous non-C-compatible type given name for linkage purposes by alias declaration; add a tag name here [-Wnon-c-typedef-for-linkage]
  using Hash = struct
                     ^
                      Hash
../Source/cmAlgorithms.h:144:5: note: type is not C-compatible due to this member declaration
    std::size_t operator()(ForwardIterator it) const
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../Source/cmAlgorithms.h:142:9: note: type is given name 'Hash' for linkage purposes by this alias declaration
  using Hash = struct
        ^
../Source/cmAlgorithms.h:150:23: warning: anonymous non-C-compatible type given name for linkage purposes by alias declaration; add a tag name here [-Wnon-c-typedef-for-linkage]
  using Equal = struct
                      ^
                       Equal
../Source/cmAlgorithms.h:152:5: note: type is not C-compatible due to this member declaration
    bool operator()(ForwardIterator it1, ForwardIterator it2) const
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../Source/cmAlgorithms.h:150:9: note: type is given name 'Equal' for linkage purposes by this alias declaration
  using Equal = struct
        ^

Backport: release

Edited by Brad King

Merge request reports