Fix Issue 11861 (#11886)
authorXiang Fan <xiangfan@microsoft.com>
Wed, 24 May 2017 22:51:38 +0000 (15:51 -0700)
committerJan Kotas <jkotas@microsoft.com>
Wed, 24 May 2017 22:51:38 +0000 (15:51 -0700)
* Fix issues exposed by building with MSVC and /permissive-.

Using full-qualified name to declare members inside class is ill-formed and incorrectly allowed by MSVC.
MSVC now gives error when /permissive- is used.

* Add a forward declaration for SafeAddRef from utilcode.h.
SafeAddRef in holder.h calls SafeAddRef in utilcode.h. The latter hasn't been declared yet, so it isn't a valid candidate during overload resolution.
It happens to work in MSVC default mode because of the lack of two phase name lookup.

src/inc/holder.h

index a92eeab..299056b 100644 (file)
@@ -1449,6 +1449,14 @@ class DacHolder
 // Holder-specific clr::SafeAddRef and clr::SafeRelease helper functions.
 namespace clr
 {
+    // Copied from utilcode.h. We can't include the header directly because there
+    // is circular reference.
+    // Forward declare the overload which is used by 'SafeAddRef' below.
+    template <typename ItfT>
+    static inline
+    typename std::enable_if< std::is_pointer<ItfT>::value, ItfT >::type
+    SafeAddRef(ItfT pItf);
+
     template < typename ItfT > __checkReturn
     ItfT *
     SafeAddRef(ReleaseHolder<ItfT> & pItf)