xref: /llvm-project/clang/test/Analysis/placement-new-user-defined.cpp (revision bc29069dc401572ba62f7dd692a3474c1ead76c9)
15e7beb0aSGabor Marton // RUN: %clang_analyze_cc1 -std=c++11 %s \
25e7beb0aSGabor Marton // RUN:   -analyzer-checker=core \
35e7beb0aSGabor Marton // RUN:   -analyzer-checker=cplusplus.NewDelete \
4*bc29069dSGabor Marton // RUN:   -analyzer-checker=cplusplus.PlacementNew \
55e7beb0aSGabor Marton // RUN:   -analyzer-output=text -verify \
65e7beb0aSGabor Marton // RUN:   -triple x86_64-unknown-linux-gnu
75e7beb0aSGabor Marton 
85e7beb0aSGabor Marton // expected-no-diagnostics
95e7beb0aSGabor Marton 
105e7beb0aSGabor Marton #include "Inputs/system-header-simulator-cxx.h"
115e7beb0aSGabor Marton 
125e7beb0aSGabor Marton struct X {
operator newX135e7beb0aSGabor Marton   static void *operator new(std::size_t sz, void *b) {
145e7beb0aSGabor Marton     return ::operator new(sz, b);
155e7beb0aSGabor Marton   }
165e7beb0aSGabor Marton   long l;
175e7beb0aSGabor Marton };
f()185e7beb0aSGabor Marton void f() {
195e7beb0aSGabor Marton   short buf;
205e7beb0aSGabor Marton   X *p1 = new (&buf) X;
215e7beb0aSGabor Marton   (void)p1;
225e7beb0aSGabor Marton }
23