Re: [PATCH 04/14] c++: use _P() defines from tree.h

2023-11-15 Thread Bernhard Reutner-Fischer
On Tue, 8 Aug 2023 16:31:39 -0400
Jason Merrill  wrote:

> On 8/2/23 12:51, Patrick Palka via Gcc-patches wrote:
> > On Thu, Jun 1, 2023 at 2:11 PM Bernhard Reutner-Fischer
> >  wrote:  
> >>
> >> Hi David, Patrick,
> >>
> >> On Thu, 1 Jun 2023 18:33:46 +0200
> >> Bernhard Reutner-Fischer  wrote:
> >>  
> >>> On Thu, 1 Jun 2023 11:24:06 -0400
> >>> Patrick Palka  wrote:
> >>>  
>  On Sat, May 13, 2023 at 7:26 PM Bernhard Reutner-Fischer via
>  Gcc-patches  wrote:  
> >>>  
> > diff --git a/gcc/cp/tree.cc b/gcc/cp/tree.cc
> > index 131b212ff73..19dfb3ed782 100644
> > --- a/gcc/cp/tree.cc
> > +++ b/gcc/cp/tree.cc
> > @@ -1173,7 +1173,7 @@ build_cplus_array_type (tree elt_type, tree 
> > index_type, int dependent)
> >   }
> >
> > /* Avoid spurious warnings with VLAs (c++/54583).  */
> > -  if (TYPE_SIZE (t) && EXPR_P (TYPE_SIZE (t)))
> > +  if (CAN_HAVE_LOCATION_P (TYPE_SIZE (t)))  
> 
>  Hmm, this change seems undesirable...  
> >>>
> >>> mhm, yes that is misleading. I'll prepare a patch to revert this.
> >>> Let me have a look if there were other such CAN_HAVE_LOCATION_P changes
> >>> that we'd want to revert.  
> >>
> >> Sorry for that!
> >> I'd revert the hunk above and the one in gcc-rich-location.cc
> >> (maybe_range_label_for_tree_type_mismatch::get_text), please see
> >> attached. Bootstrap running, ok for trunk if it passes?  
> > 
> > LGTM!  
> 
> Yes, OK.

Now applied as r14-5508 (186331063dfbcf1eacb445c473d92634c9baa90f)

thanks


Re: [PATCH 04/14] c++: use _P() defines from tree.h

2023-08-08 Thread Jason Merrill via Gcc-patches

On 8/2/23 12:51, Patrick Palka via Gcc-patches wrote:

On Thu, Jun 1, 2023 at 2:11 PM Bernhard Reutner-Fischer
 wrote:


Hi David, Patrick,

On Thu, 1 Jun 2023 18:33:46 +0200
Bernhard Reutner-Fischer  wrote:


On Thu, 1 Jun 2023 11:24:06 -0400
Patrick Palka  wrote:


On Sat, May 13, 2023 at 7:26 PM Bernhard Reutner-Fischer via
Gcc-patches  wrote:



diff --git a/gcc/cp/tree.cc b/gcc/cp/tree.cc
index 131b212ff73..19dfb3ed782 100644
--- a/gcc/cp/tree.cc
+++ b/gcc/cp/tree.cc
@@ -1173,7 +1173,7 @@ build_cplus_array_type (tree elt_type, tree index_type, 
int dependent)
  }

/* Avoid spurious warnings with VLAs (c++/54583).  */
-  if (TYPE_SIZE (t) && EXPR_P (TYPE_SIZE (t)))
+  if (CAN_HAVE_LOCATION_P (TYPE_SIZE (t)))


Hmm, this change seems undesirable...


mhm, yes that is misleading. I'll prepare a patch to revert this.
Let me have a look if there were other such CAN_HAVE_LOCATION_P changes
that we'd want to revert.


Sorry for that!
I'd revert the hunk above and the one in gcc-rich-location.cc
(maybe_range_label_for_tree_type_mismatch::get_text), please see
attached. Bootstrap running, ok for trunk if it passes?


LGTM!


Yes, OK.

Jason



