summaryrefslogtreecommitdiff
path: root/gcc/fold-const.c
diff options
context:
space:
mode:
authorMarek Polacek <polacek@redhat.com>2019-12-07 17:35:54 +0000
committerMarek Polacek <mpolacek@gcc.gnu.org>2019-12-07 17:35:54 +0000
commitbfbe98c7e0d570c903c89359cd25073e538a365e (patch)
tree0ceaef0721dd5c5812bccb95688416b27a8f1adb /gcc/fold-const.c
parentea37206decb6b4df127e65af206c58e6fc3ae60a (diff)
PR c++/91678 - wrong error with decltype and location wrapper.
Compiling this testcase results in a bogus "invalid cast" error; this occurs since the introduction of location wrappers in finish_id_expression. Here we are parsing the decltype expression via cp_parser_decltype_expr which can lead to calling various fold_* and c-family routines. They use non_lvalue_loc, but that won't create a NON_LVALUE_EXPR wrapper around a location wrapper. So before the location wrappers addition cp_parser_decltype_expr would return NON_LVALUE_EXPR <c>. Now it returns VIEW_CONVERT_EXPR<float *>(c), but the STRIP_ANY_LOCATION_WRAPPER immediately following it strips the location wrapper, and suddenly we don't know whether we have an lvalue anymore. And that's sad because then decltype produces the wrong type, causing nonsense errors. * fold-const.c (maybe_lvalue_p): Handle VIEW_CONVERT_EXPR. * g++.dg/cpp0x/decltype73.C: New test. From-SVN: r279077
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r--gcc/fold-const.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index c5bd45a6e34..8e9e299926a 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -2598,6 +2598,7 @@ maybe_lvalue_p (const_tree x)
case TARGET_EXPR:
case COND_EXPR:
case BIND_EXPR:
+ case VIEW_CONVERT_EXPR:
break;
default: