[PATCH] D150321: [clang] Document extensions from later standards

2023-05-11 Thread Nikolas Klauser via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
philnik marked an inline comment as done.
Closed by commit rGb09fad7f8e9c: [clang] Document extensions from later 
standards (authored by philnik).

Changed prior to commit:
  https://reviews.llvm.org/D150321?vs=521375=521402#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D150321/new/

https://reviews.llvm.org/D150321

Files:
  clang/docs/LanguageExtensions.rst


Index: clang/docs/LanguageExtensions.rst
===
--- clang/docs/LanguageExtensions.rst
+++ clang/docs/LanguageExtensions.rst
@@ -1370,6 +1370,41 @@
 
 More information could be found `here 
`_.
 
+Language Extensions Back-ported to Previous Standards
+=
+
+===  
= = ==
+Feature Feature Test Macro   
Introduced In Backported To Required Flags
+===  
= = ==
+variadic templates  __cpp_variadic_templates C++11 
C++03
+Alias templates __cpp_alias_templatesC++11 
C++03
+Non-static data member initializers __cpp_nsdmi  C++11 
C++03
+Range-based ``for`` loop__cpp_range_based_forC++11 
C++03
+RValue references   __cpp_rvalue_references  C++11 
C++03
+Attributes  __cpp_attributes C++11 
C++03 -fdouble-square-bracket-attributes
+variable templates  __cpp_variable_templates C++14 
C++03
+Binary literals __cpp_binary_literalsC++14 
C++03
+Relaxed constexpr   __cpp_constexpr  C++14 
C++11
+``if constexpr``__cpp_if_constexpr   C++17 
C++11
+fold expressions__cpp_fold_expressions   C++17 
C++03
+Lambda capture of \*this by value   __cpp_capture_star_this  C++17 
C++11
+Attributes on enums __cpp_enumerator_attributes  C++17 
C++11
+Guaranteed copy elision __cpp_guaranteed_copy_elisionC++17 
C++03
+Hexadecimal floating literals   __cpp_hex_float  C++17 
C++03
+``inline`` variables__cpp_inline_variables   C++17 
C++03
+Attributes on namespaces__cpp_namespace_attributes   C++17 
C++11
+Structured bindings __cpp_structured_bindingsC++17 
C++03
+template template arguments __cpp_template_template_args C++17 
C++03
+``static operator[]``   __cpp_multidimensional_subscript C++20 
C++03
+Designated initializers __cpp_designated_initializersC++20 
C++03
+Conditional ``explicit``__cpp_conditional_explicit   C++20 
C++03
+``using enum``  __cpp_using_enum C++20 
C++03
+``if consteval``__cpp_if_consteval   C++23 
C++20
+``static operator()``   __cpp_static_call_operator   C++23 
C++03
+---  
- - --
+Designated initializers  C99   
C89
+===  
= = ==
+
 Type Trait Primitives
 =
 


Index: clang/docs/LanguageExtensions.rst
===
--- clang/docs/LanguageExtensions.rst
+++ clang/docs/LanguageExtensions.rst
@@ -1370,6 +1370,41 @@
 
 More information could be found `here `_.
 
+Language Extensions Back-ported to Previous Standards
+=
+
+===  = = ==
+Feature Feature Test Macro   Introduced In Backported To Required Flags
+===  = = ==
+variadic templates  __cpp_variadic_templates C++11 C++03
+Alias templates 

[PATCH] D150321: [clang] Document extensions from later standards

2023-05-11 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM, this is awesome -- thank you for the improved docs!




Comment at: clang/docs/LanguageExtensions.rst:1373
 
+Language extensions back-ported to previous standards
+=

Seems to be the style we're using for this level of heading.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D150321/new/

https://reviews.llvm.org/D150321

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D150321: [clang] Document extensions from later standards

2023-05-11 Thread Nikolas Klauser via Phabricator via cfe-commits
philnik updated this revision to Diff 521375.
philnik marked 5 inline comments as done.
philnik added a comment.

Address comments


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D150321/new/

https://reviews.llvm.org/D150321

Files:
  clang/docs/LanguageExtensions.rst


Index: clang/docs/LanguageExtensions.rst
===
--- clang/docs/LanguageExtensions.rst
+++ clang/docs/LanguageExtensions.rst
@@ -1370,6 +1370,41 @@
 
 More information could be found `here 
`_.
 