Re: [PATCH 04/14] c++: use _P() defines from tree.h

2023-08-02 Thread Patrick Palka via Gcc-patches
On Thu, Jun 1, 2023 at 2:11 PM Bernhard Reutner-Fischer
 wrote:
>
> Hi David, Patrick,
>
> On Thu, 1 Jun 2023 18:33:46 +0200
> Bernhard Reutner-Fischer  wrote:
>
> > On Thu, 1 Jun 2023 11:24:06 -0400
> > Patrick Palka  wrote:
> >
> > > On Sat, May 13, 2023 at 7:26 PM Bernhard Reutner-Fischer via
> > > Gcc-patches  wrote:
> >
> > > > diff --git a/gcc/cp/tree.cc b/gcc/cp/tree.cc
> > > > index 131b212ff73..19dfb3ed782 100644
> > > > --- a/gcc/cp/tree.cc
> > > > +++ b/gcc/cp/tree.cc
> > > > @@ -1173,7 +1173,7 @@ build_cplus_array_type (tree elt_type, tree 
> > > > index_type, int dependent)
> > > >  }
> > > >
> > > >/* Avoid spurious warnings with VLAs (c++/54583).  */
> > > > -  if (TYPE_SIZE (t) && EXPR_P (TYPE_SIZE (t)))
> > > > +  if (CAN_HAVE_LOCATION_P (TYPE_SIZE (t)))
> > >
> > > Hmm, this change seems undesirable...
> >
> > mhm, yes that is misleading. I'll prepare a patch to revert this.
> > Let me have a look if there were other such CAN_HAVE_LOCATION_P changes
> > that we'd want to revert.
>
> Sorry for that!
> I'd revert the hunk above and the one in gcc-rich-location.cc
> (maybe_range_label_for_tree_type_mismatch::get_text), please see
> attached. Bootstrap running, ok for trunk if it passes?

LGTM!

>
> thanks,



Re: [PATCH 04/14] c++: use _P() defines from tree.h

2023-06-01 Thread Bernhard Reutner-Fischer via Gcc-patches
Hi David, Patrick,

On Thu, 1 Jun 2023 18:33:46 +0200
Bernhard Reutner-Fischer  wrote:

> On Thu, 1 Jun 2023 11:24:06 -0400
> Patrick Palka  wrote:
> 
> > On Sat, May 13, 2023 at 7:26 PM Bernhard Reutner-Fischer via
> > Gcc-patches  wrote:  
> 
> > > diff --git a/gcc/cp/tree.cc b/gcc/cp/tree.cc
> > > index 131b212ff73..19dfb3ed782 100644
> > > --- a/gcc/cp/tree.cc
> > > +++ b/gcc/cp/tree.cc
> > > @@ -1173,7 +1173,7 @@ build_cplus_array_type (tree elt_type, tree 
> > > index_type, int dependent)
> > >  }
> > >
> > >/* Avoid spurious warnings with VLAs (c++/54583).  */
> > > -  if (TYPE_SIZE (t) && EXPR_P (TYPE_SIZE (t)))
> > > +  if (CAN_HAVE_LOCATION_P (TYPE_SIZE (t)))
> > 
> > Hmm, this change seems undesirable...  
> 
> mhm, yes that is misleading. I'll prepare a patch to revert this.
> Let me have a look if there were other such CAN_HAVE_LOCATION_P changes
> that we'd want to revert.

Sorry for that!
I'd revert the hunk above and the one in gcc-rich-location.cc
(maybe_range_label_for_tree_type_mismatch::get_text), please see
attached. Bootstrap running, ok for trunk if it passes?

thanks,
>From 322bce380144b5199cca5775f7a3f0fb30a219ae Mon Sep 17 00:00:00 2001
From: Bernhard Reutner-Fischer 
Date: Thu, 1 Jun 2023 19:44:19 +0200
Subject: [PATCH] c++, analyzer: Expand CAN_HAVE_LOCATION_P macro.

