]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Disable gcc_rich_location copying and assignment.
authorMartin Sebor <msebor@redhat.com>
Tue, 31 Aug 2021 17:15:21 +0000 (11:15 -0600)
committerMartin Sebor <msebor@redhat.com>
Tue, 31 Aug 2021 17:15:21 +0000 (11:15 -0600)
gcc/cp/ChangeLog:

* parser.c (cp_parser_selection_statement): Use direct initialization
instead of copy.

gcc/ChangeLog:

* gcc-rich-location.h (gcc_rich_location): Make ctor explicit.

libcpp/ChangeLog:

* include/line-map.h (class rich_location): Disable copying and
assignment.

gcc/cp/parser.c
gcc/gcc-rich-location.h
libcpp/include/line-map.h

index 7dc4eae7102537fb614efba58b2d8d58a05f12cf..1e2a4b121eaf742a071b8ca531ef94cb8d4d2e07 100644 (file)
@@ -12848,7 +12848,7 @@ cp_parser_selection_statement (cp_parser* parser, bool *if_p,
            IF_STMT_CONSTEVAL_P (statement) = true;
            condition = finish_if_stmt_cond (boolean_false_node, statement);
 
-           gcc_rich_location richloc = tok->location;
+           gcc_rich_location richloc (tok->location);
            bool non_compound_stmt_p = false;
            if (cp_lexer_next_token_is_not (parser->lexer, CPP_OPEN_BRACE))
              {
@@ -12876,7 +12876,7 @@ cp_parser_selection_statement (cp_parser* parser, bool *if_p,
                                                RID_ELSE))
              {
                cp_token *else_tok = cp_lexer_peek_token (parser->lexer);
-               gcc_rich_location else_richloc = else_tok->location;
+               gcc_rich_location else_richloc (else_tok->location);
                guard_tinfo = get_token_indent_info (else_tok);
                /* Consume the `else' keyword.  */
                cp_lexer_consume_token (parser->lexer);
index 00747631025f021806a76500ef754d4a6adc5325..2a9e5db65d5199a5b58ebf49de9991483c81305c 100644 (file)
@@ -21,14 +21,16 @@ along with GCC; see the file COPYING3.  If not see
 #define GCC_RICH_LOCATION_H
 
 /* A gcc_rich_location is libcpp's rich_location with additional
-   helper methods for working with gcc's types.  */
+   helper methods for working with gcc's types.  The class is not
+   copyable or assignable because rich_location isn't. */
+
 class gcc_rich_location : public rich_location
 {
  public:
   /* Constructors.  */
 
   /* Constructing from a location.  */
-  gcc_rich_location (location_t loc, const range_label *label = NULL)
+  explicit gcc_rich_location (location_t loc, const range_label *label = NULL)
   : rich_location (line_table, loc, label)
   {
   }
index 7d964172469cf7d41421c5ec1c33d40ea238d5c7..464494bfb5bc96112c3e9fa51298a2b61ca4d0e2 100644 (file)
@@ -1670,6 +1670,12 @@ class rich_location
   /* Destructor.  */
   ~rich_location ();
 
+  /* The class manages the memory pointed to by the elements of
+     the M_FIXIT_HINTS vector and is not meant to be copied or
+     assigned.  */
+  rich_location (const rich_location &) = delete;
+  void operator= (const rich_location &) = delete;
+
   /* Accessors.  */
   location_t get_loc () const { return get_loc (0); }
   location_t get_loc (unsigned int idx) const;