From 878cffbd9e6e1b138a6e0d362e7b29bc0a259940 Mon Sep 17 00:00:00 2001 From: Iain Sandoe Date: Sat, 31 Oct 2020 09:25:47 +0000 Subject: Objective-C++ : Fix ICE in potential_constant_expression_1. We cannot, as things stand, handle Objective-C tree codes in the switch and deal with this by calling out to a function that has a dummy version when Objective-C is not enabled. Because of the way the logic works (with a fall through to a 'sorry' in case of unhandled expressions), the function reports cases that are known to be unsuitable for constant exprs. The dummy function always reports 'false' and thus will fall through to the 'sorry'. gcc/c-family/ChangeLog: * c-objc.h (objc_non_constant_expr_p): New. * stub-objc.c (objc_non_constant_expr_p): New. gcc/cp/ChangeLog: * constexpr.c (potential_constant_expression_1): Handle expressions known to be non-constant for Objective-C. gcc/objc/ChangeLog: * objc-act.c (objc_non_constant_expr_p): New. --- gcc/objc/objc-act.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'gcc/objc') diff --git a/gcc/objc/objc-act.c b/gcc/objc/objc-act.c index 0393bc4..c0d07ae 100644 --- a/gcc/objc/objc-act.c +++ b/gcc/objc/objc-act.c @@ -1720,7 +1720,6 @@ objc_build_class_component_ref (tree class_name, tree property_ident) } - /* This is used because we don't want to expose PROPERTY_REF to the C/C++ frontends. Maybe we should! */ bool @@ -1732,6 +1731,21 @@ objc_is_property_ref (tree node) return false; } +/* We use this to report tree codes that are known to be invalid in const- + expression contexts. */ +bool +objc_non_constant_expr_p (tree node) +{ + switch (TREE_CODE (node)) + { + default: + return false; + case MESSAGE_SEND_EXPR: + case PROPERTY_REF: + return true; + } +} + /* This function builds a setter call for a PROPERTY_REF (real, for a declared property, or artificial, for a dot-syntax accessor which is not corresponding to a property). 'lhs' must be a PROPERTY_REF -- cgit v1.1