aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Koenig <tkoenig@gcc.gnu.org>2017-03-15 07:45:39 +0000
committerThomas Koenig <tkoenig@gcc.gnu.org>2017-03-15 07:45:39 +0000
commit20305b5047e1c6ce55f47d6f4d6fa93970f752ec (patch)
tree9f77409bc00ee67483e0e197d2c38e60ff24e22a
parent142b99a8888ddb6d67e74b63789983e804b5a732 (diff)
downloadgcc-20305b5047e1c6ce55f47d6f4d6fa93970f752ec.zip
gcc-20305b5047e1c6ce55f47d6f4d6fa93970f752ec.tar.gz
gcc-20305b5047e1c6ce55f47d6f4d6fa93970f752ec.tar.bz2
re PR libfortran/79956 (many new -Wmaybe-uninitialized warnings with bootstrap-O3)
2017-03-15 Thomas Koenig <tkoenig@gcc.gnu.org> PR libfortran/79956 * libgfortran.h (GFC_ASSERT): New macro. * m4/reshape.m4 (reshape_'rtype_ccode`): Use GFC_ASSERT to specify that sdim > 0 and rdim > 0. * intrinsic/reshape_generic.c (reshape_internal): Likweise. * generated/reshape_c10.c: Regenerated. * generated/reshape_c16.c: Regenerated. * generated/reshape_c4.c: Regenerated. * generated/reshape_c8.c: Regenerated. * generated/reshape_i16.c: Regenerated. * generated/reshape_i4.c: Regenerated. * generated/reshape_i8.c: Regenerated. * generated/reshape_r10.c: Regenerated. * generated/reshape_r16.c: Regenerated. * generated/reshape_r4.c: Regenerated. * generated/reshape_r8.c: Regenerated. From-SVN: r246153
-rw-r--r--libgfortran/ChangeLog19
-rw-r--r--libgfortran/generated/reshape_c10.c9
-rw-r--r--libgfortran/generated/reshape_c16.c9
-rw-r--r--libgfortran/generated/reshape_c4.c9
-rw-r--r--libgfortran/generated/reshape_c8.c9
-rw-r--r--libgfortran/generated/reshape_i16.c9
-rw-r--r--libgfortran/generated/reshape_i4.c9
-rw-r--r--libgfortran/generated/reshape_i8.c9
-rw-r--r--libgfortran/generated/reshape_r10.c9
-rw-r--r--libgfortran/generated/reshape_r16.c9
-rw-r--r--libgfortran/generated/reshape_r4.c9
-rw-r--r--libgfortran/generated/reshape_r8.c9
-rw-r--r--libgfortran/intrinsics/reshape_generic.c12
-rw-r--r--libgfortran/libgfortran.h5
-rw-r--r--libgfortran/m4/reshape.m49
15 files changed, 144 insertions, 0 deletions
diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog
index c16b678..e670370 100644
--- a/libgfortran/ChangeLog
+++ b/libgfortran/ChangeLog
@@ -1,3 +1,22 @@
+2017-03-10 Thomas Koenig <tkoenig@gcc.gnu.org>
+
+ PR libfortran/79956
+ * libgfortran.h (GFC_ASSERT): New macro.
+ * m4/reshape.m4 (reshape_'rtype_ccode`): Use GFC_ASSERT
+ to specify that sdim > 0 and rdim > 0.
+ * intrinsic/reshape_generic.c (reshape_internal): Likweise.
+ * generated/reshape_c10.c: Regenerated.
+ * generated/reshape_c16.c: Regenerated.
+ * generated/reshape_c4.c: Regenerated.
+ * generated/reshape_c8.c: Regenerated.
+ * generated/reshape_i16.c: Regenerated.
+ * generated/reshape_i4.c: Regenerated.
+ * generated/reshape_i8.c: Regenerated.
+ * generated/reshape_r10.c: Regenerated.
+ * generated/reshape_r16.c: Regenerated.
+ * generated/reshape_r4.c: Regenerated.
+ * generated/reshape_r8.c: Regenerated.
+
2017-03-11 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR libgfortran/78854
diff --git a/libgfortran/generated/reshape_c10.c b/libgfortran/generated/reshape_c10.c
index 00c64ae..af45e96 100644
--- a/libgfortran/generated/reshape_c10.c
+++ b/libgfortran/generated/reshape_c10.c
@@ -78,6 +78,10 @@ reshape_c10 (gfc_array_c10 * const restrict ret,
index_type shape_data[GFC_MAX_DIMENSIONS];
rdim = GFC_DESCRIPTOR_EXTENT(shape,0);
+ /* rdim is always > 0; this lets the compiler optimize more and
+ avoids a potential warning. */
+ GFC_ASSERT(sdim>0);
+
if (rdim != GFC_DESCRIPTOR_RANK(ret))
runtime_error("rank of return array incorrect in RESHAPE intrinsic");
@@ -232,6 +236,11 @@ reshape_c10 (gfc_array_c10 * const restrict ret,
}
sdim = GFC_DESCRIPTOR_RANK (source);
+
+ /* sdim is always > 0; this lets the compiler optimize more and
+ avoids a warning. */
+ GFC_ASSERT(sdim>0);
+
ssize = 1;
sempty = 0;
for (n = 0; n < sdim; n++)
diff --git a/libgfortran/generated/reshape_c16.c b/libgfortran/generated/reshape_c16.c
index 4d90ce4..977a53d 100644
--- a/libgfortran/generated/reshape_c16.c
+++ b/libgfortran/generated/reshape_c16.c
@@ -78,6 +78,10 @@ reshape_c16 (gfc_array_c16 * const restrict ret,
index_type shape_data[GFC_MAX_DIMENSIONS];
rdim = GFC_DESCRIPTOR_EXTENT(shape,0);
+ /* rdim is always > 0; this lets the compiler optimize more and
+ avoids a potential warning. */
+ GFC_ASSERT(sdim>0);
+
if (rdim != GFC_DESCRIPTOR_RANK(ret))
runtime_error("rank of return array incorrect in RESHAPE intrinsic");
@@ -232,6 +236,11 @@ reshape_c16 (gfc_array_c16 * const restrict ret,
}
sdim = GFC_DESCRIPTOR_RANK (source);
+
+ /* sdim is always > 0; this lets the compiler optimize more and
+ avoids a warning. */
+ GFC_ASSERT(sdim>0);
+
ssize = 1;
sempty = 0;
for (n = 0; n < sdim; n++)
diff --git a/libgfortran/generated/reshape_c4.c b/libgfortran/generated/reshape_c4.c
index c696968..fd94689 100644
--- a/libgfortran/generated/reshape_c4.c
+++ b/libgfortran/generated/reshape_c4.c
@@ -78,6 +78,10 @@ reshape_c4 (gfc_array_c4 * const restrict ret,
index_type shape_data[GFC_MAX_DIMENSIONS];
rdim = GFC_DESCRIPTOR_EXTENT(shape,0);
+ /* rdim is always > 0; this lets the compiler optimize more and
+ avoids a potential warning. */
+ GFC_ASSERT(sdim>0);
+
if (rdim != GFC_DESCRIPTOR_RANK(ret))
runtime_error("rank of return array incorrect in RESHAPE intrinsic");
@@ -232,6 +236,11 @@ reshape_c4 (gfc_array_c4 * const restrict ret,
}
sdim = GFC_DESCRIPTOR_RANK (source);
+
+ /* sdim is always > 0; this lets the compiler optimize more and
+ avoids a warning. */
+ GFC_ASSERT(sdim>0);
+
ssize = 1;
sempty = 0;
for (n = 0; n < sdim; n++)
diff --git a/libgfortran/generated/reshape_c8.c b/libgfortran/generated/reshape_c8.c
index e7d9f9d..6377049 100644
--- a/libgfortran/generated/reshape_c8.c
+++ b/libgfortran/generated/reshape_c8.c
@@ -78,6 +78,10 @@ reshape_c8 (gfc_array_c8 * const restrict ret,
index_type shape_data[GFC_MAX_DIMENSIONS];
rdim = GFC_DESCRIPTOR_EXTENT(shape,0);
+ /* rdim is always > 0; this lets the compiler optimize more and
+ avoids a potential warning. */
+ GFC_ASSERT(sdim>0);
+
if (rdim != GFC_DESCRIPTOR_RANK(ret))
runtime_error("rank of return array incorrect in RESHAPE intrinsic");
@@ -232,6 +236,11 @@ reshape_c8 (gfc_array_c8 * const restrict ret,
}
sdim = GFC_DESCRIPTOR_RANK (source);
+
+ /* sdim is always > 0; this lets the compiler optimize more and
+ avoids a warning. */
+ GFC_ASSERT(sdim>0);
+
ssize = 1;
sempty = 0;
for (n = 0; n < sdim; n++)
diff --git a/libgfortran/generated/reshape_i16.c b/libgfortran/generated/reshape_i16.c
index bb5eb6b..65576a3 100644
--- a/libgfortran/generated/reshape_i16.c
+++ b/libgfortran/generated/reshape_i16.c
@@ -78,6 +78,10 @@ reshape_16 (gfc_array_i16 * const restrict ret,
index_type shape_data[GFC_MAX_DIMENSIONS];
rdim = GFC_DESCRIPTOR_EXTENT(shape,0);
+ /* rdim is always > 0; this lets the compiler optimize more and
+ avoids a potential warning. */
+ GFC_ASSERT(sdim>0);
+
if (rdim != GFC_DESCRIPTOR_RANK(ret))
runtime_error("rank of return array incorrect in RESHAPE intrinsic");
@@ -232,6 +236,11 @@ reshape_16 (gfc_array_i16 * const restrict ret,
}
sdim = GFC_DESCRIPTOR_RANK (source);
+
+ /* sdim is always > 0; this lets the compiler optimize more and
+ avoids a warning. */
+ GFC_ASSERT(sdim>0);
+
ssize = 1;
sempty = 0;
for (n = 0; n < sdim; n++)
diff --git a/libgfortran/generated/reshape_i4.c b/libgfortran/generated/reshape_i4.c
index 597b0cb..d07b3a9 100644
--- a/libgfortran/generated/reshape_i4.c
+++ b/libgfortran/generated/reshape_i4.c
@@ -78,6 +78,10 @@ reshape_4 (gfc_array_i4 * const restrict ret,
index_type shape_data[GFC_MAX_DIMENSIONS];
rdim = GFC_DESCRIPTOR_EXTENT(shape,0);
+ /* rdim is always > 0; this lets the compiler optimize more and
+ avoids a potential warning. */
+ GFC_ASSERT(sdim>0);
+
if (rdim != GFC_DESCRIPTOR_RANK(ret))
runtime_error("rank of return array incorrect in RESHAPE intrinsic");
@@ -232,6 +236,11 @@ reshape_4 (gfc_array_i4 * const restrict ret,
}
sdim = GFC_DESCRIPTOR_RANK (source);
+
+ /* sdim is always > 0; this lets the compiler optimize more and
+ avoids a warning. */
+ GFC_ASSERT(sdim>0);
+
ssize = 1;
sempty = 0;
for (n = 0; n < sdim; n++)
diff --git a/libgfortran/generated/reshape_i8.c b/libgfortran/generated/reshape_i8.c
index 53e35d2..f48728d 100644
--- a/libgfortran/generated/reshape_i8.c
+++ b/libgfortran/generated/reshape_i8.c
@@ -78,6 +78,10 @@ reshape_8 (gfc_array_i8 * const restrict ret,
index_type shape_data[GFC_MAX_DIMENSIONS];
rdim = GFC_DESCRIPTOR_EXTENT(shape,0);
+ /* rdim is always > 0; this lets the compiler optimize more and
+ avoids a potential warning. */
+ GFC_ASSERT(sdim>0);
+
if (rdim != GFC_DESCRIPTOR_RANK(ret))
runtime_error("rank of return array incorrect in RESHAPE intrinsic");
@@ -232,6 +236,11 @@ reshape_8 (gfc_array_i8 * const restrict ret,
}
sdim = GFC_DESCRIPTOR_RANK (source);
+
+ /* sdim is always > 0; this lets the compiler optimize more and
+ avoids a warning. */
+ GFC_ASSERT(sdim>0);
+
ssize = 1;
sempty = 0;
for (n = 0; n < sdim; n++)
diff --git a/libgfortran/generated/reshape_r10.c b/libgfortran/generated/reshape_r10.c
index 923174d..a5722d4 100644
--- a/libgfortran/generated/reshape_r10.c
+++ b/libgfortran/generated/reshape_r10.c
@@ -78,6 +78,10 @@ reshape_r10 (gfc_array_r10 * const restrict ret,
index_type shape_data[GFC_MAX_DIMENSIONS];
rdim = GFC_DESCRIPTOR_EXTENT(shape,0);
+ /* rdim is always > 0; this lets the compiler optimize more and
+ avoids a potential warning. */
+ GFC_ASSERT(sdim>0);
+
if (rdim != GFC_DESCRIPTOR_RANK(ret))
runtime_error("rank of return array incorrect in RESHAPE intrinsic");
@@ -232,6 +236,11 @@ reshape_r10 (gfc_array_r10 * const restrict ret,
}
sdim = GFC_DESCRIPTOR_RANK (source);
+
+ /* sdim is always > 0; this lets the compiler optimize more and
+ avoids a warning. */
+ GFC_ASSERT(sdim>0);
+
ssize = 1;
sempty = 0;
for (n = 0; n < sdim; n++)
diff --git a/libgfortran/generated/reshape_r16.c b/libgfortran/generated/reshape_r16.c
index 136d4f6..c56b871 100644
--- a/libgfortran/generated/reshape_r16.c
+++ b/libgfortran/generated/reshape_r16.c
@@ -78,6 +78,10 @@ reshape_r16 (gfc_array_r16 * const restrict ret,
index_type shape_data[GFC_MAX_DIMENSIONS];
rdim = GFC_DESCRIPTOR_EXTENT(shape,0);
+ /* rdim is always > 0; this lets the compiler optimize more and
+ avoids a potential warning. */
+ GFC_ASSERT(sdim>0);
+
if (rdim != GFC_DESCRIPTOR_RANK(ret))
runtime_error("rank of return array incorrect in RESHAPE intrinsic");
@@ -232,6 +236,11 @@ reshape_r16 (gfc_array_r16 * const restrict ret,
}
sdim = GFC_DESCRIPTOR_RANK (source);
+
+ /* sdim is always > 0; this lets the compiler optimize more and
+ avoids a warning. */
+ GFC_ASSERT(sdim>0);
+
ssize = 1;
sempty = 0;
for (n = 0; n < sdim; n++)
diff --git a/libgfortran/generated/reshape_r4.c b/libgfortran/generated/reshape_r4.c
index b73a968..889813c 100644
--- a/libgfortran/generated/reshape_r4.c
+++ b/libgfortran/generated/reshape_r4.c
@@ -78,6 +78,10 @@ reshape_r4 (gfc_array_r4 * const restrict ret,
index_type shape_data[GFC_MAX_DIMENSIONS];
rdim = GFC_DESCRIPTOR_EXTENT(shape,0);
+ /* rdim is always > 0; this lets the compiler optimize more and
+ avoids a potential warning. */
+ GFC_ASSERT(sdim>0);
+
if (rdim != GFC_DESCRIPTOR_RANK(ret))
runtime_error("rank of return array incorrect in RESHAPE intrinsic");
@@ -232,6 +236,11 @@ reshape_r4 (gfc_array_r4 * const restrict ret,
}
sdim = GFC_DESCRIPTOR_RANK (source);
+
+ /* sdim is always > 0; this lets the compiler optimize more and
+ avoids a warning. */
+ GFC_ASSERT(sdim>0);
+
ssize = 1;
sempty = 0;
for (n = 0; n < sdim; n++)
diff --git a/libgfortran/generated/reshape_r8.c b/libgfortran/generated/reshape_r8.c
index d35a8c9..279f89d 100644
--- a/libgfortran/generated/reshape_r8.c
+++ b/libgfortran/generated/reshape_r8.c
@@ -78,6 +78,10 @@ reshape_r8 (gfc_array_r8 * const restrict ret,
index_type shape_data[GFC_MAX_DIMENSIONS];
rdim = GFC_DESCRIPTOR_EXTENT(shape,0);
+ /* rdim is always > 0; this lets the compiler optimize more and
+ avoids a potential warning. */
+ GFC_ASSERT(sdim>0);
+
if (rdim != GFC_DESCRIPTOR_RANK(ret))
runtime_error("rank of return array incorrect in RESHAPE intrinsic");
@@ -232,6 +236,11 @@ reshape_r8 (gfc_array_r8 * const restrict ret,
}
sdim = GFC_DESCRIPTOR_RANK (source);
+
+ /* sdim is always > 0; this lets the compiler optimize more and
+ avoids a warning. */
+ GFC_ASSERT(sdim>0);
+
ssize = 1;
sempty = 0;
for (n = 0; n < sdim; n++)
diff --git a/libgfortran/intrinsics/reshape_generic.c b/libgfortran/intrinsics/reshape_generic.c
index 43a822f..09b0c36 100644
--- a/libgfortran/intrinsics/reshape_generic.c
+++ b/libgfortran/intrinsics/reshape_generic.c
@@ -66,6 +66,10 @@ reshape_internal (parray *ret, parray *source, shape_type *shape,
index_type shape_data[GFC_MAX_DIMENSIONS];
rdim = GFC_DESCRIPTOR_EXTENT(shape,0);
+ /* rdim is always > 0; this lets the compiler optimize more and
+ avoids a warning. */
+ GFC_ASSERT (rdim > 0);
+
if (rdim != GFC_DESCRIPTOR_RANK(ret))
runtime_error("rank of return array incorrect in RESHAPE intrinsic");
@@ -158,6 +162,10 @@ reshape_internal (parray *ret, parray *source, shape_type *shape,
source_extent = 1;
sdim = GFC_DESCRIPTOR_RANK (source);
+ /* sdim is always > 0; this lets the compiler optimize more and
+ avoids a warning. */
+ GFC_ASSERT(sdim>0);
+
for (n = 0; n < sdim; n++)
{
index_type se;
@@ -219,6 +227,10 @@ reshape_internal (parray *ret, parray *source, shape_type *shape,
}
sdim = GFC_DESCRIPTOR_RANK (source);
+ /* sdim is always > 0; this lets the compiler optimize more and
+ avoids a warning. */
+ GFC_ASSERT(sdim>0);
+
ssize = 1;
sempty = 0;
for (n = 0; n < sdim; n++)
diff --git a/libgfortran/libgfortran.h b/libgfortran/libgfortran.h
index cfe0476..cfa4fcf 100644
--- a/libgfortran/libgfortran.h
+++ b/libgfortran/libgfortran.h
@@ -111,6 +111,11 @@ typedef off_t gfc_offset;
#define likely(x) __builtin_expect(!!(x), 1)
#define unlikely(x) __builtin_expect(!!(x), 0)
+/* This macro can be used to annotate conditions which we know to
+ be true, so that the compiler can optimize based on the condition. */
+
+#define GFC_ASSERT(EXPR) \
+ ((void)(__builtin_expect (!(EXPR), 0) ? __builtin_unreachable (), 0 : 0))
/* Make sure we have ptrdiff_t. */
#ifndef HAVE_PTRDIFF_T
diff --git a/libgfortran/m4/reshape.m4 b/libgfortran/m4/reshape.m4
index 787844e..5ad1f13 100644
--- a/libgfortran/m4/reshape.m4
+++ b/libgfortran/m4/reshape.m4
@@ -82,6 +82,10 @@ reshape_'rtype_ccode` ('rtype` * const restrict ret,
index_type shape_data[GFC_MAX_DIMENSIONS];
rdim = GFC_DESCRIPTOR_EXTENT(shape,0);
+ /* rdim is always > 0; this lets the compiler optimize more and
+ avoids a potential warning. */
+ GFC_ASSERT(sdim>0);
+
if (rdim != GFC_DESCRIPTOR_RANK(ret))
runtime_error("rank of return array incorrect in RESHAPE intrinsic");
@@ -236,6 +240,11 @@ reshape_'rtype_ccode` ('rtype` * const restrict ret,
}
sdim = GFC_DESCRIPTOR_RANK (source);
+
+ /* sdim is always > 0; this lets the compiler optimize more and
+ avoids a warning. */
+ GFC_ASSERT(sdim>0);
+
ssize = 1;
sempty = 0;
for (n = 0; n < sdim; n++)