[PATCH] D29880: Workaround MSVC bug when using TrailingObjects from a template.

Hugh Bellamy via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 13 04:27:43 PST 2017


hughbe accepted this revision.
hughbe added a comment.
This revision is now accepted and ready to land.

I'm sorry @jyknight

Swift still doesn't compile. The error is different this time thankfully:

  #include "llvm/Support/TrailingObjects.h"
  
  // Test the use of TrailingObjects with a template class. This
  // previously failed to compile due to a bug in MSVC's member access
  // control/lookup handling for OverloadToken.
  template<typename Derived>
  class Class5 : private llvm::TrailingObjects<Derived, float, int/*, void* */> {
    using TrailingObjects = typename llvm::TrailingObjects<Derived, float, int/*,  void* */>;
    friend TrailingObjects;
  
    size_t numTrailingObjects(
      typename TrailingObjects::template OverloadToken<float>) const {
      return 1;
    }
  
    size_t numTrailingObjects(
      typename TrailingObjects::template OverloadToken<int>) const {
      return 2;
    }
  };
  
  template class Class5<int>; // instantiate to trigger the error
  // 1>consoleapplication1.cpp(17): error C2535: 'size_t Class5<Derived>::numTrailingObjects(TrailingObjects<BaseTy,TrailingTys...>::TrailingObjectsImpl<llvm::trailing_objects_internal::AlignmentCalcHelper<TrailingTys...>::Alignment,BaseTy,llvm::TrailingObjects<BaseTy,TrailingTys...>,BaseTy,TrailingTys...>::OverloadToken) const': member function already defined or declared
  // 1>  consoleapplication1.cpp(11) : note: see declaration of 'Class5<Derived>::numTrailingObjects'
  // 1>  consoleapplication1.cpp(20) : note: see reference to class template instantiation 'Class5<Derived>' being compiled
  
  // Uncommenting either of the ", void*" generic parameters removes the errors.
  // HOWEVER, uncommenting both restores the errors.


https://reviews.llvm.org/D29880





More information about the llvm-commits mailing list