aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Sema/SemaInit.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2016-12-14 03:22:16 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2016-12-14 03:22:16 +0000
commit378b8c8f012bacb85a4057e29a4e6b522842e94d (patch)
tree5ad321e81af72196f62a5cea4dfdc71a6403f854 /clang/lib/Sema/SemaInit.cpp
parenteb6a20e79ed4a5ac8d5f61f7372bb633c7362378 (diff)
downloadllvm-378b8c8f012bacb85a4057e29a4e6b522842e94d.zip
llvm-378b8c8f012bacb85a4057e29a4e6b522842e94d.tar.gz
llvm-378b8c8f012bacb85a4057e29a4e6b522842e94d.tar.bz2
[c++1z] P0217R3: Allow by-value structured binding of arrays.
llvm-svn: 289630
Diffstat (limited to 'clang/lib/Sema/SemaInit.cpp')
-rw-r--r--clang/lib/Sema/SemaInit.cpp20
1 files changed, 13 insertions, 7 deletions
diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp
index 291feea..6ece7c8 100644
--- a/clang/lib/Sema/SemaInit.cpp
+++ b/clang/lib/Sema/SemaInit.cpp
@@ -3068,6 +3068,7 @@ void InitializationSequence::Step::Destroy() {
case SK_ArrayLoopIndex:
case SK_ArrayLoopInit:
case SK_ArrayInit:
+ case SK_GNUArrayInit:
case SK_ParenthesizedArrayInit:
case SK_PassByIndirectCopyRestore:
case SK_PassByIndirectRestore:
@@ -3302,9 +3303,9 @@ void InitializationSequence::AddObjCObjectConversionStep(QualType T) {
Steps.push_back(S);
}
-void InitializationSequence::AddArrayInitStep(QualType T) {
+void InitializationSequence::AddArrayInitStep(QualType T, bool IsGNUExtension) {
Step S;
- S.Kind = SK_ArrayInit;
+ S.Kind = IsGNUExtension ? SK_GNUArrayInit : SK_ArrayInit;
S.Type = T;
Steps.push_back(S);
}
@@ -5217,8 +5218,7 @@ void InitializationSequence::InitializeFrom(Sema &S,
canPerformArrayCopy(Entity)) {
// If source is a prvalue, use it directly.
if (Initializer->getValueKind() == VK_RValue) {
- // FIXME: This produces a bogus extwarn
- AddArrayInitStep(DestType);
+ AddArrayInitStep(DestType, /*IsGNUExtension*/false);
return;
}
@@ -5251,7 +5251,7 @@ void InitializationSequence::InitializeFrom(Sema &S,
else if (Initializer->HasSideEffects(S.Context))
SetFailed(FK_NonConstantArrayInit);
else {
- AddArrayInitStep(DestType);
+ AddArrayInitStep(DestType, /*IsGNUExtension*/true);
}
}
// Note: as a GNU C++ extension, we allow list-initialization of a
@@ -6520,6 +6520,7 @@ InitializationSequence::Perform(Sema &S,
case SK_ArrayLoopIndex:
case SK_ArrayLoopInit:
case SK_ArrayInit:
+ case SK_GNUArrayInit:
case SK_ParenthesizedArrayInit:
case SK_PassByIndirectCopyRestore:
case SK_PassByIndirectRestore:
@@ -7011,13 +7012,14 @@ InitializationSequence::Perform(Sema &S,
break;
}
- case SK_ArrayInit:
+ case SK_GNUArrayInit:
// Okay: we checked everything before creating this step. Note that
// this is a GNU extension.
S.Diag(Kind.getLocation(), diag::ext_array_init_copy)
<< Step->Type << CurInit.get()->getType()
<< CurInit.get()->getSourceRange();
-
+ LLVM_FALLTHROUGH;
+ case SK_ArrayInit:
// If the destination type is an incomplete array type, update the
// type accordingly.
if (ResultType) {
@@ -7976,6 +7978,10 @@ void InitializationSequence::dump(raw_ostream &OS) const {
OS << "array initialization";
break;
+ case SK_GNUArrayInit:
+ OS << "array initialization (GNU extension)";
+ break;
+
case SK_ParenthesizedArrayInit:
OS << "parenthesized array initialization";
break;