28 lines · cpp
1// RUN: %clang_cc1 -fsyntax-only -std=c++20 -verify %s2 3using fp0_t = void (*)();4using fp1_t = int (*)();5 6extern fp0_t a, b;7extern fp1_t c;8 9bool eq0 = a == b;10bool ne0 = a != b;11bool lt0 = a < b; // expected-warning {{ordered comparison of function pointers ('fp0_t' (aka 'void (*)()') and 'fp0_t')}}12bool le0 = a <= b; // expected-warning {{ordered comparison of function pointers}}13bool gt0 = a > b; // expected-warning {{ordered comparison of function pointers}}14bool ge0 = a >= b; // expected-warning {{ordered comparison of function pointers}}15auto tw0 = a <=> b; // expected-error {{ordered comparison of function pointers}}16 17bool eq1 = a == c; // expected-error {{comparison of distinct pointer types}}18bool ne1 = a != c; // expected-error {{comparison of distinct pointer types}}19bool lt1 = a < c; // expected-warning {{ordered comparison of function pointers ('fp0_t' (aka 'void (*)()') and 'fp1_t' (aka 'int (*)()'))}}20 // expected-error@-1 {{comparison of distinct pointer types}}21bool le1 = a <= c; // expected-warning {{ordered comparison of function pointers}}22 // expected-error@-1 {{comparison of distinct pointer types}}23bool gt1 = a > c; // expected-warning {{ordered comparison of function pointers}}24 // expected-error@-1 {{comparison of distinct pointer types}}25bool ge1 = a >= c; // expected-warning {{ordered comparison of function pointers}}26 // expected-error@-1 {{comparison of distinct pointer types}}27auto tw1 = a <=> c; // expected-error {{ordered comparison of function pointers}}28