================
@@ -4093,15 +4146,33 @@ void Parser::ParseDeclarationSpecifiers(
       break;
     case tok::kw_auto:
       if (getLangOpts().CPlusPlus11 || getLangOpts().C23) {
-        if (isKnownToBeTypeSpecifier(GetLookAheadToken(1))) {
-          isInvalid = DS.SetStorageClassSpec(Actions, DeclSpec::SCS_auto, Loc,
-                                             PrevSpec, DiagID, Policy);
-          if (!isInvalid && !getLangOpts().C23)
-            Diag(Tok, diag::ext_auto_storage_class)
-              << FixItHint::CreateRemoval(DS.getStorageClassSpecLoc());
-        } else
-          isInvalid = DS.SetTypeSpecType(DeclSpec::TST_auto, Loc, PrevSpec,
-                                         DiagID, Policy);
+        // Check for concept constraint syntax: C<T> auto param
+        // If there's already a type specifier, check if the previous token was
+        // '>' by looking at the source text before 'auto'.
+        if (DS.getTypeSpecType() != DeclSpec::TST_unspecified &&
+            Loc.isValid()) {
+          const SourceManager &SM = PP.getSourceManager();
+          const char *CharData = SM.getCharacterData(Loc);
+          if (CharData) {
+            // Look backwards for '>' token, skipping whitespace
+            const char *Cur = CharData - 1;
+            const char *BufferStart =
+                SM.getBufferData(SM.getFileID(Loc)).data();
+            while (Cur >= BufferStart && (*Cur == ' ' || *Cur == '\t' ||
+                                          *Cur == '\n' || *Cur == '\r')) {
+              --Cur;
+            }
+            if (Cur >= BufferStart && *Cur == '>') {
+              // This is concept constraint syntax (C<T> auto), don't treat as
+              // conflict. The concept constraint will be handled elsewhere
+              goto DoneWithDeclSpec;
+            }
+          }
+        }
+        // Always set 'auto' as a type specifier in C++11+ and C23.
+        // Conflicts will be detected in DeclSpec::Finish().
+        isInvalid = DS.SetTypeSpecType(DeclSpec::TST_auto, Loc, PrevSpec,
+                                       DiagID, Policy);
----------------
osamakader wrote:

removed from parser.

https://github.com/llvm/llvm-project/pull/166004
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to