1 // RUN: %clang_cc1 -fsyntax-only -verify %s
2 
foo()3 template <int A, int B> void foo() {
4   (void)(A == A); // expected-warning {{self-comparison always evaluates to true}}
5   (void)(A == B);
6 }
7 template <int A, int B> struct S1 {
fooS18   void foo() {
9     (void)(A == A); // expected-warning {{self-comparison always evaluates to true}}
10     (void)(A == B);
11   }
12 };
13 
14 template <int A, int B> struct S2 {
fooS215   template <typename T> T foo() {
16     (void)(A == A); // expected-warning {{self-comparison always evaluates to true}}
17     (void)(A == B);
18   }
19 };
20 
21 struct S3 {
fooS322   template <int A, int B> void foo() {
23     (void)(A == A); // expected-warning {{self-comparison always evaluates to true}}
24     (void)(A == B);
25   }
26 };
27 
28 template <int A> struct S4 {
fooS429   template <int B> void foo() {
30     (void)(A == A); // expected-warning {{self-comparison always evaluates to true}}
31     (void)(A == B);
32   }
33 };
34 
35 const int N = 42;
foo2()36 template <int X> void foo2() {
37   (void)(X == N);
38   (void)(N == X);
39 }
40 
test()41 void test() {
42   foo<1, 1>();
43   S1<1, 1> s1; s1.foo();
44   S2<1, 1> s2; s2.foo<void>();
45   S3 s3; s3.foo<1, 1>();
46   S4<1> s4; s4.foo<1>();
47   foo2<N>();
48 }
49