public inbox for libstdc++-cvs@sourceware.org
help / color / mirror / Atom feed
From: Jonathan Wakely <redi@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org
Subject: [gcc r10-9567] libstdc++: Fix name clash with _Cosh in QNX headers [PR 95592]
Date: Mon, 29 Mar 2021 20:01:07 +0000 (GMT)	[thread overview]
Message-ID: <20210329200107.240F83851C3E@sourceware.org> (raw)

https://gcc.gnu.org/g:fa9c46939f9a5c5eb90338b80b213ec1e3579df7

commit r10-9567-gfa9c46939f9a5c5eb90338b80b213ec1e3579df7
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Wed Oct 28 12:35:44 2020 +0000

    libstdc++: Fix name clash with _Cosh in QNX headers [PR 95592]
    
    This replaces unqualified names like _Cosh with struct std::_Cosh to
    ensure there is no ambiguity with other entities with the same name.
    
    libstdc++-v3/ChangeLog:
    
            PR libstdc++/95592
            * include/bits/valarray_after.h (_DEFINE_EXPR_UNARY_OPERATOR)
            (_DEFINE_EXPR_BINARY_OPERATOR, _DEFINE_EXPR_BINARY_FUNCTION):
            Use elaborated-type-specifier and qualified-id to avoid
            ambiguities with QNX system headers.
            * testsuite/26_numerics/valarray/95592.cc: New test.
    
    (cherry picked from commit 72a87d82e0d0741d75c72c8f3d2fc070e3a02b5f)

Diff:
---
 libstdc++-v3/include/bits/valarray_after.h         | 74 +++++++++++-----------
 .../testsuite/26_numerics/valarray/95592.cc        | 29 +++++++++
 2 files changed, 66 insertions(+), 37 deletions(-)

diff --git a/libstdc++-v3/include/bits/valarray_after.h b/libstdc++-v3/include/bits/valarray_after.h
index cf84e17e5ad..439b3e9a5ed 100644
--- a/libstdc++-v3/include/bits/valarray_after.h
+++ b/libstdc++-v3/include/bits/valarray_after.h
@@ -331,9 +331,9 @@ namespace __detail
       return _Expr<_Closure, _Tp>(_Closure(this->_M_closure));            \
     }
 
-    _DEFINE_EXPR_UNARY_OPERATOR(+, __unary_plus)
-    _DEFINE_EXPR_UNARY_OPERATOR(-, __negate)
-    _DEFINE_EXPR_UNARY_OPERATOR(~, __bitwise_not)
+    _DEFINE_EXPR_UNARY_OPERATOR(+, struct std::__unary_plus)
+    _DEFINE_EXPR_UNARY_OPERATOR(-, struct std::__negate)
+    _DEFINE_EXPR_UNARY_OPERATOR(~, struct std::__bitwise_not)
 
 #undef _DEFINE_EXPR_UNARY_OPERATOR
 
@@ -402,24 +402,24 @@ namespace __detail
       return _Expr<_Closure, _Value>(_Closure(__v, __e ()));            \
     }
 
-    _DEFINE_EXPR_BINARY_OPERATOR(+, __plus)
-    _DEFINE_EXPR_BINARY_OPERATOR(-, __minus)
-    _DEFINE_EXPR_BINARY_OPERATOR(*, __multiplies)
-    _DEFINE_EXPR_BINARY_OPERATOR(/, __divides)
-    _DEFINE_EXPR_BINARY_OPERATOR(%, __modulus)
-    _DEFINE_EXPR_BINARY_OPERATOR(^, __bitwise_xor)
-    _DEFINE_EXPR_BINARY_OPERATOR(&, __bitwise_and)
-    _DEFINE_EXPR_BINARY_OPERATOR(|, __bitwise_or)
-    _DEFINE_EXPR_BINARY_OPERATOR(<<, __shift_left)
-    _DEFINE_EXPR_BINARY_OPERATOR(>>, __shift_right)
-    _DEFINE_EXPR_BINARY_OPERATOR(&&, __logical_and)
-    _DEFINE_EXPR_BINARY_OPERATOR(||, __logical_or)
-    _DEFINE_EXPR_BINARY_OPERATOR(==, __equal_to)
-    _DEFINE_EXPR_BINARY_OPERATOR(!=, __not_equal_to)
-    _DEFINE_EXPR_BINARY_OPERATOR(<, __less)
-    _DEFINE_EXPR_BINARY_OPERATOR(>, __greater)
-    _DEFINE_EXPR_BINARY_OPERATOR(<=, __less_equal)
-    _DEFINE_EXPR_BINARY_OPERATOR(>=, __greater_equal)
+    _DEFINE_EXPR_BINARY_OPERATOR(+, struct std::__plus)
+    _DEFINE_EXPR_BINARY_OPERATOR(-, struct std::__minus)
+    _DEFINE_EXPR_BINARY_OPERATOR(*, struct std::__multiplies)
+    _DEFINE_EXPR_BINARY_OPERATOR(/, struct std::__divides)
+    _DEFINE_EXPR_BINARY_OPERATOR(%, struct std::__modulus)
+    _DEFINE_EXPR_BINARY_OPERATOR(^, struct std::__bitwise_xor)
+    _DEFINE_EXPR_BINARY_OPERATOR(&, struct std::__bitwise_and)
+    _DEFINE_EXPR_BINARY_OPERATOR(|, struct std::__bitwise_or)
+    _DEFINE_EXPR_BINARY_OPERATOR(<<, struct std::__shift_left)
+    _DEFINE_EXPR_BINARY_OPERATOR(>>, struct std::__shift_right)
+    _DEFINE_EXPR_BINARY_OPERATOR(&&, struct std::__logical_and)
+    _DEFINE_EXPR_BINARY_OPERATOR(||, struct std::__logical_or)
+    _DEFINE_EXPR_BINARY_OPERATOR(==, struct std::__equal_to)
+    _DEFINE_EXPR_BINARY_OPERATOR(!=, struct std::__not_equal_to)
+    _DEFINE_EXPR_BINARY_OPERATOR(<, struct std::__less)
+    _DEFINE_EXPR_BINARY_OPERATOR(>, struct std::__greater)
+    _DEFINE_EXPR_BINARY_OPERATOR(<=, struct std::__less_equal)
+    _DEFINE_EXPR_BINARY_OPERATOR(>=, struct std::__greater_equal)
 
 #undef _DEFINE_EXPR_BINARY_OPERATOR
 
