diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 2715966e6f41..2b281c1672ca 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,7 @@ +2019-08-05 Jason Merrill + + * semantics.c (force_paren_expr): Preserve location. + 2019-08-02 Marek Polacek PR c++/91230 - wrong error with __PRETTY_FUNCTION__ and generic lambda. diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 269092de1ef0..fc90c8d6f0ea 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -1745,14 +1745,16 @@ force_paren_expr (tree expr) && TREE_CODE (expr) != SCOPE_REF) return expr; + location_t loc = cp_expr_location (expr); + if (TREE_CODE (expr) == COMPONENT_REF || TREE_CODE (expr) == SCOPE_REF) REF_PARENTHESIZED_P (expr) = true; else if (processing_template_decl) - expr = build1 (PAREN_EXPR, TREE_TYPE (expr), expr); + expr = build1_loc (loc, PAREN_EXPR, TREE_TYPE (expr), expr); else { - expr = build1 (VIEW_CONVERT_EXPR, TREE_TYPE (expr), expr); + expr = build1_loc (loc, VIEW_CONVERT_EXPR, TREE_TYPE (expr), expr); REF_PARENTHESIZED_P (expr) = true; }