On Thu, May 25, 2023 at 2:32 AM naveenh--- via Gcc-patches <gcc-patches@gcc.gnu.org> wrote: > > From: Naveen H S <nave...@marvell.com> > > This patch adds support scalar_storage_order attribute to C++ front-end. > It treats the opposite order fields similar as the packed fields are > treated such that they will not bind to references. > For arrays, the attributes applies to the inner type rather than the array > type similar. The code is similar to how it is handled in the C front-end. > > 2021-04-03 Andrew Pinski <apin...@marvell.com> > > Co-authored-by: Naveen H S <nave...@marvell.com>
First off, sorry this was sent multiple times to the list, Naveen didn't know Marvell's internal email SMTP server was delaying the mail so much; he didn't realize it went through so he sent it again. I let him know next time to send it and come back in an hour to see if it made it through for next time. Ping? Thanks, Andrew > > gcc/ChangeLog: > > * c-family/c-attribs.cc (handle_scalar_storage_order_attribute): > Do not reject the C++ cases. > * cp/class.cc (layout_nonempty_base_or_field): Fix the type of > arrays in C++. > * cp/call.cc (reference_binding): Treat reversed field similar as > packed fields. > (build_temp): Likewise. > (convert_like_internal): Emit error code for non binding reversed > endian field. > * cp/cp-tree.h (clk_implicit_rval) : Add clk_reversed. > * cp/cp-tree.c (lvalue_kind) : Handle reverse storage ordered > operands. > > gcc/testsuite/ChangeLog: > > * c-c++-common/sso/dump.h: Move from gcc.dg/sso to c-c++-common/sso. > * c-c++-common/sso/init1.h: Likewise. > * c-c++-common/sso/init13.h: Likewise. > * c-c++-common/sso/init2.h: Likewise. > * c-c++-common/sso/init3.h: Likewise. > * c-c++-common/sso/init4.h: Likewise. > * c-c++-common/sso/init5.h: Likewise. > * c-c++-common/sso/init6.h: Likewise. > * c-c++-common/sso/init7.h: Likewise. > * c-c++-common/sso/init8.h: Likewise. > * c-c++-common/sso/init9.h: Likewise. > * c-c++-common/sso/p1.c: Likewise. > * c-c++-common/sso/p13.c: Likewise. > * c-c++-common/sso/p2.c: Likewise. > * c-c++-common/sso/p3.c: Likewise. > * c-c++-common/sso/p4.c: Likewise. > * c-c++-common/sso/p5.c: Likewise. > * c-c++-common/sso/p6.c: Likewise. > * c-c++-common/sso/p7.c: Likewise. > * c-c++-common/sso/p8.c: Likewise. > * c-c++-common/sso/p9.c: Likewise. > * c-c++-common/sso/q1.c: Likewise. > * c-c++-common/sso/q13.c: Likewise. > * c-c++-common/sso/q2.c: Likewise. > * c-c++-common/sso/q3.c: Likewise. > * c-c++-common/sso/q4.c: Likewise. > * c-c++-common/sso/q5.c: Likewise. > * c-c++-common/sso/q6.c: Likewise. > * c-c++-common/sso/q7.c: Likewise. > * c-c++-common/sso/q8.c: Likewise. > * c-c++-common/sso/q9.c: Likewise. > * c-c++-common/sso/r3.c: Likewise. > * c-c++-common/sso/r5.c: Likewise. > * c-c++-common/sso/r6.c: Likewise. > * c-c++-common/sso/r7.c: Likewise. > * c-c++-common/sso/r8.c: Likewise. > * c-c++-common/sso/s3.c: Likewise. > * c-c++-common/sso/s5.c: Likewise. > * c-c++-common/sso/s6.c: Likewise. > * c-c++-common/sso/s7.c: Likewise. > * c-c++-common/sso/s8.c: Likewise. > * c-c++-common/sso/t1.c: Likewise. > * c-c++-common/sso/t13.c: Likewise. > * c-c++-common/sso/t2.c: Likewise. > * c-c++-common/sso/t3.c: Likewise. > * c-c++-common/sso/t4.c: Likewise. > * c-c++-common/sso/t5.c: Likewise. > * c-c++-common/sso/t6.c: Likewise. > * c-c++-common/sso/t7.c: Likewise. > * c-c++-common/sso/t8.c: Likewise. > * c-c++-common/sso/t9.c: Likewise. > * c-c++-common/sso/u5.c: Likewise. > * c-c++-common/sso/t6.c: Likewise. > * g++.dg/sso/sso.exp: New file. > * g++.dg/sso/auto-1.C: New file. > * g++.dg/sso/auto-2.C: New file. > * g++.dg/sso/auto-3.C: New file. > * g++.dg/sso/template-reference-1.C: New file. > * g++.dg/sso/template-reference-2.C: New file. > * g++.dg/sso/template-reference-3.C: New file. > * g++.dg/sso/template-reference-4.C: New file. > * g++.dg/sso-1.C: Modified. > --- > gcc/c-family/c-attribs.cc | 2 +- > gcc/cp/call.cc | 17 ++++++- > gcc/cp/class.cc | 22 ++++++++++ > gcc/cp/cp-tree.h | 3 +- > gcc/cp/tree.cc | 5 ++- > .../{gcc.dg => c-c++-common}/sso/dump.h | 0 > .../{gcc.dg => c-c++-common}/sso/init1.h | 0 > .../{gcc.dg => c-c++-common}/sso/init13.h | 0 > .../{gcc.dg => c-c++-common}/sso/init2.h | 0 > .../{gcc.dg => c-c++-common}/sso/init3.h | 0 > .../{gcc.dg => c-c++-common}/sso/init4.h | 0 > .../{gcc.dg => c-c++-common}/sso/init5.h | 0 > .../{gcc.dg => c-c++-common}/sso/init6.h | 0 > .../{gcc.dg => c-c++-common}/sso/init7.h | 0 > .../{gcc.dg => c-c++-common}/sso/init8.h | 0 > .../{gcc.dg => c-c++-common}/sso/init9.h | 0 > .../{gcc.dg => c-c++-common}/sso/p1.c | 0 > .../{gcc.dg => c-c++-common}/sso/p13.c | 1 + > .../{gcc.dg => c-c++-common}/sso/p2.c | 0 > .../{gcc.dg => c-c++-common}/sso/p3.c | 0 > .../{gcc.dg => c-c++-common}/sso/p4.c | 0 > .../{gcc.dg => c-c++-common}/sso/p5.c | 0 > .../{gcc.dg => c-c++-common}/sso/p6.c | 0 > .../{gcc.dg => c-c++-common}/sso/p7.c | 0 > .../{gcc.dg => c-c++-common}/sso/p8.c | 0 > .../{gcc.dg => c-c++-common}/sso/p9.c | 0 > .../{gcc.dg => c-c++-common}/sso/q1.c | 0 > .../{gcc.dg => c-c++-common}/sso/q13.c | 1 + > .../{gcc.dg => c-c++-common}/sso/q2.c | 0 > .../{gcc.dg => c-c++-common}/sso/q3.c | 0 > .../{gcc.dg => c-c++-common}/sso/q4.c | 0 > .../{gcc.dg => c-c++-common}/sso/q5.c | 0 > .../{gcc.dg => c-c++-common}/sso/q6.c | 0 > .../{gcc.dg => c-c++-common}/sso/q7.c | 0 > .../{gcc.dg => c-c++-common}/sso/q8.c | 0 > .../{gcc.dg => c-c++-common}/sso/q9.c | 0 > .../{gcc.dg => c-c++-common}/sso/r3.c | 0 > .../{gcc.dg => c-c++-common}/sso/r5.c | 0 > .../{gcc.dg => c-c++-common}/sso/r6.c | 0 > .../{gcc.dg => c-c++-common}/sso/r7.c | 0 > .../{gcc.dg => c-c++-common}/sso/r8.c | 0 > .../{gcc.dg => c-c++-common}/sso/s3.c | 0 > .../{gcc.dg => c-c++-common}/sso/s5.c | 0 > .../{gcc.dg => c-c++-common}/sso/s6.c | 0 > .../{gcc.dg => c-c++-common}/sso/s7.c | 0 > .../{gcc.dg => c-c++-common}/sso/s8.c | 0 > .../{gcc.dg => c-c++-common}/sso/t1.c | 0 > .../{gcc.dg => c-c++-common}/sso/t13.c | 1 + > .../{gcc.dg => c-c++-common}/sso/t2.c | 0 > .../{gcc.dg => c-c++-common}/sso/t3.c | 0 > .../{gcc.dg => c-c++-common}/sso/t4.c | 0 > .../{gcc.dg => c-c++-common}/sso/t5.c | 0 > .../{gcc.dg => c-c++-common}/sso/t6.c | 0 > .../{gcc.dg => c-c++-common}/sso/t7.c | 0 > .../{gcc.dg => c-c++-common}/sso/t8.c | 0 > .../{gcc.dg => c-c++-common}/sso/t9.c | 0 > .../{gcc.dg => c-c++-common}/sso/u5.c | 0 > .../{gcc.dg => c-c++-common}/sso/u6.c | 0 > gcc/testsuite/g++.dg/sso-1.C | 2 +- > gcc/testsuite/g++.dg/sso/auto-1.C | 17 +++++++ > gcc/testsuite/g++.dg/sso/auto-2.C | 17 +++++++ > gcc/testsuite/g++.dg/sso/auto-3.C | 17 +++++++ > gcc/testsuite/g++.dg/sso/sso.exp | 44 +++++++++++++++++++ > .../g++.dg/sso/template-reference-1.C | 19 ++++++++ > .../g++.dg/sso/template-reference-2.C | 19 ++++++++ > .../g++.dg/sso/template-reference-3.C | 19 ++++++++ > .../g++.dg/sso/template-reference-4.C | 19 ++++++++ > gcc/testsuite/gcc.dg/sso/sso.exp | 2 +- > 68 files changed, 220 insertions(+), 7 deletions(-) > rename gcc/testsuite/{gcc.dg => c-c++-common}/sso/dump.h (100%) > rename gcc/testsuite/{gcc.dg => c-c++-common}/sso/init1.h (100%) > rename gcc/testsuite/{gcc.dg => c-c++-common}/sso/init13.h (100%) > rename gcc/testsuite/{gcc.dg => c-c++-common}/sso/init2.h (100%) > rename gcc/testsuite/{gcc.dg => c-c++-common}/sso/init3.h (100%) > rename gcc/testsuite/{gcc.dg => c-c++-common}/sso/init4.h (100%) > rename gcc/testsuite/{gcc.dg => c-c++-common}/sso/init5.h (100%) > rename gcc/testsuite/{gcc.dg => c-c++-common}/sso/init6.h (100%) > rename gcc/testsuite/{gcc.dg => c-c++-common}/sso/init7.h (100%) > rename gcc/testsuite/{gcc.dg => c-c++-common}/sso/init8.h (100%) > rename gcc/testsuite/{gcc.dg => c-c++-common}/sso/init9.h (100%) > rename gcc/testsuite/{gcc.dg => c-c++-common}/sso/p1.c (100%) > rename gcc/testsuite/{gcc.dg => c-c++-common}/sso/p13.c (95%) > rename gcc/testsuite/{gcc.dg => c-c++-common}/sso/p2.c (100%) > rename gcc/testsuite/{gcc.dg => c-c++-common}/sso/p3.c (100%) > rename gcc/testsuite/{gcc.dg => c-c++-common}/sso/p4.c (100%) > rename gcc/testsuite/{gcc.dg => c-c++-common}/sso/p5.c (100%) > rename gcc/testsuite/{gcc.dg => c-c++-common}/sso/p6.c (100%) > rename gcc/testsuite/{gcc.dg => c-c++-common}/sso/p7.c (100%) > rename gcc/testsuite/{gcc.dg => c-c++-common}/sso/p8.c (100%) > rename gcc/testsuite/{gcc.dg => c-c++-common}/sso/p9.c (100%) > rename gcc/testsuite/{gcc.dg => c-c++-common}/sso/q1.c (100%) > rename gcc/testsuite/{gcc.dg => c-c++-common}/sso/q13.c (92%) > rename gcc/testsuite/{gcc.dg => c-c++-common}/sso/q2.c (100%) > rename gcc/testsuite/{gcc.dg => c-c++-common}/sso/q3.c (100%) > rename gcc/testsuite/{gcc.dg => c-c++-common}/sso/q4.c (100%) > rename gcc/testsuite/{gcc.dg => c-c++-common}/sso/q5.c (100%) > rename gcc/testsuite/{gcc.dg => c-c++-common}/sso/q6.c (100%) > rename gcc/testsuite/{gcc.dg => c-c++-common}/sso/q7.c (100%) > rename gcc/testsuite/{gcc.dg => c-c++-common}/sso/q8.c (100%) > rename gcc/testsuite/{gcc.dg => c-c++-common}/sso/q9.c (100%) > rename gcc/testsuite/{gcc.dg => c-c++-common}/sso/r3.c (100%) > rename gcc/testsuite/{gcc.dg => c-c++-common}/sso/r5.c (100%) > rename gcc/testsuite/{gcc.dg => c-c++-common}/sso/r6.c (100%) > rename gcc/testsuite/{gcc.dg => c-c++-common}/sso/r7.c (100%) > rename gcc/testsuite/{gcc.dg => c-c++-common}/sso/r8.c (100%) > rename gcc/testsuite/{gcc.dg => c-c++-common}/sso/s3.c (100%) > rename gcc/testsuite/{gcc.dg => c-c++-common}/sso/s5.c (100%) > rename gcc/testsuite/{gcc.dg => c-c++-common}/sso/s6.c (100%) > rename gcc/testsuite/{gcc.dg => c-c++-common}/sso/s7.c (100%) > rename gcc/testsuite/{gcc.dg => c-c++-common}/sso/s8.c (100%) > rename gcc/testsuite/{gcc.dg => c-c++-common}/sso/t1.c (100%) > rename gcc/testsuite/{gcc.dg => c-c++-common}/sso/t13.c (94%) > rename gcc/testsuite/{gcc.dg => c-c++-common}/sso/t2.c (100%) > rename gcc/testsuite/{gcc.dg => c-c++-common}/sso/t3.c (100%) > rename gcc/testsuite/{gcc.dg => c-c++-common}/sso/t4.c (100%) > rename gcc/testsuite/{gcc.dg => c-c++-common}/sso/t5.c (100%) > rename gcc/testsuite/{gcc.dg => c-c++-common}/sso/t6.c (100%) > rename gcc/testsuite/{gcc.dg => c-c++-common}/sso/t7.c (100%) > rename gcc/testsuite/{gcc.dg => c-c++-common}/sso/t8.c (100%) > rename gcc/testsuite/{gcc.dg => c-c++-common}/sso/t9.c (100%) > rename gcc/testsuite/{gcc.dg => c-c++-common}/sso/u5.c (100%) > rename gcc/testsuite/{gcc.dg => c-c++-common}/sso/u6.c (100%) > create mode 100644 gcc/testsuite/g++.dg/sso/auto-1.C > create mode 100644 gcc/testsuite/g++.dg/sso/auto-2.C > create mode 100644 gcc/testsuite/g++.dg/sso/auto-3.C > create mode 100644 gcc/testsuite/g++.dg/sso/sso.exp > create mode 100644 gcc/testsuite/g++.dg/sso/template-reference-1.C > create mode 100644 gcc/testsuite/g++.dg/sso/template-reference-2.C > create mode 100644 gcc/testsuite/g++.dg/sso/template-reference-3.C > create mode 100644 gcc/testsuite/g++.dg/sso/template-reference-4.C > > diff --git a/gcc/c-family/c-attribs.cc b/gcc/c-family/c-attribs.cc > index 072cfb69147..8ae48166f62 100644 > --- a/gcc/c-family/c-attribs.cc > +++ b/gcc/c-family/c-attribs.cc > @@ -1794,7 +1794,7 @@ handle_scalar_storage_order_attribute (tree *node, tree > name, tree args, > return NULL_TREE; > } > > - if (RECORD_OR_UNION_TYPE_P (type) && !c_dialect_cxx ()) > + if (RECORD_OR_UNION_TYPE_P (type)) > { > bool reverse = false; > > diff --git a/gcc/cp/call.cc b/gcc/cp/call.cc > index 2736f55f229..c3804bc48c4 100644 > --- a/gcc/cp/call.cc > +++ b/gcc/cp/call.cc > @@ -1862,7 +1862,8 @@ reference_binding (tree rto, tree rfrom, tree expr, > bool c_cast_p, int flags, > = (TYPE_REF_IS_RVALUE (rto) == !is_lvalue); > > if ((gl_kind & clk_bitfield) != 0 > - || ((gl_kind & clk_packed) != 0 && !TYPE_PACKED (to))) > + || ((gl_kind & clk_packed) != 0 && !TYPE_PACKED (to)) > + || (gl_kind & clk_reversed) != 0) > /* For the purposes of overload resolution, we ignore the fact > this expression is a bitfield or packed field. (In particular, > [over.ics.ref] says specifically that a function with a > @@ -8084,7 +8085,8 @@ build_temp (tree expr, tree type, int flags, > binding the field to the reference parameter to the copy constructor, > and > we'll end up with an infinite loop. If we can use a bitwise copy, then > do that now. */ > - if ((lvalue_kind (expr) & clk_packed) > + if (((lvalue_kind (expr) & clk_packed) > + || (lvalue_kind (expr) & clk_reversed)) > && CLASS_TYPE_P (TREE_TYPE (expr)) > && !type_has_nontrivial_copy_init (TREE_TYPE (expr))) > return get_target_expr (expr, complain); > @@ -8781,6 +8783,9 @@ convert_like_internal (conversion *convs, tree expr, > tree fn, int argnum, > else if (lvalue & clk_packed) > error_at (loc, "cannot bind packed field %qE to %qT", > expr, ref_type); > + else if (lvalue & clk_reversed) > + error_at (loc, "cannot bind reversed endian field %qE > to %qT", > + expr, ref_type); > else > error_at (loc, "cannot bind rvalue %qE to %qT", > expr, ref_type); > @@ -8801,6 +8806,14 @@ convert_like_internal (conversion *convs, tree expr, > tree fn, int argnum, > expr, ref_type); > return error_mark_node; > } > + if ((lvalue & clk_reversed) > + && CLASS_TYPE_P (type) > + && type_has_nontrivial_copy_init (type)) > + { > + error_at (loc, "cannot bind reversed endian field %qE to %qT", > + expr, ref_type); > + return error_mark_node; > + } > if (lvalue & clk_bitfield) > { > expr = convert_bitfield_to_declared_type (expr); > diff --git a/gcc/cp/class.cc b/gcc/cp/class.cc > index bc84f4f731a..7537bf640f3 100644 > --- a/gcc/cp/class.cc > +++ b/gcc/cp/class.cc > @@ -4387,6 +4387,28 @@ layout_nonempty_base_or_field (record_layout_info rli, > field_p = true; > } > > + /* Rewrite the type of array fields with scalar component > + if the enclosing type has reverse storage order */ > + if (TYPE_REVERSE_STORAGE_ORDER (rli->t) > + && TREE_CODE (decl) == FIELD_DECL > + && TREE_CODE (TREE_TYPE (decl)) == ARRAY_TYPE) > + { > + tree ftype = TREE_TYPE (decl); > + tree ctype = strip_array_types (ftype); > + if (!RECORD_OR_UNION_TYPE_P (ctype) && TYPE_MODE (ctype) != QImode) > + { > + tree fmain_type = TYPE_MAIN_VARIANT (ftype); > + tree *typep = &fmain_type; > + do { > + *typep = build_distinct_type_copy (*typep); > + TYPE_REVERSE_STORAGE_ORDER (*typep) = 1; > + typep = &TREE_TYPE (*typep); > + } while (TREE_CODE (*typep) == ARRAY_TYPE); > + TREE_TYPE (decl) > + = cp_build_qualified_type (fmain_type, TYPE_QUALS (ftype)); > + } > + } > + > /* Try to place the field. It may take more than one try if we have > a hard time placing the field without putting two objects of the > same type at the same address. */ > diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h > index a1b882f11fe..ae5d0bf7ebe 100644 > --- a/gcc/cp/cp-tree.h > +++ b/gcc/cp/cp-tree.h > @@ -5464,7 +5464,8 @@ enum cp_lvalue_kind_flags { > clk_class = 4, /* A prvalue of class or array type. */ > clk_bitfield = 8, /* An lvalue for a bit-field. */ > clk_packed = 16, /* An lvalue for a packed field. */ > - clk_implicit_rval = 1<<5 /* An lvalue being treated as an xvalue. */ > + clk_implicit_rval = 1<<5, /* An lvalue being treated as an xvalue. */ > + clk_reversed = 1<<6 /* An lvalue for a reversed field. */ > }; > > /* This type is used for parameters and variables which hold > diff --git a/gcc/cp/tree.cc b/gcc/cp/tree.cc > index 19dfb3ed782..5384bc9ef07 100644 > --- a/gcc/cp/tree.cc > +++ b/gcc/cp/tree.cc > @@ -186,6 +186,9 @@ lvalue_kind (const_tree ref) > } > else if (DECL_PACKED (TREE_OPERAND (ref, 1))) > op1_lvalue_kind |= clk_packed; > + else if (AGGREGATE_TYPE_P (TREE_TYPE (TREE_OPERAND (ref, 0))) > + && TYPE_REVERSE_STORAGE_ORDER (TREE_TYPE (TREE_OPERAND (ref, > 0)))) > + op1_lvalue_kind |= clk_reversed; > > return op1_lvalue_kind; > > @@ -342,7 +345,7 @@ lvalue_kind (const_tree ref) > /* It can't be both a pseudo-lvalue and a non-addressable lvalue. > A COND_EXPR of those should be wrapped in a TARGET_EXPR. */ > if ((op1_lvalue_kind & (clk_rvalueref|clk_class)) > - && (op1_lvalue_kind & (clk_bitfield|clk_packed))) > + && (op1_lvalue_kind & (clk_bitfield|clk_packed|clk_reversed))) > op1_lvalue_kind = clk_none; > return op1_lvalue_kind; > } > diff --git a/gcc/testsuite/gcc.dg/sso/dump.h > b/gcc/testsuite/c-c++-common/sso/dump.h > similarity index 100% > rename from gcc/testsuite/gcc.dg/sso/dump.h > rename to gcc/testsuite/c-c++-common/sso/dump.h > diff --git a/gcc/testsuite/gcc.dg/sso/init1.h > b/gcc/testsuite/c-c++-common/sso/init1.h > similarity index 100% > rename from gcc/testsuite/gcc.dg/sso/init1.h > rename to gcc/testsuite/c-c++-common/sso/init1.h > diff --git a/gcc/testsuite/gcc.dg/sso/init13.h > b/gcc/testsuite/c-c++-common/sso/init13.h > similarity index 100% > rename from gcc/testsuite/gcc.dg/sso/init13.h > rename to gcc/testsuite/c-c++-common/sso/init13.h > diff --git a/gcc/testsuite/gcc.dg/sso/init2.h > b/gcc/testsuite/c-c++-common/sso/init2.h > similarity index 100% > rename from gcc/testsuite/gcc.dg/sso/init2.h > rename to gcc/testsuite/c-c++-common/sso/init2.h > diff --git a/gcc/testsuite/gcc.dg/sso/init3.h > b/gcc/testsuite/c-c++-common/sso/init3.h > similarity index 100% > rename from gcc/testsuite/gcc.dg/sso/init3.h > rename to gcc/testsuite/c-c++-common/sso/init3.h > diff --git a/gcc/testsuite/gcc.dg/sso/init4.h > b/gcc/testsuite/c-c++-common/sso/init4.h > similarity index 100% > rename from gcc/testsuite/gcc.dg/sso/init4.h > rename to gcc/testsuite/c-c++-common/sso/init4.h > diff --git a/gcc/testsuite/gcc.dg/sso/init5.h > b/gcc/testsuite/c-c++-common/sso/init5.h > similarity index 100% > rename from gcc/testsuite/gcc.dg/sso/init5.h > rename to gcc/testsuite/c-c++-common/sso/init5.h > diff --git a/gcc/testsuite/gcc.dg/sso/init6.h > b/gcc/testsuite/c-c++-common/sso/init6.h > similarity index 100% > rename from gcc/testsuite/gcc.dg/sso/init6.h > rename to gcc/testsuite/c-c++-common/sso/init6.h > diff --git a/gcc/testsuite/gcc.dg/sso/init7.h > b/gcc/testsuite/c-c++-common/sso/init7.h > similarity index 100% > rename from gcc/testsuite/gcc.dg/sso/init7.h > rename to gcc/testsuite/c-c++-common/sso/init7.h > diff --git a/gcc/testsuite/gcc.dg/sso/init8.h > b/gcc/testsuite/c-c++-common/sso/init8.h > similarity index 100% > rename from gcc/testsuite/gcc.dg/sso/init8.h > rename to gcc/testsuite/c-c++-common/sso/init8.h > diff --git a/gcc/testsuite/gcc.dg/sso/init9.h > b/gcc/testsuite/c-c++-common/sso/init9.h > similarity index 100% > rename from gcc/testsuite/gcc.dg/sso/init9.h > rename to gcc/testsuite/c-c++-common/sso/init9.h > diff --git a/gcc/testsuite/gcc.dg/sso/p1.c > b/gcc/testsuite/c-c++-common/sso/p1.c > similarity index 100% > rename from gcc/testsuite/gcc.dg/sso/p1.c > rename to gcc/testsuite/c-c++-common/sso/p1.c > diff --git a/gcc/testsuite/gcc.dg/sso/p13.c > b/gcc/testsuite/c-c++-common/sso/p13.c > similarity index 95% > rename from gcc/testsuite/gcc.dg/sso/p13.c > rename to gcc/testsuite/c-c++-common/sso/p13.c > index 33af5027bd6..b7ec935e69f 100644 > --- a/gcc/testsuite/gcc.dg/sso/p13.c > +++ b/gcc/testsuite/c-c++-common/sso/p13.c > @@ -1,4 +1,5 @@ > /* { dg-do run } */ > +/* { dg-additional-options "-fext-numeric-literals" { target c++ } } */ > > #include <stdio.h> > > diff --git a/gcc/testsuite/gcc.dg/sso/p2.c > b/gcc/testsuite/c-c++-common/sso/p2.c > similarity index 100% > rename from gcc/testsuite/gcc.dg/sso/p2.c > rename to gcc/testsuite/c-c++-common/sso/p2.c > diff --git a/gcc/testsuite/gcc.dg/sso/p3.c > b/gcc/testsuite/c-c++-common/sso/p3.c > similarity index 100% > rename from gcc/testsuite/gcc.dg/sso/p3.c > rename to gcc/testsuite/c-c++-common/sso/p3.c > diff --git a/gcc/testsuite/gcc.dg/sso/p4.c > b/gcc/testsuite/c-c++-common/sso/p4.c > similarity index 100% > rename from gcc/testsuite/gcc.dg/sso/p4.c > rename to gcc/testsuite/c-c++-common/sso/p4.c > diff --git a/gcc/testsuite/gcc.dg/sso/p5.c > b/gcc/testsuite/c-c++-common/sso/p5.c > similarity index 100% > rename from gcc/testsuite/gcc.dg/sso/p5.c > rename to gcc/testsuite/c-c++-common/sso/p5.c > diff --git a/gcc/testsuite/gcc.dg/sso/p6.c > b/gcc/testsuite/c-c++-common/sso/p6.c > similarity index 100% > rename from gcc/testsuite/gcc.dg/sso/p6.c > rename to gcc/testsuite/c-c++-common/sso/p6.c > diff --git a/gcc/testsuite/gcc.dg/sso/p7.c > b/gcc/testsuite/c-c++-common/sso/p7.c > similarity index 100% > rename from gcc/testsuite/gcc.dg/sso/p7.c > rename to gcc/testsuite/c-c++-common/sso/p7.c > diff --git a/gcc/testsuite/gcc.dg/sso/p8.c > b/gcc/testsuite/c-c++-common/sso/p8.c > similarity index 100% > rename from gcc/testsuite/gcc.dg/sso/p8.c > rename to gcc/testsuite/c-c++-common/sso/p8.c > diff --git a/gcc/testsuite/gcc.dg/sso/p9.c > b/gcc/testsuite/c-c++-common/sso/p9.c > similarity index 100% > rename from gcc/testsuite/gcc.dg/sso/p9.c > rename to gcc/testsuite/c-c++-common/sso/p9.c > diff --git a/gcc/testsuite/gcc.dg/sso/q1.c > b/gcc/testsuite/c-c++-common/sso/q1.c > similarity index 100% > rename from gcc/testsuite/gcc.dg/sso/q1.c > rename to gcc/testsuite/c-c++-common/sso/q1.c > diff --git a/gcc/testsuite/gcc.dg/sso/q13.c > b/gcc/testsuite/c-c++-common/sso/q13.c > similarity index 92% > rename from gcc/testsuite/gcc.dg/sso/q13.c > rename to gcc/testsuite/c-c++-common/sso/q13.c > index cacc2a9860b..0cbf268d503 100644 > --- a/gcc/testsuite/gcc.dg/sso/q13.c > +++ b/gcc/testsuite/c-c++-common/sso/q13.c > @@ -1,4 +1,5 @@ > /* { dg-do run } */ > +/* { dg-additional-options "-fext-numeric-literals" { target c++ } } */ > > #include <stdio.h> > > diff --git a/gcc/testsuite/gcc.dg/sso/q2.c > b/gcc/testsuite/c-c++-common/sso/q2.c > similarity index 100% > rename from gcc/testsuite/gcc.dg/sso/q2.c > rename to gcc/testsuite/c-c++-common/sso/q2.c > diff --git a/gcc/testsuite/gcc.dg/sso/q3.c > b/gcc/testsuite/c-c++-common/sso/q3.c > similarity index 100% > rename from gcc/testsuite/gcc.dg/sso/q3.c > rename to gcc/testsuite/c-c++-common/sso/q3.c > diff --git a/gcc/testsuite/gcc.dg/sso/q4.c > b/gcc/testsuite/c-c++-common/sso/q4.c > similarity index 100% > rename from gcc/testsuite/gcc.dg/sso/q4.c > rename to gcc/testsuite/c-c++-common/sso/q4.c > diff --git a/gcc/testsuite/gcc.dg/sso/q5.c > b/gcc/testsuite/c-c++-common/sso/q5.c > similarity index 100% > rename from gcc/testsuite/gcc.dg/sso/q5.c > rename to gcc/testsuite/c-c++-common/sso/q5.c > diff --git a/gcc/testsuite/gcc.dg/sso/q6.c > b/gcc/testsuite/c-c++-common/sso/q6.c > similarity index 100% > rename from gcc/testsuite/gcc.dg/sso/q6.c > rename to gcc/testsuite/c-c++-common/sso/q6.c > diff --git a/gcc/testsuite/gcc.dg/sso/q7.c > b/gcc/testsuite/c-c++-common/sso/q7.c > similarity index 100% > rename from gcc/testsuite/gcc.dg/sso/q7.c > rename to gcc/testsuite/c-c++-common/sso/q7.c > diff --git a/gcc/testsuite/gcc.dg/sso/q8.c > b/gcc/testsuite/c-c++-common/sso/q8.c > similarity index 100% > rename from gcc/testsuite/gcc.dg/sso/q8.c > rename to gcc/testsuite/c-c++-common/sso/q8.c > diff --git a/gcc/testsuite/gcc.dg/sso/q9.c > b/gcc/testsuite/c-c++-common/sso/q9.c > similarity index 100% > rename from gcc/testsuite/gcc.dg/sso/q9.c > rename to gcc/testsuite/c-c++-common/sso/q9.c > diff --git a/gcc/testsuite/gcc.dg/sso/r3.c > b/gcc/testsuite/c-c++-common/sso/r3.c > similarity index 100% > rename from gcc/testsuite/gcc.dg/sso/r3.c > rename to gcc/testsuite/c-c++-common/sso/r3.c > diff --git a/gcc/testsuite/gcc.dg/sso/r5.c > b/gcc/testsuite/c-c++-common/sso/r5.c > similarity index 100% > rename from gcc/testsuite/gcc.dg/sso/r5.c > rename to gcc/testsuite/c-c++-common/sso/r5.c > diff --git a/gcc/testsuite/gcc.dg/sso/r6.c > b/gcc/testsuite/c-c++-common/sso/r6.c > similarity index 100% > rename from gcc/testsuite/gcc.dg/sso/r6.c > rename to gcc/testsuite/c-c++-common/sso/r6.c > diff --git a/gcc/testsuite/gcc.dg/sso/r7.c > b/gcc/testsuite/c-c++-common/sso/r7.c > similarity index 100% > rename from gcc/testsuite/gcc.dg/sso/r7.c > rename to gcc/testsuite/c-c++-common/sso/r7.c > diff --git a/gcc/testsuite/gcc.dg/sso/r8.c > b/gcc/testsuite/c-c++-common/sso/r8.c > similarity index 100% > rename from gcc/testsuite/gcc.dg/sso/r8.c > rename to gcc/testsuite/c-c++-common/sso/r8.c > diff --git a/gcc/testsuite/gcc.dg/sso/s3.c > b/gcc/testsuite/c-c++-common/sso/s3.c > similarity index 100% > rename from gcc/testsuite/gcc.dg/sso/s3.c > rename to gcc/testsuite/c-c++-common/sso/s3.c > diff --git a/gcc/testsuite/gcc.dg/sso/s5.c > b/gcc/testsuite/c-c++-common/sso/s5.c > similarity index 100% > rename from gcc/testsuite/gcc.dg/sso/s5.c > rename to gcc/testsuite/c-c++-common/sso/s5.c > diff --git a/gcc/testsuite/gcc.dg/sso/s6.c > b/gcc/testsuite/c-c++-common/sso/s6.c > similarity index 100% > rename from gcc/testsuite/gcc.dg/sso/s6.c > rename to gcc/testsuite/c-c++-common/sso/s6.c > diff --git a/gcc/testsuite/gcc.dg/sso/s7.c > b/gcc/testsuite/c-c++-common/sso/s7.c > similarity index 100% > rename from gcc/testsuite/gcc.dg/sso/s7.c > rename to gcc/testsuite/c-c++-common/sso/s7.c > diff --git a/gcc/testsuite/gcc.dg/sso/s8.c > b/gcc/testsuite/c-c++-common/sso/s8.c > similarity index 100% > rename from gcc/testsuite/gcc.dg/sso/s8.c > rename to gcc/testsuite/c-c++-common/sso/s8.c > diff --git a/gcc/testsuite/gcc.dg/sso/t1.c > b/gcc/testsuite/c-c++-common/sso/t1.c > similarity index 100% > rename from gcc/testsuite/gcc.dg/sso/t1.c > rename to gcc/testsuite/c-c++-common/sso/t1.c > diff --git a/gcc/testsuite/gcc.dg/sso/t13.c > b/gcc/testsuite/c-c++-common/sso/t13.c > similarity index 94% > rename from gcc/testsuite/gcc.dg/sso/t13.c > rename to gcc/testsuite/c-c++-common/sso/t13.c > index 223b42dc952..313e79cc0b7 100644 > --- a/gcc/testsuite/gcc.dg/sso/t13.c > +++ b/gcc/testsuite/c-c++-common/sso/t13.c > @@ -1,4 +1,5 @@ > /* { dg-do run } */ > +/* { dg-additional-options "-fext-numeric-literals" { target c++ } } */ > > #include <stdio.h> > > diff --git a/gcc/testsuite/gcc.dg/sso/t2.c > b/gcc/testsuite/c-c++-common/sso/t2.c > similarity index 100% > rename from gcc/testsuite/gcc.dg/sso/t2.c > rename to gcc/testsuite/c-c++-common/sso/t2.c > diff --git a/gcc/testsuite/gcc.dg/sso/t3.c > b/gcc/testsuite/c-c++-common/sso/t3.c > similarity index 100% > rename from gcc/testsuite/gcc.dg/sso/t3.c > rename to gcc/testsuite/c-c++-common/sso/t3.c > diff --git a/gcc/testsuite/gcc.dg/sso/t4.c > b/gcc/testsuite/c-c++-common/sso/t4.c > similarity index 100% > rename from gcc/testsuite/gcc.dg/sso/t4.c > rename to gcc/testsuite/c-c++-common/sso/t4.c > diff --git a/gcc/testsuite/gcc.dg/sso/t5.c > b/gcc/testsuite/c-c++-common/sso/t5.c > similarity index 100% > rename from gcc/testsuite/gcc.dg/sso/t5.c > rename to gcc/testsuite/c-c++-common/sso/t5.c > diff --git a/gcc/testsuite/gcc.dg/sso/t6.c > b/gcc/testsuite/c-c++-common/sso/t6.c > similarity index 100% > rename from gcc/testsuite/gcc.dg/sso/t6.c > rename to gcc/testsuite/c-c++-common/sso/t6.c > diff --git a/gcc/testsuite/gcc.dg/sso/t7.c > b/gcc/testsuite/c-c++-common/sso/t7.c > similarity index 100% > rename from gcc/testsuite/gcc.dg/sso/t7.c > rename to gcc/testsuite/c-c++-common/sso/t7.c > diff --git a/gcc/testsuite/gcc.dg/sso/t8.c > b/gcc/testsuite/c-c++-common/sso/t8.c > similarity index 100% > rename from gcc/testsuite/gcc.dg/sso/t8.c > rename to gcc/testsuite/c-c++-common/sso/t8.c > diff --git a/gcc/testsuite/gcc.dg/sso/t9.c > b/gcc/testsuite/c-c++-common/sso/t9.c > similarity index 100% > rename from gcc/testsuite/gcc.dg/sso/t9.c > rename to gcc/testsuite/c-c++-common/sso/t9.c > diff --git a/gcc/testsuite/gcc.dg/sso/u5.c > b/gcc/testsuite/c-c++-common/sso/u5.c > similarity index 100% > rename from gcc/testsuite/gcc.dg/sso/u5.c > rename to gcc/testsuite/c-c++-common/sso/u5.c > diff --git a/gcc/testsuite/gcc.dg/sso/u6.c > b/gcc/testsuite/c-c++-common/sso/u6.c > similarity index 100% > rename from gcc/testsuite/gcc.dg/sso/u6.c > rename to gcc/testsuite/c-c++-common/sso/u6.c > diff --git a/gcc/testsuite/g++.dg/sso-1.C b/gcc/testsuite/g++.dg/sso-1.C > index 0f59d0c4069..e4777da8036 100644 > --- a/gcc/testsuite/g++.dg/sso-1.C > +++ b/gcc/testsuite/g++.dg/sso-1.C > @@ -2,7 +2,7 @@ > > /* { dg-do compile } */ > > -struct __attribute__((scalar_storage_order("little-endian"))) Rec /* { > dg-warning "attribute ignored" } */ > +struct __attribute__((scalar_storage_order("little-endian"))) Rec /* { > dg-bogus "attribute ignored" } */ > { > int i; > }; > diff --git a/gcc/testsuite/g++.dg/sso/auto-1.C > b/gcc/testsuite/g++.dg/sso/auto-1.C > new file mode 100644 > index 00000000000..12ebcc1707b > --- /dev/null > +++ b/gcc/testsuite/g++.dg/sso/auto-1.C > @@ -0,0 +1,17 @@ > +/* { dg-do compile { target c++11 } } */ > +#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ > +struct __attribute__((scalar_storage_order("big-endian"))) Rec > +{ > + int p; > +}; > +#else > +struct __attribute__((scalar_storage_order("little-endian"))) Rec > +{ > + int p; > +}; > +#endif > + > +void f(Rec *a) > +{ > + auto t = a->p; > +} > diff --git a/gcc/testsuite/g++.dg/sso/auto-2.C > b/gcc/testsuite/g++.dg/sso/auto-2.C > new file mode 100644 > index 00000000000..d69ca8d0c66 > --- /dev/null > +++ b/gcc/testsuite/g++.dg/sso/auto-2.C > @@ -0,0 +1,17 @@ > +/* { dg-do compile { target c++14 } } */ > +#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ > +struct __attribute__((scalar_storage_order("big-endian"))) Rec > +{ > + int p; > +}; > +#else > +struct __attribute__((scalar_storage_order("little-endian"))) Rec > +{ > + int p; > +}; > +#endif > + > +decltype(auto) f(Rec *a) > +{ > + return a->p; > +} > diff --git a/gcc/testsuite/g++.dg/sso/auto-3.C > b/gcc/testsuite/g++.dg/sso/auto-3.C > new file mode 100644 > index 00000000000..80eab2389d5 > --- /dev/null > +++ b/gcc/testsuite/g++.dg/sso/auto-3.C > @@ -0,0 +1,17 @@ > +/* { dg-do compile { target c++14 } } */ > +#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ > +struct __attribute__((scalar_storage_order("big-endian"))) Rec > +{ > + int p; > +}; > +#else > +struct __attribute__((scalar_storage_order("little-endian"))) Rec > +{ > + int p; > +}; > +#endif > + > +decltype(auto) f(Rec *a) > +{ > + return (a->p); /* { dg-error "" } */ > +} > diff --git a/gcc/testsuite/g++.dg/sso/sso.exp > b/gcc/testsuite/g++.dg/sso/sso.exp > new file mode 100644 > index 00000000000..0684596e10f > --- /dev/null > +++ b/gcc/testsuite/g++.dg/sso/sso.exp > @@ -0,0 +1,44 @@ > +# Copyright (C) 2013-2017 Free Software Foundation, Inc. > + > +# This program is free software; you can redistribute it and/or modify > +# it under the terms of the GNU General Public License as published by > +# the Free Software Foundation; either version 3 of the License, or > +# (at your option) any later version. > +# > +# This program is distributed in the hope that it will be useful, > +# but WITHOUT ANY WARRANTY; without even the implied warranty of > +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > +# GNU General Public License for more details. > +# > +# You should have received a copy of the GNU General Public License > +# along with GCC; see the file COPYING3. If not see > +# <http://www.gnu.org/licenses/>. > + > +# Load support procs. > +load_lib g++-dg.exp > +load_lib torture-options.exp > + > +if { ![check_effective_target_int32] } { > + return > +} > + > +# Initialize `dg'. > +torture-init > +dg-init > + > +set SSO_TORTURE_OPTIONS [list \ > + { -O0 } \ > + { -O1 -fno-inline } \ > + { -O2 } \ > + { -O3 -finline-functions } \ > + { -Os } \ > + { -Og -g } ] > + > +set-torture-options $SSO_TORTURE_OPTIONS > + > +# Main loop. > +g++-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.C > $srcdir/c-c++-common/sso/*.c ]] "" "" > + > +# All done. > +dg-finish > +torture-finish > diff --git a/gcc/testsuite/g++.dg/sso/template-reference-1.C > b/gcc/testsuite/g++.dg/sso/template-reference-1.C > new file mode 100644 > index 00000000000..8925dff9930 > --- /dev/null > +++ b/gcc/testsuite/g++.dg/sso/template-reference-1.C > @@ -0,0 +1,19 @@ > +/* { dg-do compile } */ > +#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ > +struct __attribute__((scalar_storage_order("big-endian"))) Rec > +{ > + int p; > +}; > +#else > +struct __attribute__((scalar_storage_order("little-endian"))) Rec > +{ > + int p; > +}; > +#endif > +template <typename T> void g(const T &); > + > + > +void f(Rec *a) > +{ > + g(a->p); > +} > diff --git a/gcc/testsuite/g++.dg/sso/template-reference-2.C > b/gcc/testsuite/g++.dg/sso/template-reference-2.C > new file mode 100644 > index 00000000000..f871833991e > --- /dev/null > +++ b/gcc/testsuite/g++.dg/sso/template-reference-2.C > @@ -0,0 +1,19 @@ > +/* { dg-do compile } */ > +#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ > +struct __attribute__((scalar_storage_order("big-endian"))) Rec > +{ > + int p; > +}; > +#else > +struct __attribute__((scalar_storage_order("little-endian"))) Rec > +{ > + int p; > +}; > +#endif > +template <typename T> void g(T &); > + > + > +void f(Rec *a) > +{ > + g(a->p); /* { dg-error "" } */ > +} > diff --git a/gcc/testsuite/g++.dg/sso/template-reference-3.C > b/gcc/testsuite/g++.dg/sso/template-reference-3.C > new file mode 100644 > index 00000000000..5c2ebd37832 > --- /dev/null > +++ b/gcc/testsuite/g++.dg/sso/template-reference-3.C > @@ -0,0 +1,19 @@ > +/* { dg-do compile { target c++11 } } */ > +#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ > +struct __attribute__((scalar_storage_order("big-endian"))) Rec > +{ > + int p; > +}; > +#else > +struct __attribute__((scalar_storage_order("little-endian"))) Rec > +{ > + int p; > +}; > +#endif > +template <typename T> void g(T &&); > + > + > +void f(Rec *a) > +{ > + g(a->p); /* { dg-error "" } */ > +} > diff --git a/gcc/testsuite/g++.dg/sso/template-reference-4.C > b/gcc/testsuite/g++.dg/sso/template-reference-4.C > new file mode 100644 > index 00000000000..acc56e2e819 > --- /dev/null > +++ b/gcc/testsuite/g++.dg/sso/template-reference-4.C > @@ -0,0 +1,19 @@ > +/* { dg-do compile } */ > +#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ > +struct __attribute__((scalar_storage_order("big-endian"))) Rec > +{ > + int p; > +}; > +#else > +struct __attribute__((scalar_storage_order("little-endian"))) Rec > +{ > + int p; > +}; > +#endif > +template <typename T> void g(T &); > + > + > +void f(Rec *a) > +{ > + g( (a->p)); /* { dg-error "" } */ > +} > diff --git a/gcc/testsuite/gcc.dg/sso/sso.exp > b/gcc/testsuite/gcc.dg/sso/sso.exp > index a18f7011cea..59e756565a4 100644 > --- a/gcc/testsuite/gcc.dg/sso/sso.exp > +++ b/gcc/testsuite/gcc.dg/sso/sso.exp > @@ -37,7 +37,7 @@ set SSO_TORTURE_OPTIONS [list \ > set-torture-options $SSO_TORTURE_OPTIONS > > # Main loop. > -gcc-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.c]] "" "" > +gcc-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.c > $srcdir/c-c++-common/sso/*.c ]] "" "" > > # All done. > dg-finish > -- > 2.30.2 >