1 // RUN: %clang_cc1 -triple x86_64-windows-msvc -fexceptions -fcxx-exceptions -fms-extensions -verify %s -std=c++11 2 3 // The MS ABI has a few ways to generate constructor closures, which require 4 // instantiating and checking the semantics of default arguments. Make sure we 5 // do that right. 6 7 template <typename T> 8 struct DependentDefaultCtorArg { 9 // expected-error@+1 {{type 'int' cannot be used prior to '::' because it has no members}} 10 DependentDefaultCtorArg(int n = T::error); 11 }; 12 struct 13 __declspec(dllexport) // expected-note {{due to 'ExportDefaultCtorClosure' being dllexported}} 14 ExportDefaultCtorClosure // 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 18 template <typename T> 19 struct DependentDefaultCopyArg { DependentDefaultCopyArgDependentDefaultCopyArg20 DependentDefaultCopyArg() {} 21 // expected-error@+1 {{type 'int' cannot be used prior to '::' because it has no members}} DependentDefaultCopyArgDependentDefaultCopyArg22 DependentDefaultCopyArg(const DependentDefaultCopyArg &o, int n = T::member) {} 23 }; 24 25 struct HasMember { 26 enum { member = 0 }; 27 }; UseDependentArg()28void UseDependentArg() { throw DependentDefaultCopyArg<HasMember>(); } 29 ErrorInDependentArg()30void ErrorInDependentArg() { 31 throw DependentDefaultCopyArg<int>(); // expected-note {{required here}} 32 } 33 34 struct HasCleanup { 35 ~HasCleanup(); 36 }; 37 38 struct Default { 39 Default(const Default &o, int d = (HasCleanup(), 42)); 40 }; 41 f(const Default & d)42void f(const Default &d) { 43 throw d; 44 } 45