]> granicus.if.org Git - clang/commitdiff
Add tests for three-way self- and array comparison.
authorRichard Smith <richard-llvm@metafoo.co.uk>
Sun, 7 Jan 2018 22:03:44 +0000 (22:03 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Sun, 7 Jan 2018 22:03:44 +0000 (22:03 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321973 91177308-0d34-0410-b5e6-96231b3b80d8

test/SemaCXX/compare-cxx2a.cpp

index 61d35021cc13bc7f21c0d72ee8d3347183f79f45..d88e3bae415e0528d5189c2540c15d4b014ee2a7 100644 (file)
@@ -3,6 +3,14 @@
 
 // RUN: %clang_cc1 -triple x86_64-apple-darwin -fsyntax-only -pedantic -verify -Wsign-compare -std=c++2a %s
 
+void self_compare() {
+  int a;
+  int b[3], c[3];
+  (void)(a <=> a); // expected-warning {{self-comparison always evaluates to 'std::strong_ordering::equal'}}
+  (void)(b <=> b); // expected-warning {{self-comparison always evaluates to 'std::strong_ordering::equal'}}
+  (void)(b <=> c); // expected-warning {{array comparison always evaluates to a constant}}
+}
+
 void test0(long a, unsigned long b) {
   enum EnumA {A};
   enum EnumB {B};