Skip to content
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

[Clang] Define __cpp_pack_indexing #101956

Merged
merged 1 commit into from
Aug 5, 2024
Merged

Conversation

Sirraide
Copy link
Member

@Sirraide Sirraide commented Aug 5, 2024

Following the discussion on #101448, this defines __cpp_pack_indexing. Since pack indexing is currently supported in all language modes, the feature test macro is also defined in all language modes.

@Sirraide Sirraide added the clang:frontend Language frontend issues, e.g. anything involving "Sema" label Aug 5, 2024
@llvmbot llvmbot added the clang Clang issues not falling into any other category label Aug 5, 2024
@llvmbot
Copy link
Member

llvmbot commented Aug 5, 2024

@llvm/pr-subscribers-clang

Author: None (Sirraide)

Changes

Following the discussion on #101448, this defines __cpp_pack_indexing. Since pack indexing is currently supported in all language modes, the feature test macro is also defined in all language modes.


Full diff: https://github.com/llvm/llvm-project/pull/101956.diff

3 Files Affected:

  • (modified) clang/docs/LanguageExtensions.rst (+1)
  • (modified) clang/lib/Frontend/InitPreprocessor.cpp (+1)
  • (modified) clang/test/Lexer/cxx-features.cpp (+4)
diff --git a/clang/docs/LanguageExtensions.rst b/clang/docs/LanguageExtensions.rst
index 9dcb4ac9b75ca..be07f81cc41b0 100644
--- a/clang/docs/LanguageExtensions.rst
+++ b/clang/docs/LanguageExtensions.rst
@@ -1503,6 +1503,7 @@ Conditional ``explicit``                     __cpp_conditional_explicit       C+
 ``static operator()``                        __cpp_static_call_operator       C++23         C++03
 Attributes on Lambda-Expressions                                              C++23         C++11
 Attributes on Structured Bindings            __cpp_structured_bindings        C++26         C++03
+Pack Indexing                                __cpp_pack_indexing              C++26         C++03
 ``= delete ("should have a reason");``       __cpp_deleted_function           C++26         C++03
 -------------------------------------------- -------------------------------- ------------- -------------
 Designated initializers (N494)                                                C99           C89
diff --git a/clang/lib/Frontend/InitPreprocessor.cpp b/clang/lib/Frontend/InitPreprocessor.cpp
index 17b9ca7cb9910..8e62461d8a181 100644
--- a/clang/lib/Frontend/InitPreprocessor.cpp
+++ b/clang/lib/Frontend/InitPreprocessor.cpp
@@ -763,6 +763,7 @@ static void InitializeCPlusPlusFeatureTestMacros(const LangOptions &LangOpts,
   Builder.defineMacro("__cpp_placeholder_variables", "202306L");
 
   // C++26 features supported in earlier language modes.
+  Builder.defineMacro("__cpp_pack_indexing", "202311L");
   Builder.defineMacro("__cpp_deleted_function", "202403L");
 
   if (LangOpts.Char8)
diff --git a/clang/test/Lexer/cxx-features.cpp b/clang/test/Lexer/cxx-features.cpp
index 4c2aa3ae2c544..08b732132228b 100644
--- a/clang/test/Lexer/cxx-features.cpp
+++ b/clang/test/Lexer/cxx-features.cpp
@@ -38,6 +38,10 @@
 #error "wrong value for __cpp_deleted_function"
 #endif
 
+#if check(pack_indexing, 202311, 202311, 202311, 202311, 202311, 202311, 202311)
+#error "wrong value for __cpp_pack_indexing"
+#endif
+
 #if check(placeholder_variables, 202306, 202306, 202306, 202306, 202306, 202306, 202306)
 #error "wrong value for __cpp_placeholder_variables"
 #endif

Copy link
Contributor

@cor3ntin cor3ntin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.
I think we should backport to Clang 19. WDYT?

@Sirraide Sirraide merged commit c65afad into llvm:main Aug 5, 2024
11 checks passed
@Sirraide Sirraide deleted the __cpp_pack_indexing branch August 5, 2024 12:02
@Sirraide
Copy link
Member Author

Sirraide commented Aug 5, 2024

I think we should backport to Clang 19. WDYT?

That makes a lot of sense to me imo: the feature is already in Clang 19, this just makes it so we claim to support it too.

@Sirraide Sirraide added this to the LLVM 19.X Release milestone Aug 5, 2024
@Sirraide
Copy link
Member Author

Sirraide commented Aug 5, 2024

/cherry-pick c65afad

llvmbot pushed a commit to llvmbot/llvm-project that referenced this pull request Aug 5, 2024
Following the discussion on llvm#101448 this defines
`__cpp_pack_indexing`. Since pack indexing is currently
supported in all language modes, the feature test macro
is also defined in all language modes.

(cherry picked from commit c65afad)
@llvmbot
Copy link
Member

llvmbot commented Aug 5, 2024

/pull-request #101965

banach-space pushed a commit to banach-space/llvm-project that referenced this pull request Aug 7, 2024
Following the discussion on llvm#101448 this defines 
`__cpp_pack_indexing`. Since pack indexing is currently
supported in all language modes, the feature test macro 
is also defined in all language modes.
tru pushed a commit to llvmbot/llvm-project that referenced this pull request Aug 10, 2024
Following the discussion on llvm#101448 this defines
`__cpp_pack_indexing`. Since pack indexing is currently
supported in all language modes, the feature test macro
is also defined in all language modes.

(cherry picked from commit c65afad)
kstoimenov pushed a commit to kstoimenov/llvm-project that referenced this pull request Aug 15, 2024
Following the discussion on llvm#101448 this defines 
`__cpp_pack_indexing`. Since pack indexing is currently
supported in all language modes, the feature test macro 
is also defined in all language modes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" clang Clang issues not falling into any other category
Projects
Development

Successfully merging this pull request may close these issues.

3 participants