This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 2/3] change class-key of PODs to struct and others to class (PR 61339)


On 7/9/19 7:48 AM, Richard Sandiford wrote:
Martin Sebor <msebor@gmail.com> writes:
Hopefully with the right patch this time (thanks Jon).

On 7/8/19 4:00 PM, Martin Sebor wrote:
The attached patch changes the class-key of class definitions that
satisfy the requirements on a POD struct to 'struct', and that of
struct definitions that aren't POD to class, according to the GCC
coding convention.  The patch is also prerequisite for GCC being
able to compile cleanly with -Wmismatched-tags.

I made the changes building GCC with -Wstruct-not-pod and
-Wclass-is-pod enabled, scanning the build log for instances
of each warning, and using a script replacing the class-key
as necessary and adjusting the access of the members declared
immediately after the class-head.

Martin

PR c++/61339 - add mismatch between struct and class [-Wmismatched-tags] to non-bugs

...
gcc/lto/ChangeLog:

	* lto-dump.c: Same.

Need to cut-&-paste the description for this one.

Done.

...

libcpp/ChangeLog:

	* include/line-map.h: Change class-key from class to struct and vice
	versa to match convention and avoid -Wclass-is-pod and -Wstruct-no-pod.
	* mkdeps.c: Same.yyy

s/yyy// :-)

Ditto.


The changelog format is outdoing itself in usefulness here...

diff --git a/gcc/cgraph.h b/gcc/cgraph.h
index 18839a4a5ec..ca2a34afbae 100644
--- a/gcc/cgraph.h
+++ b/gcc/cgraph.h
@@ -100,7 +100,7 @@ enum symbol_partitioning_class
/* Base of all entries in the symbol table.
     The symtab_node is inherited by cgraph and varpol nodes.  */
-class GTY((desc ("%h.type"), tag ("SYMTAB_SYMBOL"),
+struct GTY((desc ("%h.type"), tag ("SYMTAB_SYMBOL"),
  	   chain_next ("%h.next"), chain_prev ("%h.previous")))
    symtab_node

Second line should get an extra space of indentation.

@@ -1673,8 +1675,10 @@ struct GTY(()) cgraph_indirect_call_info
    unsigned vptr_changed : 1;
  };
-struct GTY((chain_next ("%h.next_caller"), chain_prev ("%h.prev_caller"),
-	    for_user)) cgraph_edge {
+class GTY((chain_next ("%h.next_caller"), chain_prev ("%h.prev_caller"),
+	    for_user)) cgraph_edge

Similarly one fewer space here.

Done.  My simple script handles just one space issue but not this
one.

...
diff --git a/gcc/rtl.h b/gcc/rtl.h
index 31fba823435..fc1a66416cc 100644
--- a/gcc/rtl.h
+++ b/gcc/rtl.h
@@ -589,7 +594,7 @@ class GTY(()) rtx_nonjump_insn : public rtx_insn
       from rtl.def.  */
  };

-class GTY(()) rtx_jump_insn : public rtx_insn
+struct GTY(()) rtx_jump_insn : public rtx_insn
  {
  public:
    /* No extra fields, but adds the invariant:
@@ -533,7 +538,7 @@ is_a_helper <const rtx_sequence *>::test (const_rtx rt)
    return rt->code == SEQUENCE;
  }

-class GTY(()) rtx_insn : public rtx_def
+struct GTY(()) rtx_insn : public rtx_def
  {
  public:
    /* No extra fields, but adds the invariant:

Might as well get rid of these "public:"s too, unless you feel they
should be kept.

I think my script did that but gengtype choked on the struct when
it had no members so I had to put it back.  I'll try to remember
to reproduce it and open a bug for it.


OK with those changes (or without the last one), thanks.

Committed in r273308.

Martin


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]