@@ -442,20 +442,20 @@ namespace __detail
       return _Expr<_Closure, _Tp>(_Closure(__v));                        \
     }
 
-    _DEFINE_EXPR_UNARY_FUNCTION(abs, _Abs)
-    _DEFINE_EXPR_UNARY_FUNCTION(cos, _Cos)
-    _DEFINE_EXPR_UNARY_FUNCTION(acos, _Acos)
-    _DEFINE_EXPR_UNARY_FUNCTION(cosh, _Cosh)
-    _DEFINE_EXPR_UNARY_FUNCTION(sin, _Sin)
-    _DEFINE_EXPR_UNARY_FUNCTION(asin, _Asin)
-    _DEFINE_EXPR_UNARY_FUNCTION(sinh, _Sinh)
-    _DEFINE_EXPR_UNARY_FUNCTION(tan, _Tan)
-    _DEFINE_EXPR_UNARY_FUNCTION(tanh, _Tanh)
-    _DEFINE_EXPR_UNARY_FUNCTION(atan, _Atan)
-    _DEFINE_EXPR_UNARY_FUNCTION(exp, _Exp)
-    _DEFINE_EXPR_UNARY_FUNCTION(log, _Log)
-    _DEFINE_EXPR_UNARY_FUNCTION(log10, _Log10)
-    _DEFINE_EXPR_UNARY_FUNCTION(sqrt, _Sqrt)
+    _DEFINE_EXPR_UNARY_FUNCTION(abs, struct std::_Abs)
+    _DEFINE_EXPR_UNARY_FUNCTION(cos, struct std::_Cos)
+    _DEFINE_EXPR_UNARY_FUNCTION(acos, struct std::_Acos)
+    _DEFINE_EXPR_UNARY_FUNCTION(cosh, struct std::_Cosh)
+    _DEFINE_EXPR_UNARY_FUNCTION(sin, struct std::_Sin)
+    _DEFINE_EXPR_UNARY_FUNCTION(asin, struct std::_Asin)
+    _DEFINE_EXPR_UNARY_FUNCTION(sinh, struct std::_Sinh)
+    _DEFINE_EXPR_UNARY_FUNCTION(tan, struct std::_Tan)
+    _DEFINE_EXPR_UNARY_FUNCTION(tanh, struct std::_Tanh)
+    _DEFINE_EXPR_UNARY_FUNCTION(atan, struct std::_Atan)
+    _DEFINE_EXPR_UNARY_FUNCTION(exp, struct std::_Exp)
+    _DEFINE_EXPR_UNARY_FUNCTION(log, struct std::_Log)
+    _DEFINE_EXPR_UNARY_FUNCTION(log10, struct std::_Log10)
+    _DEFINE_EXPR_UNARY_FUNCTION(sqrt, struct std::_Sqrt)
 
 #undef _DEFINE_EXPR_UNARY_FUNCTION
 
@@ -545,8 +545,8 @@ namespace __detail
       return _Expr<_Closure, _Tp>(_Closure(__t, __v));                 \
     }
 
-_DEFINE_EXPR_BINARY_FUNCTION(atan2, _Atan2)
-_DEFINE_EXPR_BINARY_FUNCTION(pow, _Pow)
+_DEFINE_EXPR_BINARY_FUNCTION(atan2, struct std::_Atan2)
+_DEFINE_EXPR_BINARY_FUNCTION(pow, struct std::_Pow)
 
 #undef _DEFINE_EXPR_BINARY_FUNCTION
 
diff --git a/libstdc++-v3/testsuite/26_numerics/valarray/95592.cc b/libstdc++-v3/testsuite/26_numerics/valarray/95592.cc
new file mode 100644
index 00000000000..e530cbdc212
--- /dev/null
+++ b/libstdc++-v3/testsuite/26_numerics/valarray/95592.cc
@@ -0,0 +1,29 @@
+// Copyright (C) 2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+// { dg-do compile }
+
+// PR libstdc++/95592
+// Collision with struct _Cosh when Cross compiling libstdc++
+
+namespace std
+{
+  double _Cosh(double);
+  double _Pow(double, double);
+}
+
+#include <valarray>


                 reply	other threads:[~2021-03-29 20:01 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210329200107.240F83851C3E@sourceware.org \
    --to=redi@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    --cc=libstdc++-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).