public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/101515] New: [11/12 Regression] ICE in pp_cxx_unqualified_id, at cp/cxx-pretty-print.c:128
@ 2021-07-19 17:27 gscfq@t-online.de
  2021-07-19 17:31 ` [Bug tree-optimization/101515] " pinskia at gcc dot gnu.org
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: gscfq@t-online.de @ 2021-07-19 17:27 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101515

            Bug ID: 101515
           Summary: [11/12 Regression] ICE in pp_cxx_unqualified_id, at
                    cp/cxx-pretty-print.c:128
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gscfq@t-online.de
  Target Milestone: ---

Changed between 20210110 and 20210117 :


$ cat z1.cc
struct S
{
  int j;
};
struct T : public S
{
  virtual void h () {}
};
struct ptrmemfunc
{
  void (*ptr) ();
};
typedef void (S::*sp)();
int main ()
{
  T t;
  sp x;
  ptrmemfunc *xp = (ptrmemfunc *) &x;
  if (xp->ptr != ((void (*)())(sizeof(void *))))
    return 1;
}


$ g++-12-20210718 -c z1.cc -O0 -Wall
$
$ g++-12-20210718 -c z1.cc -O1 -Wall
'
during GIMPLE pass: uninit
In function 'int main()':
Segmentation fault
   14 | int main ()
      |     ^~~~
0xd6d5af crash_signal
        ../../gcc/toplev.c:328
0x7389fc pp_cxx_unqualified_id
        ../../gcc/cp/cxx-pretty-print.c:128
0x738c48 pp_cxx_unqualified_id
        ../../gcc/cp/cxx-pretty-print.c:174
0x738ef7 pp_cxx_nested_name_specifier
        ../../gcc/cp/cxx-pretty-print.c:254
0x7395cb pp_cxx_qualified_id
        ../../gcc/cp/cxx-pretty-print.c:303
0x8f2e12 print_mem_ref
        ../../gcc/c-family/c-pretty-print.c:2079
0x76b79d dump_expr
        ../../gcc/cp/error.c:2403
0x76eb15 expr_to_string(tree_node*)
        ../../gcc/cp/error.c:3224
0x76f2fc cp_printer
        ../../gcc/cp/error.c:4390
0x1770e9e pp_format(pretty_printer*, text_info*)
        ../../gcc/pretty-print.c:1475
0x1764d54 diagnostic_report_diagnostic(diagnostic_context*, diagnostic_info*)
        ../../gcc/diagnostic.c:1331
0x176530a diagnostic_impl
        ../../gcc/diagnostic.c:1493
0x1765862 warning_at(unsigned int, int, char const*, ...)
        ../../gcc/diagnostic.c:1630
0xf4cf15 maybe_warn_operand
        ../../gcc/tree-ssa-uninit.c:446
0xf50ece warn_uninitialized_vars
        ../../gcc/tree-ssa-uninit.c:688
0xf55b23 execute
        ../../gcc/tree-ssa-uninit.c:3053

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug tree-optimization/101515] [11/12 Regression] ICE in pp_cxx_unqualified_id, at cp/cxx-pretty-print.c:128
  2021-07-19 17:27 [Bug c++/101515] New: [11/12 Regression] ICE in pp_cxx_unqualified_id, at cp/cxx-pretty-print.c:128 gscfq@t-online.de
@ 2021-07-19 17:31 ` pinskia at gcc dot gnu.org
  2021-07-22 13:13 ` [Bug tree-optimization/101515] [11/12 Regression] ICE in pp_cxx_unqualified_id, at cp/cxx-pretty-print.c:128 since r11-6729-gadb520606ce3e1e1 marxin at gcc dot gnu.org
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-07-19 17:31 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101515

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |diagnostic
          Component|c++                         |tree-optimization
   Target Milestone|---                         |11.2

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
This is crashing while printing the warning.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug tree-optimization/101515] [11/12 Regression] ICE in pp_cxx_unqualified_id, at cp/cxx-pretty-print.c:128 since r11-6729-gadb520606ce3e1e1
  2021-07-19 17:27 [Bug c++/101515] New: [11/12 Regression] ICE in pp_cxx_unqualified_id, at cp/cxx-pretty-print.c:128 gscfq@t-online.de
  2021-07-19 17:31 ` [Bug tree-optimization/101515] " pinskia at gcc dot gnu.org
