llvm-project/clang/test/CXX
Richard Smith 5030928d60 [c++20] Implement semantic restrictions for C++20 designated
initializers.

This has some interesting interactions with our existing extensions to
support C99 designated initializers as an extension in C++. Those are
resolved as follows:

 * We continue to permit the full breadth of C99 designated initializers
   in C++, with the exception that we disallow a partial overwrite of an
   initializer with a non-trivially-destructible type. (Full overwrite
   is OK, because we won't run the first initializer at all.)

 * The C99 extensions are disallowed in SFINAE contexts and during
   overload resolution, where they could change the meaning of valid
   programs.

 * C++20 disallows reordering of initializers. We only check for that for
   the simple cases that the C++20 rules permit (designators of the form
   '.field_name =' and continue to allow reordering in other cases).
   It would be nice to improve this behavior in future.

 * All C99 designated initializer extensions produce a warning by
   default in C++20 mode. People are going to learn the C++ rules based
   on what Clang diagnoses, so it's important we diagnose these properly
   by default.

 * In C++ <= 17, we apply the C++20 rules rather than the C99 rules, and
   so still diagnose C99 extensions as described above. We continue to
   accept designated C++20-compatible initializers in C++ <= 17 silently
   by default (but naturally still reject under -pedantic-errors).

This is not a complete implementation of P0329R4. In particular, that
paper introduces new non-C99-compatible syntax { .field { init } }, and
we do not support that yet.

This is based on a previous patch by Don Hinton, though I've made
substantial changes when addressing the above interactions.

Differential Revision: https://reviews.llvm.org/D59754

llvm-svn: 370544
2019-08-30 22:52:55 +00:00
..
basic C++ DR712 and others: handle non-odr-use resulting from an lvalue-to-rvalue conversion applied to a member access or similar not-quite-trivial lvalue expression. 2019-06-14 17:46:37 +00:00
class When typo-correcting a function name, consider correcting to a type name 2019-05-09 00:57:24 +00:00
class.access Fix implementation of [temp.local]p4. 2019-02-15 21:53:07 +00:00
class.derived [cxx2a] P0641R2: (Some) type mismatches on defaulted functions only 2018-09-28 01:16:43 +00:00
concepts-ts [Concepts] Concept definitions (D40381) 2019-07-10 21:25:49 +00:00
conv Specify an explicit underlying type for this enum to fix Windows 2018-06-29 20:41:23 +00:00
cpp PR41192: fix cases where "missing ';' after class" error would 2019-04-16 00:47:45 +00:00
dcl.dcl Implement P1668R1 2019-08-19 17:39:59 +00:00
dcl.decl PR40674: fix assertion failure if a structured binding declaration has a 2019-08-24 01:23:57 +00:00
drs [Sema] Implement DR2386 for C++17 structured binding 2019-08-15 19:45:28 +00:00
except IR: print value numbers for unnamed function arguments 2019-08-03 14:28:34 +00:00
expr [c++20] Implement semantic restrictions for C++20 designated 2019-08-30 22:52:55 +00:00
lex [C++20] Implement context-sensitive header-name lexing and pp-import parsing in the preprocessor. 2019-04-11 21:18:23 +00:00
module C++ DR2387: a variable template declared wtih (or instantiated with) a 2019-04-26 01:51:08 +00:00
modules-ts [c++2a] Implement semantic restrictions for 'export' declarations. 2019-04-22 22:50:11 +00:00
over Fix regression in r360311 caused by reversed bool arguments. 2019-05-16 02:06:16 +00:00
special [SemaDeclCXX] Allow inheriting constructor declaration to specify a cv-qualified type 2019-08-17 20:57:52 +00:00
stmt.stmt Refactor the way we handle diagnosing unused expression results. 2019-01-04 16:58:14 +00:00
temp [c++20] P0780R2: Support pack-expansion of init-captures. 2019-05-21 20:10:50 +00:00