diff options
| author | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-02-15 22:38:09 +0000 |
|---|---|---|
| committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-02-15 22:38:09 +0000 |
| commit | ebeed415870befe7a06347337ff33dee2d2fcd2d (patch) | |
| tree | 604d289d6dd2da170fb8fceb6cc00551428a315a /clang/lib | |
| parent | 734909a078edcadf23fe1c8125b1b1749ec7a908 (diff) | |
| download | bcm5719-llvm-ebeed415870befe7a06347337ff33dee2d2fcd2d.tar.gz bcm5719-llvm-ebeed415870befe7a06347337ff33dee2d2fcd2d.zip | |
Support GCC's bug^Wextension allowing class array members to be initalized by a
parenthesized braced-init-list in the base/member initialization list.
llvm-svn: 150625
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/Sema/SemaInit.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp index da6892e230d..b6d55aae806 100644 --- a/clang/lib/Sema/SemaInit.cpp +++ b/clang/lib/Sema/SemaInit.cpp @@ -2417,6 +2417,7 @@ void InitializationSequence::Step::Destroy() { case SK_StringInit: case SK_ObjCObjectConversion: case SK_ArrayInit: + case SK_ParenthesizedArrayInit: case SK_PassByIndirectCopyRestore: case SK_PassByIndirectRestore: case SK_ProduceObjCObject: @@ -2618,6 +2619,13 @@ void InitializationSequence::AddArrayInitStep(QualType T) { Steps.push_back(S); } +void InitializationSequence::AddParenthesizedArrayInitStep(QualType T) { + Step S; + S.Kind = SK_ParenthesizedArrayInit; + S.Type = T; + Steps.push_back(S); +} + void InitializationSequence::AddPassByIndirectCopyRestoreStep(QualType type, bool shouldCopy) { Step s; @@ -4058,6 +4066,15 @@ InitializationSequence::InitializationSequence(Sema &S, else { AddArrayInitStep(DestType); } + } + // Note: as a GNU C++ extension, we allow initialization of a + // class member from a parenthesized initializer list. + else if (S.getLangOptions().CPlusPlus && + Entity.getKind() == InitializedEntity::EK_Member && + Initializer && isa<InitListExpr>(Initializer)) { + TryListInitialization(S, Entity, Kind, cast<InitListExpr>(Initializer), + *this); + AddParenthesizedArrayInitStep(DestType); } else if (DestAT->getElementType()->isAnyCharacterType()) SetFailed(FK_ArrayNeedsInitListOrStringLiteral); else @@ -4787,6 +4804,7 @@ InitializationSequence::Perform(Sema &S, case SK_StringInit: case SK_ObjCObjectConversion: case SK_ArrayInit: + case SK_ParenthesizedArrayInit: case SK_PassByIndirectCopyRestore: case SK_PassByIndirectRestore: case SK_ProduceObjCObject: @@ -5213,6 +5231,13 @@ InitializationSequence::Perform(Sema &S, } break; + case SK_ParenthesizedArrayInit: + // Okay: we checked everything before creating this step. Note that + // this is a GNU extension. + S.Diag(Kind.getLocation(), diag::ext_array_init_parens) + << CurInit.get()->getSourceRange(); + break; + case SK_PassByIndirectCopyRestore: case SK_PassByIndirectRestore: checkIndirectCopyRestoreSource(S, CurInit.get()); @@ -5889,6 +5914,10 @@ void InitializationSequence::dump(raw_ostream &OS) const { OS << "array initialization"; break; + case SK_ParenthesizedArrayInit: + OS << "parenthesized array initialization"; + break; + case SK_PassByIndirectCopyRestore: OS << "pass by indirect copy and restore"; break; |

