File tree Expand file tree Collapse file tree 4 files changed +3
-30
lines changed Expand file tree Collapse file tree 4 files changed +3
-30
lines changed Original file line number Diff line number Diff line change @@ -743,7 +743,6 @@ Bug Fixes to C++ Support
743743 in a ``constexpr `` function. (#GH131432)
744744- Fixed an incorrect TreeTransform for calls to ``consteval `` functions if a conversion template is present. (#GH137885)
745745- Clang now emits a warning when class template argument deduction for alias templates is used in C++17. (#GH133806)
746- - Fix missed initializer instantiation bug for variable templates. (#GH138122)
747746- Fix a crash when checking the template template parameters of a dependent lambda appearing in an alias declaration.
748747 (#GH136432), (#GH137014), (#GH138018)
749748- Fixed an assertion when trying to constant-fold various builtins when the argument
Original file line number Diff line number Diff line change @@ -6032,11 +6032,11 @@ void Sema::BuildVariableInstantiation(
60326032 Context.setStaticLocalNumber (NewVar, Context.getStaticLocalNumber (OldVar));
60336033
60346034 // Figure out whether to eagerly instantiate the initializer.
6035- if (NewVar->getType ()->isUndeducedType ()) {
6035+ if (InstantiatingVarTemplate || InstantiatingVarTemplatePartialSpec) {
6036+ // We're producing a template. Don't instantiate the initializer yet.
6037+ } else if (NewVar->getType ()->isUndeducedType ()) {
60366038 // We need the type to complete the declaration of the variable.
60376039 InstantiateVariableInitializer (NewVar, OldVar, TemplateArgs);
6038- } else if (InstantiatingVarTemplate || InstantiatingVarTemplatePartialSpec) {
6039- // We're producing a template. Don't instantiate the initializer yet.
60406040 } else if (InstantiatingSpecFromTemplate ||
60416041 (OldVar->isInline () && OldVar->isThisDeclarationADefinition () &&
60426042 !NewVar->isThisDeclarationADefinition ())) {
Original file line number Diff line number Diff line change 11// RUN: %clang_cc1 -std=c++1z %s -emit-llvm -o - -triple x86_64-linux-gnu | FileCheck %s
22
3- template <typename T> struct InlineAuto {
4- template <typename G> inline static auto var = 5 ;
5- };
6- int inlineauto = InlineAuto<int >::var<int >;
7- // CHECK: @_ZN10InlineAutoIiE3varIiEE = {{.*}}i32 5{{.*}}comdat
8- //
9- template <typename > struct PartialInlineAuto {
10- template <typename , typename > inline static auto var = 6 ;
11- template <typename T> inline static auto var<int , T> = 7 ;
12- };
13-
14- int partialinlineauto = PartialInlineAuto<int >::var<int , int >;
15- // CHECK: @_ZN17PartialInlineAutoIiE3varIiiEE = {{.*}}i32 7{{.*}}comdat
16-
173struct Q {
184 // CHECK: @_ZN1Q1kE = linkonce_odr constant i32 5, comdat
195 static constexpr int k = 5 ;
Original file line number Diff line number Diff line change @@ -27,15 +27,3 @@ template <typename T> constexpr int A<T>::n = sizeof(A) + sizeof(T);
2727template <typename T> inline constexpr int A<T>::m = sizeof (A) + sizeof (T);
2828static_assert (A<int >().f() == 5 );
2929static_assert (A<int >().g() == 5 );
30-
31- template <typename T> struct InlineAuto {
32- template <typename G> inline static auto var = 5 ;
33- };
34-
35- template <typename > struct PartialInlineAuto {
36- template <typename , typename > inline static auto var = 6 ;
37- template <typename T> inline static auto var<int , T> = 7 ;
38- };
39-
40- int inlineauto = InlineAuto<int >::var<int >;
41- int partialinlineauto = PartialInlineAuto<int >::var<int , int >;
You can’t perform that action at this time.
0 commit comments