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

Collapse All | Expand All

(-)gcc/cp/cp-tree.h.jj (+5 lines)
Lines 504-509 extern GTY(()) tree cp_global_trees[CPTI Link Here
504
      OVL_NESTED_P (in OVERLOAD)
504
      OVL_NESTED_P (in OVERLOAD)
505
      DECL_MODULE_EXPORT_P (in _DECL)
505
      DECL_MODULE_EXPORT_P (in _DECL)
506
      PACK_EXPANSION_FORCE_EXTRA_ARGS_P (in *_PACK_EXPANSION)
506
      PACK_EXPANSION_FORCE_EXTRA_ARGS_P (in *_PACK_EXPANSION)
507
      LAMBDA_EXPR_STATIC_P (in LAMBDA_EXPR)
507
   4: IDENTIFIER_MARKED (IDENTIFIER_NODEs)
508
   4: IDENTIFIER_MARKED (IDENTIFIER_NODEs)
508
      TREE_HAS_CONSTRUCTOR (in INDIRECT_REF, SAVE_EXPR, CONSTRUCTOR,
509
      TREE_HAS_CONSTRUCTOR (in INDIRECT_REF, SAVE_EXPR, CONSTRUCTOR,
509
	  CALL_EXPR, or FIELD_DECL).
510
	  CALL_EXPR, or FIELD_DECL).
Lines 1488-1493 enum cp_lambda_default_capture_mode_type Link Here
1488
#define LAMBDA_EXPR_CAPTURE_OPTIMIZED(NODE) \
1489
#define LAMBDA_EXPR_CAPTURE_OPTIMIZED(NODE) \
1489
  TREE_LANG_FLAG_2 (LAMBDA_EXPR_CHECK (NODE))
1490
  TREE_LANG_FLAG_2 (LAMBDA_EXPR_CHECK (NODE))
1490
1491
1492
/* Predicate tracking whether the lambda was declared 'static'.  */
1493
#define LAMBDA_EXPR_STATIC_P(NODE) \
1494
  TREE_LANG_FLAG_3 (LAMBDA_EXPR_CHECK (NODE))
1495
1491
/* True if this TREE_LIST in LAMBDA_EXPR_CAPTURE_LIST is for an explicit
1496
/* True if this TREE_LIST in LAMBDA_EXPR_CAPTURE_LIST is for an explicit
1492
   capture.  */
1497
   capture.  */
1493
#define LAMBDA_CAPTURE_EXPLICIT_P(NODE) \
1498
#define LAMBDA_CAPTURE_EXPLICIT_P(NODE) \
(-)gcc/cp/parser.cc.jj (-9 / +36 lines)
Lines 1994-2000 enum Link Here
1994
     constexpr.  */
1994
     constexpr.  */
1995
  CP_PARSER_FLAGS_ONLY_TYPE_OR_CONSTEXPR = 0x8,
1995
  CP_PARSER_FLAGS_ONLY_TYPE_OR_CONSTEXPR = 0x8,
1996
  /* When parsing a decl-specifier-seq, only allow mutable, constexpr or
1996
  /* When parsing a decl-specifier-seq, only allow mutable, constexpr or
1997
     for C++20 consteval.  */
1997
     for C++20 consteval or for C++23 static.  */
1998
  CP_PARSER_FLAGS_ONLY_MUTABLE_OR_CONSTEXPR = 0x10,
1998
  CP_PARSER_FLAGS_ONLY_MUTABLE_OR_CONSTEXPR = 0x10,
1999
  /* When parsing a decl-specifier-seq, allow missing typename.  */
1999
  /* When parsing a decl-specifier-seq, allow missing typename.  */
2000
  CP_PARSER_FLAGS_TYPENAME_OPTIONAL = 0x20,
2000
  CP_PARSER_FLAGS_TYPENAME_OPTIONAL = 0x20,
Lines 11714-11726 cp_parser_lambda_declarator_opt (cp_pars Link Here
11714
      omitted_parms_loc = UNKNOWN_LOCATION;
11714
      omitted_parms_loc = UNKNOWN_LOCATION;
11715
    }
11715
    }
