aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/module.cc2
-rw-r--r--gcc/testsuite/g++.dg/modules/cexpr-5_a.C13
-rw-r--r--gcc/testsuite/g++.dg/modules/cexpr-5_b.C9
3 files changed, 23 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;
diff --git a/gcc/testsuite/g++.dg/modules/cexpr-5_a.C b/gcc/testsuite/g++.dg/modules/cexpr-5_a.C
new file mode 100644
index 0000000..3a9f005
--- /dev/null
+++ b/gcc/testsuite/g++.dg/modules/cexpr-5_a.C
@@ -0,0 +1,13 @@
+// { dg-additional-options "-fmodules-ts" }
+// { dg-module-cmi M }
+
+export module M;
+
+int x = 123;
+void f() {}
+
+int& xr = x;
+auto& fr = f;
+
+constexpr int& cxr = xr;
+constexpr auto& cfr = fr;
diff --git a/gcc/testsuite/g++.dg/modules/cexpr-5_b.C b/gcc/testsuite/g++.dg/modules/cexpr-5_b.C
new file mode 100644
index 0000000..4b1b901
--- /dev/null
+++ b/gcc/testsuite/g++.dg/modules/cexpr-5_b.C
@@ -0,0 +1,9 @@
+// { dg-additional-options "-fmodules-ts" }
+
+module M;
+
+constexpr auto& use_xr = xr;
+constexpr auto& use_fr = fr;
+
+static_assert(&cxr == &use_xr);
+static_assert(&cfr == &use_fr);