@ 2021-07-22 13:13 ` marxin at gcc dot gnu.org
  2021-07-28  7:07 ` rguenth at gcc dot gnu.org
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: marxin at gcc dot gnu.org @ 2021-07-22 13:13 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101515

Martin Liška <marxin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[11/12 Regression] ICE in   |[11/12 Regression] ICE in
                   |pp_cxx_unqualified_id, at   |pp_cxx_unqualified_id, at
                   |cp/cxx-pretty-print.c:128   |cp/cxx-pretty-print.c:128
                   |                            |since
                   |                            |r11-6729-gadb520606ce3e1e1
   Last reconfirmed|                            |2021-07-22
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW
                 CC|                            |jakub at gcc dot gnu.org,
                   |                            |marxin at gcc dot gnu.org

--- Comment #2 from Martin Liška <marxin at gcc dot gnu.org> ---
Started with r11-6729-gadb520606ce3e1e1.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug tree-optimization/101515] [11/12 Regression] ICE in pp_cxx_unqualified_id, at cp/cxx-pretty-print.c:128 since r11-6729-gadb520606ce3e1e1
  2021-07-19 17:27 [Bug c++/101515] New: [11/12 Regression] ICE in pp_cxx_unqualified_id, at cp/cxx-pretty-print.c:128 gscfq@t-online.de
  2021-07-19 17:31 ` [Bug tree-optimization/101515] " pinskia at gcc dot gnu.org
  2021-07-22 13:13 ` [Bug tree-optimization/101515] [11/12 Regression] ICE in pp_cxx_unqualified_id, at cp/cxx-pretty-print.c:128 since r11-6729-gadb520606ce3e1e1 marxin at gcc dot gnu.org
@ 2021-07-28  7:07 ` rguenth at gcc dot gnu.org
  2022-01-17 14:00 ` rguenth at gcc dot gnu.org
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-07-28  7:07 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101515

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|11.2                        |11.3

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 11.2 is being released, retargeting bugs to GCC 11.3

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug tree-optimization/101515] [11/12 Regression] ICE in pp_cxx_unqualified_id, at cp/cxx-pretty-print.c:128 since r11-6729-gadb520606ce3e1e1
  2021-07-19 17:27 [Bug c++/101515] New: [11/12 Regression] ICE in pp_cxx_unqualified_id, at cp/cxx-pretty-print.c:128 gscfq@t-online.de
                   ` (2 preceding siblings ...)
  2021-07-28  7:07 ` rguenth at gcc dot gnu.org
@ 2022-01-17 14:00 ` rguenth at gcc dot gnu.org
  2022-02-04 21:53 ` qinzhao at gcc dot gnu.org
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-01-17 14:00 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101515

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P2

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug tree-optimization/101515] [11/12 Regression] ICE in pp_cxx_unqualified_id, at cp/cxx-pretty-print.c:128 since r11-6729-gadb520606ce3e1e1
  2021-07-19 17:27 [Bug c++/101515] New: [11/12 Regression] ICE in pp_cxx_unqualified_id, at cp/cxx-pretty-print.c:128 gscfq@t-online.de
                   ` (3 preceding siblings ...)
  2022-01-17 14:00 ` rguenth at gcc dot gnu.org
@ 2022-02-04 21:53 ` qinzhao at gcc dot gnu.org
  2022-02-07 21:14 ` qinzhao at gcc dot gnu.org
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: qinzhao at gcc dot gnu.org @ 2022-02-04 21:53 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101515

qinzhao at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |qinzhao at gcc dot gnu.org

