DR583, DR1512: Implement a rewrite to C++'s 'composite pointer type' rules.
authorRichard Smith <richard-llvm@metafoo.co.uk>
Fri, 21 Oct 2016 02:36:37 +0000 (02:36 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Fri, 21 Oct 2016 02:36:37 +0000 (02:36 +0000)
commit0c1c53e3fad7fadb1c182b3e26e38378d2abe7f8
treefb6ebc4ea1222b72b3768ce00b702fe8cc9df890
parent14699cf1c601d2e8f0b6bf6b8e651a14a5a1e42d
DR583, DR1512: Implement a rewrite to C++'s 'composite pointer type' rules.
This has two significant effects:

1) Direct relational comparisons between null pointer constants (0 and nullopt)
   and pointers are now ill-formed. This was always the case for C, and it
   appears that C++ only ever permitted by accident. For instance, cases like
     nullptr < &a
   are now rejected.

2) Comparisons and conditional operators between differently-cv-qualified
   pointer types now work, and produce a composite type that both source
   pointer types can convert to (when possible). For instance, comparison
   between 'int **' and 'const int **' is now valid, and uses an intermediate
   type of 'const int *const *'.

Clang previously supported #2 as an extension.

We do not accept the cases in #1 as an extension. I've tested a fair amount of
code to check that this doesn't break it, but if it turns out that someone is
relying on this, we can easily add it back as an extension.

llvm-svn: 284800
29 files changed:
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Sema/Sema.h
clang/lib/Sema/SemaExpr.cpp
clang/lib/Sema/SemaExprCXX.cpp
clang/lib/Sema/SemaOverload.cpp
clang/test/CXX/drs/dr15xx.cpp
clang/test/CXX/drs/dr5xx.cpp
clang/test/CXX/expr/expr.const/p2-0x.cpp
clang/test/CXX/over/over.built/p15.cpp [new file with mode: 0644]
clang/test/CXX/over/over.built/p16.cpp [new file with mode: 0644]
clang/test/Misc/warning-flags.c
clang/test/OpenMP/distribute_parallel_for_simd_aligned_messages.cpp
clang/test/OpenMP/distribute_simd_aligned_messages.cpp
clang/test/OpenMP/for_simd_aligned_messages.cpp
clang/test/OpenMP/parallel_for_simd_aligned_messages.cpp
clang/test/OpenMP/simd_aligned_messages.cpp
clang/test/OpenMP/target_parallel_for_simd_aligned_messages.cpp
clang/test/OpenMP/target_simd_aligned_messages.cpp
clang/test/OpenMP/taskloop_simd_aligned_messages.cpp
clang/test/SemaCXX/compare.cpp
clang/test/SemaCXX/composite-pointer-type.cpp
clang/test/SemaCXX/constant-expression-cxx11.cpp
clang/test/SemaCXX/libstdcxx_libcxx_less_hack.cpp [new file with mode: 0644]
clang/test/SemaCXX/null_in_arithmetic_ops.cpp
clang/test/SemaCXX/nullptr.cpp
clang/test/SemaCXX/nullptr_in_arithmetic_ops.cpp
clang/test/SemaCXX/warn-memsize-comparison.cpp
clang/test/SemaObjCXX/null_objc_pointer.mm
clang/www/cxx_dr_status.html