public inbox for fortran@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH 1/2] Fortran: dump-parse-tree attribs: fix unbalanced braces [PR109624]
@ 2023-05-10 16:48 Bernhard Reutner-Fischer
  2023-05-10 16:48 ` [PATCH 2/2] Fortran: dump-parse-tree: Mark debug functions with DEBUG_FUNCTION Bernhard Reutner-Fischer
       [not found] ` <204c1734-a74c-1575-d042-3aef696f6f6a@netcologne.de>
  0 siblings, 2 replies; 3+ messages in thread
From: Bernhard Reutner-Fischer @ 2023-05-10 16:48 UTC (permalink / raw)
  To: fortran; +Cc: gcc-patches, Bernhard Reutner-Fischer

From: Bernhard Reutner-Fischer <aldot@gcc.gnu.org>

gcc/fortran/ChangeLog:

	PR fortran/109624
	* dump-parse-tree.cc (debug): New function for gfc_namespace.
	(gfc_debug_code): Delete forward declaration.
	(show_attr): Make sure to print balanced braces.

---
(gdb) call debug(gfc_current_ns)

Namespace: A-H: (REAL 4) I-N: (INTEGER 4) O-Z: (REAL 4)
procedure name = fmodule
  symtree: 'C_ptr'       || symbol: 'c_ptr'
    type spec : (UNKNOWN 0)
    attributes: )

There is an open brace missing after "attributes: "

Regression tested on x86_64-linux, OK for trunk?
---
 gcc/fortran/dump-parse-tree.cc | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/gcc/fortran/dump-parse-tree.cc b/gcc/fortran/dump-parse-tree.cc
index 1fc1f311e84..2380fa04796 100644
--- a/gcc/fortran/dump-parse-tree.cc
+++ b/gcc/fortran/dump-parse-tree.cc
@@ -125,6 +125,16 @@ void debug (gfc_ref *p)
   dumpfile = tmp;
 }
 
+void
+debug (gfc_namespace *ns)
+{
+  FILE *tmp = dumpfile;
+  dumpfile = stderr;
+  show_namespace (ns);
+  fputc ('\n', dumpfile);
+  dumpfile = tmp;
+}
+
 void
 gfc_debug_expr (gfc_expr *e)
 {
@@ -136,7 +146,6 @@ gfc_debug_expr (gfc_expr *e)
 }
 
 /* Allow for dumping of a piece of code in the debugger.  */
-void gfc_debug_code (gfc_code *c);
 
 void
 gfc_debug_code (gfc_code *c)
