1 //===-- main.cpp ------------------------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 template <class T, int... Args> struct C {
10   T member;
11   bool isSixteenThirtyTwo() { return false; }
12 };
13 
14 template <> struct C<int, 16> {
15   int member;
16   bool isSixteenThirtyTwo() { return false; }
17 };
18 
19 template <> struct C<int, 16, 32> : C<int, 16> {
20   bool isSixteenThirtyTwo() { return true; }
21 };
22 
23 template <class T, typename... Args> struct D {
24   T member;
25   bool isIntBool() { return false; }
26 };
27 
28 template <> struct D<int, int> {
29   int member;
30   bool isIntBool() { return false; }
31 };
32 
33 template <> struct D<int, int, bool> : D<int, int> {
34   bool isIntBool() { return true; }
35 };
36 
37 template<int Size> struct array {
38   int Arr[Size];
39   array() {}
40 };
41 
42 int main (int argc, char const *argv[])
43 {
44     C<int,16,32> myC;
45     C<int,16> myLesserC;
46     myC.member = 64;
47     (void)C<int,16,32>().isSixteenThirtyTwo();
48     (void)C<int,16>().isSixteenThirtyTwo();
49     (void)(myC.member != 64);   //% self.expect("expression -- myC", DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ["64"])
50                                 //% self.expect("expression -- myLesserC.isSixteenThirtyTwo()", DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ["false"])
51                                 //% self.expect("expression -- myC.isSixteenThirtyTwo()", DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ["true"])
52 
53                                 // Disabling until we do template lookup correctly: http://lists.llvm.org/pipermail/lldb-commits/Week-of-Mon-20180507/040689.html
54                                 //#% self.expect("expression -- C<int, 16>().isSixteenThirtyTwo()", DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ["false"])
55                                 //#% self.expect("expression -- C<int, 16, 32>().isSixteenThirtyTwo()", DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ["true"])
56 
57     D<int,int,bool> myD;
58     D<int,int> myLesserD;
59     myD.member = 64;
60     (void)D<int,int,bool>().isIntBool();
61     (void)D<int,int>().isIntBool(); //% self.expect("expression -- myD", DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ["64"])
62                                 //% self.expect("expression -- myLesserD.isIntBool()", DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ["false"])
63                                 //% self.expect("expression -- myD.isIntBool()", DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ["true"])
64 
65                                 // See comment above.
66                                 //#% self.expect("expression -- D<int, int>().isIntBool()", DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ["false"])
67                                 //#% self.expect("expression -- D<int, int, bool>().isIntBool()", DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ["true"])
68 
69     array<3> myArray; //% self.expect("expression -- myArray", DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ["Arr"])
70 
71     return 1;
72 }
73