aboutsummaryrefslogtreecommitdiff
path: root/test/SemaCXX/self-comparison.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/SemaCXX/self-comparison.cpp')
-rw-r--r--test/SemaCXX/self-comparison.cpp21
1 files changed, 20 insertions, 1 deletions
diff --git a/test/SemaCXX/self-comparison.cpp b/test/SemaCXX/self-comparison.cpp
index fb15ec843061..ac129b68a67a 100644
--- a/test/SemaCXX/self-comparison.cpp
+++ b/test/SemaCXX/self-comparison.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++2a
int foo(int x) {
return x == x; // expected-warning {{self-comparison always evaluates to true}}
@@ -21,3 +21,22 @@ struct A {
return a == c; // expected-warning {{array comparison always evaluates to false}}
}
};
+
+namespace NA { extern "C" int x[3]; }
+namespace NB { extern "C" int x[3]; }
+bool k = NA::x == NB::x; // expected-warning {{self-comparison always evaluates to true}}
+
+template<typename T> struct Y { static inline int n; };
+bool f() {
+ return
+ Y<int>::n == Y<int>::n || // expected-warning {{self-comparison always evaluates to true}}
+ Y<void>::n == Y<int>::n;
+}
+template<typename T, typename U>
+bool g() {
+ // FIXME: Ideally we'd produce a self-comparison warning on the first of these.
+ return
+ Y<T>::n == Y<T>::n ||
+ Y<T>::n == Y<U>::n;
+}
+template bool g<int, int>(); // should not produce any warnings