diff options
author | Douglas Gregor <dgregor@apple.com> | 2009-12-22 07:24:36 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2009-12-22 07:24:36 +0000 |
commit | aa0373107968aa7a26bf63f4a2673b8325b800af (patch) | |
tree | 8d3242d7f6b67a72a3eddffee790f83047bb7b12 /lib/Sema/SemaInit.cpp | |
parent | 8257d411a759b91921681c3b7f79e50e0d9252db (diff) |
Switch initialization of parameters in a call over to
InitializationSequence (when a FunctionDecl is present). This required
a few small fixes to initialization sequences:
- Make sure to use the adjusted parameter type for initialization of
function parameters.
- Implement transparent union calling semantics in C
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91902 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaInit.cpp')
-rw-r--r-- | lib/Sema/SemaInit.cpp | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/lib/Sema/SemaInit.cpp b/lib/Sema/SemaInit.cpp index 80cfc3637e..f831b41512 100644 --- a/lib/Sema/SemaInit.cpp +++ b/lib/Sema/SemaInit.cpp @@ -1811,8 +1811,15 @@ InitializedEntity::InitializedEntity(ASTContext &Context, unsigned Index, void InitializedEntity::InitDeclLoc() { assert((Kind == EK_Variable || Kind == EK_Parameter || Kind == EK_Member) && "InitDeclLoc cannot be used with non-declaration entities."); - - if (TypeSourceInfo *DI = VariableOrMember->getTypeSourceInfo()) { + + ASTContext &Context = VariableOrMember->getASTContext(); + if (Kind == EK_Parameter && + !Context.hasSameUnqualifiedType( + cast<ParmVarDecl>(VariableOrMember)->getOriginalType(), + VariableOrMember->getType())) { + // For a parameter whose type has decayed, use the decayed type to + // build new source information. + } else if (TypeSourceInfo *DI = VariableOrMember->getTypeSourceInfo()) { TL = DI->getTypeLoc(); return; } @@ -1820,8 +1827,8 @@ void InitializedEntity::InitDeclLoc() { // FIXME: Once we've gone through the effort to create the fake // TypeSourceInfo, should we cache it in the declaration? // (If not, we "leak" it). - TypeSourceInfo *DI = VariableOrMember->getASTContext() - .CreateTypeSourceInfo(VariableOrMember->getType()); + TypeSourceInfo *DI + = Context.CreateTypeSourceInfo(VariableOrMember->getType()); DI->getTypeLoc().initialize(VariableOrMember->getLocation()); TL = DI->getTypeLoc(); } @@ -3346,6 +3353,14 @@ InitializationSequence::Perform(Sema &S, QualType SourceType = CurInitExpr->getType(); Sema::AssignConvertType ConvTy = S.CheckSingleAssignmentConstraints(Step->Type, CurInitExpr); + + // If this is a call, allow conversion to a transparent union. + if (ConvTy != Sema::Compatible && + Entity.getKind() == InitializedEntity::EK_Parameter && + S.CheckTransparentUnionArgumentConstraints(Step->Type, CurInitExpr) + == Sema::Compatible) + ConvTy = Sema::Compatible; + if (S.DiagnoseAssignmentResult(ConvTy, Kind.getLocation(), Step->Type, SourceType, CurInitExpr, getAssignmentAction(Entity))) |