Repository: apple/swift-syntax (swift)

Issue:
New parser fails to parse `@convention` attribute with `cType` argument inside an array type
### Issue Kind

Parse of Valid Source Failed

### Source Code

```swift
_ = [@convention(c, cType: "int (*)(int)") (Int32) -> Int32]()
```


### Description

The issue is that the implementation of `skipTypeAttribute` doesn’t skip over the `cType` argument here. We should probably be able to just `skipSingle` to skip over all the arguments.

https://github.com/apple/swift-syntax/blob/89dd2bde9404950dede113b7898c97f6e2bc2fc4/Sources/SwiftParser/Lookahead.swift#L165-L173

Pull request description:
Fixes #2474
rdar://122358055

Patch:
diff --git a/Sources/SwiftParser/Lookahead.swift b/Sources/SwiftParser/Lookahead.swift
index 682e5e46f68..c8d26ce6a14 100644
--- a/Sources/SwiftParser/Lookahead.swift
+++ b/Sources/SwiftParser/Lookahead.swift
@@ -162,14 +162,11 @@ extension Parser.Lookahead {
     if let (attr, handle) = self.at(anyIn: TypeAttribute.self) {
       // Ok, it is a valid attribute, eat it, and then process it.
       self.eat(handle)
-      if case .convention = attr {
-        guard
-          self.consume(if: .leftParen) != nil,
-          self.consume(if: .identifier) != nil,
-          self.consume(if: .rightParen) != nil
-        else {
-          return
-        }
+      switch attr {
+      case .convention:
+        self.skipSingle()
+      default:
+        break
       }
       return
     }


Test patch:
diff --git a/Tests/SwiftParserTest/AttributeTests.swift b/Tests/SwiftParserTest/AttributeTests.swift
index 906eae1abab..3ce6b32508e 100644
--- a/Tests/SwiftParserTest/AttributeTests.swift
+++ b/Tests/SwiftParserTest/AttributeTests.swift
@@ -886,4 +886,25 @@ final class AttributeTests: ParserTestCase {
       """
     )
   }
+
+  func testConventionAttributeInArrayType() {
+    assertParse(
+      """
+      _ = [@convention(c, cType: "int (*)(int)") (Int32) -> Int32]()
+      """,
+      substructure: ConventionAttributeArgumentsSyntax(
+        conventionLabel: .identifier("c"),
+        comma: .commaToken(),
+        cTypeLabel: .keyword(.cType),
+        colon: .colonToken(),
+        cTypeString: StringLiteralExprSyntax(
+          openingQuote: .stringQuoteToken(),
+          segments: StringLiteralSegmentListSyntax([
+            StringLiteralSegmentListSyntax.Element(StringSegmentSyntax(content: .stringSegment("int (*)(int)")))
+          ]),
+          closingQuote: .stringQuoteToken()
+        )
+      )
+    )
+  }
 }