60 lines · cpp
1// RUN: %clang_cc1 -triple arm64-apple-macosx -fsyntax-only -verify %s -Wno-ext-cxx-type-aware-allocators -std=c++26 -DINVALID_TYPE_IDENTITY_VERSION=02// RUN: %clang_cc1 -triple arm64-apple-macosx -fsyntax-only -verify %s -Wno-ext-cxx-type-aware-allocators -std=c++26 -DINVALID_TYPE_IDENTITY_VERSION=13// RUN: %clang_cc1 -triple arm64-apple-macosx -fsyntax-only -verify %s -Wno-ext-cxx-type-aware-allocators -std=c++26 -DINVALID_TYPE_IDENTITY_VERSION=24// RUN: %clang_cc1 -triple arm64-apple-macosx -fsyntax-only -verify %s -Wno-ext-cxx-type-aware-allocators -std=c++26 -DINVALID_TYPE_IDENTITY_VERSION=35// RUN: %clang_cc1 -triple arm64-apple-macosx -fsyntax-only -verify %s -Wno-ext-cxx-type-aware-allocators -std=c++26 -DINVALID_TYPE_IDENTITY_VERSION=46// RUN: %clang_cc1 -triple arm64-apple-macosx -fsyntax-only -verify %s -Wno-ext-cxx-type-aware-allocators -std=c++267 8namespace std {9#if !defined(INVALID_TYPE_IDENTITY_VERSION)10 // expected-no-diagnostics11 template <class T> struct type_identity {12 };13 #define TYPE_IDENTITY(T) std::type_identity<T>14#elif INVALID_TYPE_IDENTITY_VERSION==015 struct type_identity {};16 // expected-error@-1 {{std::type_identity must be a class template with a single type parameter}}17 #define TYPE_IDENTITY(T) std::type_identity18#elif INVALID_TYPE_IDENTITY_VERSION==119 template <class A, class B> struct type_identity {};20 // expected-error@-1 {{std::type_identity must be a class template with a single type parameter}}21 #define TYPE_IDENTITY(T) std::type_identity<T, int>22#elif INVALID_TYPE_IDENTITY_VERSION==223 enum type_identity {};24 // expected-error@-1 {{std::type_identity must be a class template with a single type parameter}}25 #define TYPE_IDENTITY(T) std::type_identity26#elif INVALID_TYPE_IDENTITY_VERSION==327 template <class T> using type_identity = int;28 #define TYPE_IDENTITY(T) std::type_identity<T>29#elif INVALID_TYPE_IDENTITY_VERSION==430 template <class T> struct inner {};31 template <class T> using type_identity = inner<T>;32 #define TYPE_IDENTITY(T) std::type_identity<T>33#endif34 using size_t = __SIZE_TYPE__;35 enum class align_val_t : long {};36}37 38template <class T> void *operator new(TYPE_IDENTITY(T), std::size_t, std::align_val_t); // #operator_new39template <class T> void operator delete(TYPE_IDENTITY(T), void*, std::size_t, std::align_val_t); // #operator_delete40 41// These error messages aren't great, but they fall out of the way we model42// alias types. Getting them in this way requires extremely unlikely code to be43// used, so this is not terrible.44 45#if INVALID_TYPE_IDENTITY_VERSION==346// expected-error@#operator_new {{'operator new' takes type size_t ('unsigned long') as 1st parameter}}47// expected-error@#operator_delete {{1st parameter of 'operator delete' must have type 'void *'}}48#elif INVALID_TYPE_IDENTITY_VERSION==449// expected-error@#operator_new {{'operator new' cannot take a dependent type as its 1st parameter; use size_t ('unsigned long') instead}}50// expected-error@#operator_delete {{'operator delete' cannot take a dependent type as its 1st parameter; use 'void *' instead}}51#endif52 53using size_t = __SIZE_TYPE__;54struct TestType {};55 56void f() {57 TestType *t = new TestType;58 delete t;59}60