diff options
author | Eli Friedman <eli.friedman@gmail.com> | 2011-10-31 20:59:03 +0000 |
---|---|---|
committer | Eli Friedman <eli.friedman@gmail.com> | 2011-10-31 20:59:03 +0000 |
commit | 90a2cdf1fb9b00c45f53d1fa3f4f349f0aeaba7c (patch) | |
tree | 2d5f7a5a2ceb2747f3c68c8cc947d93ce3c8ed2e | |
parent | dd78544d4474154fa8ee097aed3d6c5b2dff72f5 (diff) | |
download | bcm5719-llvm-90a2cdf1fb9b00c45f53d1fa3f4f349f0aeaba7c.tar.gz bcm5719-llvm-90a2cdf1fb9b00c45f53d1fa3f4f349f0aeaba7c.zip |
Add missing lvalue-to-rvalue conversion.
llvm-svn: 143364
-rw-r--r-- | clang/lib/Sema/SemaCast.cpp | 6 | ||||
-rw-r--r-- | clang/test/SemaCXX/constant-expression-cxx11.cpp | 3 |
2 files changed, 9 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaCast.cpp b/clang/lib/Sema/SemaCast.cpp index 7a063036c2f..20742a0c35a 100644 --- a/clang/lib/Sema/SemaCast.cpp +++ b/clang/lib/Sema/SemaCast.cpp @@ -529,6 +529,12 @@ CastsAwayConstness(Sema &Self, QualType SrcType, QualType DestType, /// Refer to C++ 5.2.7 for details. Dynamic casts are used mostly for runtime- /// checked downcasts in class hierarchies. void CastOperation::CheckDynamicCast() { + if (ValueKind == VK_RValue && !isPlaceholder(BuiltinType::Overload)) { + SrcExpr = Self.DefaultFunctionArrayLvalueConversion(SrcExpr.take()); + if (SrcExpr.isInvalid()) // if conversion failed, don't report another error + return; + } + QualType OrigSrcType = SrcExpr.get()->getType(); QualType DestType = Self.Context.getCanonicalType(this->DestType); diff --git a/clang/test/SemaCXX/constant-expression-cxx11.cpp b/clang/test/SemaCXX/constant-expression-cxx11.cpp index 4c662a06cc6..8c845a7bd98 100644 --- a/clang/test/SemaCXX/constant-expression-cxx11.cpp +++ b/clang/test/SemaCXX/constant-expression-cxx11.cpp @@ -197,6 +197,9 @@ constexpr bool s4 = &x >= &x; constexpr bool s5 = &x < &x; constexpr bool s6 = &x > &x; +constexpr S* sptr = &s; +constexpr bool dyncast = sptr == dynamic_cast<S*>(sptr); + using check = int[m1 + (m2<<1) + (m3<<2) + (m4<<3) + (m5<<4) + (m6<<5) + (n1<<6) + (n2<<7) + (n7<<8) + (n8<<9) + (g1<<10) + (g2<<11) + (s1<<12) + (s2<<13) + (s3<<14) + (s4<<15) + (s5<<16) + (s6<<17)]; |