@@ -17760,7 +17760,7 @@ be returned for a C mode const variable.
1776017760 function-local as well). */
1776117761 con_val = initializer_constant(var);
1776217762 if (con_val == NULL && gpp_mode &&
17763- var->init_kind == (an_init_kind) initk_none &&
17763+ var->init_kind == initk_none &&
1776417764 var->source_corresp.is_class_member &&
1776517765 !var->is_member_constant &&
1776617766 parent_class_of(var)->variant.class_struct_union.is_nonreal_class &&
@@ -17769,7 +17769,18 @@ be returned for a C mode const variable.
1776917769 in-class initializer as a constant-expression during the prototype
1777017770 instantiation of its class. In a real instantiation, the out-of-class
1777117771 definition must be present. */
17772- con_val = alloc_constant((a_constant_repr_kind)ck_template_param);
17772+ con_val = alloc_constant(ck_template_param);
17773+ make_template_param_expr_constant(var_rvalue_expr(var), con_val);
17774+ } else if (con_val == NULL && !constexpr_enabled && var->is_nonreal &&
17775+ var->init_kind == initk_none &&
17776+ var->template_info != NULL &&
17777+ var->template_info->template_arg_list != NULL) {
17778+ /* A variable template instance with template-dependent arguments
17779+ (e.g., "vt<T>" in a template), whose value is not known until
17780+ instantiation. A pre-C++11 constant expression (where variable
17781+ templates are an extension) requires a constant here, so treat
17782+ the reference as a template-dependent constant. */
17783+ con_val = alloc_constant(ck_template_param);
1777317784 make_template_param_expr_constant(var_rvalue_expr(var), con_val);
1777417785 } /* if */
1777517786 if (!C_mode() && !constexpr_enabled && strict_ansi_mode &&
0 commit comments