On 11/11/21 03:49, Matthias Kretz wrote:
On Wednesday, 8 September 2021 15:49:27 CET Matthias Kretz wrote:
On Wednesday, 8 September 2021 15:44:28 CEST Jason Merrill wrote:
On 9/8/21 5:37 AM, Matthias Kretz wrote:
On Tuesday, 7 September 2021 19:36:22 CEST Jason Merrill wrote:
case PAREN_EXPR:
-      RETURN (finish_parenthesized_expr (RECUR (TREE_OPERAND (t,
0))));
+      if (REF_PARENTHESIZED_P (t))
+       RETURN (finish_parenthesized_expr (RECUR (TREE_OPERAND (t,
0))));
+      else
+       RETURN (RECUR (TREE_OPERAND (t, 0)));

I think you need to build a new PAREN_EXPR in the assoc barrier case as
well, for it to have any effect in templates.

My intent was to ignore __builtin_assoc_barrier in templates / constexpr
evaluation since it's not affected by -fassociative-math anyway. Or do
you
mean something else?

I agree about constexpr, but why wouldn't template instantiations be
affected by -fassociative-math like any other function?

Oh, that seems like a major misunderstanding on my part. I assumed
tsubst_copy_and_build would evaluate the expressions in template arguments
🤦. I'll expand the test and will fix.

Sorry for the long delay. New patch is attached. OK for trunk?

OK.

New builtin to enable explicit use of PAREN_EXPR in C & C++ code.

Signed-off-by: Matthias Kretz <m.kr...@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.
---
  gcc/c-family/c-common.c                       |  1 +
  gcc/c-family/c-common.h                       |  2 +-
  gcc/c/c-decl.c                                |  1 +
  gcc/c/c-parser.c                              | 20 ++++++
  gcc/cp/constexpr.c                            |  8 +++
  gcc/cp/cp-objcp-common.c                      |  1 +
  gcc/cp/cp-tree.h                              | 12 ++--
  gcc/cp/parser.c                               | 14 ++++
  gcc/cp/pt.c                                   | 10 ++-
  gcc/cp/semantics.c                            | 23 ++----
  gcc/doc/extend.texi                           | 18 +++++
  .../c-c++-common/builtin-assoc-barrier-1.c    | 71 +++++++++++++++++++
  12 files changed, 158 insertions(+), 23 deletions(-)
  create mode 100644 gcc/testsuite/c-c++-common/builtin-assoc-barrier-1.c



Reply via email to