Hi, this patch fix the following bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67064 for gcc 5.2
It passes all the gcc tests except for this: FAIL: g++.dg/cpp1y/auto-fn15.C -std=gnu++14 (test for excess errors) but this also happens without the patch. This patch was implemented for gcc 5.2 changelog: diff --git a/gcc/cp/call.c b/gcc/cp/call.c index 949225b..62b8c2a 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -5131,8 +5131,6 @@ build_conditional_expr_1 (location_t loc, tree arg1, tree arg2, tree arg3, lvalue, we must add a NON_LVALUE_EXPR. */ result = rvalue (result); } - else - result = force_paren_expr (result); return result; } diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 4e525e0..1f802b0 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -5933,7 +5933,6 @@ extern tree finish_asm_stmt (int, tree, tree, tree, tree, extern tree finish_label_stmt (tree); extern void finish_label_decl (tree); extern tree finish_parenthesized_expr (tree); -extern tree force_paren_expr (tree); extern tree finish_non_static_data_member (tree, tree, tree); extern tree begin_stmt_expr (void); extern tree finish_stmt_expr_expr (tree, tree); diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 82ef642..005262d 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -1642,26 +1642,9 @@ finish_mem_initializers (tree mem_inits) emit_mem_initializers (mem_inits); } -/* Obfuscate EXPR if it looks like an id-expression or member access so - that the call to finish_decltype in do_auto_deduction will give the - right result. */ - -tree -force_paren_expr (tree expr) +static void +check_paren_expr(tree expr) { - /* This is only needed for decltype(auto) in C++14. */ - if (cxx_dialect < cxx14) - return expr; - - /* If we're in unevaluated context, we can't be deducing a - return/initializer type, so we don't need to mess with this. */ - if (cp_unevaluated_operand) - return expr; - - if (!DECL_P (expr) && TREE_CODE (expr) != COMPONENT_REF - && TREE_CODE (expr) != SCOPE_REF) - return expr; - if (TREE_CODE (expr) == COMPONENT_REF) REF_PARENTHESIZED_P (expr) = true; else if (type_dependent_expression_p (expr)) @@ -1672,7 +1655,7 @@ force_paren_expr (tree expr) if ((kind & ~clk_class) != clk_none) { tree type = unlowered_expr_type (expr); - bool rval = !!(kind & clk_rvalueref); + bool rval = (kind & clk_rvalueref); type = cp_build_reference_type (type, rval); /* This inhibits warnings in, eg, cxx_mark_addressable (c++/60955). */ @@ -1682,10 +1665,7 @@ force_paren_expr (tree expr) REF_PARENTHESIZED_P (expr) = true; } } - - return expr; } - /* Finish a parenthesized expression EXPR. */ tree @@ -1704,8 +1684,6 @@ finish_parenthesized_expr (tree expr) if (TREE_CODE (expr) == STRING_CST) PAREN_STRING_LITERAL_P (expr) = 1; - expr = force_paren_expr (expr); - return expr; } @@ -7369,7 +7347,10 @@ finish_decltype_type (tree expr, bool id_expression_or_member_access_p, type = strip_typedefs (type); if (clk != clk_none && !(clk & clk_class)) + { + check_paren_expr(expr); type = cp_build_reference_type (type, (clk & clk_rvalueref)); + } } }