-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[clang-repl] Ensure clang-repl accepts all C keywords supported in all language models #142749
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@llvm/pr-subscribers-clang Author: Anutosh Bhat (anutosh491) ChangesAs can be seen through the docs (https://github.com/llvm/llvm-project/blob/7e1fa09ce2a228c949ce4490c98f2c73ed8ada00/clang/docs/LanguageExtensions.rst#c-keywords-supported-in-all-language-modes), Clang supports certain C keywords in all language modes — this patch ensures clang-repl handles them consistently. Here's an example testing all the above keywords. We have everything in place except Full diff: https://github.com/llvm/llvm-project/pull/142749.diff 1 Files Affected:
diff --git a/clang/lib/Parse/ParseTentative.cpp b/clang/lib/Parse/ParseTentative.cpp
index 95cee824c40b7..f50bcd8ea90bb 100644
--- a/clang/lib/Parse/ParseTentative.cpp
+++ b/clang/lib/Parse/ParseTentative.cpp
@@ -1171,6 +1171,7 @@ Parser::isCXXDeclarationSpecifier(ImplicitTypenameContext AllowImplicitTypename,
case tok::kw_inline:
case tok::kw_virtual:
case tok::kw_explicit:
+ case tok::kw__Noreturn:
// Modules
case tok::kw___module_private__:
@@ -1225,6 +1226,7 @@ Parser::isCXXDeclarationSpecifier(ImplicitTypenameContext AllowImplicitTypename,
// GNU
case tok::kw_restrict:
case tok::kw__Complex:
+ case tok::kw__Imaginary:
case tok::kw___attribute:
case tok::kw___auto_type:
return TPResult::True;
|
On Main
On Branch after the change
This now works how clang would expect it to. For eg
And anything with _Noreturn would just compile fine. |
The error comes from here to be precise llvm-project/clang/lib/Parse/Parser.cpp Lines 1026 to 1028 in 41841e6
These are also a part of llvm-project/clang/include/clang/Parse/Parser.h Lines 7579 to 7583 in 9ba332f
llvm-project/clang/lib/Parse/ParseDecl.cpp Line 5811 in 2c4f677
llvm-project/clang/lib/Parse/ParseDecl.cpp Line 5856 in 2c4f677
|
Can you add tests? |
Done. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lgtm!
/cherry-pick 7ca7bcb |
/pull-request #142909 |
…ed in all language models (llvm#142749)" This reverts commit 7ca7bcb.
…ed in all language models (llvm#142749)" This broke CI on platforms such as PPC64LE and AIX due to _Float16 not being supported. We will reintroduce the changes later with proper platform guards and tests. This reverts commit 7ca7bcb.
…l language models (llvm#142749) As can be seen through the docs (https://github.com/llvm/llvm-project/blob/7e1fa09ce2a228c949ce4490c98f2c73ed8ada00/clang/docs/LanguageExtensions.rst#c-keywords-supported-in-all-language-modes), Clang supports certain C keywords in all language modes — this patch ensures clang-repl handles them consistently. Here's an example testing all the above keywords. We have everything in place except `_Imaginary` (_Complex works but _Imaginary doesn't which was weird) and `_Noreturn`
…ed in all language models (llvm#142749) (llvm#142933) This broke CI on platforms such as PPC64LE and AIX due to _Float16 not being supported. We will reintroduce the changes later with proper platform guards and tests. This reverts commit 7ca7bcb.
…l language models (llvm#142749) As can be seen through the docs (https://github.com/llvm/llvm-project/blob/7e1fa09ce2a228c949ce4490c98f2c73ed8ada00/clang/docs/LanguageExtensions.rst#c-keywords-supported-in-all-language-modes), Clang supports certain C keywords in all language modes — this patch ensures clang-repl handles them consistently. Here's an example testing all the above keywords. We have everything in place except `_Imaginary` (_Complex works but _Imaginary doesn't which was weird) and `_Noreturn`
…ed in all language models (llvm#142749) (llvm#142933) This broke CI on platforms such as PPC64LE and AIX due to _Float16 not being supported. We will reintroduce the changes later with proper platform guards and tests. This reverts commit 7ca7bcb.
As can be seen through the docs (https://github.com/llvm/llvm-project/blob/7e1fa09ce2a228c949ce4490c98f2c73ed8ada00/clang/docs/LanguageExtensions.rst#c-keywords-supported-in-all-language-modes), Clang supports certain C keywords in all language modes — this patch ensures clang-repl handles them consistently.
Here's an example testing all the above keywords. We have everything in place except
_Imaginary
(_Complex works but _Imaginary doesn't which was weird) and_Noreturn