diff options
author | Elizabeth Andrews <elizabeth.andrews@intel.com> | 2019-12-03 14:20:52 -0800 |
---|---|---|
committer | Elizabeth Andrews <elizabeth.andrews@intel.com> | 2019-12-03 15:27:19 -0800 |
commit | 878a24ee244a24c39d1c57e9af2e88c621f7cce9 (patch) | |
tree | e25f6be59d4eafb4294c3751aad095a86f9f2854 /clang/test/SemaCXX/constant-expression-cxx2a.cpp | |
parent | f139ae3d9379746164e8056c45817041417dfd4c (diff) | |
download | bcm5719-llvm-878a24ee244a24c39d1c57e9af2e88c621f7cce9.tar.gz bcm5719-llvm-878a24ee244a24c39d1c57e9af2e88c621f7cce9.zip |
Reapply "Fix crash on switch conditions of non-integer types in templates"
This patch reapplies commit 759948467ea. Patch was reverted due to a
clang-tidy test fail on Windows. The test has been modified. There
are no additional code changes.
Patch was tested with ninja check-all on Windows and Linux.
Summary of code changes:
Clang currently crashes for switch statements inside a template when the
condition is a non-integer field member because contextual implicit
conversion is skipped when parsing the condition. This conversion is
however later checked in an assert when the case statement is handled.
The conversion is skipped when parsing the condition because
the field member is set as type-dependent based on its containing class.
This patch sets the type dependency based on the field's type instead.
This patch fixes Bug 40982.
Diffstat (limited to 'clang/test/SemaCXX/constant-expression-cxx2a.cpp')
-rw-r--r-- | clang/test/SemaCXX/constant-expression-cxx2a.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/clang/test/SemaCXX/constant-expression-cxx2a.cpp b/clang/test/SemaCXX/constant-expression-cxx2a.cpp index 8db705dcdc6..c2e443b9bec 100644 --- a/clang/test/SemaCXX/constant-expression-cxx2a.cpp +++ b/clang/test/SemaCXX/constant-expression-cxx2a.cpp @@ -18,6 +18,7 @@ namespace std { [[nodiscard]] void *operator new(std::size_t, std::align_val_t, const std::nothrow_t&) noexcept; [[nodiscard]] void *operator new[](std::size_t, const std::nothrow_t&) noexcept; [[nodiscard]] void *operator new[](std::size_t, std::align_val_t, const std::nothrow_t&) noexcept; +[[nodiscard]] void *operator new[](std::size_t, std::align_val_t); void operator delete(void*, const std::nothrow_t&) noexcept; void operator delete(void*, std::align_val_t, const std::nothrow_t&) noexcept; void operator delete[](void*, const std::nothrow_t&) noexcept; @@ -1050,7 +1051,7 @@ namespace dynamic_alloc { // Ensure that we don't try to evaluate these for overflow and crash. These // are all value-dependent expressions. p = new char[n]; - p = new (n) char[n]; + p = new ((std::align_val_t)n) char[n]; p = new char(n); } } |