[gcc-6] 236/401: * Revert fix for PR c++/71912, causing PR c++/78039. Addresses: #841292.
Ximin Luo
infinity0 at debian.org
Wed Apr 5 15:49:45 UTC 2017
This is an automated email from the git hooks/post-receive script.
infinity0 pushed a commit to branch pu/reproducible_builds
in repository gcc-6.
commit ec8b7c83240c7b3438e7aa425a465076be809faa
Author: doko <doko at 6ca36cf4-e1d1-0310-8c6f-e303bb2178ca>
Date: Wed Oct 19 16:33:56 2016 +0000
* Revert fix for PR c++/71912, causing PR c++/78039. Addresses: #841292.
git-svn-id: svn://anonscm.debian.org/gcccvs/branches/sid/gcc-6@9011 6ca36cf4-e1d1-0310-8c6f-e303bb2178ca
---
debian/changelog | 1 +
debian/patches/pr71912-revert.diff | 767 +++++++++++++++++++++++++++++++++++++
debian/rules.patch | 2 +
3 files changed, 770 insertions(+)
diff --git a/debian/changelog b/debian/changelog
index 9340978..62b8683 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -9,6 +9,7 @@ gcc-6 (6.2.0-8) UNRELEASED; urgency=medium
the included headers on arm64)
- r241171 (sparc64 relocations, e1fc2925 in go master, now also in
gofrontend/gccgo)
+ * Revert fix for PR c++/71912, causing PR c++/78039. Addresses: #841292.
-- Matthias Klose <doko at debian.org> Wed, 19 Oct 2016 08:57:23 +0200
diff --git a/debian/patches/pr71912-revert.diff b/debian/patches/pr71912-revert.diff
new file mode 100644
index 0000000..2d32556
--- /dev/null
+++ b/debian/patches/pr71912-revert.diff
@@ -0,0 +1,767 @@
+# DP: Revert fix for PR c++/71912, causing PR c++/78039.
+
+Index: b/src/gcc/testsuite/ChangeLog
+===================================================================
+--- a/src/gcc/testsuite/ChangeLog
++++ b/src/gcc/testsuite/ChangeLog
+@@ -41,19 +41,6 @@
+ * gcc.target/sparc/bmaskbshuf-1.c: ...this.
+ * gcc.target/sparc/bmaskbshuf-2.c: New test.
+
+-2016-10-14 Martin Sebor <msebor at redhat.com>
+-
+- PR c++/71912
+- * g++.dg/ext/flexary4.C: Adjust.
+- * g++.dg/ext/flexary5.C: Same.
+- * g++.dg/ext/flexary9.C: Same.
+- * g++.dg/ext/flexary19.C: New test.
+- * g++.dg/ext/flexary18.C: New test.
+- * g++.dg/torture/pr64312.C: Add a dg-error directive to an ill-formed
+- regression test.
+- * g++.dg/compat/struct-layout-1_generate.c (subfield): Add argument.
+- Avoid generating a flexible array member in an array.
+-
+ 2016-10-13 Andrew Senkevich <andrew.senkevich at intel.com>
+
+ Backport from trunk
+Index: b/src/gcc/testsuite/g++.dg/torture/pr64312.C
+===================================================================
+--- a/src/gcc/testsuite/g++.dg/torture/pr64312.C
++++ b/src/gcc/testsuite/g++.dg/torture/pr64312.C
+@@ -44,7 +44,7 @@ class F
+ {
+ public:
+ int nelems;
+- int elems[]; // { dg-error "not at end" }
++ int elems[];
+ int *
+ m_fn1 ()
+ {
+@@ -88,7 +88,7 @@ public:
+ m_impl->~any_incrementable_iterator_interface ();
+ }
+ G m_buffer;
+- any_incrementable_iterator_interface *m_impl; // { dg-message "next member" }
++ any_incrementable_iterator_interface *m_impl;
+ };
+ template <class Reference> class K : public I<any_iterator<Reference> >
+ {
+Index: b/src/gcc/testsuite/g++.dg/ext/flexary4.C
+===================================================================
+--- a/src/gcc/testsuite/g++.dg/ext/flexary4.C
++++ b/src/gcc/testsuite/g++.dg/ext/flexary4.C
+@@ -102,28 +102,31 @@ struct Sx17 {
+ int a_0 [0];
+ };
+
+-// An empty struct is treated as if it had a single member of type
+-// char but the member cannot be accessed. Therefore, a struct
++// Empty structs are a GCC extension that (in C++ only) is treated
++// as if it had a single member of type char. Therefore, a struct
+ // containing a flexible array member followed by an empty struct
+ // is diagnosed to prevent the former subobject from sharing space
+ // with the latter.
+ struct Sx18 {
+ int a_x []; // { dg-error "flexible array member" }
+- struct { /* empty */ } s;
++ struct S { };
+ };
+
+-// Anonymous structs are a G++ extension. Members of anonymous structs
+-// are treated as if they were declared in the enclosing class.
++// Anonymous structs and unions are another GCC extension. Since
++// they cannot be named and thus used to store the size of a flexible
++// array member, a struct containing both is diagnosed as if
++// the flexible array member appeared alone.
+ struct Sx19 {
+- struct { int i; }; // anonymous struct
+- int a_x [];
++ struct S { };
++ union U { };
++ int a_x []; // { dg-error "in an otherwise empty" }
+ };
+
+-// Unlike in the case above, a named struct is not anonymous and
+-// so doesn't contribute its member to that of the enclosing struct.
++// Unlike in the case above, a named member of an anonymous struct
++// prevents a subsequent flexible array member from being diagnosed.
+ struct Sx20 {
+- struct S { int i; };
+- int a_x []; // { dg-error "in an otherwise empty" }
++ struct S { } s;
++ int a_x [];
+ };
+
+ struct Sx21 {
+@@ -295,15 +298,6 @@ struct Anon1 {
+
+ ASSERT_AT_END (Anon1, good);
+
+-struct NotAnon1 {
+- int n;
+- // The following is not an anonymous struct -- the type is unnamed
+- // but the object has a name.
+- struct {
+- int bad[]; // { dg-error "otherwise empty" }
+- } name;
+-};
+-
+ struct Anon2 {
+ struct {
+ int n;
+@@ -358,6 +352,7 @@ struct Anon7 {
+ int n;
+ };
+
++
+ struct Six {
+ int i;
+ int a[];
+Index: b/src/gcc/testsuite/g++.dg/ext/flexary5.C
+===================================================================
+--- a/src/gcc/testsuite/g++.dg/ext/flexary5.C
++++ b/src/gcc/testsuite/g++.dg/ext/flexary5.C
+@@ -64,29 +64,19 @@ struct D5: E1, E2, NE { char a[]; };
+
+ ASSERT_AT_END (D5, a); // { dg-warning "offsetof within non-standard-layout" }
+
+-struct A2x_1 {
++struct A2x {
+ size_t n;
+- size_t a[]; // { dg-error "not at end of .struct D6." }
+-};
+-
+-struct A2x_2 {
+- size_t n;
+- size_t a[]; // { dg-error "not at end of .struct D7." }
+-};
+-
+-struct A2x_3 {
+- size_t n;
+- size_t a[]; // { dg-error "not at end of .struct D8." }
++ size_t a[]; // { dg-error "not at end of .struct D6.| D7.| D8." }
+ };
+
+ // Verify that the flexible array member in A2x above is diagnosed
+ // for each of the three struct defintions below which also derive
+ // from another struct with a flexible array member.
+-struct D6: A2x_1, E1, A1x { };
+-struct D7: E1, A2x_2, E2, A1x { };
+-struct D8: E1, E2, A2x_3, A1x { };
++struct D6: A2x, E1, A1x { };
++struct D7: E1, A2x, E2, A1x { };
++struct D8: E1, E2, A2x, A1x { };
+
+-struct DA2x: A2x_1 { };
++struct DA2x: A2x { };
+
+ struct D9: DA2x, E1, E2 { };
+
+@@ -204,27 +194,16 @@ struct NE2: NE { };
+ struct D28: NE1, AA6x { };
+ struct D29: AA6x, NE1 { };
+
++// Verify that a flexible array member in a virtual base class is not
++// diagnosed.
+ struct A7x {
+ size_t n;
+- size_t a[]; // { dg-error "flexible array member .A7x::a. not at end of .struct D33." }
++ size_t a[];
+ };
+
+-// Verify that a flexible array member in a virtual base class is not
+-// diagnosed.
+ struct DA7xV1: virtual A7x { };
+ struct DA7xV2: virtual A7x { };
+
+ struct D30: DA7xV1, DA7xV2 { };
+ struct D31: DA7xV1, DA7xV2 { };
+ struct D32: D30, D31 { };
+-
+-// Verify the diagnostic when the flexible array is in an anonymous struct.
+-struct A8x {
+- struct { // { dg-message "next member .A8x::<anonymous struct> A8x::<anonymous>. declared here" }
+- size_t n;
+- size_t a[];
+- };
+-};
+-
+-struct D33: // { dg-message "in the definition of .struct D33." }
+- A7x, A8x { };
+Index: b/src/gcc/testsuite/g++.dg/ext/flexary9.C
+===================================================================
+--- a/src/gcc/testsuite/g++.dg/ext/flexary9.C
++++ b/src/gcc/testsuite/g++.dg/ext/flexary9.C
+@@ -281,15 +281,15 @@ struct S_S_S_x {
+
+ struct Anon1 {
+ int n;
+- struct { // { dg-warning "invalid use \[^\n\r\]* with a zero-size array" }
+- int good[0]; // { dg-warning "forbids zero-size array" }
++ struct {
++ int good[0]; // { dg-warning "zero-size array" }
+ }; // { dg-warning "anonymous struct" }
+ };
+
+ ASSERT_AT_END (Anon1, good);
+
+ struct Anon2 {
+- struct { // { dg-warning "invalid use" }
++ struct {
+ int n;
+ struct {
+ int good[0]; // { dg-warning "zero-size array" }
+@@ -300,7 +300,7 @@ struct Anon2 {
+ ASSERT_AT_END (Anon2, good);
+
+ struct Anon3 {
+- struct { // { dg-warning "invalid use" }
++ struct {
+ struct {
+ int n;
+ int good[0]; // { dg-warning "zero-size array" }
+Index: b/src/gcc/testsuite/g++.dg/compat/struct-layout-1_generate.c
+===================================================================
+--- a/src/gcc/testsuite/g++.dg/compat/struct-layout-1_generate.c
++++ b/src/gcc/testsuite/g++.dg/compat/struct-layout-1_generate.c
+@@ -495,16 +495,7 @@ struct types attrib_array_types[] = {
+ #define HASH_SIZE 32749
+ static struct entry *hash_table[HASH_SIZE];
+
+-/* The index of the current type being output. */
+-static int idx;
+-
+-/* The maximum index of the type(s) to output. */
+-static int limidx;
+-
+-/* Set to non-zero to output a single type in response to the -i option
+- (which sets LIMIDX to the index of the type to output. */
+-static int output_one;
+-static int short_enums;
++static int idx, limidx, output_one, short_enums;
+ static const char *destdir;
+ static const char *srcdir;
+ static const char *srcdir_safe;
+@@ -544,7 +535,6 @@ switchfiles (int fields)
+ fputs ("failed to create test files\n", stderr);
+ exit (1);
+ }
+-
+ for (i = 0; i < NDG_OPTIONS; i++)
+ fprintf (outfile, dg_options[i], "", srcdir_safe);
+ fprintf (outfile, "\n\
+@@ -617,14 +607,9 @@ getrandll (void)
+
+ /* Generate a subfield. The object pointed to by FLEX is set to a non-zero
+ value when the generated field is a flexible array member. When set, it
+- prevents subsequent fields from being generated (a flexible array member
+- must be the last member of the struct it's defined in). ARRAY is non-
+- zero when the enclosing structure is part of an array. In that case,
+- avoid generating a flexible array member as a subfield (such a member
+- would be invalid). */
+-
++ prevents subsequent fields from being generated (a flexible array mem*/
+ int
+-subfield (struct entry *e, char *letter, int *flex, int array)
++subfield (struct entry *e, char *letter, int *flex)
+ {
+ int i, type;
+ char buf[20];
+@@ -679,14 +664,7 @@ subfield (struct entry *e, char *letter,
+ }
+
+ for (i = 1; !*flex && i <= e[0].len; )
+- {
+- /* Avoid generating flexible array members if the enclosing
+- type is an array. */
+- int array
+- = (e[0].etype == ETYPE_STRUCT_ARRAY
+- || e[0].etype == ETYPE_UNION_ARRAY);
+- i += subfield (e + i, letter, flex, array);
+- }
++ i += subfield (e + i, letter, flex);
+
+ switch (type)
+ {
+@@ -707,7 +685,7 @@ subfield (struct entry *e, char *letter,
+ case ETYPE_ARRAY:
+ if (e[0].etype == ETYPE_ARRAY)
+ {
+- if (!array && e[0].arr_len == 255)
++ if (e[0].arr_len == 255)
+ {
+ *flex = 1;
+ snprintf (buf, 20, "%c[]", *letter);
+@@ -1163,7 +1141,6 @@ e_insert (struct entry *e)
+ hash_table[hval % HASH_SIZE] = e;
+ }
+
+-/* Output a single type. */
+ void
+ output (struct entry *e)
+ {
+@@ -1192,7 +1169,7 @@ output (struct entry *e)
+
+ int flex = 0;
+ for (i = 1; i <= e[0].len; )
+- i += subfield (e + i, &c, &flex, 0);
++ i += subfield (e + i, &c, &flex);
+
+ fputs (",", outfile);
+ c = 'a';
+Index: b/src/gcc/cp/class.c
+===================================================================
+--- a/src/gcc/cp/class.c
++++ b/src/gcc/cp/class.c
+@@ -147,12 +147,11 @@ static void check_methods (tree);
+ static void remove_zero_width_bit_fields (tree);
+ static bool accessible_nvdtor_p (tree);
+
+-/* Used by find_flexarrays and related functions. */
++/* Used by find_flexarrays and related. */
+ struct flexmems_t;
++static void find_flexarrays (tree, flexmems_t *);
+ static void diagnose_flexarrays (tree, const flexmems_t *);
+-static void find_flexarrays (tree, flexmems_t *, bool = false,
+- tree = NULL_TREE, tree = NULL_TREE);
+-static void check_flexarrays (tree, flexmems_t * = NULL, bool = false);
++static void check_flexarrays (tree, flexmems_t * = NULL);
+ static void check_bases (tree, int *, int *);
+ static void check_bases_and_members (tree);
+ static tree create_vtable_ptr (tree, tree *);
+@@ -6688,147 +6687,52 @@ field_nonempty_p (const_tree fld)
+ return false;
+ }
+
+-/* Used by find_flexarrays and related functions. */
+-
+-struct flexmems_t
+-{
++/* Used by find_flexarrays and related. */
++struct flexmems_t {
+ /* The first flexible array member or non-zero array member found
+- in the order of layout. */
++ in order of layout. */
+ tree array;
+ /* First non-static non-empty data member in the class or its bases. */
+ tree first;
+- /* The first non-static non-empty data member following either
+- the flexible array member, if found, or the zero-length array member
+- otherwise. AFTER[1] refers to the first such data member of a union
+- of which the struct containing the flexible array member or zero-length
+- array is a member, or NULL when no such union exists. This element is
+- only used during searching, not for diagnosing problems. AFTER[0]
+- refers to the first such data member that is not a member of such
+- a union. */
+- tree after[2];
+-
+- /* Refers to a struct (not union) in which the struct of which the flexible
+- array is member is defined. Used to diagnose strictly (according to C)
+- invalid uses of the latter structs. */
+- tree enclosing;
++ /* First non-static non-empty data member following either the flexible
++ array member, if found, or the zero-length array member. */
++ tree after;
+ };
+
+ /* Find either the first flexible array member or the first zero-length
+- array, in that order of preference, among members of class T (but not
+- its base classes), and set members of FMEM accordingly.
+- BASE_P is true if T is a base class of another class.
+- PUN is set to the outermost union in which the flexible array member
+- (or zero-length array) is defined if one such union exists, otherwise
+- to NULL.
+- Similarly, PSTR is set to a data member of the outermost struct of
+- which the flexible array is a member if one such struct exists,
+- otherwise to NULL. */
+-
+-static void
+-find_flexarrays (tree t, flexmems_t *fmem, bool base_p,
+- tree pun /* = NULL_TREE */,
+- tree pstr /* = NULL_TREE */)
+-{
+- /* Set the "pointer" to the outermost enclosing union if not set
+- yet and maintain it for the remainder of the recursion. */
+- if (!pun && TREE_CODE (t) == UNION_TYPE)
+- pun = t;
++ array, in that order or preference, among members of class T (but not
++ its base classes), and set members of FMEM accordingly. */
+
+- for (tree fld = TYPE_FIELDS (t); fld; fld = DECL_CHAIN (fld))
++static void
++find_flexarrays (tree t, flexmems_t *fmem)
++{
++ for (tree fld = TYPE_FIELDS (t), next; fld; fld = next)
+ {
+- if (fld == error_mark_node)
+- return;
+-
+- /* Is FLD a typedef for an anonymous struct? */
++ /* Find the next non-static data member if it exists. */
++ for (next = fld;
++ (next = DECL_CHAIN (next))
++ && TREE_CODE (next) != FIELD_DECL; );
+
+- /* FIXME: Note that typedefs (as well as arrays) need to be fully
+- handled elsewhere so that errors like the following are detected
+- as well:
+- typedef struct { int i, a[], j; } S; // bug c++/72753
+- S s [2]; // bug c++/68489
+- */
+- if (TREE_CODE (fld) == TYPE_DECL
+- && DECL_IMPLICIT_TYPEDEF_P (fld)
+- && CLASS_TYPE_P (TREE_TYPE (fld))
+- && anon_aggrname_p (DECL_NAME (fld)))
+- {
+- /* Check the nested unnamed type referenced via a typedef
+- independently of FMEM (since it's not a data member of
+- the enclosing class). */
+- check_flexarrays (TREE_TYPE (fld));
++ tree fldtype = TREE_TYPE (fld);
++ if (TREE_CODE (fld) != TYPE_DECL
++ && RECORD_OR_UNION_TYPE_P (fldtype)
++ && TYPE_ANONYMOUS_P (fldtype))
++ {
++ /* Members of anonymous structs and unions are treated as if
++ they were members of the containing class. Descend into
++ the anonymous struct or union and find a flexible array
++ member or zero-length array among its fields. */
++ find_flexarrays (fldtype, fmem);
+ continue;
+ }
+
+- /* Skip anything that's GCC-generated or not a (non-static) data
+- member. */
+- if (DECL_ARTIFICIAL (fld) || TREE_CODE (fld) != FIELD_DECL)
++ /* Skip anything that's not a (non-static) data member. */
++ if (TREE_CODE (fld) != FIELD_DECL)
+ continue;
+
+- /* Type of the member. */
+- tree fldtype = TREE_TYPE (fld);
+- if (fldtype == error_mark_node)
+- return;
+-
+- /* Determine the type of the array element or object referenced
+- by the member so that it can be checked for flexible array
+- members if it hasn't been yet. */
+- tree eltype = fldtype;
+- while (TREE_CODE (eltype) == ARRAY_TYPE
+- || TREE_CODE (eltype) == POINTER_TYPE
+- || TREE_CODE (eltype) == REFERENCE_TYPE)
+- eltype = TREE_TYPE (eltype);
+-
+- if (RECORD_OR_UNION_TYPE_P (eltype))
+- {
+- if (fmem->array && !fmem->after[bool (pun)])
+- {
+- /* Once the member after the flexible array has been found
+- we're done. */
+- fmem->after[bool (pun)] = fld;
+- break;
+- }
+-
+- if (eltype == fldtype || TYPE_ANONYMOUS_P (eltype))
+- {
+- /* Descend into the non-static member struct or union and try
+- to find a flexible array member or zero-length array among
+- its members. This is only necessary for anonymous types
+- and types in whose context the current type T has not been
+- defined (the latter must not be checked again because they
+- are already in the process of being checked by one of the
+- recursive calls). */
+-
+- tree first = fmem->first;
+- tree array = fmem->array;
+-
+- /* If this member isn't anonymous and a prior non-flexible array
+- member has been seen in one of the enclosing structs, clear
+- the FIRST member since it doesn't contribute to the flexible
+- array struct's members. */
+- if (first && !array && !ANON_AGGR_TYPE_P (eltype))
+- fmem->first = NULL_TREE;
+-
+- find_flexarrays (eltype, fmem, false, pun,
+- !pstr && TREE_CODE (t) == RECORD_TYPE ? fld : pstr);
+-
+- if (fmem->array != array)
+- continue;
+-
+- if (first && !array && !ANON_AGGR_TYPE_P (eltype))
+- {
+- /* Restore the FIRST member reset above if no flexible
+- array member has been found in this member's struct. */
+- fmem->first = first;
+- }
+-
+- /* If the member struct contains the first flexible array
+- member, or if this member is a base class, continue to
+- the next member and avoid setting the FMEM->NEXT pointer
+- to point to it. */
+- if (base_p)
+- continue;
+- }
+- }
++ /* Skip virtual table pointers. */
++ if (DECL_ARTIFICIAL (fld))
++ continue;
+
+ if (field_nonempty_p (fld))
+ {
+@@ -6839,8 +6743,8 @@ find_flexarrays (tree t, flexmems_t *fme
+ /* Remember the first non-static data member after the flexible
+ array member, if one has been found, or the zero-length array
+ if it has been found. */
+- if (fmem->array && !fmem->after[bool (pun)])
+- fmem->after[bool (pun)] = fld;
++ if (!fmem->after && fmem->array)
++ fmem->after = fld;
+ }
+
+ /* Skip non-arrays. */
+@@ -6856,16 +6760,13 @@ find_flexarrays (tree t, flexmems_t *fme
+ such field or a flexible array member has been seen to
+ handle the pathological and unlikely case of multiple
+ such members. */
+- if (!fmem->after[bool (pun)])
+- fmem->after[bool (pun)] = fld;
++ if (!fmem->after)
++ fmem->after = fld;
+ }
+ else if (integer_all_onesp (TYPE_MAX_VALUE (TYPE_DOMAIN (fldtype))))
+- {
+- /* Remember the first zero-length array unless a flexible array
+- member has already been seen. */
+- fmem->array = fld;
+- fmem->enclosing = pstr;
+- }
++ /* Remember the first zero-length array unless a flexible array
++ member has already been seen. */
++ fmem->array = fld;
+ }
+ else
+ {
+@@ -6876,39 +6777,16 @@ find_flexarrays (tree t, flexmems_t *fme
+ reset the after pointer. */
+ if (TYPE_DOMAIN (TREE_TYPE (fmem->array)))
+ {
+- fmem->after[bool (pun)] = NULL_TREE;
+ fmem->array = fld;
+- fmem->enclosing = pstr;
++ fmem->after = NULL_TREE;
+ }
+ }
+ else
+- {
+- fmem->array = fld;
+- fmem->enclosing = pstr;
+- }
++ fmem->array = fld;
+ }
+ }
+ }
+
+-/* Diagnose a strictly (by the C standard) invalid use of a struct with
+- a flexible array member (or the zero-length array extension). */
+-
+-static void
+-diagnose_invalid_flexarray (const flexmems_t *fmem)
+-{
+- if (fmem->array && fmem->enclosing
+- && pedwarn (location_of (fmem->enclosing), OPT_Wpedantic,
+- TYPE_DOMAIN (TREE_TYPE (fmem->array))
+- ? G_("invalid use of %q#T with a zero-size array "
+- "in %q#D")
+- : G_("invalid use of %q#T with a flexible array member "
+- "in %q#T"),
+- DECL_CONTEXT (fmem->array),
+- DECL_CONTEXT (fmem->enclosing)))
+- inform (DECL_SOURCE_LOCATION (fmem->array),
+- "array member %q#D declared here", fmem->array);
+-}
+-
+ /* Issue diagnostics for invalid flexible array members or zero-length
+ arrays that are not the last elements of the containing class or its
+ base classes or that are its sole members. */
+@@ -6916,70 +6794,49 @@ diagnose_invalid_flexarray (const flexme
+ static void
+ diagnose_flexarrays (tree t, const flexmems_t *fmem)
+ {
+- if (!fmem->array)
++ /* Members of anonymous structs and unions are considered to be members
++ of the containing struct or union. */
++ if (TYPE_ANONYMOUS_P (t) || !fmem->array)
+ return;
+
+- if (fmem->first && !fmem->after[0])
+- {
+- diagnose_invalid_flexarray (fmem);
+- return;
+- }
+-
+- /* Has a diagnostic been issued? */
+- bool diagd = false;
+-
+ const char *msg = 0;
+
+ if (TYPE_DOMAIN (TREE_TYPE (fmem->array)))
+ {
+- if (fmem->after[0])
++ if (fmem->after)
+ msg = G_("zero-size array member %qD not at end of %q#T");
+ else if (!fmem->first)
+ msg = G_("zero-size array member %qD in an otherwise empty %q#T");
+
+- if (msg)
+- {
+- location_t loc = DECL_SOURCE_LOCATION (fmem->array);
++ if (msg && pedwarn (DECL_SOURCE_LOCATION (fmem->array),
++ OPT_Wpedantic, msg, fmem->array, t))
+
+- if (pedwarn (loc, OPT_Wpedantic, msg, fmem->array, t))
+- {
+- inform (location_of (t), "in the definition of %q#T", t);
+- diagd = true;
+- }
+- }
++ inform (location_of (t), "in the definition of %q#T", t);
+ }
+ else
+ {
+- if (fmem->after[0])
++ if (fmem->after)
+ msg = G_("flexible array member %qD not at end of %q#T");
+ else if (!fmem->first)
+ msg = G_("flexible array member %qD in an otherwise empty %q#T");
+
+ if (msg)
+ {
+- location_t loc = DECL_SOURCE_LOCATION (fmem->array);
+- diagd = true;
+-
+- error_at (loc, msg, fmem->array, t);
++ error_at (DECL_SOURCE_LOCATION (fmem->array), msg,
++ fmem->array, t);
+
+ /* In the unlikely event that the member following the flexible
+- array member is declared in a different class, or the member
+- overlaps another member of a common union, point to it.
++ array member is declared in a different class, point to it.
+ Otherwise it should be obvious. */
+- if (fmem->after[0]
+- && ((DECL_CONTEXT (fmem->after[0])
+- != DECL_CONTEXT (fmem->array))))
+- {
+- inform (DECL_SOURCE_LOCATION (fmem->after[0]),
++ if (fmem->after
++ && (DECL_CONTEXT (fmem->after) != DECL_CONTEXT (fmem->array)))
++ inform (DECL_SOURCE_LOCATION (fmem->after),
+ "next member %q#D declared here",
+- fmem->after[0]);
+- inform (location_of (t), "in the definition of %q#T", t);
+- }
++ fmem->after);
++
++ inform (location_of (t), "in the definition of %q#T", t);
+ }
+ }
+-
+- if (!diagd && fmem->array && fmem->enclosing)
+- diagnose_invalid_flexarray (fmem);
+ }
+
+
+@@ -6992,8 +6849,7 @@ diagnose_flexarrays (tree t, const flexm
+ that fails the checks. */
+
+ static void
+-check_flexarrays (tree t, flexmems_t *fmem /* = NULL */,
+- bool base_p /* = false */)
++check_flexarrays (tree t, flexmems_t *fmem /* = NULL */)
+ {
+ /* Initialize the result of a search for flexible array and zero-length
+ array members. Avoid doing any work if the most interesting FMEM data
+@@ -7001,20 +6857,18 @@ check_flexarrays (tree t, flexmems_t *fm
+ flexmems_t flexmems = flexmems_t ();
+ if (!fmem)
+ fmem = &flexmems;
+- else if (fmem->array && fmem->first && fmem->after[0])
++ else if (fmem->array && fmem->first && fmem->after)
+ return;
+
+- tree fam = fmem->array;
+-
+ /* Recursively check the primary base class first. */
+ if (CLASSTYPE_HAS_PRIMARY_BASE_P (t))
+ {
+ tree basetype = BINFO_TYPE (CLASSTYPE_PRIMARY_BINFO (t));
+- check_flexarrays (basetype, fmem, true);
++ check_flexarrays (basetype, fmem);
+ }
+
+ /* Recursively check the base classes. */
+- int nbases = TYPE_BINFO (t) ? BINFO_N_BASE_BINFOS (TYPE_BINFO (t)) : 0;
++ int nbases = BINFO_N_BASE_BINFOS (TYPE_BINFO (t));
+ for (int i = 0; i < nbases; ++i)
+ {
+ tree base_binfo = BINFO_BASE_BINFO (TYPE_BINFO (t), i);
+@@ -7028,7 +6882,7 @@ check_flexarrays (tree t, flexmems_t *fm
+ continue;
+
+ /* Check the base class. */
+- check_flexarrays (BINFO_TYPE (base_binfo), fmem, /*base_p=*/true);
++ check_flexarrays (BINFO_TYPE (base_binfo), fmem);
+ }
+
+ if (fmem == &flexmems)
+@@ -7045,26 +6899,17 @@ check_flexarrays (tree t, flexmems_t *fm
+ /* Check the virtual base class. */
+ tree basetype = TREE_TYPE (base_binfo);
+
+- check_flexarrays (basetype, fmem, /*base_p=*/true);
++ check_flexarrays (basetype, fmem);
+ }
+ }
+
+- /* Is the type unnamed (and therefore a member of it potentially
+- an anonymous struct or union)? */
+- bool maybe_anon_p = TYPE_ANONYMOUS_P (t);
+-
+- /* Search the members of the current (possibly derived) class, skipping
+- unnamed structs and unions since those could be anonymous. */
+- if (fmem != &flexmems || !maybe_anon_p)
+- find_flexarrays (t, fmem, base_p || fam != fmem->array);
++ /* Search the members of the current (derived) class. */
++ find_flexarrays (t, fmem);
+
+- if (fmem == &flexmems && !maybe_anon_p)
++ if (fmem == &flexmems)
+ {
+- /* Issue diagnostics for invalid flexible and zero-length array
+- members found in base classes or among the members of the current
+- class. Ignore anonymous structs and unions whose members are
+- considered to be members of the enclosing class and thus will
+- be diagnosed when checking it. */
++ /* Issue diagnostics for invalid flexible and zero-length array members
++ found in base classes or among the members of the current class. */
+ diagnose_flexarrays (t, fmem);
+ }
+ }
+Index: b/src/gcc/cp/ChangeLog
+===================================================================
+--- a/src/gcc/cp/ChangeLog
++++ b/src/gcc/cp/ChangeLog
+@@ -1,13 +1,3 @@
+-2016-10-14 Martin Sebor <msebor at redhat.com>
+-
+- PR c++/71912
+- * class.c (struct flexmems_t): Add members.
+- (find_flexarrays): Add arguments. Correct handling of anonymous
+- structs.
+- (diagnose_flexarrays): Adjust to issue warnings in addition to errors.
+- (check_flexarrays): Add argument.
+- (diagnose_invalid_flexarray): New functions.
+-
+ 2016-10-04 Martin Sebor <msebor at redhat.com>
+
+ PR c++/77804
diff --git a/debian/rules.patch b/debian/rules.patch
index 8e0f68f..07ee1ee 100644
--- a/debian/rules.patch
+++ b/debian/rules.patch
@@ -99,6 +99,8 @@ debian_patches += \
libgo-rawClone-no_split_stack \
libgo-rawClone-no-pt_regs \
libgo-elf-relocations-sparc64 \
+ pr71912-revert \
+
# this is still needed on powerpc, e.g. firefox and insighttoolkit4 will ftbfs.
ifneq (,$(filter $(DEB_TARGET_ARCH),powerpc))
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/gcc-6.git
More information about the Reproducible-commits
mailing list