Skip to content

Commit c8e6bfd

Browse files
committed
Put SIL diagnostics involving Embedded Swift restrictions into the appropriate group
Embedded Swift must defer some of the diagnostics about its restrictions to late in the optimization pipeline, because some source-level constructs (such as metatypes) are allowed in specific cases that cannot be diagnosed in the type checker. Put these diagnostics into the same EmbeddedRestrictions diagnostic group as the type checker diagnostics, because that's the central point at which we can direct folks to more information about the restrictions in Embedded Swift. Addresses rdar://119383905.
1 parent c8b281c commit c8e6bfd

File tree

1 file changed

+31
-26
lines changed

1 file changed

+31
-26
lines changed

include/swift/AST/DiagnosticsSIL.def

Lines changed: 31 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -378,52 +378,57 @@ ERROR(bad_attr_on_non_const_global,none,
378378
"global variable must be a compile-time constant to use %0 attribute", (StringRef))
379379
ERROR(global_must_be_compile_time_const,none,
380380
"global variable must be a compile-time constant", ())
381-
ERROR(embedded_cannot_specialize_class_method,none,
381+
ERROR(perf_diag_existential_type,none,
382+
"cannot use a value of protocol type %0 in '@_noExistential' function", (Type))
383+
ERROR(perf_diag_existential,none,
384+
"cannot use a value of protocol type in '@_noExistential' function", ())
385+
386+
// Embedded Swift diagnostics
387+
GROUPED_ERROR(embedded_cannot_specialize_class_method,EmbeddedRestrictions,none,
382388
"classes cannot have a non-final, generic method %0 in embedded Swift", (DeclName))
383-
ERROR(embedded_cannot_specialize_witness_method,none,
389+
GROUPED_ERROR(embedded_cannot_specialize_witness_method,EmbeddedRestrictions,none,
384390
"a protocol type cannot contain a generic method %0 in embedded Swift", (DeclName))
385-
ERROR(cannot_specialize_class,none,
391+
GROUPED_ERROR(cannot_specialize_class,EmbeddedRestrictions,none,
386392
"cannot specialize %0 because class definition is not available (make sure to build with -wmo)", (Type))
387-
ERROR(embedded_swift_existential_type,none,
393+
GROUPED_ERROR(embedded_swift_existential_type,EmbeddedRestrictions,none,
388394
"cannot use a value of protocol type %0 in embedded Swift", (Type))
389-
ERROR(embedded_swift_existential_protocol,none,
395+
GROUPED_ERROR(embedded_swift_existential_protocol,EmbeddedRestrictions,none,
390396
"cannot use a value of protocol type 'any %0' in embedded Swift", (StringRef))
391-
ERROR(embedded_swift_existential,none,
397+
GROUPED_ERROR(embedded_swift_existential,EmbeddedRestrictions,none,
392398
"cannot use a value of protocol type in embedded Swift", ())
393-
ERROR(perf_diag_existential_type,none,
394-
"cannot use a value of protocol type %0 in '@_noExistential' function", (Type))
395-
ERROR(perf_diag_existential,none,
396-
"cannot use a value of protocol type in '@_noExistential' function", ())
397-
ERROR(embedded_swift_value_deinit,none,
399+
GROUPED_ERROR(embedded_swift_value_deinit,EmbeddedRestrictions,none,
398400
"cannot de-virtualize deinit of type %0", (Type))
399-
ERROR(embedded_swift_metatype_type,none,
401+
GROUPED_ERROR(embedded_swift_metatype_type,EmbeddedRestrictions,none,
400402
"cannot use metatype of type %0 in embedded Swift", (Type))
401-
ERROR(embedded_swift_metatype,none,
403+
GROUPED_ERROR(embedded_swift_metatype,EmbeddedRestrictions,none,
402404
"cannot use metatype in embedded Swift", ())
403-
ERROR(embedded_swift_keypath,none,
405+
GROUPED_ERROR(embedded_swift_keypath,EmbeddedRestrictions,none,
404406
"cannot use key path in embedded Swift", ())
405-
ERROR(embedded_swift_dynamic_cast,none,
407+
GROUPED_ERROR(embedded_swift_dynamic_cast,EmbeddedRestrictions,none,
406408
"cannot do dynamic casting in embedded Swift", ())
407-
ERROR(embedded_swift_allocating_type,none,
408-
"cannot use allocating type %0 in -no-allocations mode", (Type))
409-
ERROR(embedded_swift_allocating_coroutine,none,
410-
"cannot use co-routines (like accessors) in -no-allocations mode", ())
411-
ERROR(embedded_swift_allocating_closure,none,
412-
"cannot use escaping closures in -no-allocations mode", ())
413-
ERROR(embedded_swift_allocating,none,
414-
"cannot use allocating operation in -no-allocations mode", ())
415-
ERROR(embedded_capture_of_generic_value_with_deinit,none,
409+
GROUPED_ERROR(embedded_capture_of_generic_value_with_deinit,EmbeddedRestrictions,none,
416410
"capturing generic non-copyable type with deinit in escaping closure not supported in embedded Swift", ())
417-
ERROR(embedded_call_generic_function,none,
411+
GROUPED_ERROR(embedded_call_generic_function,EmbeddedRestrictions,none,
418412
"cannot specialize generic function or default protocol method in this context", ())
419-
ERROR(embedded_call_generic_function_with_dynamic_self,none,
413+
GROUPED_ERROR(embedded_call_generic_function_with_dynamic_self,EmbeddedRestrictions,none,
420414
"cannot call an initializer or static method, which is defined as default protocol method, from a class method or initializer", ())
421415
NOTE(embedded_specialization_called_from,none,
422416
"generic specialization called here", ())
423417
NOTE(embedded_existential_created,none,
424418
"protocol type value created here", ())
425419
NOTE(embedded_constructor_called,none,
426420
"instance of type created here", ())
421+
422+
// no-allocations diagnostics
423+
ERROR(embedded_swift_allocating_type,none,
424+
"cannot use allocating type %0 in -no-allocations mode", (Type))
425+
ERROR(embedded_swift_allocating_coroutine,none,
426+
"cannot use co-routines (like accessors) in -no-allocations mode", ())
427+
ERROR(embedded_swift_allocating_closure,none,
428+
"cannot use escaping closures in -no-allocations mode", ())
429+
ERROR(embedded_swift_allocating,none,
430+
"cannot use allocating operation in -no-allocations mode", ())
431+
427432
ERROR(wrong_linkage_for_serialized_function,none,
428433
"function has wrong linkage to be called from %0", (StringRef))
429434
NOTE(performance_called_from,none,

0 commit comments

Comments
 (0)