Debian Codegraph @

clang/test/SemaCXX/operator-new-size-diagnose_if.cpp

raw
1 // RUN: %clang_cc1 %s -verify -fno-builtin -std=c++14
2
3 using size_t = decltype(sizeof(int));
4
5 #define _diagnose_if(...) __attribute__((diagnose_if(__VA_ARGS__)))
6
7 namespace operator_new {
8 struct T0 {
9 int j = 0;
10 static void *operator new(size_t i) _diagnose_if(i == sizeof(int), "yay", "warning"); // expected-note{{from 'diagnose_if'}}
11 };
12
13 struct T1 {
14 int j = 0;
15 static void *operator new[](size_t i) _diagnose_if(i == 8 * sizeof(int), "yay", "warning"); // expected-note 2{{from 'diagnose_if'}}
16 };
17
18 void run(int x) {
19 new T0; // expected-warning{{yay}}
20 new T1[8]; // expected-warning{{yay}}
21 new T1[4][2]; // expected-warning{{yay}}
22 new T1[x]; // no warning.
23 }
24 } // namespace operator_new