aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2020-02-03 16:03:45 -0500
committerJason Merrill <jason@redhat.com>2020-02-03 17:52:17 -0500
commit87fbd5347b33883006dc77e779b9edc590fcd2f0 (patch)
tree348baf29ff78fbda5e5cbdf5556c0aeebb6509d6 /gcc/cp
parent8fda2c274ac66d60c1dfc1349e9efb4e8c2a3580 (diff)
downloadgcc-87fbd5347b33883006dc77e779b9edc590fcd2f0.zip
gcc-87fbd5347b33883006dc77e779b9edc590fcd2f0.tar.gz
gcc-87fbd5347b33883006dc77e779b9edc590fcd2f0.tar.bz2
c++: Fix constexpr vs. reference parameter.
[expr.const] specifically rules out mentioning a reference even if its address is never used, because it implies indirection that is similarly non-constant for a pointer variable. PR c++/66477 * constexpr.c (cxx_eval_constant_expression) [PARM_DECL]: Don't defer loading the value of a reference.
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/constexpr.c2
2 files changed, 6 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index a8af79c..8b35213 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,11 @@
2020-02-03 Jason Merrill <jason@redhat.com>
+ PR c++/66477
+ * constexpr.c (cxx_eval_constant_expression) [PARM_DECL]: Don't
+ defer loading the value of a reference.
+
+2020-02-03 Jason Merrill <jason@redhat.com>
+
PR c++/91953
* constexpr.c (potential_constant_expression_1) [PARM_DECL]: Allow
empty class type.
diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c
index a39ba41..3962763 100644
--- a/gcc/cp/constexpr.c
+++ b/gcc/cp/constexpr.c
@@ -5322,8 +5322,6 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t,
r = *p;
else if (lval)
/* Defer in case this is only used for its type. */;
- else if (TYPE_REF_P (TREE_TYPE (t)))
- /* Defer, there's no lvalue->rvalue conversion. */;
else if (COMPLETE_TYPE_P (TREE_TYPE (t))
&& is_really_empty_class (TREE_TYPE (t), /*ignore_vptr*/false))
{