1a5728872c7702ddd09537c95bc3cbd20e1f2fb09Daniel Dunbar// RUN: %clang_cc1 -fsyntax-only -pedantic -verify %s 26d507a6d96ea6379bc1df207abe26ad4cbe6563dDouglas Gregor 36d507a6d96ea6379bc1df207abe26ad4cbe6563dDouglas Gregor// [dcl.ambig.res]p1: 46d507a6d96ea6379bc1df207abe26ad4cbe6563dDouglas Gregorstruct S { 56d507a6d96ea6379bc1df207abe26ad4cbe6563dDouglas Gregor S(int); 66d507a6d96ea6379bc1df207abe26ad4cbe6563dDouglas Gregor void bar(); 76d507a6d96ea6379bc1df207abe26ad4cbe6563dDouglas Gregor}; 86d507a6d96ea6379bc1df207abe26ad4cbe6563dDouglas Gregor 96d507a6d96ea6379bc1df207abe26ad4cbe6563dDouglas Gregorint returns_an_int(); 106d507a6d96ea6379bc1df207abe26ad4cbe6563dDouglas Gregor 116d507a6d96ea6379bc1df207abe26ad4cbe6563dDouglas Gregorvoid foo(double a) 126d507a6d96ea6379bc1df207abe26ad4cbe6563dDouglas Gregor{ 136d507a6d96ea6379bc1df207abe26ad4cbe6563dDouglas Gregor S w(int(a)); // expected-warning{{disambiguated}} 146d507a6d96ea6379bc1df207abe26ad4cbe6563dDouglas Gregor w(17); 1560c93c9981c467738369702e7aa23fd58c2b6aacDouglas Gregor S x1(int()); // expected-warning{{disambiguated}} 1660c93c9981c467738369702e7aa23fd58c2b6aacDouglas Gregor x1(&returns_an_int); 176d507a6d96ea6379bc1df207abe26ad4cbe6563dDouglas Gregor S y((int)a); 186d507a6d96ea6379bc1df207abe26ad4cbe6563dDouglas Gregor y.bar(); 196d507a6d96ea6379bc1df207abe26ad4cbe6563dDouglas Gregor S z = int(a); 206d507a6d96ea6379bc1df207abe26ad4cbe6563dDouglas Gregor z.bar(); 216d507a6d96ea6379bc1df207abe26ad4cbe6563dDouglas Gregor} 226d507a6d96ea6379bc1df207abe26ad4cbe6563dDouglas Gregor 236d507a6d96ea6379bc1df207abe26ad4cbe6563dDouglas Gregor// [dcl.ambig.res]p3: 246d507a6d96ea6379bc1df207abe26ad4cbe6563dDouglas Gregorchar *p; 256d507a6d96ea6379bc1df207abe26ad4cbe6563dDouglas Gregorvoid *operator new(__SIZE_TYPE__, int); 266d507a6d96ea6379bc1df207abe26ad4cbe6563dDouglas Gregorvoid foo3() { 276d507a6d96ea6379bc1df207abe26ad4cbe6563dDouglas Gregor const int x = 63; 286d507a6d96ea6379bc1df207abe26ad4cbe6563dDouglas Gregor new (int(*p)) int; //new-placement expression 296d507a6d96ea6379bc1df207abe26ad4cbe6563dDouglas Gregor new (int(*[x])); //new type-id 306d507a6d96ea6379bc1df207abe26ad4cbe6563dDouglas Gregor} 316d507a6d96ea6379bc1df207abe26ad4cbe6563dDouglas Gregor 326d507a6d96ea6379bc1df207abe26ad4cbe6563dDouglas Gregor// [dcl.ambig.res]p4: 336d507a6d96ea6379bc1df207abe26ad4cbe6563dDouglas Gregortemplate <class T> // expected-note{{here}} 346d507a6d96ea6379bc1df207abe26ad4cbe6563dDouglas Gregorstruct S4 { 356d507a6d96ea6379bc1df207abe26ad4cbe6563dDouglas Gregor T *p; 366d507a6d96ea6379bc1df207abe26ad4cbe6563dDouglas Gregor}; 376d507a6d96ea6379bc1df207abe26ad4cbe6563dDouglas GregorS4<int()> x; //type-id 386d507a6d96ea6379bc1df207abe26ad4cbe6563dDouglas GregorS4<int(1)> y; // expected-error{{must be a type}} 396d507a6d96ea6379bc1df207abe26ad4cbe6563dDouglas Gregor 406d507a6d96ea6379bc1df207abe26ad4cbe6563dDouglas Gregor// [dcl.ambig.res]p5: 416d507a6d96ea6379bc1df207abe26ad4cbe6563dDouglas Gregorvoid foo5() 426d507a6d96ea6379bc1df207abe26ad4cbe6563dDouglas Gregor{ 436d507a6d96ea6379bc1df207abe26ad4cbe6563dDouglas Gregor (void)sizeof(int(1)); //expression 446d507a6d96ea6379bc1df207abe26ad4cbe6563dDouglas Gregor // FIXME: should we make this an error rather than a warning? 456d507a6d96ea6379bc1df207abe26ad4cbe6563dDouglas Gregor // (It affects SFINAE) 466d507a6d96ea6379bc1df207abe26ad4cbe6563dDouglas Gregor (void)sizeof(int()); // expected-warning{{function type}} 476d507a6d96ea6379bc1df207abe26ad4cbe6563dDouglas Gregor} 486d507a6d96ea6379bc1df207abe26ad4cbe6563dDouglas Gregor 496d507a6d96ea6379bc1df207abe26ad4cbe6563dDouglas Gregor// [dcl.ambig.res]p6: 506d507a6d96ea6379bc1df207abe26ad4cbe6563dDouglas Gregorvoid foo6() 516d507a6d96ea6379bc1df207abe26ad4cbe6563dDouglas Gregor{ 526d507a6d96ea6379bc1df207abe26ad4cbe6563dDouglas Gregor (void)(int(1)); //expression 539cc11e70031365972424b43f439021d88096b146Sebastian Redl (void)(int())1; // expected-error{{to 'int ()'}} 546d507a6d96ea6379bc1df207abe26ad4cbe6563dDouglas Gregor} 556d507a6d96ea6379bc1df207abe26ad4cbe6563dDouglas Gregor 566d507a6d96ea6379bc1df207abe26ad4cbe6563dDouglas Gregor// [dcl.ambig.res]p7: 576d507a6d96ea6379bc1df207abe26ad4cbe6563dDouglas Gregorclass C7 { }; 586d507a6d96ea6379bc1df207abe26ad4cbe6563dDouglas Gregorvoid f7(int(C7)) { } // expected-note{{candidate}} 596d507a6d96ea6379bc1df207abe26ad4cbe6563dDouglas Gregorint g7(C7); 606d507a6d96ea6379bc1df207abe26ad4cbe6563dDouglas Gregorvoid foo7() { 616d507a6d96ea6379bc1df207abe26ad4cbe6563dDouglas Gregor f7(1); // expected-error{{no matching function}} 626d507a6d96ea6379bc1df207abe26ad4cbe6563dDouglas Gregor f7(g7); //OK 636d507a6d96ea6379bc1df207abe26ad4cbe6563dDouglas Gregor} 646d507a6d96ea6379bc1df207abe26ad4cbe6563dDouglas Gregor 656d507a6d96ea6379bc1df207abe26ad4cbe6563dDouglas Gregorvoid h7(int *(C7[10])) { } // expected-note{{previous}} 666d507a6d96ea6379bc1df207abe26ad4cbe6563dDouglas Gregorvoid h7(int *(*_fp)(C7 _parm[10])) { } // expected-error{{redefinition}} 671e054213f8416a48866105216ad4a45f1e7c24deArgyrios Kyrtzidis 681e054213f8416a48866105216ad4a45f1e7c24deArgyrios Kyrtzidisstruct S5 { 691e054213f8416a48866105216ad4a45f1e7c24deArgyrios Kyrtzidis static bool const value = false; 701e054213f8416a48866105216ad4a45f1e7c24deArgyrios Kyrtzidis}; 711e054213f8416a48866105216ad4a45f1e7c24deArgyrios Kyrtzidisint foo8() { 721e054213f8416a48866105216ad4a45f1e7c24deArgyrios Kyrtzidis int v(int(S5::value)); // expected-warning{{disambiguated}} expected-error{{parameter declarator cannot be qualified}} 731e054213f8416a48866105216ad4a45f1e7c24deArgyrios Kyrtzidis} 74346af03b21db01264852afb8a86719c9284855feArgyrios Kyrtzidis 75346af03b21db01264852afb8a86719c9284855feArgyrios Kyrtzidistemplate<typename T> 76346af03b21db01264852afb8a86719c9284855feArgyrios Kyrtzidisvoid rdar8739801( void (T::*)( void ) __attribute__((unused)) ); 77