================
@@ -3686,14 +3686,14 @@ Preprocessor::LexEmbedParameters(Token &CurTok, bool 
ForHasEmbed) {
           std::pair<tok::TokenKind, SourceLocation> Matches) {
         Diag(CurTok, diag::err_expected) << Expected;
         Diag(Matches.second, diag::note_matching) << Matches.first;
-        if (CurTok.isNot(EndTokenKind))
----------------
a-tarasyuk wrote:

@cor3ntin, thanks for the feedback. For known parameters such as `if_empty`, 
`prefix`, etc., parsing proceeds by expecting a parenthesized argument list 
immediately after `LexPPParameterName`

https://github.com/llvm/llvm-project/blob/4772815a8248801edc017db450e17c857df7c17a/clang/lib/Lex/PPDirectives.cpp#L3864

https://github.com/llvm/llvm-project/blob/4772815a8248801edc017db450e17c857df7c17a/clang/lib/Lex/PPDirectives.cpp#L3909-L3918

https://github.com/llvm/llvm-project/blob/4772815a8248801edc017db450e17c857df7c17a/clang/lib/Lex/PPDirectives.cpp#L3814-L3815

https://github.com/llvm/llvm-project/blob/4772815a8248801edc017db450e17c857df7c17a/clang/lib/Lex/PPDirectives.cpp#L3696-L3697

If the `(` is missing, `ExpectOrDiagAndSkipToEOD` diagnoses the error and 
attempts recovery by discarding the remainder of the directive. In cases like:

```
#if __has_embed("" if_empty
```

the parser reaches end-of-directive immediately after the parameter name, so 
`CurTok` is already `tok::eod`. Calling `DiscardUntilEndOfDirective` in this 
state attempts to discard past the end of the directive and triggers the 
assertion. Please let me know if this reasoning makes sense or if there’s a 
better approach.









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

Reply via email to