Commit f6c927e
[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 #143708.
---------
Co-authored-by: Corentin Jabot <corentinjabot@gmail.com>1 parent 2f4a804 commit f6c927e
File tree
4 files changed
+58
-1
lines changed- clang
- docs
- include/clang/Basic
- lib/Sema
- test/SemaCXX
4 files changed
+58
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
699 | 699 | | |
700 | 700 | | |
701 | 701 | | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
702 | 705 | | |
703 | 706 | | |
704 | 707 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8308 | 8308 | | |
8309 | 8309 | | |
8310 | 8310 | | |
| 8311 | + | |
| 8312 | + | |
| 8313 | + | |
8311 | 8314 | | |
8312 | 8315 | | |
8313 | 8316 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2752 | 2752 | | |
2753 | 2753 | | |
2754 | 2754 | | |
2755 | | - | |
| 2755 | + | |
2756 | 2756 | | |
2757 | 2757 | | |
2758 | 2758 | | |
| 2759 | + | |
| 2760 | + | |
| 2761 | + | |
| 2762 | + | |
| 2763 | + | |
| 2764 | + | |
| 2765 | + | |
| 2766 | + | |
| 2767 | + | |
| 2768 | + | |
2759 | 2769 | | |
2760 | 2770 | | |
2761 | 2771 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
170 | 170 | | |
171 | 171 | | |
172 | 172 | | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
173 | 214 | | |
174 | 215 | | |
175 | 216 | | |
| |||
0 commit comments