aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/module.cc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/cp/module.cc')
-rw-r--r--gcc/cp/module.cc34
1 files changed, 27 insertions, 7 deletions
diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc
index a2e0d6d..f562bf8 100644
--- a/gcc/cp/module.cc
+++ b/gcc/cp/module.cc
@@ -14062,9 +14062,10 @@ depset::hash::make_dependency (tree decl, entity_kind ek)
streaming the definition in such cases. */
dep->clear_flag_bit<DB_DEFN_BIT> ();
- if (DECL_DECLARED_CONSTEXPR_P (decl))
- /* Also, a constexpr variable initialized to a TU-local
- value is an exposure. */
+ if (DECL_DECLARED_CONSTEXPR_P (decl)
+ || DECL_INLINE_VAR_P (decl))
+ /* A constexpr variable initialized to a TU-local value,
+ or an inline value (PR c++/119996), is an exposure. */
dep->set_flag_bit<DB_EXPOSURE_BIT> ();
}
}
@@ -14822,9 +14823,16 @@ depset::hash::find_dependencies (module_state *module)
}
walker.end ();
+ /* If we see either a class template or a deduction guide, make
+ sure to add all visible deduction guides. We need to check
+ both in case they have been added in separate modules, or
+ one is in the GMF and would have otherwise been discarded. */
if (!is_key_order ()
&& DECL_CLASS_TEMPLATE_P (decl))
add_deduction_guides (decl);
+ if (!is_key_order ()
+ && deduction_guide_p (decl))
+ add_deduction_guides (TYPE_NAME (TREE_TYPE (TREE_TYPE (decl))));
if (!is_key_order ()
&& TREE_CODE (decl) == TEMPLATE_DECL
@@ -15025,12 +15033,24 @@ depset::hash::finalize_dependencies ()
break;
}
- if (!explained && VAR_P (decl) && DECL_DECLARED_CONSTEXPR_P (decl))
+ if (!explained
+ && VAR_P (decl)
+ && (DECL_DECLARED_CONSTEXPR_P (decl)
+ || DECL_INLINE_VAR_P (decl)))
{
auto_diagnostic_group d;
- error_at (DECL_SOURCE_LOCATION (decl),
- "%qD is declared %<constexpr%> and is initialized to "
- "a TU-local value", decl);
+ if (DECL_DECLARED_CONSTEXPR_P (decl))
+ error_at (DECL_SOURCE_LOCATION (decl),
+ "%qD is declared %<constexpr%> and is initialized to "
+ "a TU-local value", decl);
+ else
+ {
+ /* This can only occur with references. */
+ gcc_checking_assert (TYPE_REF_P (TREE_TYPE (decl)));
+ error_at (DECL_SOURCE_LOCATION (decl),
+ "%qD is a reference declared %<inline%> and is "
+ "constant-initialized to a TU-local value", decl);
+ }
bool informed = is_tu_local_value (decl, DECL_INITIAL (decl),
/*explain=*/true);
gcc_checking_assert (informed);