--- Comment #4 from qinzhao at gcc dot gnu.org ---
the latest gcc12 failed with the same issue.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug tree-optimization/101515] [11/12 Regression] ICE in pp_cxx_unqualified_id, at cp/cxx-pretty-print.c:128 since r11-6729-gadb520606ce3e1e1
  2021-07-19 17:27 [Bug c++/101515] New: [11/12 Regression] ICE in pp_cxx_unqualified_id, at cp/cxx-pretty-print.c:128 gscfq@t-online.de
                   ` (4 preceding siblings ...)
  2022-02-04 21:53 ` qinzhao at gcc dot gnu.org
@ 2022-02-07 21:14 ` qinzhao at gcc dot gnu.org
  2022-02-07 21:17 ` qinzhao at gcc dot gnu.org
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: qinzhao at gcc dot gnu.org @ 2022-02-07 21:14 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101515

--- Comment #5 from qinzhao at gcc dot gnu.org ---
the root cause for this bug is:

1. there is no NAME for the pointer to member function type as the following:
(in cp/decl.cc)

tree
build_ptrmemfunc_type (tree type)
{
....
10655   finish_builtin_struct (t, "__ptrmemfunc_type", fields, ptr_type_node);
10656 
10657   /* Zap out the name so that the back end will give us the debugging
10658      information for this anonymous RECORD_TYPE.  */
10659   TYPE_NAME (t) = NULL_TREE;
...
}

2. therefore, when printing this ptrmemfun type (which is a RECORD_TYPE), we
should consider that it might not have a TYPE_NAME, however, in the current
handling "pp_cxx_unqualified_id", the TYPE_NAME is assumed to be non-NULL, this
is not correct. 

 126 static void
 127 pp_cxx_unqualified_id (cxx_pretty_printer *pp, tree t)
 128 {
 129   enum tree_code code = TREE_CODE (t);
 130   switch (code)
... 
 169     case RECORD_TYPE:
 170     case UNION_TYPE:
 171     case ENUMERAL_TYPE:
 172     case TYPENAME_TYPE:
 173     case UNBOUND_CLASS_TEMPLATE:
 174       pp_cxx_unqualified_id (pp, TYPE_NAME (t)); ===> the ICE happens here
due to TYPE_NAME is NULL.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug tree-optimization/101515] [11/12 Regression] ICE in pp_cxx_unqualified_id, at cp/cxx-pretty-print.c:128 since r11-6729-gadb520606ce3e1e1
  2021-07-19 17:27 [Bug c++/101515] New: [11/12 Regression] ICE in pp_cxx_unqualified_id, at cp/cxx-pretty-print.c:128 gscfq@t-online.de
                   ` (5 preceding siblings ...)
  2022-02-07 21:14 ` qinzhao at gcc dot gnu.org
@ 2022-02-07 21:17 ` qinzhao at gcc dot gnu.org
  2022-02-10 21:58 ` qinzhao at gcc dot gnu.org
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: qinzhao at gcc dot gnu.org @ 2022-02-07 21:17 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101515

--- Comment #6 from qinzhao at gcc dot gnu.org ---
the following patch fixed this bug:
[opc@qinzhao-aarch64-ol8 latest_gcc]$ git diff
diff --git a/gcc/cp/cxx-pretty-print.cc b/gcc/cp/cxx-pretty-print.cc
index 4f9a090e520d..744ed0add5ba 100644
--- a/gcc/cp/cxx-pretty-print.cc
+++ b/gcc/cp/cxx-pretty-print.cc
@@ -171,7 +171,10 @@ pp_cxx_unqualified_id (cxx_pretty_printer *pp, tree t)
     case ENUMERAL_TYPE:
     case TYPENAME_TYPE:
     case UNBOUND_CLASS_TEMPLATE:
