~ubuntu-branches/ubuntu/trusty/llvm-toolchain-snapshot/trusty-201310232150

« back to all changes in this revision

Viewing changes to clang/lib/Sema/SemaCast.cpp

  • Committer: Package Import Robot
  • Author(s): Sylvestre Ledru
  • Date: 2013-05-27 15:01:57 UTC
  • mfrom: (0.10.1) (0.9.1) (0.8.1) (0.7.1) (0.6.1) (0.5.2)
  • Revision ID: package-import@ubuntu.com-20130527150157-tdkrsjpuvht7v0qx
Tags: 1:3.4~svn182733-1~exp1
* New snapshot release (3.4 release)
* Add a symlink of libLLVM-3.4.so.1 to usr/lib/llvm-3.4/lib/libLLVM-3.4.so
    to fix make the llvm-config-3.4 --libdir work (Closes: #708677)
  * Various packages rename to allow co installations:
    * libclang1 => libclang1-3.4
    * libclang1-dbg => libclang1-3.4-dbg
    * libclang-dev => libclang-3.4-dev
    * libclang-common-dev => libclang-common-3.4-dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
333
333
    : (CT == CT_Functional)? InitializationKind::CreateFunctionalCast(range,
334
334
                                                             listInitialization)
335
335
    : InitializationKind::CreateCast(/*type range?*/ range);
336
 
  InitializationSequence sequence(S, entity, initKind, &src, 1);
 
336
  InitializationSequence sequence(S, entity, initKind, src);
337
337
 
338
338
  assert(sequence.Failed() && "initialization succeeded on second try?");
339
339
  switch (sequence.getFailureKind()) {
1418
1418
        ? InitializationKind::CreateFunctionalCast(OpRange, ListInitialization)
1419
1419
    : InitializationKind::CreateCast(OpRange);
1420
1420
  Expr *SrcExprRaw = SrcExpr.get();
1421
 
  InitializationSequence InitSeq(Self, Entity, InitKind, &SrcExprRaw, 1);
 
1421
  InitializationSequence InitSeq(Self, Entity, InitKind, SrcExprRaw);
1422
1422
 
1423
1423
  // At this point of CheckStaticCast, if the destination is a reference,
1424
1424
  // or the expression is an overload expression this has to work. 
1452
1452
  DestType = Self.Context.getCanonicalType(DestType);
1453
1453
  QualType SrcType = SrcExpr->getType();
1454
1454
  if (const ReferenceType *DestTypeTmp =DestType->getAs<ReferenceType>()) {
1455
 
    if (DestTypeTmp->isLValueReferenceType() && !SrcExpr->isLValue()) {
 
1455
    if (isa<LValueReferenceType>(DestTypeTmp) && !SrcExpr->isLValue()) {
1456
1456
      // Cannot const_cast non-lvalue to lvalue reference type. But if this
1457
1457
      // is C-style, static_cast might find a way, so we simply suggest a
1458
1458
      // message and tell the parent to keep searching.
1460
1460
      return TC_NotApplicable;
1461
1461
    }
1462
1462
 
 
1463
    // It's not completely clear under the standard whether we can
 
1464
    // const_cast bit-field gl-values.  Doing so would not be
 
1465
    // intrinsically complicated, but for now, we say no for
 
1466
    // consistency with other compilers and await the word of the
 
1467
    // committee.
 
1468
    if (SrcExpr->refersToBitField()) {
 
1469
      msg = diag::err_bad_cxx_cast_bitfield;
 
1470
      return TC_NotApplicable;
 
1471
    }
 
1472
 
1463
1473
    // C++ 5.2.11p4: An lvalue of type T1 can be [cast] to an lvalue of type T2
1464
1474
    //   [...] if a pointer to T1 can be [cast] to the type pointer to T2.
1465
1475
    DestType = Self.Context.getPointerType(DestTypeTmp->getPointeeType());