brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.5 KiB · 676bd48 Raw
45 lines · cpp
1// RUN: %clang_cc1 -triple x86_64-windows-msvc -fexceptions -fcxx-exceptions -fms-extensions -verify %s -std=c++112 3// The MS ABI has a few ways to generate constructor closures, which require4// instantiating and checking the semantics of default arguments. Make sure we5// do that right.6 7template <typename T>8struct DependentDefaultCtorArg {9  // expected-error@+1 {{type 'int' cannot be used prior to '::' because it has no members}}10  DependentDefaultCtorArg(int n = T::error);11};12struct13__declspec(dllexport) // expected-note {{due to 'ExportDefaultCtorClosure' being dllexported}}14ExportDefaultCtorClosure // expected-note {{in instantiation of default function argument expression for 'DependentDefaultCtorArg<int>' required here}} expected-note {{implicit default constructor for 'ExportDefaultCtorClosure' first required here}}15: DependentDefaultCtorArg<int>16{};17 18template <typename T>19struct DependentDefaultCopyArg {20  DependentDefaultCopyArg() {}21  // expected-error@+1 {{type 'int' cannot be used prior to '::' because it has no members}}22  DependentDefaultCopyArg(const DependentDefaultCopyArg &o, int n = T::member) {}23};24 25struct HasMember {26  enum { member = 0 };27};28void UseDependentArg() { throw DependentDefaultCopyArg<HasMember>(); }29 30void ErrorInDependentArg() {31  throw DependentDefaultCopyArg<int>(); // expected-note {{required here}}32}33 34struct HasCleanup {35  ~HasCleanup();36};37 38struct Default {39  Default(const Default &o, int d = (HasCleanup(), 42));40};41 42void f(const Default &d) {43  throw d;44}45