11716
11716
11717
  if (lambda_specs.storage_class == sc_mutable)
11717
  if (lambda_specs.storage_class == sc_mutable
11718
      || lambda_specs.storage_class == sc_static)
11718
    {
11719
    {
11719
      LAMBDA_EXPR_MUTABLE_P (lambda_expr) = 1;
11720
      if (lambda_specs.storage_class == sc_mutable)
11720
      quals = TYPE_UNQUALIFIED;
11721
	{
11722
	  LAMBDA_EXPR_MUTABLE_P (lambda_expr) = 1;
11723
	  quals = TYPE_UNQUALIFIED;
11724
	}
11725
      else if (LAMBDA_EXPR_DEFAULT_CAPTURE_MODE (lambda_expr) != CPLD_NONE
11726
	       || LAMBDA_EXPR_CAPTURE_LIST (lambda_expr))
11727
	error_at (lambda_specs.locations[ds_storage_class],
11728
		  "%<static%> lambda specifier with lambda capture");
11729
      else
11730
	{
11731
	  LAMBDA_EXPR_STATIC_P (lambda_expr) = 1;
11732
	  quals = TYPE_UNQUALIFIED;
11733
	}
11721
      if (lambda_specs.conflicting_specifiers_p)
11734
      if (lambda_specs.conflicting_specifiers_p)
11722
	error_at (lambda_specs.locations[ds_storage_class],
11735
	error_at (lambda_specs.locations[ds_storage_class],
11723
		  "duplicate %<mutable%>");
11736
		  "conflicting lambda specifiers");
11724
    }
11737
    }
11725
11738
11726
  tx_qual = cp_parser_tx_qualifier_opt (parser);
11739
  tx_qual = cp_parser_tx_qualifier_opt (parser);
