libstdc++: Fix name clash with _Cosh in QNX headers [PR 95592]
authorJonathan Wakely <jwakely@redhat.com>
Wed, 28 Oct 2020 12:35:44 +0000 (12:35 +0000)
committerJonathan Wakely <jwakely@redhat.com>
Wed, 28 Oct 2020 12:35:44 +0000 (12:35 +0000)
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.

libstdc++-v3/include/bits/valarray_after.h
libstdc++-v3/testsuite/26_numerics/valarray/95592.cc [new file with mode: 0644]

index cf84e17e5ade127ba3cbdea9aaf72b7c990f12eb..439b3e9a5edd7f34c77e7a33fc640c385a01d852 100644 (file)
@@ -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 (file)
index 0000000..e530cbd
--- /dev/null
@@ -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>