diff options
author | Baranov Victor <bar.victor.2002@gmail.com> | 2025-07-12 09:58:06 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-07-12 09:58:06 +0300 |
commit | f6c927e8dbe8e760c5d21c52f0c211ab3fb58735 (patch) | |
tree | 3d2f21d320e4f2033292af50ed80a5534b2a5c09 /clang/lib/Basic/SourceManager.cpp | |
parent | 2f4a804e6eb597e792cf069726c6190127c478fb (diff) | |
download | llvm-f6c927e8dbe8e760c5d21c52f0c211ab3fb58735.zip llvm-f6c927e8dbe8e760c5d21c52f0c211ab3fb58735.tar.gz llvm-f6c927e8dbe8e760c5d21c52f0c211ab3fb58735.tar.bz2 |
[Clang] Improve diagnostics for 'placement new' with const storage argument (#144270)
Before this patch, the following code gave misleading diagnostics about
absence of `#include <new>`:
```cpp
#include <new>
struct X { int n; };
int foo() {
const X cx = {5};
// error: no matching 'operator new' function for non-allocating placement new expression; include <new>
(void)new(&cx) X{10};
};
```
Now it gives correct diagnostics about constness of passed argument:
```cpp
#include <new>
struct X { int n; };
int foo() {
const X cx = {5};
// error: placement new expression with a const-qualified argument of type 'const X *' is not allowed
(void)new(&cx) X{10};
};
```
Fixes https://github.com/llvm/llvm-project/issues/143708.
---------
Co-authored-by: Corentin Jabot <corentinjabot@gmail.com>
Diffstat (limited to 'clang/lib/Basic/SourceManager.cpp')
0 files changed, 0 insertions, 0 deletions