File tree Expand file tree Collapse file tree 4 files changed +32
-1
lines changed Expand file tree Collapse file tree 4 files changed +32
-1
lines changed Original file line number Diff line number Diff line change @@ -604,6 +604,7 @@ Bug Fixes to C++ Support
604
604
- Clang now issues an error when placement new is used to modify a const-qualified variable
605
605
in a ``constexpr `` function. (#GH131432)
606
606
- Clang now emits a warning when class template argument deduction for alias templates is used in C++17. (#GH133806)
607
+ - Fix missing initializer for inline static template member with auto type caused by delayed template instantiation. (#GH138122)
607
608
608
609
Bug Fixes to AST Handling
609
610
^^^^^^^^^^^^^^^^^^^^^^^^^
Original file line number Diff line number Diff line change @@ -6027,8 +6027,12 @@ void Sema::BuildVariableInstantiation(
6027
6027
Context.setManglingNumber (NewVar, Context.getManglingNumber (OldVar));
6028
6028
Context.setStaticLocalNumber (NewVar, Context.getStaticLocalNumber (OldVar));
6029
6029
6030
+ bool VarTemplateWithAutoType =
6031
+ OldVar->getTypeSourceInfo ()->getType ()->getAs <AutoType>();
6032
+
6030
6033
// Figure out whether to eagerly instantiate the initializer.
6031
- if (InstantiatingVarTemplate || InstantiatingVarTemplatePartialSpec) {
6034
+ if (!VarTemplateWithAutoType &&
6035
+ (InstantiatingVarTemplate || InstantiatingVarTemplatePartialSpec)) {
6032
6036
// We're producing a template. Don't instantiate the initializer yet.
6033
6037
} else if (NewVar->getType ()->isUndeducedType ()) {
6034
6038
// We need the type to complete the declaration of the variable.
Original file line number Diff line number Diff line change 1
1
// RUN: %clang_cc1 -std=c++1z %s -emit-llvm -o - -triple x86_64-linux-gnu | FileCheck %s
2
2
3
+ template <typename T> struct InlineAuto {
4
+ template <typename G> inline static auto var = 5 ;
5
+ };
6
+ int inlineauot = 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 partialinlineauot = PartialInlineAuto<int >::var<int , int >;
15
+ // CHECK: @_ZN17PartialInlineAutoIiE3varIiiEE = {{.*}}i32 7{{.*}}comdat
16
+
3
17
struct Q {
4
18
// CHECK: @_ZN1Q1kE = linkonce_odr constant i32 5, comdat
5
19
static constexpr int k = 5 ;
Original file line number Diff line number Diff line change @@ -27,3 +27,15 @@ template <typename T> constexpr int A<T>::n = sizeof(A) + sizeof(T);
27
27
template <typename T> inline constexpr int A<T>::m = sizeof (A) + sizeof (T);
28
28
static_assert (A<int >().f() == 5 );
29
29
static_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 inlineauot = InlineAuto<int >::var<int >;
41
+ int partialinlineauot = PartialInlineAuto<int >::var<int , int >;
You can’t perform that action at this time.
0 commit comments