https://bugs.llvm.org/show_bug.cgi?id=41991

            Bug ID: 41991
           Summary: c++2a: unable to set attributes to defaulted member
                    functions
           Product: clang
           Version: 8.0
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++2a
          Assignee: unassignedclangb...@nondot.org
          Reporter: developm...@jordi.vilar.cat
                CC: blitzrak...@gmail.com, erik.pilking...@gmail.com,
                    llvm-bugs@lists.llvm.org, richard-l...@metafoo.co.uk

The following code, compiled with clang-8 -std=c++2a, fails with:
  error: an attribute list cannot appear here

(it also issues error: only special member functions may be defaulted, but this
is reported in a separated bug report #41989)

#include <compare>

struct type
{
// original
    [[nodiscard]] friend constexpr std::strong_equality operator<=>(const
type&, const type&) noexcept = default;

//  variant #1
//    [[nodiscard]] friend constexpr std::strong_equality operator<=>(const
type&, const type&) noexcept;

// variant #2
//    [[nodiscard]] friend constexpr std::strong_equality operator<=>(const
type&, const type&) noexcept { return std::strong_ordering::equal; }
};

With variant #1, clang complaints with the same error, this time is correct as
attribues for friend declarations are not allowed as per specs.

With variant #2, clang accepts the code with no complaints as the friend
operator is now a definition and attributes are allowed in this case.

With the original variant, clang applies the rule for friend declaration when
in fact it is a (implicit) definition, that is, the friend operator is not
expected to be later defined.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to