Fix bustage on VC++ and gcc 2.7.2.x caused by incorrect overload resolution.

This commit is contained in:
dbaron%fas.harvard.edu 2001-04-07 17:25:16 +00:00
parent a3c8569fdf
commit 1244386ebc
3 changed files with 63 additions and 2 deletions

View File

@ -3487,6 +3487,51 @@ if test "$_PEDANTIC"; then
esac
fi
dnl Autoconf test for gcc 2.7.2.x (and maybe others?) so that we don't
dnl provide non-const forms of the operator== for comparing nsCOMPtrs to
dnl raw pointers in nsCOMPtr.h. (VC++ has the same bug.)
AC_LANG_CPLUSPLUS
_SAVE_CXXFLAGS=$CXXFLAGS
CXXFLAGS="$CXXFLAGS ${_WARNINGS_CXXFLAGS}"
AC_CACHE_CHECK(for correct overload resolution with const and templates,
ac_nscap_nonconst_opeq_bug,
[AC_TRY_COMPILE([
template <class T>
class Pointer
{
public:
T* myPtr;
};
template <class T, class U>
int operator==(const Pointer<T>& rhs, U* lhs)
{
return rhs.myPtr == lhs;
}
template <class T, class U>
int operator==(const Pointer<T>& rhs, const U* lhs)
{
return rhs.myPtr == lhs;
}
],
[
Pointer<int> foo;
const int* bar;
return foo == bar;
],
ac_nscap_nonconst_opeq_bug="no",
ac_nscap_nonconst_opeq_bug="yes")])
AC_LANG_C
CXXFLAGS="$_SAVE_CXXFLAGS"
if test "$ac_nscap_nonconst_opeq_bug" = "yes" ; then
AC_DEFINE(NSCAP_DONT_PROVIDE_NONCONST_OPEQ)
fi
dnl pass -Wno-long-long to the compiler
MOZ_ARG_ENABLE_BOOL(long-long-warning,
[ --enable-long-long-warning

View File

@ -1193,7 +1193,15 @@ operator!=( const U* lhs, const nsCOMPtr<T>& rhs )
// better conversion for the other argument, define additional
// |operator==| without the |const| on the raw pointer.
// See bug 65664 for details.
#ifndef CANT_RESOLVE_CPP_CONST_AMBIGUITY
// This is defined by an autoconf test, but VC++ also has a bug that
// prevents us from using these. (It also, fortunately, has the bug
// that we don't need them either.)
#ifdef _MSC_VER
#define NSCAP_DONT_PROVIDE_NONCONST_OPEQ
#endif
#ifndef NSCAP_DONT_PROVIDE_NONCONST_OPEQ
template <class T, class U>
inline
NSCAP_BOOL

View File

@ -1193,7 +1193,15 @@ operator!=( const U* lhs, const nsCOMPtr<T>& rhs )
// better conversion for the other argument, define additional
// |operator==| without the |const| on the raw pointer.
// See bug 65664 for details.
#ifndef CANT_RESOLVE_CPP_CONST_AMBIGUITY
// This is defined by an autoconf test, but VC++ also has a bug that
// prevents us from using these. (It also, fortunately, has the bug
// that we don't need them either.)
#ifdef _MSC_VER
#define NSCAP_DONT_PROVIDE_NONCONST_OPEQ
#endif
#ifndef NSCAP_DONT_PROVIDE_NONCONST_OPEQ
template <class T, class U>
inline
NSCAP_BOOL