View | Details | Return to bug 2316 | Differences between
and this patch

Collapse All | Expand All

(-)libstdc++-v3/include/ext/string_conversions.h (-6 / +5 lines)
Lines 44-53 Link Here
44
_GLIBCXX_BEGIN_NAMESPACE_VERSION
44
_GLIBCXX_BEGIN_NAMESPACE_VERSION
45
45
46
  // Helper for all the sto* functions.
46
  // Helper for all the sto* functions.
47
  template<typename _TRet, typename _Ret = _TRet, typename _CharT,
47
  template<typename _Ret, typename _F, typename _CharT,
48
	   typename... _Base>
48
	   typename... _Base>
49
    _Ret
49
    _Ret
50
    __stoa(_TRet (*__convf) (const _CharT*, _CharT**, _Base...),
50
    __stoa(_F __convf,
51
	   const char* __name, const _CharT* __str, std::size_t* __idx,
51
	   const char* __name, const _CharT* __str, std::size_t* __idx,
52
	   _Base... __base)
52
	   _Base... __base)
53
    {
53
    {
Lines 55-61 Link Here
55
55
56
      _CharT* __endptr;
56
      _CharT* __endptr;
57
      errno = 0;
57
      errno = 0;
58
      const _TRet __tmp = __convf(__str, &__endptr, __base...);
58
      const auto __tmp = __convf(__str, &__endptr, __base...);
59
59
60
      if (__endptr == __str)
60
      if (__endptr == __str)
61
	std::__throw_invalid_argument(__name);
61
	std::__throw_invalid_argument(__name);
Lines 74-83 Link Here
74
    }
74
    }
75
75
76
  // Helper for the to_string / to_wstring functions.
76
  // Helper for the to_string / to_wstring functions.
77
  template<typename _String, typename _CharT = typename _String::value_type>
77
  template<typename _String, typename _F, typename _CharT = typename _String::value_type>
78
    _String
78
    _String
79
    __to_xstring(int (*__convf) (_CharT*, std::size_t, const _CharT*,
79
    __to_xstring(_F __convf, std::size_t __n,
80
				 __builtin_va_list), std::size_t __n,
81
		 const _CharT* __fmt, ...)
80
		 const _CharT* __fmt, ...)
