Clang Project

clang_source_code/test/SemaCXX/cxx03-aligned-allocation-unscoped-enum.cpp
1// RUN: %clang_cc1 -std=c++03 -triple x86_64-pc-linux-gnu %s \
2// RUN:   -faligned-allocation -emit-llvm -o - -Wno-c++11-extensions | FileCheck %s
3
4// Ensure Clang doesn't confuse std::align_val_t with the sized deallocation
5// parameter when the enum type is unscoped. Libc++ does this in C++03 in order
6// to support aligned allocation in that dialect.
7
8using size_t = __decltype(sizeof(0));
9
10namespace std {
11enum align_val_t : size_t {};
12}
13_Static_assert(__is_same(__underlying_type(std::align_val_t), size_t), "");
14
15// CHECK-LABEL: define void @_Z1fPi(
16void f(int *p) {
17  // CHECK-NOT: call void @_ZdlPvSt11align_val_t(
18  // CHECK: call void @_ZdlPv(
19  // CHECK: ret void
20  delete p;
21}
22