Bug 573143 - invalid arguments to template
Summary: invalid arguments to template
Status: NEW
Alias: None
Product: CDT
Classification: Tools
Component: cdt-indexer (show other bugs)
Version: 10.2.0   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact: Jonah Graham CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-04-25 12:12 EDT by Joost Kraaijeveld CLA
Modified: 2021-06-30 23:10 EDT (History)
3 users (show)

See Also:


Attachments
Example showing the problem (2.20 KB, text/x-c++src)
2021-04-25 12:12 EDT, Joost Kraaijeveld CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Joost Kraaijeveld CLA 2021-04-25 12:12:49 EDT
Created attachment 286226 [details]
Example showing the problem

The indexer gives a semantic error "Invalid arguments" on the lines 76-78 of the code attached. Gcc 10 ( g++ (Debian 10.2.1-6) 10.2.1 20210110 ) compiles it OK and I think it is correct C++-code.
Comment 1 Marc-André Laperle CLA 2021-06-30 23:10:20 EDT
Smaller and stand-alone:

struct JavaObject {
  void toString() {
  }
};

template<bool, typename _Tp = void>
struct enable_if {
};

// Partial specialization for true.
template<typename _Tp>
struct enable_if<true, _Tp> {
  typedef _Tp type;
};

template<typename _Tp, _Tp __v>
struct integral_constant {
  static constexpr _Tp value = __v;
  typedef integral_constant<_Tp, __v> type;
};

template<typename _Tp, _Tp __v>
constexpr _Tp integral_constant<_Tp, __v>::value;

typedef integral_constant<bool, true> true_type;

typedef integral_constant<bool, false> false_type;

template<typename >
struct is_const: public false_type {
};

template<typename _Tp>
struct is_const<_Tp const> : public true_type {
};

template<typename >
struct __is_member_function_pointer_helper: public false_type {
};

template<typename _Tp, typename _Cp>
struct __is_member_function_pointer_helper<_Tp _Cp::*> : public integral_constant<bool, !is_const<const _Tp>::value>::type {
};

template<typename _Tp>
struct is_member_function_pointer: public __is_member_function_pointer_helper<_Tp>::type {
};

struct Adaptor {
  template<typename T, typename enable_if<is_member_function_pointer<decltype(&T::asString)>::value>::type* = nullptr>
  void convert(const T &aT) {
  }

  template<typename T, typename enable_if<is_member_function_pointer<decltype(&T::toString)>::value>::type* = nullptr>
  void convert(const T &aT) {
  }
};

int main() {

  JavaObject jo;
  Adaptor adaptor;
  adaptor.convert(jo);

  return 0;
}