brintos

brintos / llvm-project-archived public Read only

0
0
Text · 4.0 KiB · ae989c6 Raw
168 lines · cpp
1// RUN: %clang_cc1 -verify %s -std=c++17 -Wno-unused2 3template<typename ...Ts> void PackInsideTypedefDeclaration() {4  ([] {5    typedef Ts Type;6    (void)Type();7  }(), ...);8}9template void PackInsideTypedefDeclaration<>();10template void PackInsideTypedefDeclaration<int>();11template void PackInsideTypedefDeclaration<int, float>();12 13template<typename ...Ts> void PackInsideTypedefDeclarationInvalid() {14  [] { // expected-error {{contains unexpanded parameter pack 'Ts'}}15    typedef Ts Type;16    (void)Type();17  };18 19  ([] {20    typedef Ts Type;21    // A reference to a typedef containing an unexpanded pack does not22    // itself contain an unexpanded pack.23    f(Type()...); // expected-error {{does not contain any unexpanded}}24  }, ...);25}26 27 28template<typename ...Ts> void PackInsideAliasDeclaration() {29  ([] {30    using Type = Ts;31    (void)Type();32  }(), ...);33}34template void PackInsideAliasDeclaration<>();35template void PackInsideAliasDeclaration<int>();36template void PackInsideAliasDeclaration<int, float>();37 38template<typename ...Ts> void PackInsideAliasDeclarationInvalid() {39  [] { // expected-error {{contains unexpanded parameter pack 'Ts'}}40    using Type = Ts;41    (void)Type();42  };43  ([] {44    using Type = Ts;45    // A reference to an alias containing an unexpanded pack does not46    // itself contain an unexpanded pack.47    f(Type()...); // expected-error {{does not contain any unexpanded}}48  }, ...);49}50 51 52template<typename ...Ts> void PackInsideUsingDeclaration() {53  ([] {54    struct A {55      using Type = Ts;56    };57    struct B : A {58      using typename A::Type;59    };60    (void)typename B::Type();61  }(), ...);62}63template void PackInsideUsingDeclaration<>();64template void PackInsideUsingDeclaration<int>();65template void PackInsideUsingDeclaration<int, float>();66 67template<typename ...Ts> void PackInsideUsingDeclarationInvalid() {68  ([] {69    struct A {70      using Type = Ts;71    };72    struct B : A {73      using typename A::Type...; // expected-error {{does not contain any unexpanded}}74    };75  }(), ...);76}77 78 79template<typename ...Ts> void PackInsideVarDeclaration() {80  ([] {81    Ts ts;82    (void)ts;83  }, ...);84}85template void PackInsideVarDeclaration<>();86template void PackInsideVarDeclaration<int>();87template void PackInsideVarDeclaration<int, float>();88 89template<typename ...Ts> void PackInsideVarDeclarationInvalid() {90  [] { // expected-error {{contains unexpanded parameter pack 'Ts'}}91    Ts ts;92    (void)ts;93  };94}95 96 97template<typename ...Ts> void PackInsideFunctionDeclaration() {98  ([] {99    Ts ts(Ts);100    ts({});101  }, ...);102}103template void PackInsideFunctionDeclaration<>();104template void PackInsideFunctionDeclaration<int>();105template void PackInsideFunctionDeclaration<int, float>();106 107template<typename ...Ts> void PackInsideFunctionDeclarationInvalid() {108  [] { // expected-error {{contains unexpanded parameter pack 'Ts'}}109    Ts ts(Ts);110    ts({});111  };112}113 114 115template<typename ...Ts> void PackInsideLocalClass() {116  ([] {117    class Local {118      Ts ts;119    };120    Local l;121  }, ...);122}123template void PackInsideLocalClass<>();124template void PackInsideLocalClass<int>();125template void PackInsideLocalClass<int, float>();126 127template<typename ...Ts> void PackInsideLocalClassInvalid() {128  [] { // expected-error {{contains unexpanded parameter pack 'Ts'}}129    class Local {130      Ts ts;131    };132    Local l;133  };134}135 136template<typename T> using Int = int;137struct AClass {};138template<typename T> using Class = AClass;139template<typename ...Ts> void HiddenPack() {140  (Int<Ts>(), ...);141  (Int<Ts>{}, ...);142  (Class<Ts>(), ...);143  (Class<Ts>{}, ...);144 145  ([] {146   Int<Ts>();147   }, ...);148  ([] {149   Int<Ts>{};150   }, ...);151  ([] {152   Class<Ts>();153   }, ...);154  ([] {155   Class<Ts>{};156   }, ...);157}158template void HiddenPack<>();159template void HiddenPack<int>();160template void HiddenPack<int, float>();161 162template<typename ...Ts> void HiddenPackInvalid() {163  Int<Ts>(); // expected-error {{unexpanded}}164  Int<Ts>{}; // expected-error {{unexpanded}}165  Class<Ts>(); // expected-error {{unexpanded}}166  Class<Ts>{}; // expected-error {{unexpanded}}167}168