Hi!

I've bootstrapped/regtested (x86_64-linux and i686-linux) and committed 
following
4 backports to gcc-7-branch:

        Jakub
2017-09-15  Jakub Jelinek  <ja...@redhat.com>

        Backported from mainline
        2017-09-12  Jakub Jelinek  <ja...@redhat.com>

        PR target/82112
        * c-common.c (sync_resolve_size): Instead of c_dialect_cxx ()
        assertion check that in the condition.
        (get_atomic_generic_size): Likewise.  Before testing if parameter
        has pointer type, if it has array type, call for C++
        default_conversion to perform array-to-pointer conversion.

        * c-c++-common/pr82112.c: New test.
        * gcc.dg/pr82112.c: New test.

--- gcc/c-family/c-common.c     (revision 252002)
+++ gcc/c-family/c-common.c     (revision 252003)
@@ -6478,10 +6478,9 @@ sync_resolve_size (tree function, vec<tr
     }
 
   argtype = type = TREE_TYPE ((*params)[0]);
-  if (TREE_CODE (type) == ARRAY_TYPE)
+  if (TREE_CODE (type) == ARRAY_TYPE && c_dialect_cxx ())
     {
       /* Force array-to-pointer decay for C++.  */
-      gcc_assert (c_dialect_cxx());
       (*params)[0] = default_conversion ((*params)[0]);
       type = TREE_TYPE ((*params)[0]);
     }
