Hi!
I've backported a couple of patches to gcc-6-branch after
bootstrapping/regtesting them on x86_64-linux and i686-linux.
Jakub
2017-01-17 Jakub Jelinek <[email protected]>
Backported from mainline
2016-12-21 Jakub Jelinek <[email protected]>
PR fortran/78866
* openmp.c (resolve_omp_clauses): Diagnose assumed size arrays in
OpenMP map, to and from clauses.
* trans-openmp.c: Include diagnostic-core.h, temporarily redefining
GCC_DIAG_STYLE to __gcc_tdiag__.
(gfc_omp_finish_clause): Diagnose implicitly mapped assumed size
arrays.
* gfortran.dg/gomp/map-1.f90: Add expected error.
* gfortran.dg/gomp/pr78866-1.f90: New test.
* gfortran.dg/gomp/pr78866-2.f90: New test.
--- gcc/fortran/openmp.c (revision 243859)
+++ gcc/fortran/openmp.c (revision 243860)
@@ -3530,6 +3530,11 @@ resolve_omp_clauses (gfc_code *code, gfc
else
resolve_oacc_data_clauses (n->sym, n->where, name);
}
+ else if (list != OMP_CLAUSE_DEPEND
+ && n->sym->as
+ && n->sym->as->type == AS_ASSUMED_SIZE)
+ gfc_error ("Assumed size array %qs in %s clause at %L",
+ n->sym->name, name, &n->where);
}
if (list != OMP_LIST_DEPEND)
--- gcc/fortran/trans-openmp.c (revision 243859)
+++ gcc/fortran/trans-openmp.c (revision 243860)
@@ -37,6 +37,11 @@ along with GCC; see the file COPYING3.
#include "arith.h"
#include "omp-low.h"
#include "gomp-constants.h"
+#undef GCC_DIAG_STYLE
+#define GCC_DIAG_STYLE __gcc_tdiag__
+#include "diagnostic-core.h"
+#undef GCC_DIAG_STYLE
+#define GCC_DIAG_STYLE __gcc_gfc__
int ompws_flags;
@@ -1028,6 +1033,21 @@ gfc_omp_finish_clause (tree c, gimple_se
return;
tree decl = OMP_CLAUSE_DECL (c);
+
+ /* Assumed-size arrays can't be mapped implicitly, they have to be
+ mapped explicitly using array sections. */
+ if (TREE_CODE (decl) == PARM_DECL
+ && GFC_ARRAY_TYPE_P (TREE_TYPE (decl))
+ && GFC_TYPE_ARRAY_AKIND (TREE_TYPE (decl)) == GFC_ARRAY_UNKNOWN
+ && GFC_TYPE_ARRAY_UBOUND (TREE_TYPE (decl),
+ GFC_TYPE_ARRAY_RANK (TREE_TYPE (decl)) - 1)
+ == NULL)
+ {
+ error_at (OMP_CLAUSE_LOCATION (c),
+ "implicit mapping of assumed size array %qD", decl);
+ return;
+ }
+
tree c2 = NULL_TREE, c3 = NULL_TREE, c4 = NULL_TREE;
if (POINTER_TYPE_P (TREE_TYPE (decl)))
{
--- gcc/testsuite/gfortran.dg/gomp/pr78866-1.f90 (nonexistent)
+++ gcc/testsuite/gfortran.dg/gomp/pr78866-1.f90 (revision 243860)
@@ -0,0 +1,19 @@
+! PR fortran/78866
+! { dg-do compile }
+
+subroutine pr78866(x)
+ integer :: x(*)
+!$omp target map(x) ! { dg-error "Assumed size array" }
+ x(1) = 1
+!$omp end target
+!$omp target data map(tofrom: x) ! { dg-error "Assumed size array" }
+!$omp target update to(x) ! { dg-error "Assumed size array" }
+!$omp target update from(x) ! { dg-error "Assumed size array" }
+!$omp end target data
+!$omp target map(x(:23)) ! { dg-bogus "Assumed size array" }
+ x(1) = 1
+!$omp end target
+!$omp target map(x(:)) ! { dg-error "upper bound of assumed
size array section" }
+ x(1) = 1 ! { dg-error "not a proper array
section" "" { target *-*-* } .-1 }
+!$omp end target
+end
--- gcc/testsuite/gfortran.dg/gomp/pr78866-2.f90 (nonexistent)
+++ gcc/testsuite/gfortran.dg/gomp/pr78866-2.f90 (revision 243860)
@@ -0,0 +1,9 @@
+! PR fortran/78866
+! { dg-do compile }
+
+subroutine pr78866(x)
+ integer :: x(*)
+!$omp target ! { dg-error "implicit mapping of assumed size array" }
+ x(1) = 1
+!$omp end target
+end
--- gcc/testsuite/gfortran.dg/gomp/map-1.f90 (revision 243859)
+++ gcc/testsuite/gfortran.dg/gomp/map-1.f90 (revision 243860)
@@ -70,7 +70,7 @@ subroutine test(aas)
! { dg-error "Rightmost upper bound of assumed size array section not
specified" "" { target *-*-* } 68 }
! { dg-error "'aas' in MAP clause at \\\(1\\\) is not a proper array
section" "" { target *-*-* } 68 }
- !$omp target map(aas) ! { dg-error "The upper bound in the last dimension
must appear" "" { xfail *-*-* } }
+ !$omp target map(aas) ! { dg-error "Assumed size array" }
!$omp end target
!$omp target map(aas(5:7))
2017-01-17 Jakub Jelinek <[email protected]>
Backported from mainline
2017-01-04 Jakub Jelinek <[email protected]>
PR c++/71182
* parser.c (cp_lexer_previous_token): Use vec_safe_address in the
assertion, as lexer->buffer may be NULL.
* g++.dg/cpp0x/pr71182.C: New test.
--- gcc/cp/parser.c (revision 244069)
+++ gcc/cp/parser.c (revision 244070)
@@ -766,7 +766,7 @@ cp_lexer_previous_token (cp_lexer *lexer
/* Skip past purged tokens. */
while (tp->purged_p)
{
- gcc_assert (tp != lexer->buffer->address ());
+ gcc_assert (tp != vec_safe_address (lexer->buffer));
tp--;
}
--- gcc/testsuite/g++.dg/cpp0x/pr71182.C (nonexistent)
+++ gcc/testsuite/g++.dg/cpp0x/pr71182.C (revision 244070)
@@ -0,0 +1,12 @@
+// PR c++/71182
+// { dg-do compile { target c++11 } }
+
+class A {
+ template <typename> void As();
+};
+template <typename T> class B : A {
+ void f() {
+ A *g ;
+ g ? g->As<T>() : nullptr;
+ }
+};
2017-01-17 Jakub Jelinek <[email protected]>
Backported from mainline
2017-01-04 Jakub Jelinek <[email protected]>
PR c++/78693
* parser.c (cp_parser_simple_declaration): Only complain about
inconsistent auto deduction if auto_result doesn't use auto.
* g++.dg/cpp0x/pr78693.C: New test.
--- gcc/cp/parser.c (revision 244073)
+++ gcc/cp/parser.c (revision 244074)
@@ -12799,9 +12799,11 @@ cp_parser_simple_declaration (cp_parser*
}
}
- if (auto_result)
+ if (auto_result
+ && (!processing_template_decl || !type_uses_auto (auto_result)))
{
- if (last_type && last_type != error_mark_node
+ if (last_type
+ && last_type != error_mark_node
&& !same_type_p (auto_result, last_type))
{
/* If the list of declarators contains more than one declarator,
--- gcc/testsuite/g++.dg/cpp0x/pr78693.C (nonexistent)
+++ gcc/testsuite/g++.dg/cpp0x/pr78693.C (revision 244074)
@@ -0,0 +1,31 @@
+// PR c++/78693
+// { dg-do compile { target c++11 } }
+
+template <class T>
+void
+foo (T t)
+{
+ auto i = t, j = 1; // { dg-bogus "inconsistent deduction" }
+}
+
+template <class T>
+void
+bar (T t)
+{
+ auto i = 1, j = t, k = 2; // { dg-bogus "inconsistent deduction" }
+}
+
+template <class T, class U>
+void
+foo (T t, U u)
+{
+ auto i = t, j = u; // { dg-bogus "inconsistent deduction" }
+}
+
+void
+foo ()
+{
+ foo (0);
+ bar (0);
+ foo (1, 2);
+}
2017-01-17 Jakub Jelinek <[email protected]>
Backported from mainline
2017-01-04 Jakub Jelinek <[email protected]>
PR c++/78949
* typeck.c (cp_build_unary_op): Call mark_rvalue_use on arg if it has
vector type.
* c-c++-common/Wunused-var-16.c: New test.
--- gcc/cp/typeck.c (revision 244074)
+++ gcc/cp/typeck.c (revision 244075)
@@ -5848,6 +5848,8 @@ cp_build_unary_op (enum tree_code code,
errstring = _("wrong type argument to bit-complement");
else if (!noconvert && CP_INTEGRAL_TYPE_P (TREE_TYPE (arg)))
arg = cp_perform_integral_promotions (arg, complain);
+ else if (!noconvert && VECTOR_TYPE_P (TREE_TYPE (arg)))
+ arg = mark_rvalue_use (arg);
break;
case ABS_EXPR:
--- gcc/testsuite/c-c++-common/Wunused-var-16.c (nonexistent)
+++ gcc/testsuite/c-c++-common/Wunused-var-16.c (revision 244075)
@@ -0,0 +1,15 @@
+/* PR c++/78949 */
+/* { dg-do compile } */
+/* { dg-options "-Wunused" } */
+
+typedef unsigned char V __attribute__((vector_size(16)));
+V v;
+
+void
+foo ()
+{
+ V y = {};
+ V x = {}; // { dg-bogus "set but not used" }
+ y &= ~x;
+ v = y;
+}
2017-01-17 Jakub Jelinek <[email protected]>
Backported from mainline
2017-01-11 Jakub Jelinek <[email protected]>
PR middle-end/50199
* lto-lang.c (lto_post_options): Force flag_merge_constants = 1
if it was 0.
* gcc.dg/lto/pr50199_0.c: New test.
--- gcc/lto/lto-lang.c (revision 244303)
+++ gcc/lto/lto-lang.c (revision 244304)
@@ -857,6 +857,12 @@ lto_post_options (const char **pfilename
support. */
flag_excess_precision_cmdline = EXCESS_PRECISION_FAST;
+ /* When partitioning, we can tear appart STRING_CSTs uses from the same
+ TU into multiple partitions. Without constant merging the constants
+ might not be equal at runtime. See PR50199. */
+ if (!flag_merge_constants)
+ flag_merge_constants = 1;
+
/* Initialize the compiler back end. */
return false;
}
--- gcc/testsuite/gcc.dg/lto/pr50199_0.c (nonexistent)
+++ gcc/testsuite/gcc.dg/lto/pr50199_0.c (revision 244304)
@@ -0,0 +1,17 @@
+/* PR middle-end/50199 */
+/* { dg-lto-options {{-O2 -flto -fno-merge-constants
--param=lto-min-partition=1}} } */
+
+__attribute__ ((noinline)) const char *
+foo (const char *x)
+{
+ return x;
+}
+
+int
+main ()
+{
+ const char *a = "ab";
+ if (a != foo (a))
+ __builtin_abort ();
+ return 0;
+}
2017-01-17 Jakub Jelinek <[email protected]>
Backported from mainline
2017-01-11 Jakub Jelinek <[email protected]>
PR c++/78341
* parser.c (cp_parser_std_attribute_spec): Remove over-eager
assertion. Formatting fix.
* g++.dg/cpp0x/pr78341.C: New test.
--- gcc/cp/parser.c (revision 244328)
+++ gcc/cp/parser.c (revision 244329)
@@ -24925,11 +24925,7 @@ cp_parser_std_attribute_spec (cp_parser
if (!cp_parser_parse_definitely (parser))
{
- gcc_assert (alignas_expr == error_mark_node
- || alignas_expr == NULL_TREE);
-
- alignas_expr =
- cp_parser_assignment_expression (parser);
+ alignas_expr = cp_parser_assignment_expression (parser);
if (alignas_expr == error_mark_node)
cp_parser_skip_to_end_of_statement (parser);
if (alignas_expr == NULL_TREE
--- gcc/testsuite/g++.dg/cpp0x/pr78341.C (nonexistent)
+++ gcc/testsuite/g++.dg/cpp0x/pr78341.C (revision 244329)
@@ -0,0 +1,4 @@
+// PR c++/78341
+// { dg-do compile { target c++11 } }
+
+alignas (alignas double // { dg-error "" }
2017-01-17 Jakub Jelinek <[email protected]>
PR debug/78839
* dwarf2out.c (field_byte_offset): Restore the
PCC_BITFIELD_TYPE_MATTERS behavior for INTEGER_CST DECL_FIELD_OFFSET
and DECL_FIELD_BIT_OFFSET. Use fold_build2 instead of build2 + fold.
(analyze_variants_discr, gen_variant_part): Use fold_build2 instead
of build2 + fold.
--- gcc/dwarf2out.c (revision 244544)
+++ gcc/dwarf2out.c (revision 244545)
@@ -17980,10 +17980,6 @@ static dw_loc_descr_ref
field_byte_offset (const_tree decl, struct vlr_context *ctx,
HOST_WIDE_INT *cst_offset)
{
- offset_int object_offset_in_bits;
- offset_int object_offset_in_bytes;
- offset_int bitpos_int;
- bool is_byte_offset_cst, is_bit_offset_cst;
tree tree_result;
dw_loc_list_ref loc_result;
@@ -17994,20 +17990,21 @@ field_byte_offset (const_tree decl, stru
else
gcc_assert (TREE_CODE (decl) == FIELD_DECL);
- is_bit_offset_cst = TREE_CODE (DECL_FIELD_BIT_OFFSET (decl)) != INTEGER_CST;
- is_byte_offset_cst = TREE_CODE (DECL_FIELD_OFFSET (decl)) != INTEGER_CST;
-
/* We cannot handle variable bit offsets at the moment, so abort if it's the
case. */
- if (is_bit_offset_cst)
+ if (TREE_CODE (DECL_FIELD_BIT_OFFSET (decl)) != INTEGER_CST)
return NULL;
#ifdef PCC_BITFIELD_TYPE_MATTERS
/* We used to handle only constant offsets in all cases. Now, we handle
properly dynamic byte offsets only when PCC bitfield type doesn't
matter. */
- if (PCC_BITFIELD_TYPE_MATTERS && is_byte_offset_cst && is_bit_offset_cst)
+ if (PCC_BITFIELD_TYPE_MATTERS
+ && TREE_CODE (DECL_FIELD_OFFSET (decl)) == INTEGER_CST)
{
+ offset_int object_offset_in_bits;
+ offset_int object_offset_in_bytes;
+ offset_int bitpos_int;
tree type;
tree field_size_tree;
offset_int deepest_bitpos;
@@ -18102,13 +18099,23 @@ field_byte_offset (const_tree decl, stru
object_offset_in_bits
= round_up_to_align (object_offset_in_bits, decl_align_in_bits);
}
+
+ object_offset_in_bytes
+ = wi::lrshift (object_offset_in_bits, LOG2_BITS_PER_UNIT);
+ if (ctx->variant_part_offset == NULL_TREE)
+ {
+ *cst_offset = object_offset_in_bytes.to_shwi ();
+ return NULL;
+ }
+ tree_result = wide_int_to_tree (sizetype, object_offset_in_bytes);
}
+ else
#endif /* PCC_BITFIELD_TYPE_MATTERS */
+ tree_result = byte_position (decl);
- tree_result = byte_position (decl);
if (ctx->variant_part_offset != NULL_TREE)
- tree_result = fold (build2 (PLUS_EXPR, TREE_TYPE (tree_result),
- ctx->variant_part_offset, tree_result));
+ tree_result = fold_build2 (PLUS_EXPR, TREE_TYPE (tree_result),
+ ctx->variant_part_offset, tree_result);
/* If the byte offset is a constant, it's simplier to handle a native
constant rather than a DWARF expression. */
@@ -23744,14 +23751,12 @@ analyze_variants_discr (tree variant_par
if (!lower_cst_included)
lower_cst
- = fold (build2 (PLUS_EXPR, TREE_TYPE (lower_cst),
- lower_cst,
- build_int_cst (TREE_TYPE (lower_cst), 1)));
+ = fold_build2 (PLUS_EXPR, TREE_TYPE (lower_cst), lower_cst,
+ build_int_cst (TREE_TYPE (lower_cst), 1));
if (!upper_cst_included)
upper_cst
- = fold (build2 (MINUS_EXPR, TREE_TYPE (upper_cst),
- upper_cst,
- build_int_cst (TREE_TYPE (upper_cst), 1)));
+ = fold_build2 (MINUS_EXPR, TREE_TYPE (upper_cst), upper_cst,
+ build_int_cst (TREE_TYPE (upper_cst), 1));
if (!get_discr_value (lower_cst,
&new_node->dw_discr_lower_bound)
@@ -23922,8 +23927,8 @@ gen_variant_part (tree variant_part_decl
we recurse. */
vlr_sub_ctx.variant_part_offset
- = fold (build2 (PLUS_EXPR, TREE_TYPE (variant_part_offset),
- variant_part_offset, byte_position (member)));
+ = fold_build2 (PLUS_EXPR, TREE_TYPE (variant_part_offset),
+ variant_part_offset, byte_position (member));
gen_variant_part (member, &vlr_sub_ctx, variant_die);
}
else