This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix OpenMP incorrect locus introduced by r128223 (PR middle-end/34694)
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Diego Novillo <dnovillo at google dot com>, Richard Henderson <rth at redhat dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Mon, 7 Jan 2008 08:26:45 -0500
- Subject: [PATCH] Fix OpenMP incorrect locus introduced by r128223 (PR middle-end/34694)
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
Hi!
http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=128223
now in move_stmt_r sometimes decides to duplicate even VAR_DECLs
there weren't duplicated before:
/* Replace T with its duplicate. T should no longer appear in the
parent function, so this looks wasteful; however, it may appear
in referenced_vars, and more importantly, as virtual operands of
statements, and in alias lists of other variables. It would be
quite difficult to expunge it from all those places. ??? It might
suffice to do this for addressable variables. */
if ((TREE_CODE (t) == VAR_DECL
&& !is_global_var (t))
|| TREE_CODE (t) == CONST_DECL)
replace_by_duplicate_decl (tp, p->vars_map, p->to_context);
but as this isn't done during scan_omp* phase which takes care about setting
input_location, DECL_SOURCE_LOCATION of the newly created VAR_DECLs is
wrong.
Fixed thusly, regtested on x86_64-linux. Ok for trunk?
2008-01-07 Jakub Jelinek <jakub@redhat.com>
PR middle-end/34694
* omp-low.c (copy_var_decl): Copy also DECL_SOURCE_LOCATION.
* gcc.dg/gomp/pr34694.c: New test.
* g++.dg/gomp/pr34694.C: New test.
--- gcc/omp-low.c.jj 2008-01-02 21:02:33.000000000 +0100
+++ gcc/omp-low.c 2008-01-07 13:33:11.000000000 +0100
@@ -529,6 +529,7 @@ copy_var_decl (tree var, tree name, tree
DECL_ARTIFICIAL (copy) = DECL_ARTIFICIAL (var);
DECL_IGNORED_P (copy) = DECL_IGNORED_P (var);
DECL_CONTEXT (copy) = DECL_CONTEXT (var);
+ DECL_SOURCE_LOCATION (copy) = DECL_SOURCE_LOCATION (var);
TREE_USED (copy) = 1;
DECL_SEEN_IN_BIND_EXPR_P (copy) = 1;
--- gcc/testsuite/gcc.dg/gomp/pr34694.c.jj 2008-01-07 13:41:42.000000000 +0100
+++ gcc/testsuite/gcc.dg/gomp/pr34694.c 2008-01-07 13:41:30.000000000 +0100
@@ -0,0 +1,15 @@
+/* PR middle-end/34694 */
+/* { dg-do compile } */
+/* { dg-options "-O -fopenmp -Wall" } */
+
+int i;
+
+void
+foo ()
+{
+#pragma omp parallel
+ {
+ int j; /* { dg-message "note: 'j' was declared here" } */
+ i = j; /* { dg-warning "is used uninitialized" } */
+ }
+}
--- gcc/testsuite/g++.dg/gomp/pr34694.C.jj 2008-01-07 13:41:42.000000000 +0100
+++ gcc/testsuite/g++.dg/gomp/pr34694.C 2008-01-07 13:42:57.000000000 +0100
@@ -0,0 +1,15 @@
+// PR middle-end/34694
+// { dg-do compile }
+// { dg-options "-O -fopenmp -Wall" }
+
+int i;
+
+void
+foo ()
+{
+#pragma omp parallel
+ {
+ int j; // { dg-warning "note: 'j' was declared here" }
+ i = j; // { dg-warning "is used uninitialized" }
+ }
+}
Jakub