+Language extensions back-ported to previous standards
+=
+
+===  
= = ==
+Feature Feature Test Macro   
Introduced In Backported To Required Flags
+===  
= = ==
+variadic templates  __cpp_variadic_templates C++11 
C++03
+Alias templates __cpp_alias_templatesC++11 
C++03
+Non-static data member initializers __cpp_nsdmi  C++11 
C++03
+Range-based ``for`` loop__cpp_range_based_forC++11 
C++03
+RValue references   __cpp_rvalue_references  C++11 
C++03
+Attributes  __cpp_attributes C++11 
C++03 -fdouble-square-bracket-attributes
+variable templates  __cpp_variable_templates C++14 
C++03
+Binary literals __cpp_binary_literalsC++14 
C++03
+Relaxed constexpr   __cpp_constexpr  C++14 
C++11
+``if constexpr``__cpp_if_constexpr   C++17 
C++11
+fold expressions__cpp_fold_expressions   C++17 
C++03
+Lambda capture of \*this by value   __cpp_capture_star_this  C++17 
C++11
+Attributes on enums __cpp_enumerator_attributes  C++17 
C++11
+Guaranteed copy elision __cpp_guaranteed_copy_elisionC++17 
C++03
+Hexadecimal floating literals   __cpp_hex_float  C++17 
C++03
+``inline`` variables__cpp_inline_variables   C++17 
C++03
+Attributes on namespaces__cpp_namespace_attributes   C++17 
C++11
+Structured bindings __cpp_structured_bindingsC++17 
C++03
+template template arguments __cpp_template_template_args C++17 
C++03
+``static operator[]``   __cpp_multidimensional_subscript C++20 
C++03
+Designated initializers __cpp_designated_initializersC++20 
C++03
+Conditional ``explicit``__cpp_conditional_explicit   C++20 
C++03
+``using enum``  __cpp_using_enum C++20 
C++03
+``if consteval``__cpp_if_consteval   C++23 
C++20
+``static operator()``   __cpp_static_call_operator   C++23 
C++03
+---  
- - --
+Designated initializers  C99   
C89
+===  
= = ==
+
 Type Trait Primitives
 =
 


Index: clang/docs/LanguageExtensions.rst
===
--- clang/docs/LanguageExtensions.rst
+++ clang/docs/LanguageExtensions.rst
@@ -1370,6 +1370,41 @@
 
 More information could be found `here `_.
 
+Language extensions back-ported to previous standards
+=
+
+===  = = ==
+Feature Feature Test Macro   Introduced In Backported To Required Flags
+===  = = ==
+variadic templates  __cpp_variadic_templates C++11 C++03
+Alias templates __cpp_alias_templatesC++11 C++03
+Non-static data member initializers __cpp_nsdmi  C++11 C++03
+Range-based ``for`` loop__cpp_range_based_forC++11 C++03
+RValue 

[PATCH] D150321: [clang] Document extensions from later standards

2023-05-11 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/docs/LanguageExtensions.rst:1386
+Relaxed constexpr   __cpp_constexpr  C++14 
C++11
+Designated initializers __cpp_designated_initializersC++20 
C++03
+Attributes on enums __cpp_enumerator_attributes  C++17 
C++11

philnik wrote:
> aaron.ballman wrote:
> > This brings up a few questions for me: how should we handle C? For example, 
> > designated initializers also exist in C99 and are backported to C89? And 
> > how should we handle C features extended into C++ (or vice versa)?
> > 
> > Should we have multiple tables? Should we try to put both languages into 
> > one table with different columns?
> > 
> > (I'm not asking you to sign up to figure out the C extensions, just trying 
> > to get an idea for whether we want to change the layout of this table to 
> > account for that sort of thing.)
> I think it would make sense to put C features that are back-ported into 
> previous standards also into this table (are there FTMs for C?). C into C++ 
> or vice versa should probably live somewhere else, since in these cases it 
> would also be interesting how things interact with other language features. 
> Maybe this is not as much of a problem for C++->C(?), but definitely for 
> C->C++. e.g. `__restrict` on member functions or VLAs with non-trivial 
> classes. Essentially, there is a lot more to say than "this also exists in 
> previous standards".
> I think it would make sense to put C features that are back-ported into 
> previous standards also into this table (are there FTMs for C?).

