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 int main (int argc, char const *argv[]) 38 { 39 C<int,16,32> myC; 40 C<int,16> myLesserC; 41 myC.member = 64; 42 (void)C<int,16,32>().isSixteenThirtyTwo(); 43 (void)C<int,16>().isSixteenThirtyTwo(); 44 (void)(myC.member != 64); //% self.expect("expression -- myC", DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ["64"]) 45 //% self.expect("expression -- myLesserC.isSixteenThirtyTwo()", DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ["false"]) 46 //% self.expect("expression -- myC.isSixteenThirtyTwo()", DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ["true"]) 47 48 // Disabling until we do template lookup correctly: http://lists.llvm.org/pipermail/lldb-commits/Week-of-Mon-20180507/040689.html 49 //#% self.expect("expression -- C<int, 16>().isSixteenThirtyTwo()", DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ["false"]) 50 //#% self.expect("expression -- C<int, 16, 32>().isSixteenThirtyTwo()", DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ["true"]) 51 52 D<int,int,bool> myD; 53 D<int,int> myLesserD; 54 myD.member = 64; 55 (void)D<int,int,bool>().isIntBool(); 56 (void)D<int,int>().isIntBool(); 57 return myD.member != 64; //% self.expect("expression -- myD", DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ["64"]) 58 //% self.expect("expression -- myLesserD.isIntBool()", DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ["false"]) 59 //% self.expect("expression -- myD.isIntBool()", DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ["true"]) 60 61 // See comment above. 62 //#% self.expect("expression -- D<int, int>().isIntBool()", DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ["false"]) 63 //#% self.expect("expression -- D<int, int, bool>().isIntBool()", DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ["true"]) 64 } 65