Fix determination of whether a reinterpret_cast casts away constness.
authorRichard Smith <richard-llvm@metafoo.co.uk>
Tue, 10 Jul 2018 23:04:35 +0000 (23:04 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Tue, 10 Jul 2018 23:04:35 +0000 (23:04 +0000)
commitf276e2dc461833d3ef0b89a0b09d2e11776d9e84
tree02b9a8f6fc1e84d6e2f6b4b71ed5689fbdd92d88
parent0ed0febb3e58081edf1c69b62d28f72703a417f8
Fix determination of whether a reinterpret_cast casts away constness.

The "casts away constness" check doesn't care at all how the different
layers of the source and destination type were formed: for example, if
the source is a pointer and the destination is a pointer-to-member, the
types are still decomposed and their pointee qualifications are still
checked.

This rule is bizarre and somewhat ridiculous, so as an extension we
accept code making use of such reinterpret_casts with a warning outside
of SFINAE contexts.

llvm-svn: 336738
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Sema/SemaCast.cpp
clang/test/CXX/expr/expr.post/expr.reinterpret.cast/p2.cpp [new file with mode: 0644]
clang/test/Sema/warn-cast-qual.c