-      pp_cxx_unqualified_id (pp, TYPE_NAME (t));
+      if (TYPE_NAME (t))
+       pp_cxx_unqualified_id (pp, TYPE_NAME (t));
+      else
+       pp_string (pp, "<unnamed type>");
       if (tree ti = TYPE_TEMPLATE_INFO_MAYBE_ALIAS (t))
        if (PRIMARY_TEMPLATE_P (TI_TEMPLATE (ti)))
          {

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug tree-optimization/101515] [11/12 Regression] ICE in pp_cxx_unqualified_id, at cp/cxx-pretty-print.c:128 since r11-6729-gadb520606ce3e1e1
  2021-07-19 17:27 [Bug c++/101515] New: [11/12 Regression] ICE in pp_cxx_unqualified_id, at cp/cxx-pretty-print.c:128 gscfq@t-online.de
                   ` (6 preceding siblings ...)
  2022-02-07 21:17 ` qinzhao at gcc dot gnu.org
@ 2022-02-10 21:58 ` qinzhao at gcc dot gnu.org
  2022-03-19  7:42 ` cvs-commit at gcc dot gnu.org
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: qinzhao at gcc dot gnu.org @ 2022-02-10 21:58 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101515

--- Comment #7 from qinzhao at gcc dot gnu.org ---
for the following IR:

  struct sp x;
  void (*<T389>) (void) _1;
 ...
  <bb 2> [local count: 1073741824]:
  _1 = MEM[(struct ptrmemfunc_U *)&x].ptr;
  _7 = _1 != 8B;


***Before commit r11-6729-gadb520606ce3e1e1.

it reported:

t.cc:19:11: warning: ‘x.ptrmemfunc_U::ptr’ is used uninitialized
[-Wuninitialized]

***After commit r11-6729-gadb520606ce3e1e1.

1. without the patch in comment #6:

ICE. 

2. with the patch in comment #6:

it reported:

t.cc:19:11: warning: ‘*(ptrmemfunc_U*)((char*)&x + offsetof(void
(S::*)(),<unnamed type>::__pfn)).ptrmemfunc_U::ptr’ is used uninitialized
[-Wuninitialized]

***The major difference between the message before r11-6729-gadb520606ce3e1e1
and after it is:

in the message after this commit, (if resolved the ICE), the type conversion
from "S::ptrmemfunc" to ptrmemfunc_U is emitted in the message, before this
commit, this type conversion is not emitted at all. 

So, the question is: shall we expose the type conversion from "S::ptrmemfunc"
to "ptrmemfunc_U" to the user?

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug tree-optimization/101515] [11/12 Regression] ICE in pp_cxx_unqualified_id, at cp/cxx-pretty-print.c:128 since r11-6729-gadb520606ce3e1e1
  2021-07-19 17:27 [Bug c++/101515] New: [11/12 Regression] ICE in pp_cxx_unqualified_id, at cp/cxx-pretty-print.c:128 gscfq@t-online.de
                   ` (7 preceding siblings ...)
  2022-02-10 21:58 ` qinzhao at gcc dot gnu.org
