This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] 4.2 backport of the fixes for PR 25923 and PR 31847
- From: Simon Martin <simartin at users dot sourceforge dot net>
- To: gcc-patches at gcc dot gnu dot org
- Date: Mon, 04 Jun 2007 20:24:59 +0200
- Subject: [PATCH] 4.2 backport of the fixes for PR 25923 and PR 31847
Hi all.
Here's a patch to backport into 4.2 the fix for PR 25923 (Garbled
diagnostics with -O -Wuninitialized) and for a problem that was
introduced by it, PR 31847 (Printing to dump file broken).
Those were respectively approved in
http://gcc.gnu.org/ml/gcc-patches/2007-04/msg01603.html
and
http://gcc.gnu.org/ml/gcc-patches/2007-05/msg00528.html
I have successfully bootstrapped and regtested it on
i386-apple-darwin8.9.1 (C, C++, Java and Fortran). Is it OK?
Thanks in advance,
Simon
2007-06-01 Simon Martin <simartin@users.sourceforge.net>
PR diagnostic/25923
* tree-pass.h (TDF_DIAGNOSTIC): New dump control to specify that a
diagnostic message is being built.
* tree-pretty-print.c (dump_generic_node): Only write the formatted text
into BUFFER's stream if we are not building a diagnostic message.
* toplev.c (default_tree_printer): Pass TDF_DIAGNOSTIC to
dump_generic_node.
* Makefile.in (toplev.o): Depend on tree-pass.h.
PR 31847
* tree-dump.c (dump_options): Don't use TDF_DIAGNOSTIC in "*-all" tree
dumps.
Index: gcc/tree-dump.c
===================================================================
--- gcc/tree-dump.c (revision 125268)
+++ gcc/tree-dump.c (working copy)
@@ -785,7 +785,7 @@ static const struct dump_option_value_in
{"uid", TDF_UID},
{"stmtaddr", TDF_STMTADDR},
{"all", ~(TDF_RAW | TDF_SLIM | TDF_LINENO | TDF_TREE | TDF_RTL | TDF_IPA
- | TDF_STMTADDR | TDF_GRAPH)},
+ | TDF_STMTADDR | TDF_GRAPH | TDF_DIAGNOSTIC)},
{NULL, 0}
};
Index: gcc/tree-pretty-print.c
===================================================================
--- gcc/tree-pretty-print.c (revision 125268)
+++ gcc/tree-pretty-print.c (working copy)
@@ -403,8 +403,8 @@ dump_omp_clauses (pretty_printer *buffer
/* Dump the node NODE on the pretty_printer BUFFER, SPC spaces of indent.
- FLAGS specifies details to show in the dump (see TDF_* in tree.h). If
- IS_STMT is true, the object printed is considered to be a statement
+ FLAGS specifies details to show in the dump (see TDF_* in tree-pass.h).
+ If IS_STMT is true, the object printed is considered to be a statement
and it is terminated by ';' if appropriate. */
int
@@ -1921,7 +1921,11 @@ dump_generic_node (pretty_printer *buffe
if (is_stmt && is_expr)
pp_semicolon (buffer);
- pp_write_text_to_stream (buffer);
+
+ /* If we're building a diagnostic, the formatted text will be written
+ into BUFFER's stream by the caller; otherwise, write it now. */
+ if (!(flags & TDF_DIAGNOSTIC))
+ pp_write_text_to_stream (buffer);
return spc;
}
Index: gcc/tree-pass.h
===================================================================
--- gcc/tree-pass.h (revision 125268)
+++ gcc/tree-pass.h (working copy)
@@ -69,6 +69,9 @@ enum tree_dump_index
#define TDF_GRAPH (1 << 13) /* a graph dump is being emitted */
+#define TDF_DIAGNOSTIC (1 << 14) /* A dump to be put in a diagnostic
+ message. */
+
extern char *get_dump_file_name (enum tree_dump_index);
extern int dump_enabled_p (enum tree_dump_index);
extern int dump_initialized_p (enum tree_dump_index);
Index: gcc/toplev.c
===================================================================
--- gcc/toplev.c (revision 125268)
+++ gcc/toplev.c (working copy)
@@ -82,6 +82,7 @@ Software Foundation, 51 Franklin Street,
#include "value-prof.h"
#include "alloc-pool.h"
#include "tree-mudflap.h"
+#include "tree-pass.h"
#if defined (DWARF2_UNWIND_INFO) || defined (DWARF2_DEBUGGING_INFO)
#include "dwarf2out.h"
@@ -1460,7 +1461,7 @@ default_tree_printer (pretty_printer * p
pp_string (pp, n);
}
else
- dump_generic_node (pp, t, 0, 0, 0);
+ dump_generic_node (pp, t, 0, TDF_DIAGNOSTIC, 0);
return true;
}
Index: gcc/Makefile.in
===================================================================
--- gcc/Makefile.in (revision 125268)
+++ gcc/Makefile.in (working copy)
@@ -2152,7 +2152,7 @@ toplev.o : toplev.c $(CONFIG_H) $(SYSTEM
value-prof.h $(PARAMS_H) $(TM_P_H) reload.h dwarf2asm.h $(TARGET_H) \
langhooks.h insn-flags.h $(CFGLAYOUT_H) $(CFGLOOP_H) hosthooks.h \
$(CGRAPH_H) $(COVERAGE_H) alloc-pool.h $(GGC_H) $(INTEGRATE_H) \
- $(CPPLIB_H) opts.h params.def tree-mudflap.h $(REAL_H)
+ $(CPPLIB_H) opts.h params.def tree-mudflap.h $(REAL_H) tree-pass.h
$(CC) $(ALL_CFLAGS) $(ALL_CPPFLAGS) \
-DTARGET_NAME=\"$(target_noncanonical)\" \
-c $(srcdir)/toplev.c $(OUTPUT_OPTION)
2007-06-01 Simon Martin <simartin@users.sourceforge.net>
PR diagnostic/25923
* gfortran.dg/pr25923.f90: New test.
PR 31847
* gcc.dg/pr31847.c: New test.
! { dg-do compile }
! { dg-options "-O -Wuninitialized" }
module foo
implicit none
type bar
integer :: yr
end type
contains
function baz(arg) result(res) ! { dg-warning "res.yr' may be" }
type(bar), intent(in) :: arg
type(bar) :: res
logical, external:: some_func
if (.not. some_func(arg)) then
call fatal('arg not valid')
else
res = arg
end if
end function baz
end module foo
/* PR 31847 */
/* { dg-do compile } */
/* { dg-options "-O2 -fdump-tree-pre-all" } */
extern int bar(int);
int foo()
{
int a = 0;
return bar(a);
}
/* { dg-final { scan-tree-dump-not "Created value for " "pre"} } */
/* { dg-final { cleanup-tree-dump "pre" } } */