82
    {
81
    {
83
      // XXX Eventually the result will be constructed in place in
82
      // XXX Eventually the result will be constructed in place in
(-)libstdc++-v3/include/bits/basic_string.h (-16 / +16 lines)
Lines 2807-2847 Link Here
2807
  // 21.4 Numeric Conversions [string.conversions].
2807
  // 21.4 Numeric Conversions [string.conversions].
2808
  inline int
2808
  inline int
2809
  stoi(const string& __str, size_t* __idx = 0, int __base = 10)
2809
  stoi(const string& __str, size_t* __idx = 0, int __base = 10)
2810
  { return __gnu_cxx::__stoa<long, int>(&std::strtol, "stoi", __str.c_str(),
2810
  { return __gnu_cxx::__stoa<int>(&std::strtol, "stoi", __str.c_str(),
2811
					__idx, __base); }
2811
					__idx, __base); }
2812
2812
2813
  inline long
2813
  inline long
2814
  stol(const string& __str, size_t* __idx = 0, int __base = 10)
2814
  stol(const string& __str, size_t* __idx = 0, int __base = 10)
2815
  { return __gnu_cxx::__stoa(&std::strtol, "stol", __str.c_str(),
2815
  { return __gnu_cxx::__stoa<long>(&std::strtol, "stol", __str.c_str(),
2816
			     __idx, __base); }
2816
			     __idx, __base); }
2817
2817
2818
  inline unsigned long
2818
  inline unsigned long
2819
  stoul(const string& __str, size_t* __idx = 0, int __base = 10)
2819
  stoul(const string& __str, size_t* __idx = 0, int __base = 10)
2820
  { return __gnu_cxx::__stoa(&std::strtoul, "stoul", __str.c_str(),
2820
  { return __gnu_cxx::__stoa<unsigned long>(&std::strtoul, "stoul", __str.c_str(),
2821
			     __idx, __base); }
2821
			     __idx, __base); }
2822
2822
2823
  inline long long
2823
  inline long long
2824
  stoll(const string& __str, size_t* __idx = 0, int __base = 10)
2824
  stoll(const string& __str, size_t* __idx = 0, int __base = 10)
2825
  { return __gnu_cxx::__stoa(&std::strtoll, "stoll", __str.c_str(),
2825
  { return __gnu_cxx::__stoa<long long>(&std::strtoll, "stoll", __str.c_str(),
2826
			     __idx, __base); }
2826
			     __idx, __base); }
2827
2827
2828
  inline unsigned long long
2828
  inline unsigned long long
2829
  stoull(const string& __str, size_t* __idx = 0, int __base = 10)
2829
  stoull(const string& __str, size_t* __idx = 0, int __base = 10)
2830
  { return __gnu_cxx::__stoa(&std::strtoull, "stoull", __str.c_str(),
2830
  { return __gnu_cxx::__stoa<unsigned long long>(&std::strtoull, "stoull", __str.c_str(),
2831
			     __idx, __base); }
2831
			     __idx, __base); }
2832
2832
2833
  // NB: strtof vs strtod.
2833
  // NB: strtof vs strtod.
2834
  inline float
2834
  inline float
2835
  stof(const string& __str, size_t* __idx = 0)
2835
  stof(const string& __str, size_t* __idx = 0)
2836
  { return __gnu_cxx::__stoa(&std::strtof, "stof", __str.c_str(), __idx); }
2836
  { return __gnu_cxx::__stoa<float>(&std::strtof, "stof", __str.c_str(), __idx); }
2837
2837
2838
  inline double
2838
  inline double
2839
  stod(const string& __str, size_t* __idx = 0)
2839
  stod(const string& __str, size_t* __idx = 0)
2840
  { return __gnu_cxx::__stoa(&std::strtod, "stod", __str.c_str(), __idx); }
2840
  { return __gnu_cxx::__stoa<double>(&std::strtod, "stod", __str.c_str(), __idx); }
2841
2841
2842
  inline long double
2842
  inline long double
2843
  stold(const string& __str, size_t* __idx = 0)
2843
  stold(const string& __str, size_t* __idx = 0)
2844
  { return __gnu_cxx::__stoa(&std::strtold, "stold", __str.c_str(), __idx); }
2844
  { return __gnu_cxx::__stoa<long double>(&std::strtold, "stold", __str.c_str(), __idx); }
2845
2845
2846
  // NB: (v)snprintf vs sprintf.
2846
  // NB: (v)snprintf vs sprintf.
2847
2847
Lines 2910-2950 Link Here
2910
#ifdef _GLIBCXX_USE_WCHAR_T
2910
#ifdef _GLIBCXX_USE_WCHAR_T
2911
  inline int 
2911
  inline int 
2912
  stoi(const wstring& __str, size_t* __idx = 0, int __base = 10)
2912
  stoi(const wstring& __str, size_t* __idx = 0, int __base = 10)
2913
  { return __gnu_cxx::__stoa<long, int>(&std::wcstol, "stoi", __str.c_str(),
2913
  { return __gnu_cxx::__stoa<int>(&std::wcstol, "stoi", __str.c_str(),
2914
					__idx, __base); }
2914
					__idx, __base); }
2915
2915
2916
  inline long 
2916
  inline long 
2917
  stol(const wstring& __str, size_t* __idx = 0, int __base = 10)
2917
  stol(const wstring& __str, size_t* __idx = 0, int __base = 10)
2918
  { return __gnu_cxx::__stoa(&std::wcstol, "stol", __str.c_str(),
2918
  { return __gnu_cxx::__stoa<long>(&std::wcstol, "stol", __str.c_str(),
2919
			     __idx, __base); }
2919
			     __idx, __base); }
2920
2920
2921
  inline unsigned long
2921
  inline unsigned long
2922
  stoul(const wstring& __str, size_t* __idx = 0, int __base = 10)
2922
  stoul(const wstring& __str, size_t* __idx = 0, int __base = 10)
2923
  { return __gnu_cxx::__stoa(&std::wcstoul, "stoul", __str.c_str(),
2923
  { return __gnu_cxx::__stoa<unsigned long>(&std::wcstoul, "stoul", __str.c_str(),
2924
			     __idx, __base); }
2924
			     __idx, __base); }
2925
2925
2926
  inline long long
2926
  inline long long
2927
  stoll(const wstring& __str, size_t* __idx = 0, int __base = 10)
2927
  stoll(const wstring& __str, size_t* __idx = 0, int __base = 10)
2928
  { return __gnu_cxx::__stoa(&std::wcstoll, "stoll", __str.c_str(),
2928
  { return __gnu_cxx::__stoa<long long>(&std::wcstoll, "stoll", __str.c_str(),
2929
			     __idx, __base); }
2929
			     __idx, __base); }
2930
2930
2931
  inline unsigned long long
2931
  inline unsigned long long
2932
  stoull(const wstring& __str, size_t* __idx = 0, int __base = 10)
2932
  stoull(const wstring& __str, size_t* __idx = 0, int __base = 10)
2933
  { return __gnu_cxx::__stoa(&std::wcstoull, "stoull", __str.c_str(),
2933
  { return __gnu_cxx::__stoa<unsigned long long>(&std::wcstoull, "stoull", __str.c_str(),
2934
			     __idx, __base); }
2934
			     __idx, __base); }
2935
2935
2936
  // NB: wcstof vs wcstod.
2936
  // NB: wcstof vs wcstod.
2937
  inline float
2937
  inline float
2938
  stof(const wstring& __str, size_t* __idx = 0)
2938
  stof(const wstring& __str, size_t* __idx = 0)
2939
  { return __gnu_cxx::__stoa(&std::wcstof, "stof", __str.c_str(), __idx); }
2939
  { return __gnu_cxx::__stoa<float>(&std::wcstof, "stof", __str.c_str(), __idx); }
2940
2940
2941
  inline double
2941
  inline double
2942
  stod(const wstring& __str, size_t* __idx = 0)
2942
  stod(const wstring& __str, size_t* __idx = 0)
2943
  { return __gnu_cxx::__stoa(&std::wcstod, "stod", __str.c_str(), __idx); }
2943
  { return __gnu_cxx::__stoa<double>(&std::wcstod, "stod", __str.c_str(), __idx); }
2944
2944
2945
  inline long double
2945
  inline long double
2946
  stold(const wstring& __str, size_t* __idx = 0)
2946
  stold(const wstring& __str, size_t* __idx = 0)
2947
  { return __gnu_cxx::__stoa(&std::wcstold, "stold", __str.c_str(), __idx); }
2947
  { return __gnu_cxx::__stoa<long double>(&std::wcstold, "stold", __str.c_str(), __idx); }
2948
2948
2949
  // DR 1261.
2949
  // DR 1261.
2950
  inline wstring
2950
  inline wstring
(-)gcc/tree.c (-3 / +13 lines)
Lines 7521-7527 Link Here
7521
   If such a type has already been constructed, reuse it.  */
7521
   If such a type has already been constructed, reuse it.  */
7522
7522
7523
tree
7523
tree
7524
build_function_type (tree value_type, tree arg_types)
7524
build_function_type2 (tree value_type, tree arg_types, int extern_c)
7525
{
7525
{
7526
  tree t;
7526
  tree t;
7527
  hashval_t hashcode = 0;
7527
  hashval_t hashcode = 0;
Lines 7538-7547 Link Here
7538
  t = make_node (FUNCTION_TYPE);
7538
  t = make_node (FUNCTION_TYPE);
7539
  TREE_TYPE (t) = value_type;
7539
  TREE_TYPE (t) = value_type;
7540
  TYPE_ARG_TYPES (t) = arg_types;
7540
  TYPE_ARG_TYPES (t) = arg_types;
7541
  if(extern_c)
7542
  {
7543
    TYPE_MINVAL (t) = integer_one_node;
7544
  }
7541
7545
7542
  /* If we already have such a type, use the old one.  */
7546
  /* If we already have such a type, use the old one.  */
7543
  hashcode = iterative_hash_object (TYPE_HASH (value_type), hashcode);
7547
  hashcode = iterative_hash_object (TYPE_HASH (value_type), hashcode);
7544
  hashcode = type_hash_list (arg_types, hashcode);
7548
  hashcode = type_hash_list (arg_types, hashcode);
7549
  hashcode = iterative_hash_object (extern_c, hashcode);
7545
  t = type_hash_canon (hashcode, t);
7550
  t = type_hash_canon (hashcode, t);
7546
7551
7547
  /* Set up the canonical type. */
7552
  /* Set up the canonical type. */
Lines 7553-7565 Link Here
7553
  if (any_structural_p)
7558
  if (any_structural_p)
7554
    SET_TYPE_STRUCTURAL_EQUALITY (t);
7559
    SET_TYPE_STRUCTURAL_EQUALITY (t);
7555
  else if (any_noncanonical_p)
7560
  else if (any_noncanonical_p)
7556
    TYPE_CANONICAL (t) = build_function_type (TYPE_CANONICAL (value_type),
7561
    TYPE_CANONICAL (t) = build_function_type2 (TYPE_CANONICAL (value_type),
7557
					      canon_argtypes);
7562
					      canon_argtypes, extern_c);
7558
7563
7559
  if (!COMPLETE_TYPE_P (t))
7564
  if (!COMPLETE_TYPE_P (t))
7560
    layout_type (t);
7565
    layout_type (t);
7561
  return t;
7566
  return t;
7562
}
7567
}
7568
tree
7569
build_function_type (tree value_type, tree arg_types)
7570
{
7571
  return build_function_type2 (value_type, arg_types, 0);
7572
}
7563
7573
7564
/* Build variant of function type ORIG_TYPE skipping ARGS_TO_SKIP.  */
7574
/* Build variant of function type ORIG_TYPE skipping ARGS_TO_SKIP.  */
7565
7575
(-)gcc/tree.h (+1 lines)
Lines 4337-4342 Link Here
4337
extern tree build_nonshared_array_type (tree, tree);
4337
extern tree build_nonshared_array_type (tree, tree);
4338
extern tree build_array_type_nelts (tree, unsigned HOST_WIDE_INT);
4338
extern tree build_array_type_nelts (tree, unsigned HOST_WIDE_INT);
4339
extern tree build_function_type (tree, tree);
4339
extern tree build_function_type (tree, tree);
4340
extern tree build_function_type2 (tree, tree, int);
4340
extern tree build_function_type_list (tree, ...);
4341
extern tree build_function_type_list (tree, ...);
4341
extern tree build_function_type_skip_args (tree, bitmap);
4342
extern tree build_function_type_skip_args (tree, bitmap);
4342
extern tree build_function_decl_skip_args (tree, bitmap);
4343
extern tree build_function_decl_skip_args (tree, bitmap);
(-)gcc/cp/typeck.c (+2 lines)
Lines 1281-1286 Link Here
1281
	return false;
1281
	return false;
1282
      if (!compparms (TYPE_ARG_TYPES (t1), TYPE_ARG_TYPES (t2)))
1282
      if (!compparms (TYPE_ARG_TYPES (t1), TYPE_ARG_TYPES (t2)))
1283
	return false;
1283
	return false;
1284
      if (TYPE_MINVAL (t1) != TYPE_MINVAL (t2))
1285
	return false;
1284
      break;
1286
      break;
1285
1287
1286
    case ARRAY_TYPE:
1288
    case ARRAY_TYPE:
(-)gcc/cp/decl.c (-1 / +1 lines)
Lines 9177-9183 Link Here
9177
		parms = NULL_TREE;
9177
		parms = NULL_TREE;
9178
	      }
9178
	      }
9179
9179
9180
	    type = build_function_type (type, arg_types);
9180
	    type = build_function_type2 (type, arg_types, current_lang_name == lang_name_c);
9181
	  }
9181
	  }
9182
	  break;
9182
	  break;
9183
9183
(-)gcc/cp/mangle.c (+2 lines)
Lines 2264-2269 Link Here
2264
    }
2264
    }
2265
2265
2266
  write_char ('F');
2266
  write_char ('F');
2267
  if(TYPE_MINVAL (type))
2268
    write_char ('Y');
2267
  /* We don't track whether or not a type is `extern "C"'.  Note that
2269
  /* We don't track whether or not a type is `extern "C"'.  Note that
2268
     you can have an `extern "C"' function that does not have
2270
     you can have an `extern "C"' function that does not have
2269
     `extern "C"' type, and vice versa:
2271
     `extern "C"' type, and vice versa:

Return to bug 2316