Lines 11807-11812 cp_parser_lambda_declarator_opt (cp_pars Link Here
11807
    if (lambda_specs.locations[ds_consteval])
11820
    if (lambda_specs.locations[ds_consteval])
11808
      return_type_specs.locations[ds_consteval]
11821
      return_type_specs.locations[ds_consteval]
11809
	= lambda_specs.locations[ds_consteval];
11822
	= lambda_specs.locations[ds_consteval];
11823
    if (LAMBDA_EXPR_STATIC_P (lambda_expr))
11824
      {
11825
	return_type_specs.storage_class = sc_static;
11826
	return_type_specs.locations[ds_storage_class]
11827
	  = lambda_specs.locations[ds_storage_class];
11828
      }
11810
11829
11811
    p = obstack_alloc (&declarator_obstack, 0);
11830
    p = obstack_alloc (&declarator_obstack, 0);
11812
11831
Lines 11830-11837 cp_parser_lambda_declarator_opt (cp_pars Link Here
11830
      {
11849
      {
11831
	DECL_INITIALIZED_IN_CLASS_P (fco) = 1;
11850
	DECL_INITIALIZED_IN_CLASS_P (fco) = 1;
11832
	DECL_ARTIFICIAL (fco) = 1;
11851
	DECL_ARTIFICIAL (fco) = 1;
11833
	/* Give the object parameter a different name.  */
11852
	if (!LAMBDA_EXPR_STATIC_P (lambda_expr))
11834
	DECL_NAME (DECL_ARGUMENTS (fco)) = closure_identifier;
11853
	  /* Give the object parameter a different name.  */
11854
	  DECL_NAME (DECL_ARGUMENTS (fco)) = closure_identifier;
11835
	DECL_SET_LAMBDA_FUNCTION (fco, true);
11855
	DECL_SET_LAMBDA_FUNCTION (fco, true);
11836
      }
11856
      }
11837
    if (template_param_list)
11857
    if (template_param_list)
Lines 16008-16015 cp_parser_decl_specifier_seq (cp_parser* Link Here
16008
	  && token->keyword != RID_MUTABLE
16028
	  && token->keyword != RID_MUTABLE
16009
	  && token->keyword != RID_CONSTEXPR
16029
	  && token->keyword != RID_CONSTEXPR
16010
	  && token->keyword != RID_CONSTEVAL)
16030
	  && token->keyword != RID_CONSTEVAL)
16011
	error_at (token->location, "%qD invalid in lambda",
16031
	{
16012
		  ridpointers[token->keyword]);
16032
	  if (token->keyword != RID_STATIC)
16033
	    error_at (token->location, "%qD invalid in lambda",
16034
		      ridpointers[token->keyword]);
16035
	  else if (cxx_dialect < cxx23)
16036
	    pedwarn (token->location, OPT_Wc__23_extensions,
16037
		     "%qD only valid in lambda with %<-std=c++23%> or "
16038
		     "%<-std=gnu++23%>", ridpointers[token->keyword]);
16039
	}
16013
16040
16014
      if (ds != ds_last)
16041
      if (ds != ds_last)
16015
	set_and_check_decl_spec_loc (decl_specs, ds, token);
16042
	set_and_check_decl_spec_loc (decl_specs, ds, token);
(-)gcc/cp/decl.cc.jj (-1 / +18 lines)
Lines 15299-15306 grok_op_properties (tree decl, bool comp Link Here
15299
     an enumeration, or a reference to an enumeration.  13.4.0.6 */
15299
     an enumeration, or a reference to an enumeration.  13.4.0.6 */
15300
  if (! methodp || DECL_STATIC_FUNCTION_P (decl))
15300
  if (! methodp || DECL_STATIC_FUNCTION_P (decl))
15301
    {
15301
    {
15302
      if (operator_code == CALL_EXPR)
15303
	{
15304
	  if (! DECL_STATIC_FUNCTION_P (decl))
15305
	    {
15306
	      error_at (loc, "%qD must be a member function", decl);
15307
	      return false;
15308
	    }
15309
	  if (cxx_dialect < cxx23
15310
	      /* For lambdas we diagnose static lambda specifier elsewhere.  */
15311
	      && ! LAMBDA_FUNCTION_P (decl)
15312
	      /* For instantiations, we have diagnosed this already.  */
15313
	      && ! DECL_USE_TEMPLATE (decl))
15314
	    pedwarn (loc, OPT_Wc__23_extensions, "%qD may be a static member "
15315
	      "function only with %<-std=c++23%> or %<-std=gnu++23%>", decl);
15316
	  /* There are no further restrictions on the arguments to an
15317
	     overloaded "operator ()".  */
15318
	  return true;
15319
	}
15302
      if (operator_code == TYPE_EXPR
15320
      if (operator_code == TYPE_EXPR
15303
	  || operator_code == CALL_EXPR
15304
	  || operator_code == COMPONENT_REF
15321
	  || operator_code == COMPONENT_REF
15305
	  || operator_code == ARRAY_REF
15322
	  || operator_code == ARRAY_REF
15306
	  || operator_code == NOP_EXPR)
15323
	  || operator_code == NOP_EXPR)
(-)gcc/cp/call.cc.jj (-4 / +28 lines)
Lines 12133-12142 joust (struct z_candidate *cand1, struct Link Here
12133
  len = cand1->num_convs;
12133
  len = cand1->num_convs;
12134
  if (len != cand2->num_convs)
12134
  if (len != cand2->num_convs)
12135
    {
12135
    {
12136
      int static_1 = DECL_STATIC_FUNCTION_P (cand1->fn);
12136
      int static_1 = (TREE_CODE (cand1->fn) == FUNCTION_DECL
12137
      int static_2 = DECL_STATIC_FUNCTION_P (cand2->fn);
12137
		      && DECL_STATIC_FUNCTION_P (cand1->fn));
12138
      int static_2 = (TREE_CODE (cand2->fn) == FUNCTION_DECL
12139
		      && DECL_STATIC_FUNCTION_P (cand2->fn));
12138
12140
12139
      if (DECL_CONSTRUCTOR_P (cand1->fn)
12141
      if (TREE_CODE (cand1->fn) == FUNCTION_DECL
12142
	  && TREE_CODE (cand2->fn) == FUNCTION_DECL
12143
	  && DECL_CONSTRUCTOR_P (cand1->fn)
12140
	  && is_list_ctor (cand1->fn) != is_list_ctor (cand2->fn))
12144
	  && is_list_ctor (cand1->fn) != is_list_ctor (cand2->fn))
12141
	/* We're comparing a near-match list constructor and a near-match
12145
	/* We're comparing a near-match list constructor and a near-match
12142
	   non-list constructor.  Just treat them as unordered.  */
12146
	   non-list constructor.  Just treat them as unordered.  */
Lines 12145-12153 joust (struct z_candidate *cand1, struct Link Here
12145
      gcc_assert (static_1 != static_2);
12149
      gcc_assert (static_1 != static_2);
12146
12150
12147
      if (static_1)
12151
      if (static_1)
12148
	off2 = 1;
12152
	{
12153
	  /* C++23 [over.best.ics.general] says:
12154
	     When the parameter is the implicit object parameter of a static
12155
	     member function, the implicit conversion sequence is a standard
12156
	     conversion sequence that is neither better nor worse than any
12157
	     other standard conversion sequence.
12158
	     Apply this for C++23 or when the static member function is
12159
	     overloaded call operator (C++23 feature we accept as an
12160
	     extension).  */
12161
	  if ((cxx_dialect >= cxx23
12162
	       || (DECL_OVERLOADED_OPERATOR_P (cand1->fn)
12163
		   && DECL_OVERLOADED_OPERATOR_IS (cand1->fn, CALL_EXPR)))
12164
	      && CONVERSION_RANK (cand2->convs[0]) >= cr_user)
12165
	    winner = -1;
12166
	  off2 = 1;
12167
	}
12149
      else
12168
      else
12150
	{
12169
	{
12170
	  if ((cxx_dialect >= cxx23
12171
	       || (DECL_OVERLOADED_OPERATOR_P (cand2->fn)
12172
		   && DECL_OVERLOADED_OPERATOR_IS (cand2->fn, CALL_EXPR)))
12173
	      && CONVERSION_RANK (cand1->convs[0]) >= cr_user)
12174
	    winner = -1;
12151
	  off1 = 1;
12175
	  off1 = 1;
12152
	  --len;
12176
	  --len;
12153
	}
12177
	}
(-)gcc/cp/lambda.cc.jj (-20 / +72 lines)
Lines 1099-1105 maybe_add_lambda_conv_op (tree type) Link Here
1099
  tree optype = TREE_TYPE (callop);
1099
  tree optype = TREE_TYPE (callop);
1100
  tree fn_result = TREE_TYPE (optype);
1100
  tree fn_result = TREE_TYPE (optype);
1101
1101
1102
  tree thisarg = build_int_cst (TREE_TYPE (DECL_ARGUMENTS (callop)), 0);
1102
  tree thisarg = NULL_TREE;
1103
  if (TREE_CODE (optype) == METHOD_TYPE)
1104
    thisarg = build_int_cst (TREE_TYPE (DECL_ARGUMENTS (callop)), 0);
1103
  if (generic_lambda_p)
1105
  if (generic_lambda_p)
1104
    {
1106
    {
1105
      ++processing_template_decl;
1107
      ++processing_template_decl;
Lines 1109-1126 maybe_add_lambda_conv_op (tree type) Link Here
1109
	 return expression for a deduced return call op to allow for simple
1111
	 return expression for a deduced return call op to allow for simple
1110
	 implementation of the conversion operator.  */
1112
	 implementation of the conversion operator.  */
1111
1113
1112
      tree instance = cp_build_fold_indirect_ref (thisarg);
1113
      tree objfn = lookup_template_function (DECL_NAME (callop),
1114
      tree objfn = lookup_template_function (DECL_NAME (callop),
1114
					     DECL_TI_ARGS (callop));
1115
					     DECL_TI_ARGS (callop));
1115
      objfn = build_min (COMPONENT_REF, NULL_TREE,
1116
      int nargs = list_length (DECL_ARGUMENTS (callop));
1116
			 instance, objfn, NULL_TREE);
1117
      if (thisarg)
1117
      int nargs = list_length (DECL_ARGUMENTS (callop)) - 1;
1118
	{
1119
	  tree instance = cp_build_fold_indirect_ref (thisarg);
1120
	  objfn = build_min (COMPONENT_REF, NULL_TREE,
1121
			     instance, objfn, NULL_TREE);
1122
	  --nargs;
1123
	  call = prepare_op_call (objfn, nargs);
1124
	}
1118
1125
1119
      call = prepare_op_call (objfn, nargs);
1120
      if (type_uses_auto (fn_result))
1126
      if (type_uses_auto (fn_result))
1121
	decltype_call = prepare_op_call (objfn, nargs);
1127
	decltype_call = prepare_op_call (objfn, nargs);
1122
    }
1128
    }
1123
  else
1129
  else if (thisarg)
1124
    {
1130
    {
1125
      direct_argvec = make_tree_vector ();
1131
      direct_argvec = make_tree_vector ();
1126
      direct_argvec->quick_push (thisarg);
1132
      direct_argvec->quick_push (thisarg);
Lines 1135-1143 maybe_add_lambda_conv_op (tree type) Link Here
1135
  tree fn_args = NULL_TREE;
1141
  tree fn_args = NULL_TREE;
1136
  {
1142
  {
1137
    int ix = 0;
1143
    int ix = 0;
1138
    tree src = DECL_CHAIN (DECL_ARGUMENTS (callop));
1144
    tree src = DECL_ARGUMENTS (callop);
1139
    tree tgt = NULL;
1145
    tree tgt = NULL;
1140
1146
1147
    if (thisarg)
1148
      src = DECL_CHAIN (src);
1149
    else if (!decltype_call)
1150
      src = NULL_TREE;
1141
    while (src)
1151
    while (src)
1142
      {
1152
      {
1143
	tree new_node = copy_node (src);
1153
	tree new_node = copy_node (src);
Lines 1160-1171 maybe_add_lambda_conv_op (tree type) Link Here
1160
	if (generic_lambda_p)
1170
	if (generic_lambda_p)
1161
	  {
1171
	  {
1162
	    tree a = tgt;
1172
	    tree a = tgt;
1163
	    if (DECL_PACK_P (tgt))
1173
	    if (thisarg)
1164
	      {
1174
	      {
1165
		a = make_pack_expansion (a);
1175
		if (DECL_PACK_P (tgt))
1166
		PACK_EXPANSION_LOCAL_P (a) = true;
1176
		  {
1177
		    a = make_pack_expansion (a);
1178
		    PACK_EXPANSION_LOCAL_P (a) = true;
1179
		  }
1180
		CALL_EXPR_ARG (call, ix) = a;
1167
	      }
1181
	      }
1168
	    CALL_EXPR_ARG (call, ix) = a;
1169
1182
1170
	    if (decltype_call)
1183
	    if (decltype_call)
1171
	      {
1184
	      {
Lines 1193-1199 maybe_add_lambda_conv_op (tree type) Link Here
1193
	     tf_warning_or_error);
1206
	     tf_warning_or_error);
1194
	}
1207
	}
1195
    }
1208
    }
1196
  else
1209
  else if (thisarg)
1197
    {
1210
    {
1198
      /* Don't warn on deprecated or unavailable lambda declarations, unless
1211
      /* Don't warn on deprecated or unavailable lambda declarations, unless
1199
	 the lambda is actually called.  */
1212
	 the lambda is actually called.  */
Lines 1203-1216 maybe_add_lambda_conv_op (tree type) Link Here
1203
			   direct_argvec->address ());
1216
			   direct_argvec->address ());
1204
    }
1217
    }
1205
1218
1206
  CALL_FROM_THUNK_P (call) = 1;
1219
  if (thisarg)
1207
  SET_EXPR_LOCATION (call, UNKNOWN_LOCATION);
1220
    {
1221
      CALL_FROM_THUNK_P (call) = 1;
1222
      SET_EXPR_LOCATION (call, UNKNOWN_LOCATION);
1223
    }
1208
1224
1209
  tree stattype = build_function_type (fn_result, FUNCTION_ARG_CHAIN (callop));
1225
  tree stattype
1210
  stattype = (cp_build_type_attribute_variant
1226
    = build_function_type (fn_result, thisarg ? FUNCTION_ARG_CHAIN (callop)
1211
	      (stattype, TYPE_ATTRIBUTES (optype)));
1227
				      : TYPE_ARG_TYPES (optype));
1212
  if (flag_noexcept_type
1228
  stattype = cp_build_type_attribute_variant (stattype,
1213
      && TYPE_NOTHROW_P (TREE_TYPE (callop)))
1229
					      TYPE_ATTRIBUTES (optype));
1230
  if (flag_noexcept_type && TYPE_NOTHROW_P (TREE_TYPE (callop)))
1214
    stattype = build_exception_variant (stattype, noexcept_true_spec);
1231
    stattype = build_exception_variant (stattype, noexcept_true_spec);
1215
1232
1216
  if (generic_lambda_p)
1233
  if (generic_lambda_p)
Lines 1249-1254 maybe_add_lambda_conv_op (tree type) Link Here
1249
1266
1250
  add_method (type, fn, false);
1267
  add_method (type, fn, false);
1251
1268
1269
  if (thisarg == NULL_TREE)
1270
    {
1271
      /* For static lambda, just return operator().  */
1272
      if (nested)
1273
	push_function_context ();
1274
      else
1275
	/* Still increment function_depth so that we don't GC in the
1276
	   middle of an expression.  */
1277
	++function_depth;
1278
1279
      /* Generate the body of the conversion op.  */
1280
1281
      start_preparsed_function (convfn, NULL_TREE,
1282
				SF_PRE_PARSED | SF_INCLASS_INLINE);
1283
      tree body = begin_function_body ();
1284
      tree compound_stmt = begin_compound_stmt (0);
1285
1286
      /* decl_needed_p needs to see that it's used.  */
1287
      TREE_USED (callop) = 1;
1288
      finish_return_stmt (decay_conversion (callop, tf_warning_or_error));
1289
1290
      finish_compound_stmt (compound_stmt);
1291
      finish_function_body (body);
1292
1293
      fn = finish_function (/*inline_p=*/true);
1294
      if (!generic_lambda_p)
1295
	expand_or_defer_fn (fn);
1296
1297
      if (nested)
1298
	pop_function_context ();
1299
      else
1300
	--function_depth;
1301
      return;
1302
    }
1303
1252
  /* Generic thunk code fails for varargs; we'll complain in mark_used if
1304
  /* Generic thunk code fails for varargs; we'll complain in mark_used if
1253
     the conversion op is used.  */
1305
     the conversion op is used.  */
1254
  if (varargs_function_p (callop))
1306
  if (varargs_function_p (callop))
(-)gcc/cp/error.cc.jj (-1 / +7 lines)
Lines 1692-1698 dump_lambda_function (cxx_pretty_printer Link Here
1692
{
1692
{
1693
  /* A lambda's signature is essentially its "type".  */
1693
  /* A lambda's signature is essentially its "type".  */
1694
  dump_type (pp, DECL_CONTEXT (fn), flags);
1694
  dump_type (pp, DECL_CONTEXT (fn), flags);
1695
  if (!(TYPE_QUALS (class_of_this_parm (TREE_TYPE (fn))) & TYPE_QUAL_CONST))
1695
  if (TREE_CODE (TREE_TYPE (fn)) == FUNCTION_TYPE)
1696
    {
1697
      pp->padding = pp_before;
1698
      pp_c_ws_string (pp, "static");
1699
    }
1700
  else if (!(TYPE_QUALS (class_of_this_parm (TREE_TYPE (fn)))
1701
	     & TYPE_QUAL_CONST))
1696
    {
1702
    {
1697
      pp->padding = pp_before;
1703
      pp->padding = pp_before;
1698
      pp_c_ws_string (pp, "mutable");
1704
      pp_c_ws_string (pp, "mutable");
(-)gcc/c-family/c-cppbuiltin.cc.jj (+1 lines)
Lines 1081-1086 c_cpp_builtins (cpp_reader *pfile) Link Here
1081
	  cpp_define (pfile, "__cpp_constexpr=202110L");
1081
	  cpp_define (pfile, "__cpp_constexpr=202110L");
1082
	  cpp_define (pfile, "__cpp_multidimensional_subscript=202110L");
1082
	  cpp_define (pfile, "__cpp_multidimensional_subscript=202110L");
1083
	  cpp_define (pfile, "__cpp_named_character_escapes=202207L");
1083
	  cpp_define (pfile, "__cpp_named_character_escapes=202207L");
1084
	  cpp_define (pfile, "__cpp_static_call_operator=202207L");
1084
	}
1085
	}
1085
      if (flag_concepts)
1086
      if (flag_concepts)
1086
        {
1087
        {
(-)gcc/testsuite/g++.dg/template/error30.C.jj (-1 / +1 lines)
Lines 2-5 Link Here
2
2
3
template<int> struct A;
3
template<int> struct A;
4
4
5
template<template<typename> class B> A<B<int>::x> operator() (); // { dg-error "51:.A<B<int>::x> operator\\(\\)\\(\\). must be a non-static member function" }
5
template<template<typename> class B> A<B<int>::x> operator() (); // { dg-error "51:.A<B<int>::x> operator\\(\\)\\(\\). must be a member function" }
(-)gcc/testsuite/g++.dg/cpp1z/constexpr-lambda13.C.jj (-2 / +2 lines)
Lines 1-5 Link Here
1
// { dg-do compile { target c++17 } }
1
// { dg-do compile { target c++17 } }
2
2
3
auto l1 = []() constexpr constexpr { }; // { dg-error "duplicate" }
3
auto l1 = []() constexpr constexpr { }; // { dg-error "duplicate" }
4
auto l2 = []() mutable mutable { }; // { dg-error "duplicate" }
4
auto l2 = []() mutable mutable { }; // { dg-error "conflicting lambda specifiers" }
5
auto l3 = []() static { };	    // { dg-error "static" }
5
auto l3 = []() static { };	    // { dg-error "static' only valid in lambda with" "" { target c++20_down } }
(-)gcc/testsuite/g++.dg/cpp23/feat-cxx2b.C.jj (+6 lines)
Lines 563-565 Link Here
563
#elif __cpp_named_character_escapes != 202207
563
#elif __cpp_named_character_escapes != 202207
564
#  error "__cpp_named_character_escapes != 202207"
564
#  error "__cpp_named_character_escapes != 202207"
565
#endif
565
#endif
566
567
#ifndef __cpp_static_call_operator
568
#  error "__cpp_static_call_operator"
569
#elif __cpp_static_call_operator != 202207
570
#  error "__cpp_static_call_operator != 202207"
571
#endif
(-)gcc/testsuite/g++.dg/cpp23/static-operator-call1.C.jj (+41 lines)
Line 0 Link Here
1
// P1169R4 - static operator()
2
// { dg-do compile { target c++11 } }
3
// { dg-options "" }
4
5
template <typename T>
6
struct S
7
{
8
  static constexpr bool operator () (T const &x, T const &y) { return x < y; }; // { dg-warning "may be a static member function only with" "" { target c++20_down } }
9
  using P = bool (*) (T const &, T const &);
10
  operator P () const { return operator (); }
11
};
12
13
static_assert (S<int> {} (1, 2), "");
14
15
template <typename T>
16
void
17
bar (T &x)
18
{
19
  x (1, 2);
20
}
21
22
void
23
foo ()
24
{
25
#if __cpp_constexpr >= 201603L
26
  auto a = [](int x, int y) static constexpr { return x + y; };			// { dg-warning "'static' only valid in lambda with" "" { target { c++17 && c++20_down } } }
27
  static_assert (a (1, 2) == 3, "");
28
  bar (*a);
29
#endif
30
  auto b = []() static { return 1; };						// { dg-warning "'static' only valid in lambda with" "" { target c++20_down } }
31
  b ();
32
  auto c = [](int x, int y) static { return x + y; };				// { dg-warning "'static' only valid in lambda with" "" { target c++20_down } }
33
  c (1, 2);
34
  bar (*c);
35
#if __cpp_generic_lambdas >= 201707L
36
  auto d = []<typename T, typename U>(T x, U y) static { return x + y; };	// { dg-warning "'static' only valid in lambda with" "" { target c++20_only } }
37
  d (1, 2L);
38
#endif
39
  S<long> s;
40
  s(1L, 2L);
41
}
(-)gcc/testsuite/g++.dg/cpp23/static-operator-call2.C.jj (+22 lines)
Line 0 Link Here
1
// P1169R4 - static operator()
2
// { dg-do compile { target c++11 } }
3
// { dg-options "" }
4
5
void
6
foo ()
7
{
8
  int u = 0;
9
  auto a = [](int x, int y) mutable mutable { return x + y; };		// { dg-error "conflicting lambda specifiers" }
10
  auto b = [](int x, int y) static static { return x + y; };		// { dg-error "conflicting lambda specifiers" }
11
									// { dg-warning "'static' only valid in lambda with" "" { target c++20_down } .-1 }
12
  auto c = [](int x, int y) static mutable { return x + y; };		// { dg-error "conflicting lambda specifiers" }
13
									// { dg-warning "'static' only valid in lambda with" "" { target c++20_down } .-1 }
14
  auto d = [](int x, int y) mutable static { return x + y; };		// { dg-error "conflicting lambda specifiers" }
15
									// { dg-warning "'static' only valid in lambda with" "" { target c++20_down } .-1 }
16
  auto e = [=](int x, int y) static { return x + y; };			// { dg-error "lambda specifier with lambda capture" }
17
									// { dg-warning "'static' only valid in lambda with" "" { target c++20_down } .-1 }
18
  auto f = [&](int x, int y) static { return x + y; };			// { dg-error "lambda specifier with lambda capture" }
19
									// { dg-warning "'static' only valid in lambda with" "" { target c++20_down } .-1 }
20
  auto g = [u](int x, int y) static { return x + y; };			// { dg-error "lambda specifier with lambda capture" }
21
									// { dg-warning "'static' only valid in lambda with" "" { target c++20_down } .-1 }
22
}
(-)gcc/testsuite/g++.old-deja/g++.jason/operator.C.jj (-1 / +1 lines)
Lines 6-12 typedef __SIZE_TYPE__ size_t; Link Here
6
6
7
struct A {
7
struct A {
8
  int operator?:(int a, int b);	   // { dg-error "prohibits overloading" } 
8
  int operator?:(int a, int b);	   // { dg-error "prohibits overloading" } 
9
  static int operator()(int a);	   // { dg-error "14:.static int A::operator\\(\\)\\(int\\). must be a non-static member function" }
9
  static int operator()(int a);	   // { dg-warning "14:.static int A::operator\\(\\)\\(int\\). may be a static member function only with" "" { target c++20_down } }
10
  static int operator+(A,A);	   // { dg-error "14:.static int A::operator\\+\\(A, A\\). must be either a non-static member function or a non-member function" } 
10
  static int operator+(A,A);	   // { dg-error "14:.static int A::operator\\+\\(A, A\\). must be either a non-static member function or a non-member function" } 
11
  int operator+(int a, int b = 1); // { dg-error "7:.int A::operator\\+\\(int, int\\). must have either zero or one argument" }
11
  int operator+(int a, int b = 1); // { dg-error "7:.int A::operator\\+\\(int, int\\). must have either zero or one argument" }
12
  int operator++(char);		   // { dg-error "7:postfix .int A::operator\\+\\+\\(char\\). must have .int. as its argument" }
12
  int operator++(char);		   // { dg-error "7:postfix .int A::operator\\+\\+\\(char\\). must have .int. as its argument" }

Return to bug 106651