diff options
Diffstat (limited to 'clang/test/AST/ByteCode')
| -rw-r--r-- | clang/test/AST/ByteCode/cxx11.cpp | 11 | ||||
| -rw-r--r-- | clang/test/AST/ByteCode/invalid.cpp | 18 |
2 files changed, 29 insertions, 0 deletions
diff --git a/clang/test/AST/ByteCode/cxx11.cpp b/clang/test/AST/ByteCode/cxx11.cpp index 753e51df..9561535 100644 --- a/clang/test/AST/ByteCode/cxx11.cpp +++ b/clang/test/AST/ByteCode/cxx11.cpp @@ -387,3 +387,14 @@ struct Counter { // Passing an lvalue by value makes a non-elidable copy. constexpr int PassByValue(Counter c) { return c.copies; } static_assert(PassByValue(Counter(0)) == 0, "expect no copies"); + +namespace PointerCast { + /// The two interpreters disagree here. + struct S { int x, y; } s; + constexpr S* sptr = &s; + struct U {}; + struct Str { + int e : (Str*)(sptr) == (Str*)(sptr); // expected-error {{not an integral constant expression}} \ + // expected-note {{cast that performs the conversions of a reinterpret_cast}} + }; +} diff --git a/clang/test/AST/ByteCode/invalid.cpp b/clang/test/AST/ByteCode/invalid.cpp index 1f2d6bc..115c866 100644 --- a/clang/test/AST/ByteCode/invalid.cpp +++ b/clang/test/AST/ByteCode/invalid.cpp @@ -88,4 +88,22 @@ namespace InvalidBitCast { // both-note {{in call to}} + struct sockaddr + { + char sa_data[8]; + }; + struct in_addr + { + unsigned int s_addr; + }; + struct sockaddr_in + { + unsigned short int sin_port; + struct in_addr sin_addr; + }; + /// Bitcast from sockaddr to sockaddr_in. Used to crash. + unsigned int get_addr(sockaddr addr) { + return ((sockaddr_in *)&addr)->sin_addr.s_addr; + } + } |