@@ -758,12 +767,13 @@ show_expr (gfc_expr *p)
 static void
 show_attr (symbol_attribute *attr, const char * module)
 {
+  fputc ('(', dumpfile);
   if (attr->flavor != FL_UNKNOWN)
     {
       if (attr->flavor == FL_DERIVED && attr->pdt_template)
-	fputs (" (PDT-TEMPLATE", dumpfile);
+	fputs ("PDT-TEMPLATE ", dumpfile);
       else
-    fprintf (dumpfile, "(%s ", gfc_code2string (flavors, attr->flavor));
+	fprintf (dumpfile, "%s ", gfc_code2string (flavors, attr->flavor));
     }
   if (attr->access != ACCESS_UNKNOWN)
     fprintf (dumpfile, "%s ", gfc_code2string (access_types, attr->access));
-- 
2.30.2


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

* [PATCH 2/2] Fortran: dump-parse-tree: Mark debug functions with DEBUG_FUNCTION
  2023-05-10 16:48 [PATCH 1/2] Fortran: dump-parse-tree attribs: fix unbalanced braces [PR109624] Bernhard Reutner-Fischer
@ 2023-05-10 16:48 ` Bernhard Reutner-Fischer
       [not found] ` <204c1734-a74c-1575-d042-3aef696f6f6a@netcologne.de>
  1 sibling, 0 replies; 3+ messages in thread
From: Bernhard Reutner-Fischer @ 2023-05-10 16:48 UTC (permalink / raw)
  To: fortran; +Cc: gcc-patches, Bernhard Reutner-Fischer

From: Bernhard Reutner-Fischer <aldot@gcc.gnu.org>

gcc/fortran/ChangeLog:

	* dump-parse-tree.cc (gfc_debug_expr): Remove forward declaration.
	(debug): Add DEBUG_FUNCTION.
	(show_code_node): Remove erroneous whitespace.

---
Regression tested on x86_64-linux, OK for trunk?
---
 gcc/fortran/dump-parse-tree.cc | 38 ++++++++++++++++++++--------------
 1 file changed, 22 insertions(+), 16 deletions(-)

diff --git a/gcc/fortran/dump-parse-tree.cc b/gcc/fortran/dump-parse-tree.cc
index 2380fa04796..644f8f37d63 100644
--- a/gcc/fortran/dump-parse-tree.cc
+++ b/gcc/fortran/dump-parse-tree.cc
@@ -55,10 +55,8 @@ static void show_typespec (gfc_typespec *);
 static void show_ref (gfc_ref *);
 static void show_attr (symbol_attribute *, const char *);
 
-/* Allow dumping of an expression in the debugger.  */
-void gfc_debug_expr (gfc_expr *);
-
-void debug (symbol_attribute *attr)
+DEBUG_FUNCTION void
+debug (symbol_attribute *attr)
 {
   FILE *tmp = dumpfile;
   dumpfile = stderr;
@@ -67,7 +65,8 @@ void debug (symbol_attribute *attr)
   dumpfile = tmp;
 }
 
-void debug (gfc_formal_arglist *formal)
+DEBUG_FUNCTION void
+debug (gfc_formal_arglist *formal)
 {
   FILE *tmp = dumpfile;
   dumpfile = stderr;
@@ -80,12 +79,14 @@ void debug (gfc_formal_arglist *formal)
   dumpfile = tmp;
 }
 
-void debug (symbol_attribute attr)
+DEBUG_FUNCTION void
+debug (symbol_attribute attr)
 {
   debug (&attr);
 }
 
-void debug (gfc_expr *e)
+DEBUG_FUNCTION void
+debug (gfc_expr *e)
 {
   FILE *tmp = dumpfile;
   dumpfile = stderr;
@@ -102,7 +103,8 @@ void debug (gfc_expr *e)
   dumpfile = tmp;
 }
 
-void debug (gfc_typespec *ts)
+DEBUG_FUNCTION void
+debug (gfc_typespec *ts)
 {
   FILE *tmp = dumpfile;
   dumpfile = stderr;
@@ -111,12 +113,14 @@ void debug (gfc_typespec *ts)
   dumpfile = tmp;
 }
 
-void debug (gfc_typespec ts)
+DEBUG_FUNCTION void
+debug (gfc_typespec ts)
 {
   debug (&ts);
 }
 
-void debug (gfc_ref *p)
+DEBUG_FUNCTION void
+debug (gfc_ref *p)
 {
   FILE *tmp = dumpfile;
   dumpfile = stderr;
@@ -125,7 +129,7 @@ void debug (gfc_ref *p)
   dumpfile = tmp;
 }
 
-void
+DEBUG_FUNCTION void
 debug (gfc_namespace *ns)
 {
   FILE *tmp = dumpfile;
@@ -135,7 +139,7 @@ debug (gfc_namespace *ns)
   dumpfile = tmp;
 }
 
-void
+DEBUG_FUNCTION void
 gfc_debug_expr (gfc_expr *e)
 {
   FILE *tmp = dumpfile;
@@ -147,7 +151,7 @@ gfc_debug_expr (gfc_expr *e)
 
 /* Allow for dumping of a piece of code in the debugger.  */
 
-void
+DEBUG_FUNCTION void
 gfc_debug_code (gfc_code *c)
 {
   FILE *tmp = dumpfile;
@@ -157,7 +161,8 @@ gfc_debug_code (gfc_code *c)
   dumpfile = tmp;
 }
 
-void debug (gfc_symbol *sym)
+DEBUG_FUNCTION void
+debug (gfc_symbol *sym)
 {
   FILE *tmp = dumpfile;
   dumpfile = stderr;
@@ -2513,7 +2518,7 @@ show_code_node (int level, gfc_code *c)
     case EXEC_SYNC_MEMORY:
       fputs ("SYNC MEMORY ", dumpfile);
       if (c->expr2 != NULL)
- 	{
+	{
 	  fputs (" stat=", dumpfile);
 	  show_expr (c->expr2);
 	}
@@ -4031,7 +4036,8 @@ gfc_dump_global_symbols (FILE *f)
 
 /* Show an array ref.  */
 
-void debug (gfc_array_ref *ar)
+DEBUG_FUNCTION void
+debug (gfc_array_ref *ar)
 {
   FILE *tmp = dumpfile;
   dumpfile = stderr;
-- 
2.30.2


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

* Re: [PATCH 1/2] Fortran: dump-parse-tree attribs: fix unbalanced braces [PR109624]
       [not found] ` <204c1734-a74c-1575-d042-3aef696f6f6a@netcologne.de>
@ 2023-05-10 19:11   ` Bernhard Reutner-Fischer
  0 siblings, 0 replies; 3+ messages in thread
From: Bernhard Reutner-Fischer @ 2023-05-10 19:11 UTC (permalink / raw)
  To: Thomas Koenig; +Cc: gfortran, gcc-patches

[re-adding the lists, i hope you don't mind]

On Wed, 10 May 2023 18:52:54 +0200
Thomas Koenig <tkoenig@netcologne.de> wrote:

> Hi Bernhard,
> 
> both patches look good to me.

Pushed as r14-664-g39f7c0963a9c00 and r14-665-gbdc10c2bfaceb3
Thanks!

> 
> No user impact, so they should have the lowest possible impact :-)
> 
> (And I didn't know about DEBUG_FUNCTION, that could come in handy
> later).
> 
> Thanks for the patch!
> 
> Best regards
> 
>      Thomas


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

end of thread, other threads:[~2023-05-10 19:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-10 16:48 [PATCH 1/2] Fortran: dump-parse-tree attribs: fix unbalanced braces [PR109624] Bernhard Reutner-Fischer
2023-05-10 16:48 ` [PATCH 2/2] Fortran: dump-parse-tree: Mark debug functions with DEBUG_FUNCTION Bernhard Reutner-Fischer
     [not found] ` <204c1734-a74c-1575-d042-3aef696f6f6a@netcologne.de>
2023-05-10 19:11   ` [PATCH 1/2] Fortran: dump-parse-tree attribs: fix unbalanced braces [PR109624] Bernhard Reutner-Fischer

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).