This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
C++ PATCH: Fix PR 14123
- From: Gabriel Dos Reis <gdr at cs dot tamu dot edu>
- To: gcc-patches at gcc dot gnu dot org
- Date: 27 Jun 2004 16:39:44 -0500
- Subject: C++ PATCH: Fix PR 14123
- Organization: Texas A&M University, Department of Computer Science
This patchlet fixes an odd parenthesis display when rendering
pointer to array members. This PR has been reported against 3.4.0,
but in effect it has been there for much longer than that -- therefore
it is not a regression.
Regtested on an i686-pc-linux-gnu. No regression. Applied to
mainline.
-- Gaby
Index: cp/ChangeLog
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/ChangeLog,v
retrieving revision 1.4135
diff -p -r1.4135 ChangeLog
*** cp/ChangeLog 27 Jun 2004 18:56:45 -0000 1.4135
--- cp/ChangeLog 27 Jun 2004 21:35:34 -0000
***************
*** 1,3 ****
--- 1,12 ----
+ 2004-06-27 Gabriel Dos Reis <gdr@integrable-solutions.net>
+
+ PR c++/14123
+ * cxx-pretty-print.c (pp_cxx_ptr_operator): Properly put
+ paranthesis in case of pointers to array members.
+ * error.c (dump_type_prefix): Likewise.
+ (dump_type_suffix): Maybe issue a whitespace when printing
+ ARRAY_TYPE.
+
2004-06-27 Mark Mitchell <mark@codesourcery.com>
PR c++/16193
Index: cp/cxx-pretty-print.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/cxx-pretty-print.c,v
retrieving revision 1.24
diff -p -r1.24 cxx-pretty-print.c
*** cp/cxx-pretty-print.c 26 Jun 2004 21:11:17 -0000 1.24
--- cp/cxx-pretty-print.c 27 Jun 2004 21:35:34 -0000
*************** pp_cxx_ptr_operator (cxx_pretty_printer
*** 1100,1105 ****
--- 1100,1107 ----
case OFFSET_TYPE:
if (TYPE_PTR_TO_MEMBER_P (t))
{
+ if (TREE_CODE (TREE_TYPE (t)) == ARRAY_TYPE)
+ pp_cxx_left_paren (pp);
pp_cxx_nested_name_specifier (pp, TYPE_PTRMEM_CLASS_TYPE (t));
pp_star (pp);
pp_cxx_cv_qualifier_seq (pp, t);
Index: cp/error.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/error.c,v
retrieving revision 1.253
diff -p -r1.253 error.c
*** cp/error.c 27 Jun 2004 15:20:41 -0000 1.253
--- cp/error.c 27 Jun 2004 21:35:36 -0000
*************** dump_type_prefix (tree t, int flags)
*** 512,522 ****
--- 512,525 ----
if (TREE_CODE (t) == OFFSET_TYPE) /* pmfs deal with this in d_t_p */
{
pp_maybe_space (cxx_pp);
+ if (TREE_CODE (TREE_TYPE (t)) == ARRAY_TYPE)
+ pp_cxx_left_paren (cxx_pp);
dump_type (TYPE_OFFSET_BASETYPE (t), flags);
pp_cxx_colon_colon (cxx_pp);
}
pp_cxx_star (cxx_pp);
pp_cxx_cv_qualifier_seq (cxx_pp, t);
+ pp_base (cxx_pp)->padding = pp_before;
break;
/* Can only be reached through function pointer -- this would not be
*************** dump_type_suffix (tree t, int flags)
*** 613,618 ****
--- 616,622 ----
}
case ARRAY_TYPE:
+ pp_maybe_space (cxx_pp);
pp_cxx_left_bracket (cxx_pp);
if (TYPE_DOMAIN (t))
{
Index: testsuite/g++.dg/other/ptrmem5.C
===================================================================
RCS file: testsuite/g++.dg/other/ptrmem5.C
diff -N testsuite/g++.dg/other/ptrmem5.C
*** /dev/null 1 Jan 1970 00:00:00 -0000
--- testsuite/g++.dg/other/ptrmem5.C 27 Jun 2004 21:35:37 -0000
***************
*** 0 ****
--- 1,12 ----
+ // PR 14123
+
+ struct a
+ {
+ int x[8];
+ };
+
+ int main()
+ {
+ int a::*n[8];
+ n = &a::x; // { dg-error "int \\(a::\\*\\)" }
+ }