With a host compiler that does not define __GNUC__, the obstack.h
macros apply -> directly to their argument instead of first converting
it to struct obstack *.  Passing an obstack_watermark to them then
fails to compile.  Add operator-> so that both versions work.

Bootstrapped and regression-tested on x86_64-pc-linux-gnu
(default languages, --disable-multilib), with no new regressions
relative to the unmodified baseline.

Also tested with a non-GCC, EDG-based host compiler (GNU extensions
disabled) on a non-glibc platform, where the patch resolves a build
failure.

gcc/ChangeLog:

        * obstack-utils.h (obstack_watermark::operator->): New.

Signed-off-by: Shiva <[email protected]>
---
 gcc/obstack-utils.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/gcc/obstack-utils.h b/gcc/obstack-utils.h
index 948f0711e69..eb74c1bca96 100644
--- a/gcc/obstack-utils.h
+++ b/gcc/obstack-utils.h
@@ -73,6 +73,9 @@ public:
   ~obstack_watermark () { obstack_free (m_obstack, m_start); }
 
   operator obstack *() const { return m_obstack; }
+  // The non-GNU versions of the obstack.h macros apply -> directly
+  // to their argument.
+  obstack *operator-> () const { return m_obstack; }
   void keep () { m_start = XOBNEWVAR (m_obstack, char, 0); }
 
 private:

Reply via email to