1d052a578SRichard Smith // RUN: %clang_cc1 -std=c++2a -verify %s 2d052a578SRichard Smith 3*5253d913SRichard Smith struct Good1 { 4*5253d913SRichard Smith bool operator==(const Good1&) const = default; 5*5253d913SRichard Smith bool operator!=(const Good1&) const = default; 6*5253d913SRichard Smith }; 7*5253d913SRichard Smith struct Good2 { 8*5253d913SRichard Smith friend bool operator==(const Good2&, const Good2&) = default; 9*5253d913SRichard Smith friend bool operator!=(const Good2&, const Good2&) = default; 10d052a578SRichard Smith }; 11d052a578SRichard Smith 12d052a578SRichard Smith enum Bool : bool {}; 13d052a578SRichard Smith struct Bad { 14d052a578SRichard Smith bool &operator==(const Bad&) const = default; // expected-error {{return type for defaulted equality comparison operator must be 'bool', not 'bool &'}} 15d052a578SRichard Smith const bool operator!=(const Bad&) const = default; // expected-error {{return type for defaulted equality comparison operator must be 'bool', not 'const bool'}} 16d052a578SRichard Smith friend Bool operator==(const Bad&, const Bad&) = default; // expected-error {{return type for defaulted equality comparison operator must be 'bool', not 'Bool'}} 17d052a578SRichard Smith friend int operator!=(const Bad&, const Bad&) = default; // expected-error {{return type for defaulted equality comparison operator must be 'bool', not 'int'}} 18d052a578SRichard Smith }; 19d052a578SRichard Smith 20d052a578SRichard Smith template<typename T> struct Ugly { 21d052a578SRichard Smith T operator==(const Ugly&) const = default; // expected-error {{return type}} 22d052a578SRichard Smith T operator!=(const Ugly&) const = default; // expected-error {{return type}} 23d052a578SRichard Smith friend T operator==(const Ugly&, const Ugly&) = default; // expected-error {{return type}} 24d052a578SRichard Smith friend T operator!=(const Ugly&, const Ugly&) = default; // expected-error {{return type}} 25d052a578SRichard Smith }; 26d052a578SRichard Smith template struct Ugly<bool>; 27d052a578SRichard Smith template struct Ugly<int>; // expected-note {{in instantiation of}} 28