aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/semantics.c
diff options
context:
space:
mode:
authorMatthias Kretz <m.kretz@gsi.de>2021-07-16 10:46:24 +0200
committerMatthias Kretz <m.kretz@gsi.de>2021-11-18 11:24:11 +0100
commitefb7c51024ccad9df293e6caf134d78b3d00cf89 (patch)
tree571a6a7d4dbf3d5df7235bb4dca060b50b14d41e /gcc/cp/semantics.c
parentedd2249b17fb7150da66b03adb1a4e381926047d (diff)
downloadgcc-efb7c51024ccad9df293e6caf134d78b3d00cf89.zip
gcc-efb7c51024ccad9df293e6caf134d78b3d00cf89.tar.gz
gcc-efb7c51024ccad9df293e6caf134d78b3d00cf89.tar.bz2
c-family: Add __builtin_assoc_barrier
New builtin to enable explicit use of PAREN_EXPR in C & C++ code. Signed-off-by: Matthias Kretz <m.kretz@gsi.de> gcc/testsuite/ChangeLog: * c-c++-common/builtin-assoc-barrier-1.c: New test. gcc/cp/ChangeLog: * constexpr.c (cxx_eval_constant_expression): Handle PAREN_EXPR via cxx_eval_constant_expression. * cp-objcp-common.c (names_builtin_p): Handle RID_BUILTIN_ASSOC_BARRIER. * cp-tree.h: Adjust TREE_LANG_FLAG documentation to include PAREN_EXPR in REF_PARENTHESIZED_P. (REF_PARENTHESIZED_P): Add PAREN_EXPR. * parser.c (cp_parser_postfix_expression): Handle RID_BUILTIN_ASSOC_BARRIER. * pt.c (tsubst_copy_and_build): If the PAREN_EXPR is not a parenthesized initializer, build a new PAREN_EXPR. * semantics.c (force_paren_expr): Simplify conditionals. Set REF_PARENTHESIZED_P on PAREN_EXPR. (maybe_undo_parenthesized_ref): Test PAREN_EXPR for REF_PARENTHESIZED_P. gcc/c-family/ChangeLog: * c-common.c (c_common_reswords): Add __builtin_assoc_barrier. * c-common.h (enum rid): Add RID_BUILTIN_ASSOC_BARRIER. gcc/c/ChangeLog: * c-decl.c (names_builtin_p): Handle RID_BUILTIN_ASSOC_BARRIER. * c-parser.c (c_parser_postfix_expression): Likewise. gcc/ChangeLog: * doc/extend.texi: Document __builtin_assoc_barrier.
Diffstat (limited to 'gcc/cp/semantics.c')
-rw-r--r--gcc/cp/semantics.c23
1 files changed, 7 insertions, 16 deletions
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index 1540442..8f79f04 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -2048,24 +2048,17 @@ force_paren_expr (tree expr, bool even_uneval)
if (cp_unevaluated_operand && !even_uneval)
return expr;
- if (!DECL_P (tree_strip_any_location_wrapper (expr))
- && TREE_CODE (expr) != COMPONENT_REF
- && 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_loc (loc, PAREN_EXPR, TREE_TYPE (expr), expr);
- else
+ else if (DECL_P (tree_strip_any_location_wrapper (expr)))
{
- expr = build1_loc (loc, VIEW_CONVERT_EXPR, TREE_TYPE (expr), expr);
+ location_t loc = cp_expr_location (expr);
+ const tree_code code = processing_template_decl ? PAREN_EXPR
+ : VIEW_CONVERT_EXPR;
+ expr = build1_loc (loc, code, TREE_TYPE (expr), expr);
REF_PARENTHESIZED_P (expr) = true;
}
-
return expr;
}
@@ -2090,10 +2083,8 @@ maybe_undo_parenthesized_ref (tree t)
|| TREE_CODE (t) == STATIC_CAST_EXPR);
t = TREE_OPERAND (t, 0);
}
- else if (TREE_CODE (t) == PAREN_EXPR)
- t = TREE_OPERAND (t, 0);
- else if (TREE_CODE (t) == VIEW_CONVERT_EXPR
- && REF_PARENTHESIZED_P (t))
+ else if ((TREE_CODE (t) == PAREN_EXPR || TREE_CODE (t) == VIEW_CONVERT_EXPR)
+ && REF_PARENTHESIZED_P (t))
t = TREE_OPERAND (t, 0);
return t;