1539470e7d38f71b7a0700e1f1b371e76480cf0a6Larisse Voufo// RUN: %clang_cc1 -fsyntax-only -std=c++1y -DCXX1Y -Wc++98-compat-pedantic -verify %s -DCXX1Y2 2539470e7d38f71b7a0700e1f1b371e76480cf0a6Larisse Voufo// RUN: %clang_cc1 -fsyntax-only -std=c++1y -DCXX1Y -Wc++98-compat -Werror %s -DCXX1Y2 3661a99690bc133bbaa029da925481d4a860dec90Richard Smith// RUN: %clang_cc1 -fsyntax-only -std=c++11 -Wc++98-compat-pedantic -verify %s 47fe6208c3fa91f835813bb78236ef5c2bbf81053Richard Smith// RUN: %clang_cc1 -fsyntax-only -std=c++11 -Wc++98-compat -Werror %s 5176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines// RUN: %clang_cc1 -fsyntax-only -std=c++98 -Werror %s -DCXX98 6661a99690bc133bbaa029da925481d4a860dec90Richard Smith 7539470e7d38f71b7a0700e1f1b371e76480cf0a6Larisse Voufo// RUN: %clang_cc1 -fsyntax-only -std=c++1y -Wc++98-compat-pedantic -verify %s -Wno-c++98-c++11-compat-pedantic -DCXX1Y2 824ce46c8cec99d2e63bed052696e79b6487885fbRichard Smith 9661a99690bc133bbaa029da925481d4a860dec90Richard Smith// -Wc++98-compat-pedantic warns on C++11 features which we accept without a 10661a99690bc133bbaa029da925481d4a860dec90Richard Smith// warning in C++98 mode. 11661a99690bc133bbaa029da925481d4a860dec90Richard Smith 12661a99690bc133bbaa029da925481d4a860dec90Richard Smith#line 32767 // ok 13661a99690bc133bbaa029da925481d4a860dec90Richard Smith#line 32768 // expected-warning {{#line number greater than 32767 is incompatible with C++98}} 14661a99690bc133bbaa029da925481d4a860dec90Richard Smith 15661a99690bc133bbaa029da925481d4a860dec90Richard Smith#define VA_MACRO(x, ...) x // expected-warning {{variadic macros are incompatible with C++98}} 169f728cd37476c6588b06d241fa778d2df6e277daRichard SmithVA_MACRO(,x) // expected-warning {{empty macro arguments are incompatible with C++98}} 177fe6208c3fa91f835813bb78236ef5c2bbf81053Richard Smith 187fe6208c3fa91f835813bb78236ef5c2bbf81053Richard Smith; // expected-warning {{extra ';' outside of a function is incompatible with C++98}} 197fe6208c3fa91f835813bb78236ef5c2bbf81053Richard Smith 207fe6208c3fa91f835813bb78236ef5c2bbf81053Richard Smithenum Enum { 217fe6208c3fa91f835813bb78236ef5c2bbf81053Richard Smith Enum_value, // expected-warning {{commas at the end of enumerator lists are incompatible with C++98}} 227fe6208c3fa91f835813bb78236ef5c2bbf81053Richard Smith}; 23ebaf0e6ab743394dda086a01b457838cb6e589a8Richard Smith 24ebaf0e6ab743394dda086a01b457838cb6e589a8Richard Smithtemplate<typename T> struct InstantiationAfterSpecialization {}; 25ebaf0e6ab743394dda086a01b457838cb6e589a8Richard Smithtemplate<> struct InstantiationAfterSpecialization<int> {}; // expected-note {{here}} 26ebaf0e6ab743394dda086a01b457838cb6e589a8Richard Smithtemplate struct InstantiationAfterSpecialization<int>; // expected-warning {{explicit instantiation of 'InstantiationAfterSpecialization<int>' that occurs after an explicit specialization is incompatible with C++98}} 27ebaf0e6ab743394dda086a01b457838cb6e589a8Richard Smith 28ebaf0e6ab743394dda086a01b457838cb6e589a8Richard Smithvoid *dlsym(); 29ebaf0e6ab743394dda086a01b457838cb6e589a8Richard Smithvoid (*FnPtr)() = (void(*)())dlsym(); // expected-warning {{cast between pointer-to-function and pointer-to-object is incompatible with C++98}} 30ebaf0e6ab743394dda086a01b457838cb6e589a8Richard Smithvoid *FnVoidPtr = (void*)&dlsym; // expected-warning {{cast between pointer-to-function and pointer-to-object is incompatible with C++98}} 31ebaf0e6ab743394dda086a01b457838cb6e589a8Richard Smith 32ebaf0e6ab743394dda086a01b457838cb6e589a8Richard Smithstruct ConvertToInt { 33ebaf0e6ab743394dda086a01b457838cb6e589a8Richard Smith operator int(); 34ebaf0e6ab743394dda086a01b457838cb6e589a8Richard Smith}; 35539470e7d38f71b7a0700e1f1b371e76480cf0a6Larisse Voufoint *ArraySizeConversion = new int[ConvertToInt()]; 36539470e7d38f71b7a0700e1f1b371e76480cf0a6Larisse Voufo#ifdef CXX1Y2 370bb5199941d6058b866afe01956cca36e64cc247Larisse Voufo// expected-warning@-2 {{implicit conversion from array size expression of type 'ConvertToInt' to integral type 'size_t' is incompatible with C++98}} 38539470e7d38f71b7a0700e1f1b371e76480cf0a6Larisse Voufo#else 39539470e7d38f71b7a0700e1f1b371e76480cf0a6Larisse Voufo// expected-warning@-4 {{implicit conversion from array size expression of type 'ConvertToInt' to integral type 'int' is incompatible with C++98}} 40539470e7d38f71b7a0700e1f1b371e76480cf0a6Larisse Voufo#endif 419324583ad2afd09db8c9967cd05c4fa44bac9555Richard Smith 429324583ad2afd09db8c9967cd05c4fa44bac9555Richard Smithtemplate<typename T> class ExternTemplate {}; 439324583ad2afd09db8c9967cd05c4fa44bac9555Richard Smithextern template class ExternTemplate<int>; // expected-warning {{extern templates are incompatible with C++98}} 44e3b136bd873508c9ac0ee6eba98c2a810a177ebaDmitri Gribenko 45e3b136bd873508c9ac0ee6eba98c2a810a177ebaDmitri Gribenkolong long ll1 = // expected-warning {{'long long' is incompatible with C++98}} 46e3b136bd873508c9ac0ee6eba98c2a810a177ebaDmitri Gribenko -42LL; // expected-warning {{'long long' is incompatible with C++98}} 47e3b136bd873508c9ac0ee6eba98c2a810a177ebaDmitri Gribenkounsigned long long ull1 = // expected-warning {{'long long' is incompatible with C++98}} 48e3b136bd873508c9ac0ee6eba98c2a810a177ebaDmitri Gribenko 42ULL; // expected-warning {{'long long' is incompatible with C++98}} 49e3b136bd873508c9ac0ee6eba98c2a810a177ebaDmitri Gribenko 502fcf0de8a122ddb265d8c32d6ac1012c070e4f24Richard Smithint k = 0b1001; 512fcf0de8a122ddb265d8c32d6ac1012c070e4f24Richard Smith#ifdef CXX1Y 52176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines// expected-warning@-2 {{binary integer literals are incompatible with C++ standards before C++14}} 532fcf0de8a122ddb265d8c32d6ac1012c070e4f24Richard Smith#endif 54176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines 55176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hinesnamespace CopyCtorIssues { 56176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines struct Private { 57176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines Private(); 58176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines private: 59176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines Private(const Private&); // expected-note {{declared private here}} 60176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines }; 61176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines struct NoViable { 62176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines NoViable(); 63176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines NoViable(NoViable&); // expected-note {{not viable}} 64176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines }; 65176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines struct Ambiguous { 66176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines Ambiguous(); 67176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines Ambiguous(const Ambiguous &, int = 0); // expected-note {{candidate}} 68176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines Ambiguous(const Ambiguous &, double = 0); // expected-note {{candidate}} 69176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines }; 70176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines struct Deleted { 71176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines Private p; // expected-note {{implicitly deleted}} 72176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines }; 73176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines 74176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines const Private &a = Private(); // expected-warning {{copying variable of type 'CopyCtorIssues::Private' when binding a reference to a temporary would invoke an inaccessible constructor in C++98}} 75176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines const NoViable &b = NoViable(); // expected-warning {{copying variable of type 'CopyCtorIssues::NoViable' when binding a reference to a temporary would find no viable constructor in C++98}} 76176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines#if !CXX98 77176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines const Ambiguous &c = Ambiguous(); // expected-warning {{copying variable of type 'CopyCtorIssues::Ambiguous' when binding a reference to a temporary would find ambiguous constructors in C++98}} 78176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines#endif 79176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines const Deleted &d = Deleted(); // expected-warning {{copying variable of type 'CopyCtorIssues::Deleted' when binding a reference to a temporary would invoke a deleted constructor in C++98}} 80176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines} 81