@@ -6646,10 +6645,9 @@ get_atomic_generic_size (location_t loc,
 
   /* Get type of first parameter, and determine its size.  */
   type_0 = TREE_TYPE ((*params)[0]);
-  if (TREE_CODE (type_0) == ARRAY_TYPE)
+  if (TREE_CODE (type_0) == ARRAY_TYPE && c_dialect_cxx ())
     {
       /* Force array-to-pointer decay for C++.  */
-      gcc_assert (c_dialect_cxx());
       (*params)[0] = default_conversion ((*params)[0]);
       type_0 = TREE_TYPE ((*params)[0]);
     }
@@ -6688,6 +6686,12 @@ get_atomic_generic_size (location_t loc,
       /* __atomic_compare_exchange has a bool in the 4th position, skip it.  */
       if (n_param == 6 && x == 3)
         continue;
+      if (TREE_CODE (type) == ARRAY_TYPE && c_dialect_cxx ())
+       {
+         /* Force array-to-pointer decay for C++.  */
+         (*params)[x] = default_conversion ((*params)[x]);
+         type = TREE_TYPE ((*params)[x]);
+       }
       if (!POINTER_TYPE_P (type))
        {
          error_at (loc, "argument %d of %qE must be a pointer type", x + 1,
--- gcc/testsuite/gcc.dg/pr82112.c      (nonexistent)
+++ gcc/testsuite/gcc.dg/pr82112.c      (revision 252003)
@@ -0,0 +1,21 @@
+/* PR target/82112 */
+/* { dg-do compile } */
+/* { dg-options "-std=gnu90" } */
+
+struct S { int a[10]; } bar (void);
+int b, c;
+
+void
+foo (void)
+{
+  __atomic_load (bar ().a, &b, __ATOMIC_ACQUIRE);      /* { dg-error "argument 
1 of .__atomic_load. must be a non-void pointer type" } */
+  __atomic_load (&b, bar ().a, __ATOMIC_ACQUIRE);      /* { dg-error "argument 
2 of .__atomic_load. must be a pointer type" } */
+  __atomic_store (bar ().a, &b, __ATOMIC_SEQ_CST);     /* { dg-error "argument 
1 of .__atomic_store. must be a non-void pointer type" } */
+  __atomic_store (&b, bar ().a, __ATOMIC_SEQ_CST);     /* { dg-error "argument 
2 of .__atomic_store. must be a pointer type" } */
+  __atomic_exchange (bar ().a, &b, &c, __ATOMIC_RELAXED);      /* { dg-error 
"argument 1 of .__atomic_exchange. must be a non-void pointer type" } */
+  __atomic_exchange (&b, bar ().a, &c, __ATOMIC_RELAXED);      /* { dg-error 
"argument 2 of .__atomic_exchange. must be a pointer type" } */
+  __atomic_exchange (&b, &c, bar ().a, __ATOMIC_RELAXED);      /* { dg-error 
"argument 3 of .__atomic_exchange. must be a pointer type" } */
+  __atomic_compare_exchange (bar ().a, &b, &c, 1, __ATOMIC_RELAXED, 
__ATOMIC_RELAXED); /* { dg-error "argument 1 of .__atomic_compare_exchange. 
must be a non-void pointer type" } */
+  __atomic_compare_exchange (&b, bar ().a, &c, 1, __ATOMIC_RELAXED, 
__ATOMIC_RELAXED); /* { dg-error "argument 2 of .__atomic_compare_exchange. 
must be a pointer type" } */
+  __atomic_compare_exchange (&b, &c, bar ().a, 1, __ATOMIC_RELAXED, 
__ATOMIC_RELAXED); /* { dg-error "argument 3 of .__atomic_compare_exchange. 
must be a pointer type" } */
+}
--- gcc/testsuite/c-c++-common/pr82112.c        (nonexistent)
+++ gcc/testsuite/c-c++-common/pr82112.c        (revision 252003)
@@ -0,0 +1,13 @@
+/* PR target/82112 */
+/* { dg-do compile } */
+
+int c[10], d[10], e[10], f[10], g[10], h[10], i[10], j[10], k[10], l[10];
+
+void
+foo (void)
+{
+  __atomic_load (c, d, __ATOMIC_ACQUIRE);
+  __atomic_store (e, f, __ATOMIC_SEQ_CST);
+  __atomic_exchange (g, h, i, __ATOMIC_RELAXED);
+  __atomic_compare_exchange (j, k, l, 1, __ATOMIC_RELAXED, __ATOMIC_RELAXED);
+}
2017-09-15  Jakub Jelinek  <ja...@redhat.com>

        Backported from mainline
        2017-09-12  Jakub Jelinek  <ja...@redhat.com>

        PR target/82112
        * config/rs6000/rs6000-c.c (altivec_resolve_overloaded_builtin): For
        ALTIVEC_BUILTIN_VEC_LD if arg1 has array type call default_conversion
        on it early, rather than manual conversion late.  For
        ALTIVEC_BUILTIN_VEC_ST if arg2 has array type call default_conversion
        instead of performing manual conversion.

        * gcc.target/powerpc/pr82112.c: New test.
        * g++.dg/ext/altivec-18.C: New test.

--- gcc/config/rs6000/rs6000-c.c        (revision 252027)
+++ gcc/config/rs6000/rs6000-c.c        (revision 252028)
@@ -6489,7 +6489,13 @@ altivec_resolve_overloaded_builtin (loca
 
       /* Strip qualifiers like "const" from the pointer arg.  */
       tree arg1_type = TREE_TYPE (arg1);
-      if (!POINTER_TYPE_P (arg1_type) && TREE_CODE (arg1_type) != ARRAY_TYPE)
+      if (TREE_CODE (arg1_type) == ARRAY_TYPE && c_dialect_cxx ())
+       {
+         /* Force array-to-pointer decay for C++.  */
+         arg1 = default_conversion (arg1);
+         arg1_type = TREE_TYPE (arg1);
+       }
+      if (!POINTER_TYPE_P (arg1_type))
        goto bad;
 
       tree inner_type = TREE_TYPE (arg1_type);
@@ -6509,15 +6515,6 @@ altivec_resolve_overloaded_builtin (loca
          if (!ptrofftype_p (TREE_TYPE (arg0)))
            arg0 = build1 (NOP_EXPR, sizetype, arg0);
 
-         tree arg1_type = TREE_TYPE (arg1);
-         if (TREE_CODE (arg1_type) == ARRAY_TYPE)
-           {
-             arg1_type = TYPE_POINTER_TO (TREE_TYPE (arg1_type));
-             tree const0 = build_int_cstu (sizetype, 0);
-             tree arg1_elt0 = build_array_ref (loc, arg1, const0);
-             arg1 = build1 (ADDR_EXPR, arg1_type, arg1_elt0);
-           }
-
          tree addr = fold_build2_loc (loc, POINTER_PLUS_EXPR, arg1_type,
                                       arg1, arg0);
          tree aligned = fold_build2_loc (loc, BIT_AND_EXPR, arg1_type, addr,
@@ -6572,12 +6569,11 @@ altivec_resolve_overloaded_builtin (loca
            arg1 = build1 (NOP_EXPR, sizetype, arg1);
 
          tree arg2_type = TREE_TYPE (arg2);
-         if (TREE_CODE (arg2_type) == ARRAY_TYPE)
+         if (TREE_CODE (arg2_type) == ARRAY_TYPE && c_dialect_cxx ())
            {
-             arg2_type = TYPE_POINTER_TO (TREE_TYPE (arg2_type));
-             tree const0 = build_int_cstu (sizetype, 0);
-             tree arg2_elt0 = build_array_ref (loc, arg2, const0);
-             arg2 = build1 (ADDR_EXPR, arg2_type, arg2_elt0);
+             /* Force array-to-pointer decay for C++.  */
+             arg2 = default_conversion (arg2);
+             arg2_type = TREE_TYPE (arg2);
            }
 
          /* Find the built-in to make sure a compatible one exists; if not
--- gcc/testsuite/gcc.target/powerpc/pr82112.c  (nonexistent)
+++ gcc/testsuite/gcc.target/powerpc/pr82112.c  (revision 252028)
@@ -0,0 +1,16 @@
+/* PR target/82112 */
+/* { dg-do compile } */
+/* { dg-require-effective-target powerpc_altivec_ok } */
+/* { dg-options "-maltivec -std=gnu90" } */
+
+#include <altivec.h>
+
+struct __attribute__((aligned (16))) S { unsigned char c[64]; } bar (void);
+vector unsigned char v;
+
+void
+foo (void)
+{
+  vec_ld (0, bar ().c);        /* { dg-error "invalid parameter combination 
for AltiVec intrinsic" } */
+  vec_st (v, 0, bar ().c);     /* { dg-error "invalid parameter combination 
for AltiVec intrinsic" } */
+}
--- gcc/testsuite/g++.dg/ext/altivec-18.C       (nonexistent)
+++ gcc/testsuite/g++.dg/ext/altivec-18.C       (revision 252028)
@@ -0,0 +1,14 @@
+// PR target/82112
+// { dg-do compile { target powerpc*-*-* } }
+// { dg-require-effective-target powerpc_altivec_ok }
+// { dg-options "-maltivec" }
+
+#include <altivec.h>
+
+__attribute__((aligned (16))) extern const unsigned char c[16];
+
+void
+foo (void)
+{
+  vec_ld (0, c);
+}
2017-09-15  Jakub Jelinek  <ja...@redhat.com>

        Backported from mainline
        2017-09-14  Jakub Jelinek  <ja...@redhat.com>
 
        PR target/81325
        * cfgbuild.c (find_bb_boundaries): Ignore debug insns in decisions
        if and where to split a bb, except for splitting before debug insn
        sequences followed by non-label real insn.  Delete debug insns
        in between basic blocks.

        * g++.dg/cpp0x/pr81325.C: New test.

--- gcc/cfgbuild.c      (revision 252751)
+++ gcc/cfgbuild.c      (revision 252752)
@@ -442,9 +442,10 @@ find_bb_boundaries (basic_block bb)
   rtx_insn *end = BB_END (bb), *x;
   rtx_jump_table_data *table;
   rtx_insn *flow_transfer_insn = NULL;
+  rtx_insn *debug_insn = NULL;
   edge fallthru = NULL;
 
-  if (insn == BB_END (bb))
+  if (insn == end)
     return;
 
   if (LABEL_P (insn))
@@ -455,27 +456,49 @@ find_bb_boundaries (basic_block bb)
     {
       enum rtx_code code = GET_CODE (insn);
 
+      if (code == DEBUG_INSN)
+       {
+         if (flow_transfer_insn && !debug_insn)
+           debug_insn = insn;
+       }
       /* In case we've previously seen an insn that effects a control
         flow transfer, split the block.  */
-      if ((flow_transfer_insn || code == CODE_LABEL)
-         && inside_basic_block_p (insn))
+      else if ((flow_transfer_insn || code == CODE_LABEL)
+              && inside_basic_block_p (insn))
        {
-         fallthru = split_block (bb, PREV_INSN (insn));
+         rtx_insn *prev = PREV_INSN (insn);
+
+         /* If the first non-debug inside_basic_block_p insn after a control
+            flow transfer is not a label, split the block before the debug
+            insn instead of before the non-debug insn, so that the debug
+            insns are not lost.  */
+         if (debug_insn && code != CODE_LABEL && code != BARRIER)
+           prev = PREV_INSN (debug_insn);
+         fallthru = split_block (bb, prev);
          if (flow_transfer_insn)
            {
              BB_END (bb) = flow_transfer_insn;
 
+             rtx_insn *next;
              /* Clean up the bb field for the insns between the blocks.  */
              for (x = NEXT_INSN (flow_transfer_insn);
                   x != BB_HEAD (fallthru->dest);
-                  x = NEXT_INSN (x))
-               if (!BARRIER_P (x))
-                 set_block_for_insn (x, NULL);
+                  x = next)
+               {
+                 next = NEXT_INSN (x);
+                 /* Debug insns should not be in between basic blocks,
+                    drop them on the floor.  */
+                 if (DEBUG_INSN_P (x))
+                   delete_insn (x);
+                 else if (!BARRIER_P (x))
+                   set_block_for_insn (x, NULL);
+               }
            }
 
          bb = fallthru->dest;
          remove_edge (fallthru);
          flow_transfer_insn = NULL;
+         debug_insn = NULL;
          if (code == CODE_LABEL && LABEL_ALT_ENTRY_P (insn))
            make_edge (ENTRY_BLOCK_PTR_FOR_FN (cfun), bb, 0);
        }
@@ -498,17 +521,23 @@ find_bb_boundaries (basic_block bb)
   /* In case expander replaced normal insn by sequence terminating by
      return and barrier, or possibly other sequence not behaving like
      ordinary jump, we need to take care and move basic block boundary.  */
-  if (flow_transfer_insn)
+  if (flow_transfer_insn && flow_transfer_insn != end)
     {
       BB_END (bb) = flow_transfer_insn;
 
       /* Clean up the bb field for the insns that do not belong to BB.  */
-      x = flow_transfer_insn;
-      while (x != end)
+      rtx_insn *next;
+      for (x = NEXT_INSN (flow_transfer_insn); ; x = next)
        {
-         x = NEXT_INSN (x);
-         if (!BARRIER_P (x))
+         next = NEXT_INSN (x);
+         /* Debug insns should not be in between basic blocks,
+            drop them on the floor.  */
+         if (DEBUG_INSN_P (x))
+           delete_insn (x);
+         else if (!BARRIER_P (x))
            set_block_for_insn (x, NULL);
+         if (x == end)
+           break;
        }
     }
 
--- gcc/testsuite/g++.dg/cpp0x/pr81325.C        (nonexistent)
+++ gcc/testsuite/g++.dg/cpp0x/pr81325.C        (revision 252752)
@@ -0,0 +1,84 @@
+// PR target/81325
+// { dg-do compile { target c++11 } }
+// { dg-options "-O2 -fcompare-debug" }
+
+struct A { A(const char *, const int & = 0); };
+template <typename> struct B;
+template <typename> struct C {
+  int _M_i;
+  void m_fn1() { __atomic_fetch_add(&_M_i, 0, __ATOMIC_RELAXED); }
+};
+struct D {
+  int *Data;
+  long Length = 0;
+  D(int) : Data() {}
+};
+template <> struct B<int> : C<int> {};
+struct F {
+  B<int> RefCount;
+  void m_fn2() { RefCount.m_fn1(); }
+};
+struct G {
+  F *Obj;
+  G(const G &p1) : Obj(p1.Obj) {
+    if (Obj) {
+      F *a = 0;
+      a->m_fn2();
+    }
+  }
+};
+struct H {
+  int CPlusPlus : 1;
+};
+struct I {
+  enum {} KindId;
+};
+template <typename ResultT, typename ArgT> struct J {
+  void operator()();
+  ResultT operator()(ArgT) {}
+};
+struct K {
+  int AllowBind;
+  I SupportedKind;
+  I RestrictKind;
+  G Implementation;
+};
+struct L {
+  L(int) : Implementation(Implementation) {}
+  K Implementation;
+};
+struct M {
+  int Param1;
+};
+struct N {
+  N(int, L &p2) : Param2(p2) {}
+  L Param2;
+};
+struct O {
+  L m_fn3();
+};
+L ignoringImpCasts(L);
+J<O, L> b;
+L hasName(const A &);
+M hasOverloadedOperatorName(D);
+J<O, int> c;
+struct P {
+  void m_fn4(L, int);
+};
+struct Q {
+  void m_fn5(P *);
+};
+H d;
+void Q::m_fn5(P *p1) {
+  if (!d.CPlusPlus) {
+    c();
+    L e = 0, f = ignoringImpCasts(e);
+    b(ignoringImpCasts(f)).m_fn3();
+  }
+  hasOverloadedOperatorName(0);
+  hasName("");
+  L g = 0;
+  N(0, g);
+  L h(0);
+  p1->m_fn4(h, 0);
+}
2017-09-15  Jakub Jelinek  <ja...@redhat.com>

        Backported from mainline
        2017-09-14  Jakub Jelinek  <ja...@redhat.com>

        PR c++/81314
        * cp-gimplify.c (omp_var_to_track): Look through references.
        (omp_cxx_notice_variable): Likewise.

        * testsuite/libgomp.c++/pr81314.C: New test.

--- gcc/cp/cp-gimplify.c        (revision 252769)
+++ gcc/cp/cp-gimplify.c        (revision 252770)
@@ -895,6 +895,8 @@ omp_var_to_track (tree decl)
   tree type = TREE_TYPE (decl);
   if (is_invisiref_parm (decl))
     type = TREE_TYPE (type);
+  else if (TREE_CODE (type) == REFERENCE_TYPE)
+    type = TREE_TYPE (type);
   while (TREE_CODE (type) == ARRAY_TYPE)
     type = TREE_TYPE (type);
   if (type == error_mark_node || !CLASS_TYPE_P (type))
@@ -947,6 +949,8 @@ omp_cxx_notice_variable (struct cp_gener
              tree type = TREE_TYPE (decl);
              if (is_invisiref_parm (decl))
                type = TREE_TYPE (type);
+             else if (TREE_CODE (type) == REFERENCE_TYPE)
+               type = TREE_TYPE (type);
              while (TREE_CODE (type) == ARRAY_TYPE)
                type = TREE_TYPE (type);
              get_copy_ctor (type, tf_none);
--- libgomp/testsuite/libgomp.c++/pr81314.C     (nonexistent)
+++ libgomp/testsuite/libgomp.c++/pr81314.C     (revision 252770)
@@ -0,0 +1,38 @@
+// PR c++/81314
+// { dg-do link }
+
+template <int N>
+struct S {
+  S () { s = 0; }
+  S (const S &x) { s = x.s; }
+  ~S () {}
+  int s;
+};
+
+void
+foo (S<2> &x)
+{
+  #pragma omp taskloop
+  for (int i = 0; i < 100; ++i)
+    x.s++;
+}
+
+void
+bar (S<3> &x)
+{
+  #pragma omp task
+  x.s++;
+}
+
+int
+main ()
+{
+  S<2> s;
+  S<3> t;
+  #pragma omp parallel
+  #pragma omp master
+  {
+    foo (s);
+    bar (t);
+  }
+}

Reply via email to