aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorNathaniel Shead <nathanieloshead@gmail.com>2024-09-12 20:06:39 +1000
committerNathaniel Shead <nathanieloshead@gmail.com>2024-09-27 13:49:23 +1000
commit1a0b33ebc57ebcc9595b19050f5c36c1f9d39e3e (patch)
tree5b0544ee90a41cf709e7812d8fd1dc4cc247ae21 /gcc/cp
parentd0762e93ce1ed046e1dd9477ebe0ad941c298677 (diff)
downloadgcc-1a0b33ebc57ebcc9595b19050f5c36c1f9d39e3e.zip
gcc-1a0b33ebc57ebcc9595b19050f5c36c1f9d39e3e.tar.gz
gcc-1a0b33ebc57ebcc9595b19050f5c36c1f9d39e3e.tar.bz2
c++/modules: Allow imported references in constant expressions
Currently the streaming code uses TREE_CONSTANT to determine whether an entity will have a definition that is interesting to stream out. This is not sufficient, however; we also need to write the definition of references, since although not TREE_CONSTANT they can still be usable in constant expressions. As such this patch uses the existing decl_maybe_constant_var function which correctly handles this case. gcc/cp/ChangeLog: * module.cc (has_definition): Use decl_maybe_constant_var instead of TREE_CONSTANT. gcc/testsuite/ChangeLog: * g++.dg/modules/cexpr-5_a.C: New test. * g++.dg/modules/cexpr-5_b.C: New test. Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com> Reviewed-by: Jason Merrill <jason@redhat.com>
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/module.cc2
1 files changed, 1 insertions, 1 deletions
diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc
index f5df9e8..65b37b4 100644
--- a/gcc/cp/module.cc
+++ b/gcc/cp/module.cc
@@ -11829,7 +11829,7 @@ has_definition (tree decl)
since there's no TU to emit them in otherwise. */
return true;
- if (!TREE_CONSTANT (decl))
+ if (!decl_maybe_constant_var_p (decl))
return false;
return true;