@ 2022-03-19  7:42 ` cvs-commit at gcc dot gnu.org
  2022-03-19  7:43 ` [Bug tree-optimization/101515] [11 " jakub at gcc dot gnu.org
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-03-19  7:42 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101515

--- Comment #8 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>:

https://gcc.gnu.org/g:2663d18356b0a62f5a800c7e5596d814cd3c2c41

commit r12-7720-g2663d18356b0a62f5a800c7e5596d814cd3c2c41
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Sat Mar 19 08:40:47 2022 +0100

    c-family: Fix up ICE during pretty-printing of PMF related expression
[PR101515]

    The intent of r11-6729 is that it prints something that helps user to
figure
    out what exactly is being accessed.
    When we find a unique non-static data member that is being accessed, even
    when we can't fold it nicely, IMNSHO it is better to print
      ((sometype *)&var)->field
    or
      (*(sometype *)&var).field
    instead of
      *(fieldtype *)((char *)&var + 56)
    because the user doesn't know what is at offset 56, we shouldn't ask user
    to decipher structure layout etc.

    One question is if we could return something better for the
TYPE_PTRMEMFUNC_FLAG
    RECORD_TYPE members here (something that would print it more
naturally/readably
    in a C++ way), though the fact that the routine is in c-family makes it
    harder.

    Another one is whether we shouldn't punt for FIELD_DECLs that don't have
    nicely printable name of its containing scope, something like:
                    if (tree scope = get_containing_scope (field))
                      if (TYPE_P (scope) && TYPE_NAME (scope) == NULL_TREE)
                        break;
                    return cop;
    or so.  This patch implements that.

    Note the returned cop is a COMPONENT_REF where the first argument has a
    nicely printable type name (x with type sp), but sp's TYPE_MAIN_VARIANT
    is the unnamed TYPE_PTRMEMFUNC_FLAG.  So another possibility would be if
    we see such a problem for the FIELD_DECL's scope, check if
TYPE_MAIN_VARIANT
    of the first COMPONENT_REF's argument is equal to that scope and in that
    case use TREE_TYPE of the first COMPONENT_REF's argument as the scope
    instead.

    2022-03-19  Jakub Jelinek  <jakub@redhat.com>

            PR c++/101515
            * c-pretty-print.cc (c_fold_indirect_ref_for_warn): For C++ don't
            return COMPONENT_REFs with FIELD_DECLs whose containing scope can't
            be printed.

            * g++.dg/warn/pr101515.C: New test.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug tree-optimization/101515] [11 Regression] ICE in pp_cxx_unqualified_id, at cp/cxx-pretty-print.c:128 since r11-6729-gadb520606ce3e1e1
  2021-07-19 17:27 [Bug c++/101515] New: [11/12 Regression] ICE in pp_cxx_unqualified_id, at cp/cxx-pretty-print.c:128 gscfq@t-online.de
                   ` (8 preceding siblings ...)
  2022-03-19  7:42 ` cvs-commit at gcc dot gnu.org
