Fix diagnostic for @c enum T: Int128.#90028
Conversation
This PR fixes the incorrect diagnostic when an integer type known to Swift but
not to C/Objective-C is used with an `@c` or `@objc` enum:
```swift
@c enum T: Int128 {} // 🛑 '@c' enum raw type 'Int128' is not an integer type
```
The diagnostic now reads:
> 🛑 '@c' enum raw type 'Int128' must be an integer type expressible in C
(Substituting "Objective-C" when `@objc` is used.)
|
@swift-ci test |
| errorRange = enumDecl->getInherited().getEntry(0).getSourceRange(); | ||
| enumDecl->diagnose(diag::objc_enum_raw_type_not_integer, attr, rawType) | ||
| .highlight(errorRange); | ||
| auto languageName = dyn_cast<ObjCAttr>(attr) ? "Objective-C" : "C"; |
There was a problem hiding this comment.
Should we factor this out into common utility?
There was a problem hiding this comment.
I think if there are other examples yes, otherwise "not until there are other examples."
|
This seems like it should be supported. Since a while back we map Even if we don't end up supporting |
|
I'm happy to bikeshed the spelling. However, at least as of the toolchain I was using, it wasn't supported, so if it's a very new feature, great—and we should still tweak the diagnostic because there are other integer types in Swift that aren't valid as enum bases in C. At least, that's my take. |
This PR fixes the incorrect diagnostic when an integer type known to Swift but not to C/Objective-C is used with an
@cor@objcenum:The diagnostic now reads:
(Substituting "Objective-C" when
@objcis used.)