r14-985-gca2007a9bb3074 used the collapsed macro definition
CAN_HAVE_LOCATION_P in gcc-rich-location.cc and r14-977-g8861c80733da5c
in c++'s build_cplus_array_type ().
However, although otherwise correct, the usage of CAN_HAVE_LOCATION_P
in these two spots is misleading, so this patch reverts aforementioned
two hunks.

gcc/cp/ChangeLog:

* tree.cc (build_cplus_array_type): Revert using the macro
CAN_HAVE_LOCATION_P.

gcc/ChangeLog:

* gcc-rich-location.cc 
(maybe_range_label_for_tree_type_mismatch::get_text):
Revert using the macro CAN_HAVE_LOCATION_P.
---
 gcc/cp/tree.cc   | 2 +-
 gcc/gcc-rich-location.cc | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/gcc/cp/tree.cc b/gcc/cp/tree.cc
index 19dfb3ed782..9363166152a 100644
--- a/gcc/cp/tree.cc
+++ b/gcc/cp/tree.cc
@@ -1173,7 +1173,7 @@ build_cplus_array_type (tree elt_type, tree index_type, 
int dependent)
 }
 
   /* Avoid spurious warnings with VLAs (c++/54583).  */
-  if (CAN_HAVE_LOCATION_P (TYPE_SIZE (t)))
+  if (TYPE_SIZE (t) && EXPR_P (TYPE_SIZE (t)))
 suppress_warning (TYPE_SIZE (t), OPT_Wunused);
 
   /* Push these needs up to the ARRAY_TYPE so that initialization takes
diff --git a/gcc/gcc-rich-location.cc b/gcc/gcc-rich-location.cc
index edecf07f81e..d02a5144cc6 100644
--- a/gcc/gcc-rich-location.cc
+++ b/gcc/gcc-rich-location.cc
@@ -200,7 +200,7 @@ maybe_range_label_for_tree_type_mismatch::get_text 
(unsigned range_idx) const
   tree expr_type = TREE_TYPE (m_expr);
 
   tree other_type = NULL_TREE;
-  if (CAN_HAVE_LOCATION_P (m_other_expr))
+  if (m_other_expr && EXPR_P (m_other_expr))
 other_type = TREE_TYPE (m_other_expr);
 
   range_label_for_type_mismatch inner (expr_type, other_type);
-- 
2.30.2



Re: [PATCH 04/14] c++: use _P() defines from tree.h

2023-06-01 Thread Bernhard Reutner-Fischer via Gcc-patches
On Thu, 1 Jun 2023 11:24:06 -0400
Patrick Palka  wrote:

> On Sat, May 13, 2023 at 7:26 PM Bernhard Reutner-Fischer via
> Gcc-patches  wrote:

> > diff --git a/gcc/cp/tree.cc b/gcc/cp/tree.cc
> > index 131b212ff73..19dfb3ed782 100644
> > --- a/gcc/cp/tree.cc
> > +++ b/gcc/cp/tree.cc
> > @@ -1173,7 +1173,7 @@ build_cplus_array_type (tree elt_type, tree 
> > index_type, int dependent)
> >  }
> >
> >/* Avoid spurious warnings with VLAs (c++/54583).  */
> > -  if (TYPE_SIZE (t) && EXPR_P (TYPE_SIZE (t)))
> > +  if (CAN_HAVE_LOCATION_P (TYPE_SIZE (t)))  
> 
> Hmm, this change seems undesirable...

mhm, yes that is misleading. I'll prepare a patch to revert this.
Let me have a look if there were other such CAN_HAVE_LOCATION_P changes
that we'd want to revert.

thanks,


Re: [PATCH 04/14] c++: use _P() defines from tree.h

