diff options
author | Daniel Dunbar <daniel@zuster.org> | 2009-08-10 03:01:36 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2009-08-10 03:01:36 +0000 |
commit | 1df5109f475bcbc528eb1fb9fdb179dcadbb33a6 (patch) | |
tree | ef613876a2162db4f5bc717ca55e4f07646310c0 /lib/Sema | |
parent | fd6ad3cf9c8fc6904bd5f33212207aa69743fd45 (diff) |
Revert r78535, it is causing a number of failures to build projects.
--- Reverse-merging r78535 into '.':
D test/Sema/altivec-init.c
U include/clang/Basic/DiagnosticSemaKinds.td
U include/clang/AST/Expr.h
U include/clang/AST/StmtNodes.def
U include/clang/Parse/Parser.h
U include/clang/Parse/Action.h
U tools/clang-cc/clang-cc.cpp
U lib/Frontend/PrintParserCallbacks.cpp
U lib/CodeGen/CGExprScalar.cpp
U lib/Sema/SemaInit.cpp
U lib/Sema/Sema.h
U lib/Sema/SemaExpr.cpp
U lib/Sema/SemaTemplateInstantiateExpr.cpp
U lib/AST/StmtProfile.cpp
U lib/AST/Expr.cpp
U lib/AST/StmtPrinter.cpp
U lib/Parse/ParseExpr.cpp
U lib/Parse/ParseExprCXX.cpp
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@78551 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema')
-rw-r--r-- | lib/Sema/Sema.h | 16 | ||||
-rw-r--r-- | lib/Sema/SemaExpr.cpp | 83 | ||||
-rw-r--r-- | lib/Sema/SemaInit.cpp | 45 | ||||
-rw-r--r-- | lib/Sema/SemaTemplateInstantiateExpr.cpp | 16 |
4 files changed, 13 insertions, 147 deletions
diff --git a/lib/Sema/Sema.h b/lib/Sema/Sema.h index e183e3a496..4f7ae7ec0d 100644 --- a/lib/Sema/Sema.h +++ b/lib/Sema/Sema.h @@ -50,7 +50,6 @@ namespace clang { class Stmt; class Expr; class InitListExpr; - class ParenListExpr; class DesignatedInitExpr; class CallExpr; class DeclRefExpr; @@ -1485,10 +1484,7 @@ public: virtual OwningExprResult ActOnCharacterConstant(const Token &); virtual OwningExprResult ActOnParenExpr(SourceLocation L, SourceLocation R, ExprArg Val); - virtual OwningExprResult ActOnParenListExpr(SourceLocation L, - SourceLocation R, - MultiExprArg Val); - + /// ActOnStringLiteral - The specified tokens were lexed as pasted string /// fragments (e.g. "foo" "bar" L"baz"). virtual OwningExprResult ActOnStringLiteral(const Token *Toks, @@ -1549,14 +1545,8 @@ public: SourceLocation *CommaLocs, SourceLocation RParenLoc); - virtual OwningExprResult ActOnCastExpr(Scope *S, SourceLocation LParenLoc, - TypeTy *Ty, SourceLocation RParenLoc, - ExprArg Op); - - OwningExprResult ConvertParenListExpr(Scope *S, ParenListExpr *E); - OwningExprResult ActOnCastOfParenListExpr(Scope *S, SourceLocation LParenLoc, - SourceLocation RParenLoc, - ParenListExpr *E, QualType Ty); + virtual OwningExprResult ActOnCastExpr(SourceLocation LParenLoc, TypeTy *Ty, + SourceLocation RParenLoc, ExprArg Op); virtual OwningExprResult ActOnCompoundLiteral(SourceLocation LParenLoc, TypeTy *Ty, diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index 23e58de68c..f00ab5412d 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -1918,8 +1918,7 @@ Sema::ActOnArraySubscriptExpr(Scope *S, ExprArg Base, SourceLocation LLoc, << LHSExp->getSourceRange() << RHSExp->getSourceRange()); } // C99 6.5.2.1p1 - if (!(IndexExpr->getType()->isIntegerType() && - IndexExpr->getType()->isScalarType()) && !IndexExpr->isTypeDependent()) + if (!IndexExpr->getType()->isIntegerType() && !IndexExpr->isTypeDependent()) return ExprError(Diag(LLoc, diag::err_typecheck_subscript_not_integer) << IndexExpr->getSourceRange()); @@ -2115,11 +2114,6 @@ Sema::ActOnMemberReferenceExpr(Scope *S, ExprArg Base, SourceLocation OpLoc, Expr *BaseExpr = Base.takeAs<Expr>(); assert(BaseExpr && "no record expression"); - // If BaseExpr is a ParenListExpr then convert it into a standard - // paren expr since this is not an altivec initializer. - if (ParenListExpr *PE = dyn_cast<ParenListExpr>(BaseExpr)) - BaseExpr = ConvertParenListExpr(S, PE).takeAs<Expr>(); - // Perform default conversions. DefaultFunctionArrayConversion(BaseExpr); @@ -2695,11 +2689,6 @@ Sema::ActOnCallExpr(Scope *S, ExprArg fn, SourceLocation LParenLoc, FunctionDecl *FDecl = NULL; NamedDecl *NDecl = NULL; DeclarationName UnqualifiedName; - - // If the function is a ParenListExpr, then convert it into a standard - // paren expr since this is not an altivec initializer. - if (ParenListExpr *PE = dyn_cast<ParenListExpr>(Fn)) - Fn = ConvertParenListExpr(S, PE).takeAs<Expr>(); if (getLangOptions().CPlusPlus) { // Determine whether this is a dependent call inside a C++ template, @@ -3101,7 +3090,7 @@ bool Sema::CheckExtVectorCast(SourceRange R, QualType DestTy, QualType SrcTy) { } Action::OwningExprResult -Sema::ActOnCastExpr(Scope *S, SourceLocation LParenLoc, TypeTy *Ty, +Sema::ActOnCastExpr(SourceLocation LParenLoc, TypeTy *Ty, SourceLocation RParenLoc, ExprArg Op) { CastExpr::CastKind Kind = CastExpr::CK_Unknown; @@ -3110,10 +3099,6 @@ Sema::ActOnCastExpr(Scope *S, SourceLocation LParenLoc, TypeTy *Ty, Expr *castExpr = Op.takeAs<Expr>(); QualType castType = QualType::getFromOpaquePtr(Ty); - - // If the Expr being casted is a ParenListExpr, handle it specially. - if (ParenListExpr *PE = dyn_cast<ParenListExpr>(castExpr)) - return ActOnCastOfParenListExpr(S, LParenLoc, RParenLoc, PE, castType); if (CheckCastTypes(SourceRange(LParenLoc, RParenLoc), castType, castExpr, Kind)) @@ -3123,68 +3108,6 @@ Sema::ActOnCastExpr(Scope *S, SourceLocation LParenLoc, TypeTy *Ty, LParenLoc, RParenLoc)); } -/// This is not an AltiVec-style cast, so turn the ParenListExpr into a sequence -/// of comma binary operators. -Action::OwningExprResult -Sema::ConvertParenListExpr(Scope *S, ParenListExpr *E) { - OwningExprResult Result(*this, E->getExpr(0)); - - for (unsigned i = 1, e = E->getNumExprs(); i != e && !Result.isInvalid(); ++i) - Result = ActOnBinOp(S, E->getExprLoc(), tok::comma, move(Result), - Owned(E->getExpr(i))); - return move(Result); -} - -Action::OwningExprResult -Sema::ActOnCastOfParenListExpr(Scope *S, SourceLocation LParenLoc, - SourceLocation RParenLoc, - ParenListExpr *E, QualType Ty) { - // If this is an altivec initializer, '(' type ')' '(' init, ..., init ')' - // then handle it as such. - if (getLangOptions().AltiVec && Ty->isVectorType()) { - if (E->getNumExprs() == 0) { - Diag(E->getExprLoc(), diag::err_altivec_empty_initializer); - return ExprError(); - } - - llvm::SmallVector<Expr *, 8> initExprs; - for (unsigned i = 0, e = E->getNumExprs(); i != e; ++i) - initExprs.push_back(E->getExpr(i)); - - // FIXME: This means that pretty-printing the final AST will produce curly - // braces instead of the original commas. - InitListExpr *E = new (Context) InitListExpr(LParenLoc, &initExprs[0], - initExprs.size(), RParenLoc); - E->setType(Ty); - return ActOnCompoundLiteral(LParenLoc, Ty.getAsOpaquePtr(), RParenLoc, - Owned(E)); - } else { - // This is not an AltiVec-style cast, so turn the ParenListExpr into a - // sequence of BinOp comma operators. - OwningExprResult Result = ConvertParenListExpr(S, E); - Expr *castExpr = (Expr *)Result.get(); - CastExpr::CastKind Kind = CastExpr::CK_Unknown; - - if (CheckCastTypes(SourceRange(LParenLoc, RParenLoc), Ty, castExpr, Kind)) - return ExprError(); - - return Owned(new (Context) CStyleCastExpr(Ty.getNonReferenceType(), - CastExpr::CK_Unknown, - Result.takeAs<Expr>(), Ty, - LParenLoc, RParenLoc)); - } -} - -Action::OwningExprResult Sema::ActOnParenListExpr(SourceLocation L, - SourceLocation R, - MultiExprArg Val) { - unsigned nexprs = Val.size(); - Expr **exprs = reinterpret_cast<Expr**>(Val.release()); - assert((exprs != 0) && "ActOnParenListExpr() missing expr list"); - Expr *expr = new (Context) ParenListExpr(Context, L, exprs, nexprs, R); - return Owned(expr); -} - /// Note that lhs is not null here, even if this is the gnu "x ?: y" extension. /// In that case, lhs = cond. /// C99 6.5.15 @@ -3209,8 +3132,6 @@ QualType Sema::CheckConditionalOperands(Expr *&Cond, Expr *&LHS, Expr *&RHS, } // Now check the two expressions. - if (LHSTy->isVectorType() || RHSTy->isVectorType()) - return CheckVectorOperands(QuestionLoc, LHS, RHS); // If both operands have arithmetic type, do the usual arithmetic conversions // to find a common type: C99 6.5.15p3,5. diff --git a/lib/Sema/SemaInit.cpp b/lib/Sema/SemaInit.cpp index 1e564ce45f..29113822f7 100644 --- a/lib/Sema/SemaInit.cpp +++ b/lib/Sema/SemaInit.cpp @@ -805,47 +805,16 @@ void InitListChecker::CheckVectorType(InitListExpr *IList, QualType DeclType, unsigned &StructuredIndex) { if (Index < IList->getNumInits()) { const VectorType *VT = DeclType->getAsVectorType(); - unsigned maxElements = VT->getNumElements(); - unsigned numEltsInit = 0; + int maxElements = VT->getNumElements(); QualType elementType = VT->getElementType(); - if (!SemaRef.getLangOptions().OpenCL) { - for (unsigned i = 0; i < maxElements; ++i, ++numEltsInit) { - // Don't attempt to go past the end of the init list - if (Index >= IList->getNumInits()) - break; - CheckSubElementType(IList, elementType, Index, - StructuredList, StructuredIndex); - } - } else { - // OpenCL initializers allows vectors to be constructed from vectors. - for (unsigned i = 0; i < maxElements; ++i) { - // Don't attempt to go past the end of the init list - if (Index >= IList->getNumInits()) - break; - QualType IType = IList->getInit(Index)->getType(); - if (!IType->isVectorType()) { - CheckSubElementType(IList, elementType, Index, - StructuredList, StructuredIndex); - ++numEltsInit; - } else { - const VectorType *IVT = IType->getAsVectorType(); - unsigned numIElts = IVT->getNumElements(); - QualType VecType = SemaRef.Context.getExtVectorType(elementType, - numIElts); - CheckSubElementType(IList, VecType, Index, - StructuredList, StructuredIndex); - numEltsInit += numIElts; - } - } + for (int i = 0; i < maxElements; ++i) { + // Don't attempt to go past the end of the init list + if (Index >= IList->getNumInits()) + break; + CheckSubElementType(IList, elementType, Index, + StructuredList, StructuredIndex); } - - // OpenCL & AltiVec require all elements to be initialized. - if (numEltsInit != maxElements) - if (SemaRef.getLangOptions().OpenCL || SemaRef.getLangOptions().AltiVec) - SemaRef.Diag(IList->getSourceRange().getBegin(), - diag::err_vector_incorrect_num_initializers) - << (numEltsInit < maxElements) << maxElements << numEltsInit; } } diff --git a/lib/Sema/SemaTemplateInstantiateExpr.cpp b/lib/Sema/SemaTemplateInstantiateExpr.cpp index 7a09210fe0..186c98cf53 100644 --- a/lib/Sema/SemaTemplateInstantiateExpr.cpp +++ b/lib/Sema/SemaTemplateInstantiateExpr.cpp @@ -639,20 +639,6 @@ TemplateExprInstantiator::VisitInitListExpr(InitListExpr *E) { } Sema::OwningExprResult -TemplateExprInstantiator::VisitParenListExpr(ParenListExpr *E) { - ASTOwningVector<&ActionBase::DeleteExpr, 4> Inits(SemaRef); - for (unsigned I = 0, N = E->getNumExprs(); I != N; ++I) { - OwningExprResult Init = Visit(E->getExpr(I)); - if (Init.isInvalid()) - return SemaRef.ExprError(); - Inits.push_back(Init.takeAs<Expr>()); - } - - return SemaRef.ActOnParenListExpr(E->getLParenLoc(), E->getRParenLoc(), - move_arg(Inits)); -} - -Sema::OwningExprResult TemplateExprInstantiator::VisitDesignatedInitExpr(DesignatedInitExpr *E) { Designation Desig; @@ -900,7 +886,7 @@ TemplateExprInstantiator::VisitCStyleCastExpr(CStyleCastExpr *E) { if (SubExpr.isInvalid()) return SemaRef.ExprError(); - return SemaRef.ActOnCastExpr(/*Scope=*/0, E->getLParenLoc(), + return SemaRef.ActOnCastExpr(E->getLParenLoc(), ExplicitTy.getAsOpaquePtr(), E->getRParenLoc(), move(SubExpr)); |