@ 2022-03-19  7:43 ` jakub at gcc dot gnu.org
  2022-03-29  5:54 ` cvs-commit at gcc dot gnu.org
  2022-03-30  8:16 ` jakub at gcc dot gnu.org
  11 siblings, 0 replies; 13+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-03-19  7:43 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101515

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[11/12 Regression] ICE in   |[11 Regression] ICE in
                   |pp_cxx_unqualified_id, at   |pp_cxx_unqualified_id, at
                   |cp/cxx-pretty-print.c:128   |cp/cxx-pretty-print.c:128
                   |since                       |since
                   |r11-6729-gadb520606ce3e1e1  |r11-6729-gadb520606ce3e1e1

--- Comment #9 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Fixed on the trunk so far.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug tree-optimization/101515] [11 Regression] ICE in pp_cxx_unqualified_id, at cp/cxx-pretty-print.c:128 since r11-6729-gadb520606ce3e1e1
  2021-07-19 17:27 [Bug c++/101515] New: [11/12 Regression] ICE in pp_cxx_unqualified_id, at cp/cxx-pretty-print.c:128 gscfq@t-online.de
                   ` (9 preceding siblings ...)
  2022-03-19  7:43 ` [Bug tree-optimization/101515] [11 " jakub at gcc dot gnu.org
@ 2022-03-29  5:54 ` cvs-commit at gcc dot gnu.org
  2022-03-30  8:16 ` jakub at gcc dot gnu.org
  11 siblings, 0 replies; 13+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-03-29  5:54 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101515

--- Comment #10 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-11 branch has been updated by Jakub Jelinek
<jakub@gcc.gnu.org>:

https://gcc.gnu.org/g:f70464efbfa9469c57ac75b9aa5a62a2cff4f1fe

commit r11-9732-gf70464efbfa9469c57ac75b9aa5a62a2cff4f1fe
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Sat Mar 19 08:40:47 2022 +0100

    c-family: Fix up ICE during pretty-printing of PMF related expression
[PR101515]

    The intent of r11-6729 is that it prints something that helps user to
figure
    out what exactly is being accessed.
    When we find a unique non-static data member that is being accessed, even
    when we can't fold it nicely, IMNSHO it is better to print
      ((sometype *)&var)->field
    or
      (*(sometype *)&var).field
    instead of
      *(fieldtype *)((char *)&var + 56)
    because the user doesn't know what is at offset 56, we shouldn't ask user
    to decipher structure layout etc.

    One question is if we could return something better for the
TYPE_PTRMEMFUNC_FLAG
    RECORD_TYPE members here (something that would print it more
naturally/readably
    in a C++ way), though the fact that the routine is in c-family makes it
    harder.

    Another one is whether we shouldn't punt for FIELD_DECLs that don't have
    nicely printable name of its containing scope, something like:
                    if (tree scope = get_containing_scope (field))
                      if (TYPE_P (scope) && TYPE_NAME (scope) == NULL_TREE)
                        break;
                    return cop;
    or so.  This patch implements that.

    Note the returned cop is a COMPONENT_REF where the first argument has a
    nicely printable type name (x with type sp), but sp's TYPE_MAIN_VARIANT
    is the unnamed TYPE_PTRMEMFUNC_FLAG.  So another possibility would be if
    we see such a problem for the FIELD_DECL's scope, check if
TYPE_MAIN_VARIANT
    of the first COMPONENT_REF's argument is equal to that scope and in that
    case use TREE_TYPE of the first COMPONENT_REF's argument as the scope
    instead.

    2022-03-19  Jakub Jelinek  <jakub@redhat.com>

            PR c++/101515
            * c-pretty-print.c (c_fold_indirect_ref_for_warn): For C++ don't
            return COMPONENT_REFs with FIELD_DECLs whose containing scope can't
            be printed.

            * g++.dg/warn/pr101515.C: New test.

    (cherry picked from commit 2663d18356b0a62f5a800c7e5596d814cd3c2c41)

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug tree-optimization/101515] [11 Regression] ICE in pp_cxx_unqualified_id, at cp/cxx-pretty-print.c:128 since r11-6729-gadb520606ce3e1e1
  2021-07-19 17:27 [Bug c++/101515] New: [11/12 Regression] ICE in pp_cxx_unqualified_id, at cp/cxx-pretty-print.c:128 gscfq@t-online.de
                   ` (10 preceding siblings ...)
  2022-03-29  5:54 ` cvs-commit at gcc dot gnu.org
@ 2022-03-30  8:16 ` jakub at gcc dot gnu.org
  11 siblings, 0 replies; 13+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-03-30  8:16 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101515

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
           Assignee|qinzhao at gcc dot gnu.org         |jakub at gcc dot gnu.org
             Status|NEW                         |RESOLVED

--- Comment #11 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Fixed for 11.3 too.

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2022-03-30  8:16 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-19 17:27 [Bug c++/101515] New: [11/12 Regression] ICE in pp_cxx_unqualified_id, at cp/cxx-pretty-print.c:128 gscfq@t-online.de
2021-07-19 17:31 ` [Bug tree-optimization/101515] " pinskia at gcc dot gnu.org
2021-07-22 13:13 ` [Bug tree-optimization/101515] [11/12 Regression] ICE in pp_cxx_unqualified_id, at cp/cxx-pretty-print.c:128 since r11-6729-gadb520606ce3e1e1 marxin at gcc dot gnu.org
2021-07-28  7:07 ` rguenth at gcc dot gnu.org
2022-01-17 14:00 ` rguenth at gcc dot gnu.org
2022-02-04 21:53 ` qinzhao at gcc dot gnu.org
2022-02-07 21:14 ` qinzhao at gcc dot gnu.org
2022-02-07 21:17 ` qinzhao at gcc dot gnu.org
2022-02-10 21:58 ` qinzhao at gcc dot gnu.org
2022-03-19  7:42 ` cvs-commit at gcc dot gnu.org
2022-03-19  7:43 ` [Bug tree-optimization/101515] [11 " jakub at gcc dot gnu.org
2022-03-29  5:54 ` cvs-commit at gcc dot gnu.org
2022-03-30  8:16 ` jakub at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).