Okay, I think that makes sense to me. Clang has feature test macros for some C 
functionality (e.g., `c_generic_selections`, more full list at: 
https://github.com/llvm/llvm-project/blob/main/clang/include/clang/Basic/Features.def#L241)

> C into C++ or vice versa should probably live somewhere else, since in these 
> cases it would also be interesting how things interact with other language 
> features.

Sold!



Comment at: clang/docs/LanguageExtensions.rst:1387
+Designated initializers __cpp_designated_initializersC++20 
C++03
+Attributes on enums __cpp_enumerator_attributes  C++17 
C++11
+Guaranteed copy elision __cpp_guaranteed_copy_elisionC++17 
C++03

philnik wrote:
> aaron.ballman wrote:
> > What are your thoughts on extensions enabled by a feature flag? e.g., 
> > https://godbolt.org/z/ex9K5dzv6
> I actually had no idea they existed (might be worth documenting :P)! 
> Specifically for this case: Is there any reason this is behind a feature 
> flag? I guess it's a non-conforming extension? If not, I'd say just make it 
> an enabled-by-default extension (it would be a really nice cleanup 
> opportunity for libc++). Anyways, we could add another column "flags 
> required" for these cases. Do you know how many of these kinds of flags there 
> are?
> I actually had no idea they existed (might be worth documenting :P)! 

Right? 
https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-fdouble-square-bracket-attributes
 exists but is hardly ideal.

> Specifically for this case: Is there any reason this is behind a feature 
> flag? I guess it's a non-conforming extension? If not, I'd say just make it 
> an enabled-by-default extension (it would be a really nice cleanup 
> opportunity for libc++).

It's a bit of an odd situation. I added the feature flag because I wanted to 
expose this functionality in C before WG14 adopted the functionality and it 
wasn't entirely clear whether I would run into ambiguities with Objective-C's 
message sending syntax. C++ has this language rule: 
http://eel.is/c++draft/dcl.dcl#dcl.attr.grammar-7  but Objective-C allows for 
things like `[[foo bar] baz];`. We had already solved this for C++, but it 
wasn't entirely clear whether we'd hit other situations in older language modes 
or different situations.

These days, it may be possible we could enable this extension by default in all 
language modes.

> Anyways, we could add another column "flags required" for these cases. Do you 
> know how many of these kinds of flags there are?

I can't think of many... Features.def lists the language options required for 
various features and extensions, and it doesn't look like many have specific 
flags, though there are some that needs a more general flag like 
`-fms-extensions`. We do have things like `-fno-rtti` disabling RTTI, but I 
don't think we want to list that sort of thing here.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D150321/new/

https://reviews.llvm.org/D150321

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D150321: [clang] Document extensions from later standards

2023-05-11 Thread Nikolas Klauser via Phabricator via cfe-commits
philnik added inline comments.



Comment at: clang/docs/LanguageExtensions.rst:1386
+Relaxed constexpr   __cpp_constexpr  C++14 
C++11
+Designated initializers __cpp_designated_initializersC++20 
C++03
+Attributes on enums __cpp_enumerator_attributes  C++17 
C++11

aaron.ballman wrote:
> This brings up a few questions for me: how should we handle C? For example, 
> designated initializers also exist in C99 and are backported to C89? And how 
> should we handle C features extended into C++ (or vice versa)?
> 
> Should we have multiple tables? Should we try to put both languages into one 
> table with different columns?
> 
> (I'm not asking you to sign up to figure out the C extensions, just trying to 
> get an idea for whether we want to change the layout of this table to account 
> for that sort of thing.)
I think it would make sense to put C features that are back-ported into 
previous standards also into this table (are there FTMs for C?). C into C++ or 
vice versa should probably live somewhere else, since in these cases it would 
also be interesting how things interact with other language features. Maybe 
this is not as much of a problem for C++->C(?), but definitely for C->C++. e.g. 
`__restrict` on member functions or VLAs with non-trivial classes. Essentially, 
there is a lot more to say than "this also exists in previous standards".



Comment at: clang/docs/LanguageExtensions.rst:1387
+Designated initializers __cpp_designated_initializersC++20 
C++03
+Attributes on enums __cpp_enumerator_attributes  C++17 
C++11
+Guaranteed copy elision __cpp_guaranteed_copy_elisionC++17 
C++03

aaron.ballman wrote:
> What are your thoughts on extensions enabled by a feature flag? e.g., 
> https://godbolt.org/z/ex9K5dzv6
I actually had no idea they existed (might be worth documenting :P)! 
Specifically for this case: Is there any reason this is behind a feature flag? 
I guess it's a non-conforming extension? If not, I'd say just make it an 
enabled-by-default extension (it would be a really nice cleanup opportunity for 
libc++). Anyways, we could add another column "flags required" for these cases. 
Do you know how many of these kinds of flags there are?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D150321/new/

https://reviews.llvm.org/D150321

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D150321: [clang] Document extensions from later standards

2023-05-11 Thread Hristo Hristov via Phabricator via cfe-commits
H-G-Hristov added inline comments.



Comment at: clang/docs/LanguageExtensions.rst:1398
+``static operator()``   __cpp_static_call_operator   C++23 
C++03
+Strucuted bindings  __cpp_structured_bindingsC++17 
C++03
+template template arguments __cpp_template_template_args C++17 
C++03




Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D150321/new/

https://reviews.llvm.org/D150321

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D150321: [clang] Document extensions from later standards

2023-05-11 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Thank you for working on this! Just a few questions, but in general, this is 
looking good.




Comment at: clang/docs/LanguageExtensions.rst:1386
+Relaxed constexpr   __cpp_constexpr  C++14 
C++11
+Designated initializers __cpp_designated_initializersC++20 
C++03
+Attributes on enums __cpp_enumerator_attributes  C++17 
C++11

This brings up a few questions for me: how should we handle C? For example, 
designated initializers also exist in C99 and are backported to C89? And how 
should we handle C features extended into C++ (or vice versa)?

Should we have multiple tables? Should we try to put both languages into one 
table with different columns?

(I'm not asking you to sign up to figure out the C extensions, just trying to 
get an idea for whether we want to change the layout of this table to account 
for that sort of thing.)



Comment at: clang/docs/LanguageExtensions.rst:1387
+Designated initializers __cpp_designated_initializersC++20 
C++03
+Attributes on enums __cpp_enumerator_attributes  C++17 
C++11
+Guaranteed copy elision __cpp_guaranteed_copy_elisionC++17 
C++03

What are your thoughts on extensions enabled by a feature flag? e.g., 
https://godbolt.org/z/ex9K5dzv6


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D150321/new/

https://reviews.llvm.org/D150321

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D150321: [clang] Document extensions from later standards

2023-05-10 Thread Nikolas Klauser via Phabricator via cfe-commits
philnik created this revision.
philnik added a reviewer: aaron.ballman.
Herald added a project: All.
philnik requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D150321

Files:
  clang/docs/LanguageExtensions.rst


Index: clang/docs/LanguageExtensions.rst
===
--- clang/docs/LanguageExtensions.rst
+++ clang/docs/LanguageExtensions.rst
@@ -1370,6 +1370,38 @@
 
 More information could be found `here 
`_.
 
+Language extensions back-ported to previous standards
+=
+
+===  
= =
+Feature Feature Test Macro   
Introduced In Backported To
+===  
= =
+Conditional ``explicit``__cpp_conditional_explicit   C++20 
C++03
+``if constexpr``__cpp_if_constexpr   C++17 
C++11
+fold expressions__cpp_fold_expressions   C++17 
C++03
+Alias templates __cpp_alias_templatesC++11 
C++03
+Binary literals __cpp_binary_literalsC++14 
C++03
+Lambda capture of \*this by value   __cpp_capture_star_this  C++17 
C++11
+Relaxed constexpr   __cpp_constexpr  C++14 
C++11
+Designated initializers __cpp_designated_initializersC++20 
C++03
+Attributes on enums __cpp_enumerator_attributes  C++17 
C++11
+Guaranteed copy elision __cpp_guaranteed_copy_elisionC++17 
C++03
+``if consteval``__cpp_if_consteval   C++23 
C++20
+Hexadecimal floating literals   __cpp_hex_float  C++17 
C++03
+``inline`` variables__cpp_inline_variables   C++17 
C++03
+``static operator[]``   __cpp_multidimensional_subscript C++20 
C++03
+Attributes on namespaces__cpp_namespace_attributes   C++17 
C++11
+Non-static data member initializers __cpp_nsdmi  C++11 
C++03
+Range-based ``for`` loop__cpp_range_based_forC++11 
C++03
+RValue references   __cpp_rvalue_references  C++11 
C++03
+``static operator()``   __cpp_static_call_operator   C++23 
C++03
+Strucuted bindings  __cpp_structured_bindingsC++17 
C++03
+template template arguments __cpp_template_template_args C++17 
C++03
+``using enum``  __cpp_using_enum C++20 
C++03
+variable templates  __cpp_variable_templates C++14 
C++03
+variadic templates  __cpp_variadic_templates C++11 
C++03
+===  
= ==
+
 Type Trait Primitives
 =
 


Index: clang/docs/LanguageExtensions.rst
===
--- clang/docs/LanguageExtensions.rst
+++ clang/docs/LanguageExtensions.rst
@@ -1370,6 +1370,38 @@
 
 More information could be found `here `_.
 
+Language extensions back-ported to previous standards
+=
+
+===  = =
+Feature Feature Test Macro   Introduced In Backported To
+===  = =
+Conditional ``explicit``__cpp_conditional_explicit   C++20 C++03
+``if constexpr``__cpp_if_constexpr   C++17 C++11
+fold expressions__cpp_fold_expressions   C++17 C++03
+Alias templates __cpp_alias_templatesC++11 C++03
+Binary literals __cpp_binary_literalsC++14 C++03
+Lambda capture of \*this by value   __cpp_capture_star_this  C++17 C++11
+Relaxed constexpr   __cpp_constexpr  C++14 C++11
+Designated initializers __cpp_designated_initializersC++20 C++03
+Attributes on enums __cpp_enumerator_attributes  C++17 C++11
+Guaranteed copy elision __cpp_guaranteed_copy_elisionC++17 C++03
+``if consteval``