Message ID | 1573867416-55618-5-git-send-email-dmalcolm@redhat.com |
---|---|
State | New |
Headers | show |
Series | RFC: Add a static analysis framework to GCC | expand |
On 11/15/19 6:22 PM, David Malcolm wrote: > gcc/ChangeLog: > * sbitmap.h (auto_sbitmap): Add operator const sbitmap &. > --- > gcc/sbitmap.h | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/gcc/sbitmap.h b/gcc/sbitmap.h > index a33175d..3c5b0a4 100644 > --- a/gcc/sbitmap.h > +++ b/gcc/sbitmap.h > @@ -295,6 +295,7 @@ public: > > /* Allow calling sbitmap functions on our bitmap. */ > operator sbitmap () { return m_bitmap; } > + operator const sbitmap &() const { return m_bitmap; } Did you mean: operator const_sbitmap () const { return m_bitmap; } ? bitmap is a pointer to simple_bitmap_def so const sbitmap& is a const reference to a non-constant simple_bitmap_def, i.e., a modifiable simple_bitmap_def object. I'm guessing the goal of the new overload is to prevent the object from being modified. Otherwise, if you're just adding the overload to make conversions from const auto_sbitmap valid, then making the existing operator const would do that. Martin > > private: > /* Prevent making a copy that refers to our sbitmap. */ >
diff --git a/gcc/sbitmap.h b/gcc/sbitmap.h index a33175d..3c5b0a4 100644 --- a/gcc/sbitmap.h +++ b/gcc/sbitmap.h @@ -295,6 +295,7 @@ public: /* Allow calling sbitmap functions on our bitmap. */ operator sbitmap () { return m_bitmap; } + operator const sbitmap &() const { return m_bitmap; } private: /* Prevent making a copy that refers to our sbitmap. */