2023-06-01 Thread Patrick Palka via Gcc-patches
On Sat, May 13, 2023 at 7:26 PM Bernhard Reutner-Fischer via
Gcc-patches  wrote:
>
> From: Bernhard Reutner-Fischer 
>
> gcc/cp/ChangeLog:
>
> * call.cc (promoted_arithmetic_type_p): Use _P defines from tree.h.
> (build_conditional_expr): Ditto.
> (convert_like_internal): Ditto.
> (convert_arg_to_ellipsis): Ditto.
> (build_over_call): Ditto.
> (compare_ics): Ditto.
> * class.cc (is_empty_base_ref): Ditto.
> * coroutines.cc (rewrite_param_uses): Ditto.
> * cp-tree.h (DECL_DISCRIMINATOR_P): Ditto.
> (ARITHMETIC_TYPE_P): Ditto.
> * cvt.cc (ocp_convert): Ditto.
> * cxx-pretty-print.cc (pp_cxx_template_argument_list): Ditto.
> * decl.cc (layout_var_decl): Ditto.
> (get_tuple_size): Ditto.
> * error.cc (dump_simple_decl): Ditto.
> * lambda.cc (start_lambda_scope): Ditto.
> * mangle.cc (write_template_arg): Ditto.
> * method.cc (spaceship_comp_cat): Ditto.
> * module.cc (node_template_info): Ditto.
> (trees_out::start): Ditto.
> (trees_out::decl_node): Ditto.
> (trees_in::read_var_def): Ditto.
> (set_instantiating_module): Ditto.
> * name-lookup.cc (maybe_record_mergeable_decl): Ditto.
> (consider_decl): Ditto.
> (maybe_add_fuzzy_decl): Ditto.
> * pt.cc (convert_nontype_argument): Ditto.
> * semantics.cc (handle_omp_array_sections_1): Ditto.
> (finish_omp_clauses): Ditto.
> (finish_omp_target_clauses_r): Ditto.
> (is_this_parameter): Ditto.
> * tree.cc (build_cplus_array_type): Ditto.
> (is_this_expression): Ditto.
> * typeck.cc (do_warn_enum_conversions): Ditto.
> * typeck2.cc (store_init_value): Ditto.
> (check_narrowing): Ditto.
> ---
>  gcc/cp/call.cc | 42 +++---
>  gcc/cp/class.cc|  2 +-
>  gcc/cp/coroutines.cc   |  2 +-
>  gcc/cp/cp-tree.h   |  4 ++--
>  gcc/cp/cvt.cc  |  2 +-
>  gcc/cp/cxx-pretty-print.cc |  2 +-
>  gcc/cp/decl.cc |  4 ++--
>  gcc/cp/error.cc|  2 +-
>  gcc/cp/lambda.cc   |  2 +-
>  gcc/cp/mangle.cc   |  2 +-
>  gcc/cp/method.cc   |  2 +-
>  gcc/cp/module.cc   | 12 +--
>  gcc/cp/name-lookup.cc  |  6 +++---
>  gcc/cp/pt.cc   |  2 +-
>  gcc/cp/semantics.cc| 24 +++---
>  gcc/cp/tree.cc |  4 ++--
>  gcc/cp/typeck.cc   |  4 ++--
>  gcc/cp/typeck2.cc  | 10 -
>  18 files changed, 64 insertions(+), 64 deletions(-)
>
> diff --git a/gcc/cp/call.cc b/gcc/cp/call.cc
> index 2a06520c0c1..6e13d17f6b8 100644
> --- a/gcc/cp/call.cc
> +++ b/gcc/cp/call.cc
> @@ -2746,7 +2746,7 @@ promoted_arithmetic_type_p (tree type)
>   integral types plus floating types.  */
>return ((CP_INTEGRAL_TYPE_P (type)
>&& same_type_p (type_promotes_to (type), type))
> - || TREE_CODE (type) == REAL_TYPE);
> + || SCALAR_FLOAT_TYPE_P (type));
>  }
>
>  /* Create any builtin operator overload candidates for the operator in
> @@ -5759,10 +5759,10 @@ build_conditional_expr (const op_location_t &loc,
>if ((TREE_CODE (arg2) == EXCESS_PRECISION_EXPR
> || TREE_CODE (arg3) == EXCESS_PRECISION_EXPR)
>&& (TREE_CODE (arg2_type) == INTEGER_TYPE
> - || TREE_CODE (arg2_type) == REAL_TYPE
> + || SCALAR_FLOAT_TYPE_P (arg2_type)
>   || TREE_CODE (arg2_type) == COMPLEX_TYPE)
>&& (TREE_CODE (arg3_type) == INTEGER_TYPE
> - || TREE_CODE (arg3_type) == REAL_TYPE
> + || SCALAR_FLOAT_TYPE_P (arg3_type)
>   || TREE_CODE (arg3_type) == COMPLEX_TYPE))
>  {
>semantic_result_type
> @@ -5775,8 +5775,8 @@ build_conditional_expr (const op_location_t &loc,
> t1 = TREE_TYPE (t1);
>   if (TREE_CODE (t2) == COMPLEX_TYPE)
> t2 = TREE_TYPE (t2);
> - gcc_checking_assert (TREE_CODE (t1) == REAL_TYPE
> -  && TREE_CODE (t2) == REAL_TYPE
> + gcc_checking_assert (SCALAR_FLOAT_TYPE_P (t1)
> +  && SCALAR_FLOAT_TYPE_P (t2)
>&& (extended_float_type_p (t1)
>|| extended_float_type_p (t2))
>&& cp_compare_floating_point_conversion_ranks
> @@ -6127,8 +6127,8 @@ build_conditional_expr (const op_location_t &loc,
> t1 = TREE_TYPE (t1);
>   if (TREE_CODE (t2) == COMPLEX_TYPE)
> t2 = TREE_TYPE (t2);
> - gcc_checking_assert (TREE_CODE (t1) == REAL_TYPE
> -  && TREE_CODE (t2) == REAL_TYPE
> + gcc_checking_assert (SCALAR_FLOAT_TYPE_P (t1)
> +  && SCALAR_FLOAT_TYPE_P (t2)
>&& (extended_float_type_p (t1)
>

[PATCH 04/14] c++: use _P() defines from tree.h

2023-05-13 Thread Bernhard Reutner-Fischer via Gcc-patches
From: Bernhard Reutner-Fischer 

gcc/cp/ChangeLog:

* call.cc (promoted_arithmetic_type_p): Use _P defines from tree.h.
(build_conditional_expr): Ditto.
(convert_like_internal): Ditto.
(convert_arg_to_ellipsis): Ditto.
(build_over_call): Ditto.
(compare_ics): Ditto.
* class.cc (is_empty_base_ref): Ditto.
* coroutines.cc (rewrite_param_uses): Ditto.
* cp-tree.h (DECL_DISCRIMINATOR_P): Ditto.
(ARITHMETIC_TYPE_P): Ditto.
* cvt.cc (ocp_convert): Ditto.
* cxx-pretty-print.cc (pp_cxx_template_argument_list): Ditto.
* decl.cc (layout_var_decl): Ditto.
(get_tuple_size): Ditto.
* error.cc (dump_simple_decl): Ditto.
* lambda.cc (start_lambda_scope): Ditto.
* mangle.cc (write_template_arg): Ditto.
* method.cc (spaceship_comp_cat): Ditto.
* module.cc (node_template_info): Ditto.
(trees_out::start): Ditto.
(trees_out::decl_node): Ditto.
(trees_in::read_var_def): Ditto.
(set_instantiating_module): Ditto.
* name-lookup.cc (maybe_record_mergeable_decl): Ditto.
(consider_decl): Ditto.
(maybe_add_fuzzy_decl): Ditto.
* pt.cc (convert_nontype_argument): Ditto.
* semantics.cc (handle_omp_array_sections_1): Ditto.
(finish_omp_clauses): Ditto.
(finish_omp_target_clauses_r): Ditto.
(is_this_parameter): Ditto.
* tree.cc (build_cplus_array_type): Ditto.
(is_this_expression): Ditto.
* typeck.cc (do_warn_enum_conversions): Ditto.
* typeck2.cc (store_init_value): Ditto.
(check_narrowing): Ditto.
---
 gcc/cp/call.cc | 42 +++---
 gcc/cp/class.cc|  2 +-
 gcc/cp/coroutines.cc   |  2 +-
 gcc/cp/cp-tree.h   |  4 ++--
 gcc/cp/cvt.cc  |  2 +-
 gcc/cp/cxx-pretty-print.cc |  2 +-
 gcc/cp/decl.cc |  4 ++--
 gcc/cp/error.cc|  2 +-
 gcc/cp/lambda.cc   |  2 +-
 gcc/cp/mangle.cc   |  2 +-
 gcc/cp/method.cc   |  2 +-
 gcc/cp/module.cc   | 12 +--
 gcc/cp/name-lookup.cc  |  6 +++---
 gcc/cp/pt.cc   |  2 +-
 gcc/cp/semantics.cc| 24 +++---
 gcc/cp/tree.cc |  4 ++--
 gcc/cp/typeck.cc   |  4 ++--
 gcc/cp/typeck2.cc  | 10 -
 18 files changed, 64 insertions(+), 64 deletions(-)

diff --git a/gcc/cp/call.cc b/gcc/cp/call.cc
index 2a06520c0c1..6e13d17f6b8 100644
--- a/gcc/cp/call.cc
+++ b/gcc/cp/call.cc
@@ -2746,7 +2746,7 @@ promoted_arithmetic_type_p (tree type)
  integral types plus floating types.  */
   return ((CP_INTEGRAL_TYPE_P (type)
   && same_type_p (type_promotes_to (type), type))
- || TREE_CODE (type) == REAL_TYPE);
+ || SCALAR_FLOAT_TYPE_P (type));
 }
 
 /* Create any builtin operator overload candidates for the operator in
@@ -5759,10 +5759,10 @@ build_conditional_expr (const op_location_t &loc,
   if ((TREE_CODE (arg2) == EXCESS_PRECISION_EXPR
|| TREE_CODE (arg3) == EXCESS_PRECISION_EXPR)
   && (TREE_CODE (arg2_type) == INTEGER_TYPE
- || TREE_CODE (arg2_type) == REAL_TYPE
+ || SCALAR_FLOAT_TYPE_P (arg2_type)
  || TREE_CODE (arg2_type) == COMPLEX_TYPE)
   && (TREE_CODE (arg3_type) == INTEGER_TYPE
- || TREE_CODE (arg3_type) == REAL_TYPE
+ || SCALAR_FLOAT_TYPE_P (arg3_type)
  || TREE_CODE (arg3_type) == COMPLEX_TYPE))
 {
   semantic_result_type
@@ -5775,8 +5775,8 @@ build_conditional_expr (const op_location_t &loc,
t1 = TREE_TYPE (t1);
  if (TREE_CODE (t2) == COMPLEX_TYPE)
t2 = TREE_TYPE (t2);
- gcc_checking_assert (TREE_CODE (t1) == REAL_TYPE
-  && TREE_CODE (t2) == REAL_TYPE
+ gcc_checking_assert (SCALAR_FLOAT_TYPE_P (t1)
+  && SCALAR_FLOAT_TYPE_P (t2)
   && (extended_float_type_p (t1)
   || extended_float_type_p (t2))
   && cp_compare_floating_point_conversion_ranks
@@ -6127,8 +6127,8 @@ build_conditional_expr (const op_location_t &loc,
t1 = TREE_TYPE (t1);
  if (TREE_CODE (t2) == COMPLEX_TYPE)
t2 = TREE_TYPE (t2);
- gcc_checking_assert (TREE_CODE (t1) == REAL_TYPE
-  && TREE_CODE (t2) == REAL_TYPE
+ gcc_checking_assert (SCALAR_FLOAT_TYPE_P (t1)
+  && SCALAR_FLOAT_TYPE_P (t2)
   && (extended_float_type_p (t1)
   || extended_float_type_p (t2))
   && cp_compare_floating_point_conversion_ranks
@@ -6147,8 +6147,8 @@ build_conditional_expr (const op_location_t &loc,
t1 = TREE_TYPE (t1);
  if (TREE_CODE (t2) == COMPLEX_TYPE)
t2 = TREE_TYPE (t2);
-