summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaCXX/self-comparison.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/test/SemaCXX/self-comparison.cpp')
-rw-r--r--clang/test/SemaCXX/self-comparison.cpp17
1 files changed, 16 insertions, 1 deletions
diff --git a/clang/test/SemaCXX/self-comparison.cpp b/clang/test/SemaCXX/self-comparison.cpp
index 2af19abb30a..ac129b68a67 100644
--- a/clang/test/SemaCXX/self-comparison.cpp
+++ b/clang/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}}
@@ -25,3 +25,18 @@ struct A {
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
OpenPOWER on IntegriCloud