tigerleapgorge created this revision. tigerleapgorge added a reviewer: rsmith. tigerleapgorge added a subscriber: cfe-commits.
Hi everyone, I am back again with Lit test C++11 compatibility patch #9. 30 tests are updated this time. They are follows. CXX/basic/basic.stc/basic.stc.dynamic/p2-noexceptions.cpp Operator delete’s throwing prototype has changed. (C++ standard 18.6 [support.dynamic]) C++98 prototype: void operator delete (void* ptr) throw(); C++11 prototype: void operator delete (void* ptr) noexcept; This test redeclares operator delete without “noexcept” Added the following expected Warning for C++11 (2 instances) C++11: warning: function previously declared with an explicit exception specification redeclared with an implicit exception specification [-Wimplicit-exception-spec-mismatch] CXX/basic/basic.stc/basic.stc.dynamic/p2.cpp Operator new’s throwing prototype has changed: C++98 prototype: void* operator new (std::size_t size) throw (std::bad_alloc); C++11 prototype: void* operator new (std::size_t size); This test declares operator new with “throw(std::bad_alloc)” then redeclares operator new again without a throw. In C++11 the redeclaration is the same as the prototype. Restricted the following to warning C++98. C++98: warning: 'operator new' is missing exception specification 'throw(std::bad_alloc)' [-Wmissing-exception-spec] note: previous declaration is here Operator delete’s throwing prototype has also changed (see previous test p2-noexceptions.cpp for prototypes): This test declares operator delete with “throw()”, then redeclares operator delete without a throw. Expect the following change in diagnostics. C++98: warning: 'operator delete' is missing exception specification 'throw()' [-Wmissing-exception-spec] note: previous declaration is here C++11: warning: function previously declared with an explicit exception specification redeclared with an implicit exception specification [-Wimplicit-exception-spec-mismatch] note: previous declaration is here CXX/class.access/class.friend/p1.cpp This test verifies when a class befriends another class. C++11’s “constexpr” feature interferes with Clang’s “befriend implicitly-declared members” feature. This test contains 2 parts: test6 and test7. Test6: (r101122 – “Allow classes to befriend implicitly-declared members.”) Struct A is declared as POD. Struct B befriends A’s implicitly-declared constructor. This amounts to a re-declaration of struct A with a different const-ness. Therefore, add the following diagnostics to the expected diagnostics. C++11: error: non-constexpr declaration of 'A' follows constexpr declaration note: previous declaration is here For test7: (r101173 – “Support befriending members of class template specializations.”) This test is intended to verify A’s private constructor inside struct template X’s specialization. However, struct X’s constructor and destructor are explicitly declared, struct X’s copy-constructor is implicitly declared. When class A befriends X’s implicitly declared copy-constructor, Clang issues a similar error to that of test 6. But, this error stops the generation of subsequent errors. Since the intended target of this test are the subsequent errors, I added a struct X copy constructor declaration to stop the first error. CXX/class.access/p4.cpp When constructing a class that contains a member that cannot be initialized, C++98 and C++11 issues similar diagnostics but in opposite order. C++98 messages begin with the innermost member that failed to initialize. C++11 messages begin with the outermost constructor that was implicitly deleted. The diff here is quite large. It has 3 parts. Test2: Change in diagnostics. (2 sets) C++98: error: base class 'test2::A' has private default constructor note: declared private here note: implicit default constructor for 'test2::B' first required here C++11: error: call to implicitly-deleted default constructor of 'test2::B' note: default constructor of 'B' is implicitly deleted because base class 'test2::A' has an inaccessible default constructor C++98: error: inherited virtual base class 'test2::A' has private default constructor note: declared private here note: implicit default constructor for 'test2::D' first required here C++11: error: call to implicitly-deleted default constructor of 'test2::D' note: default constructor of 'D' is implicitly deleted because base class 'test2::A' has an inaccessible default constructor Test3: Massive reduction in diagnostics issued. Class template “Base” has a private destructor. Class “Derived3” multiple-inherits specializations of “Base” and derived class of specializations of “Base”. In C++98/03, Clang issues diagnostics for all paths of the inheritances from Base to Derived3. In C++11, Clang issues diagnostics on just the first path. C++98: error: base class 'Base<3>' has private destructor note: implicitly declared private here note: implicit default constructor for 'test3::Base3' first required here error: base class 'Base<2>' has private destructor note: implicitly declared private here note: implicit default constructor for 'test3::Base2' first required here error: base class 'Base<0>' has private destructor note: implicitly declared private here error: base class 'Base<1>' has private destructor note: implicitly declared private here error: base class 'test3::Base2' has private destructor note: implicitly declared private here error: inherited virtual base class 'Base<2>' has private destructor note: implicitly declared private here error: inherited virtual base class 'Base<3>' has private destructor note: implicitly declared private here note: implicit default constructor for 'test3::Derived3' first required here error: base class 'Base<0>' has private destructor note: implicitly declared private here error: base class 'Base<1>' has private destructor note: implicitly declared private here error: base class 'test3::Base2' has private destructor note: implicitly declared private here error: inherited virtual base class 'Base<2>' has private destructor note: implicitly declared private here error: inherited virtual base class 'Base<3>' has private destructor note: implicitly declared private here note: implicit destructor for 'test3::Derived3' first required here C++11: error: call to implicitly-deleted default constructor of 'test3::Derived3' note: default constructor of 'Derived3' is implicitly deleted because base class 'Base<0>' has an inaccessible destructor Test5: Change in diagnostics (4 sets) C++98: error: 'operator=' is a private member of 'test5::A' note: implicitly declared private here note: implicit copy assignment operator for 'test5::Test1' first required here C++11: error: object of type 'test5::Test1' cannot be assigned because its copy assignment operator is implicitly deleted note: copy assignment operator of 'Test1' is implicitly deleted because field 'a' has an inaccessible copy assignment operator C++98: error: 'operator=' is a private member of 'test5::A' note: implicitly declared private here note: implicit copy assignment operator for 'test5::Test2' first required here C++11: error: object of type 'test5::Test2' cannot be assigned because its copy assignment operator is implicitly deleted note: copy assignment operator of 'Test2' is implicitly deleted because base class 'test5::A' has an inaccessible copy assignment operator C++98: error: field of type 'test6::A' has private copy constructor note: declared private here note: implicit copy constructor for 'test6::Test1' first required here C++11: error: call to implicitly-deleted copy constructor of 'test6::Test1' note: copy constructor of 'Test1' is implicitly deleted because field 'a' has an inaccessible copy constructor C++98: error: base class 'test6::A' has private copy constructor note: declared private here note: implicit copy constructor for 'test6::Test2' first required here C++11: error: call to implicitly-deleted copy constructor of 'test6::Test2' note: copy constructor of 'Test2' is implicitly deleted because base class 'test6::A' has an inaccessible copy constructor CXX/dcl.dcl/basic.namespace/namespace.udecl/p4.cpp This test verifies “using” declarations. Add 2 Errors for C++11. C++11: error: using declaration refers into 'Subclass::', which is not a base class of 'C' C++11: error: using declaration refers to its own class The accompanying Note is no longer issued in C++11, guard it to C++98/03. Existing: error: using declaration refers to its own class C++98 only: note: target of using declaration CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x-fixits.cpp For this test to compile under C++98/03. Lit test CXX/dcl.decl/dcl.init/dcl.init.list/p7-cxx11-nowarn.cpp covers C++11 behavior. CXX/dcl.decl/dcl.init/dcl.init.ref/p5-cxx03-extra-copy.cpp Force this test to run under C++98/03. Lit test CXX/dcl.decl/dcl.init/dcl.init.ref/p5-cxx0x-no-extra-copy.cpp covers C++11 behavior. CXX/dcl.decl/dcl.init/p5.cpp Similar to test CXX/class.access/p4.cpp When constructing a class that contains a member that cannot be initialized, C++98 and C++11 issues similar diagnostics but in opposite order. C++98 messages begin with the innermost member that failed to initialize. C++11 messages begin with the outermost constructor that was implicitly deleted. C++98: error: implicit default constructor for 'S' must explicitly initialize the reference member 'x' note: declared here note: implicit default constructor for 'S' first required here C++11: error: call to implicitly-deleted default constructor of 'S' note: default constructor of 'S' is implicitly deleted because field 'x' of reference type 'int &' would not be initialized C++98: error: reference to type 'int' requires an initializer note: in value-initialization of type 'S' here C++11: error: call to implicitly-deleted default constructor of 'S' note: default constructor of 'S' is implicitly deleted because field 'x' of reference type 'int &' would not be initialized C++98: error: reference to type 'int' requires an initializer note: in value-initialization of type 'S' here note: in value-initialization of type 'T' here C++11: error: call to implicitly-deleted default constructor of 'T' note: default constructor of 'T' is implicitly deleted because base class 'S' has a deleted default constructor note: default constructor of 'S' is implicitly deleted because field 'x' of reference type 'int &' would not be initialized C++98: error: reference to type 'int' requires an initializer note: in value-initialization of type 'S' here note: in value-initialization of type 'T' here note: in value-initialization of type 'U' here C++11: error: call to implicitly-deleted default constructor of 'U' note: default constructor of 'U' is implicitly deleted because field 't' has a deleted default constructor note: default constructor of 'T' is implicitly deleted because base class 'S' has a deleted default constructor note: default constructor of 'S' is implicitly deleted because field 'x' of reference type 'int &' would not be initialized Restrict the following Warning to C++98 (2 instances) C++98: warning: in-class initialization of non-static data member is a C++11 extension CXX/special/class.dtor/p9.cpp Change in diagnostics when a derived class overloads the delete operator without declaring an overriding destructor. *This test make use of sizeof() therefore is marked with –std=gnu++XX instead of the usual –std=c++XX C++98: error: no suitable member 'operator delete' in 'C' note: member 'operator delete' declared here note: implicit destructor for 'test2::C' first required here C++11: error: deleted function '~C' cannot override a non-deleted function note: overridden virtual function is here error: attempt to use a deleted function note: virtual destructor requires an unambiguous, accessible 'operator delete' CXX/temp/temp.arg/temp.arg.nontype/p5.cpp Change in diagnostics due to constexpr in C++11 (3 instances) C++98: error: non-type template argument for template parameter of pointer type 'int (*) (int)' must have its address taken C++11: error: non-type template argument of type 'int (*)(int)' is not a constant expression note: read of non-constexpr variable 'funcptr' is not allowed in a constant expression note: declared here Similar change as above, only difference is in the Note message. (1 instance) C++98: error: non-type template argument for template parameter of pointer type 'int *' must have its address taken C++11: error: non-type template argument of type 'int' is not a constant expression note: read of non-const variable 'baz' is not allowed in a constant expression note: declared here Restrict the following message to C++98. (1 instance) C++98: warning: address non-type template argument cannot be surrounded by parentheses CXX/temp/temp.spec/temp.expl.spec/p4.cpp Change in diagnostics. C++98: error: implicit default constructor for 'X<IntHolder, int>::Inner' must explicitly initialize the member 'value' which does not have a default constructor note: member is declared here note: 'IntHolder' declared here note: implicit default constructor for 'X<IntHolder, int>::Inner' first required here C++11: error: call to implicitly-deleted default constructor of 'X<IntHolder, int>::Inner' note: default constructor of 'Inner' is implicitly deleted because field 'value' has no default constructor Addition Note in C++11 accompanying the existing Error. (2 instances) C++98 and C++11: error: no matching constructor for initialization of 'IntHolder' C++98 and C++11: candidate constructor (the implicit copy constructor) not viable New to C++11: note: candidate constructor (the implicit move constructor) not viable CXX/temp/temp.spec/temp.explicit/p4.cpp Restrict the following C++98 specific Warnings (5 instances) C++98: warning: explicit instantiation of 'f0<long>' that occurs after an explicit specialization will be ignored (C++11 extension) note: previous template specialization is here Restrict the following C++98 specific Warning (1 instance) C++98: warning: extern templates are a C++11 extension [-Wc++11-extensions] CodeGenCXX/debug-info-use-after-free.cpp Mark base class destructor “~AAA(){}” as “protected” so that the derived class “C3” can inherit from it. Otherwise we would get the following Error in C++11: C++11: error: deleted function '~C3' cannot override a non-deleted function note: overridden virtual function is here CodeGenCXX/dynamic-cast-hint.cpp Mark base class destructors protected so that they can be inherited. Otherwise we would get the following Error in C++11: C++11: error: deleted function '~C' cannot override a non-deleted function note: overridden virtual function is here OpenMP/distribute_collapse_messages.cpp 2 additional Notes in C++11 following existing error. (4 instances) C++98 and C++11: error: expression is not an integral constant expression New to C++11: note: non-constexpr function 'foobool' cannot be used in a constant expression New to C++11: note: declared here Change in diagnostics (3 instances) C++98: error: expression is not an integral constant expression C++11: error: integral constant expression must have integral or unscoped enumeration type, not 'char *' OpenMP/ordered_messages.cpp In this test, foo() is being used in the place of an integral constant. C++11 added 2 additional Notes following the existing Warning (2 instances) C++98 and C++11: error: expression is not an integral constant expression New to C++11: note: non-constexpr function 'foo' cannot be used in a constant expression New to C++11: note: declared here OpenMP/target_parallel_for_collapse_messages.cpp Same as above, C++11 added 2 new Notes following the existing Warning (4 instances) Existing: error: expression is not an integral constant expression C++11: note: non-constexpr function 'foobool' cannot be used in a constant expression C++11: note: declared here Change in diagnostics (2 instances) C++98: expression is not an integral constant expression C++11: integral constant expression must have integral or unscoped enumeration type, not 'char *' OpenMP/target_parallel_for_ordered_messages.cpp Nearly identical to the test above (target_parallel_for_collapse_messages.cpp). SemaCXX/i-c-e-cxx.cpp This test verifies GNU extensions. Change in diagnostics. C++98: error: expression is not an integral constant expression C++11: error: case value is not a constant expression Restrict the following to C++98: C++98: note: read of object outside its lifetime is not allowed in a constant expression C++98: warning: no case matching constant switch condition '1' C++98: warning: in-class initializer for static data member is not a constant expression; folding it to a constant is a GNU extension C++98: warning: 'long long' is a C++11 extension [-Wc++11-long-long] C++98: warning: warning: variable length array folded to constant array as an extension [-Wgnu-folding-constant] note: initializer of 'nonconst' is not a constant expression note: declared here SemaCXX/implicit-virtual-member-functions.cpp Change in diagnostics (3 instances) C++98: error: no suitable member 'operator delete' in 'B' note: member 'operator delete' declared here note: implicit destructor for 'B' first required here C++11: error: deleted function '~B' cannot override a non-deleted function note: overridden virtual function is here Added diagnostics in C++11 when target is Microsoft. C++11: error: attempt to use a deleted function note: virtual destructor requires an unambiguous, accessible 'operator delete' SemaCXX/new-delete.cpp C++11 has one additional note following no matching constructor error. Existing: error: no matching constructor for initialization of 'S' Existing: note: candidate constructor (the implicit copy constructor) not viable C++11: candidate constructor (the implicit move constructor) not viable Restrict the following to C++98. C++98: warning: 'operator new' is missing exception specification 'throw(std::bad_alloc)' C++98: warning: 'operator new' is missing exception specification 'throw(std::bad_alloc)' C++98: note: previous declaration is here Add the following to C++11: C++11: warning: function previously declared with an explicit exception specification redeclared with an implicit exception specification Change in diagnostic severity: C++98: error: array size is negative C++11: warning: array size is negative C++98: error: array is too large (2000000000 elements) C++11: warning: array is too large (2000000000 elements) Change in diagnostics (2 instances) C++98: error: array size expression must have integral or enumeration type, not 'S' C++11: error: array size expression must have integral or unscoped enumeration type, not 'S' Change in diagnostics C++98: error: expected expression C++11: error: expected variable name or 'this' in lambda capture list C++98: error: no suitable member 'operator delete' in 'X11' note: member 'operator delete' declared here note: implicit destructor for 'X11' first required here C++11: error: deleted function '~X11' cannot override a non-deleted function note: overridden virtual function is here error: attempt to use a deleted function note: virtual destructor requires an unambiguous, accessible 'operator delete' C++98: error: field of type 'ArrayNewNeedsDtor::A' has private destructor note: declared private here note: implicit destructor for 'ArrayNewNeedsDtor::B' first required here C++11: error: attempt to use a deleted function note: destructor of 'B' is implicitly deleted because field 'a' has an inaccessible destructor SemaCXX/no-wchar.cpp C++11 had deprecated wchar_t. Change in diagnostics. C++98: conversion from string literal to 'wchar_t *' (aka 'unsigned short *') is deprecated C++11: ISO C++11 does not allow conversion from string literal to 'wchar_t *' (aka 'unsigned short *') SemaCXX/virtual-member-functions-key-function.cpp Change in diagnostics (2 instances) C++98: error: no suitable member 'operator delete' in 'B' note: member 'operator delete' declared here note: implicit destructor for 'B' first required here C++11: error: deleted function '~B' cannot override a non-deleted function note: overridden virtual function is here SemaCXX/warn-bool-conversion.cpp C++11 is more strict with pointer initializations. Boolean literal conversion diagnostics changed from Warning in C++98/03 to Error with Note in C++11. C++98: warning: initialization of pointer of type 'int *' to null from a constant boolean expression [-Wbool-conversion] C++11: error: cannot initialize a variable of type 'int *' with an rvalue of type 'bool' C++98: warning: initialization of pointer of type 'int *' to null from a constant boolean expression [-Wbool-conversion] C++11: error: cannot initialize a parameter of type 'int *' with an rvalue of type 'bool' note: passing argument to parameter 'j' here C++98: warning: initialization of pointer of type 'int *' to null from a constant boolean expression [-Wbool-conversion] C++11: error: no matching function for call to 'foo' note: candidate function not viable: requires 2 arguments, but 1 was provided Calling the function “void foo(int* i, int *j=(false))” with one actual argument was OK in C++98/03, but is an Error in C++11. Added the following. C++11: Error: no matching function for call to 'foo'. SemaCXX/zero-length-arrays.cpp In this test, class Bar has contains 3 zero-length arrays of class Foo. Class Foo has a private copy constructor. Bar’s implicit copy constructor was considered undefined was C++98/03, it is considered deleted in C++11. [class.copy] 12.8 \ 11. http://en.cppreference.com/w/cpp/language/copy_constructor#Deleted_implicitly-declared_copy_constructor Added the followed expected diagnostics for C++11. C++11: error: call to implicitly-deleted copy constructor of 'Bar' note: copy constructor of 'Bar' is implicitly deleted because field 'foos' has an inaccessible copy constructor SemaTemplate/instantiate-c99.cpp Added static_cast<>() inside designated initializers. Otherwise compiling this test in C++11 would result in the following Error. C++11: error: non-constant-expression cannot be narrowed from type 'int' to 'float' in initializer list [-Wc++11-narrowing] SemaTemplate/temp_explicit.cpp Restrict the following to C++98. C++98: warning: explicit instantiation of 'X0<char, char>' that occurs after an explicit specialization will be ignored (C++11 extension) [-Wc++11-extensions] note: previous template specialization is here Change in severity for the follow 3 diagnostics. C++98: warning: explicit instantiation of 'Inner2' not in a namespace enclosing 'N2' C++11: error: explicit instantiation of 'Inner2' not in a namespace enclosing 'N2' C++98: warning: explicit instantiation of 'N1::X7' must occur in namespace 'N1' C++11: error: explicit instantiation of 'N1::X7' must occur in namespace 'N1' C++98: warning: explicit instantiation of 'X9' must occur at global scope C++11: error: explicit instantiation of 'X9' must occur at global scope SemaTemplate/value-dependent-null-pointer-constant.cpp String literal and int is no longer compatible in C++11. Added 3 expected Errors for C++11. C++11: error: incompatible operand types ('const char *' and 'int') C++11: error: incompatible operand types ('int' and 'const char *') C++11: error: comparison between pointer and integer ('const char *' and 'int') SemaTemplate/virtual-member-functions.cpp Change in diagnostics when derived class inherits a private destructor in the base class. C++98: error: base class 'PR7114::A' has private destructor note: implicitly declared private here note: implicit destructor for 'PR7114::B<float>::Inner' first required here C++11: error: deleted function '~Inner' cannot override a non-deleted function note: in instantiation of member class 'PR7114::B<int>::Inner' requested here note: in instantiation of template class 'PR7114::B<int>' requested here note: overridden virtual function is here error: deleted function '~Inner' cannot override a non-deleted function note: in instantiation of member class 'PR7114::B<float>::Inner' requested here note: in instantiation of template class 'PR7114::B<float>' requested here note: overridden virtual function is here error: deleted function '~X' cannot override a non-deleted function note: in instantiation of template class 'PR7114::X<int>' requested here note: overridden virtual function is here Sincerely, Charles Li http://reviews.llvm.org/D20710 Files: test/CXX/basic/basic.stc/basic.stc.dynamic/p2-noexceptions.cpp test/CXX/basic/basic.stc/basic.stc.dynamic/p2.cpp test/CXX/class.access/class.friend/p1.cpp test/CXX/class.access/p4.cpp test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p4.cpp test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x-fixits.cpp test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-cxx03-extra-copy.cpp test/CXX/dcl.decl/dcl.init/p5.cpp test/CXX/special/class.dtor/p9.cpp test/CXX/temp/temp.arg/temp.arg.nontype/p5.cpp test/CXX/temp/temp.spec/temp.expl.spec/p4.cpp test/CXX/temp/temp.spec/temp.explicit/p4.cpp test/CodeGenCXX/debug-info-use-after-free.cpp test/CodeGenCXX/dynamic-cast-hint.cpp test/OpenMP/distribute_collapse_messages.cpp test/OpenMP/ordered_messages.cpp test/OpenMP/target_parallel_for_collapse_messages.cpp test/OpenMP/target_parallel_for_ordered_messages.cpp test/SemaCXX/i-c-e-cxx.cpp test/SemaCXX/implicit-virtual-member-functions.cpp test/SemaCXX/new-delete.cpp test/SemaCXX/no-wchar.cpp test/SemaCXX/virtual-member-functions-key-function.cpp test/SemaCXX/warn-bool-conversion.cpp test/SemaCXX/zero-length-arrays.cpp test/SemaTemplate/instantiate-c99.cpp test/SemaTemplate/temp_explicit.cpp test/SemaTemplate/value-dependent-null-pointer-constant.cpp test/SemaTemplate/virtual-member-functions.cpp
Index: test/SemaTemplate/virtual-member-functions.cpp =================================================================== --- test/SemaTemplate/virtual-member-functions.cpp +++ test/SemaTemplate/virtual-member-functions.cpp @@ -1,5 +1,9 @@ // RUN: %clang_cc1 -triple %itanium_abi_triple -fsyntax-only -verify %s +// RUN: %clang_cc1 -triple %itanium_abi_triple -fsyntax-only -verify -std=c++98 %s +// RUN: %clang_cc1 -triple %itanium_abi_triple -fsyntax-only -verify -std=c++11 %s // RUN: %clang_cc1 -triple %ms_abi_triple -DMSABI -fsyntax-only -verify %s +// RUN: %clang_cc1 -triple %ms_abi_triple -DMSABI -fsyntax-only -std=c++98 -verify %s +// RUN: %clang_cc1 -triple %ms_abi_triple -DMSABI -fsyntax-only -std=c++11 -verify %s namespace PR5557 { template <class T> struct A { @@ -76,34 +80,74 @@ } namespace PR7114 { - class A { virtual ~A(); }; // expected-note{{declared private here}} + class A { virtual ~A(); }; +#if __cplusplus <= 199711L + // expected-note@-2{{declared private here}} +#else + // expected-note@-4 3 {{overridden virtual function is here}} +#endif template<typename T> class B { public: - class Inner : public A { }; // expected-error{{base class 'PR7114::A' has private destructor}} + class Inner : public A { }; +#if __cplusplus <= 199711L +// expected-error@-2{{base class 'PR7114::A' has private destructor}} +#else +// expected-error@-4 2 {{deleted function '~Inner' cannot override a non-deleted function}} +#ifdef MSABI +// expected-note@-6 1 {{destructor of 'Inner' is implicitly deleted because base class 'PR7114::A' has an inaccessible destructor}} +#endif +#endif + static Inner i; static const unsigned value = sizeof(i) == 4; +#if __cplusplus >= 201103L +// expected-note@-2 {{in instantiation of member class 'PR7114::B<int>::Inner' requested here}} +// expected-note@-3 {{in instantiation of member class 'PR7114::B<float>::Inner' requested here}} +#endif }; int f() { return B<int>::value; } +#if __cplusplus >= 201103L +// expected-note@-2 {{in instantiation of template class 'PR7114::B<int>' requested here}} +#endif #ifdef MSABI - void test_typeid(B<float>::Inner bfi) { // expected-note{{implicit destructor}} + void test_typeid(B<float>::Inner bfi) { +#if __cplusplus <= 199711L +// expected-note@-2 {{implicit destructor}} +#else +// expected-error@-4 {{attempt to use a deleted function}} +// expected-note@-5 {{in instantiation of template class 'PR7114::B<float>' requested here}} +#endif + (void)typeid(bfi); #else void test_typeid(B<float>::Inner bfi) { - (void)typeid(bfi); // expected-note{{implicit destructor}} +#if __cplusplus >= 201103L +// expected-note@-2 {{in instantiation of template class 'PR7114::B<float>' requested here}} +#endif + (void)typeid(bfi); +#if __cplusplus <= 199711L +// expected-note@-2 {{implicit destructor}} +#endif #endif } template<typename T> struct X : A { +#if __cplusplus >= 201103L +// expected-error@-2{{deleted function '~X' cannot override a non-deleted function}} +#endif void f() { } }; void test_X(X<int> &xi, X<float> &xf) { xi.f(); +#if __cplusplus >= 201103L +// expected-note@-2 {{in instantiation of template class 'PR7114::X<int>' requested here}} +#endif } } Index: test/SemaTemplate/value-dependent-null-pointer-constant.cpp =================================================================== --- test/SemaTemplate/value-dependent-null-pointer-constant.cpp +++ test/SemaTemplate/value-dependent-null-pointer-constant.cpp @@ -1,17 +1,30 @@ -// RUN: %clang_cc1 -fsyntax-only %s +// RUN: %clang_cc1 -fsyntax-only -verify %s +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s template<typename T, int N> struct X0 { const char *f0(bool Cond) { return Cond? "honk" : N; +#if __cplusplus >= 201103L +// expected-error@-2 {{incompatible operand types ('const char *' and 'int')}} +#else +// expected-no-diagnostics +#endif } const char *f1(bool Cond) { return Cond? N : "honk"; +#if __cplusplus >= 201103L +// expected-error@-2 {{incompatible operand types ('int' and 'const char *')}} +#endif } bool f2(const char *str) { return str == N; +#if __cplusplus >= 201103L +// expected-error@-2 {{comparison between pointer and integer ('const char *' and 'int')}} +#endif } }; Index: test/SemaTemplate/temp_explicit.cpp =================================================================== --- test/SemaTemplate/temp_explicit.cpp +++ test/SemaTemplate/temp_explicit.cpp @@ -1,4 +1,6 @@ // RUN: %clang_cc1 -fsyntax-only -verify -pedantic -Wc++11-compat %s +// RUN: %clang_cc1 -fsyntax-only -verify -pedantic -Wc++11-compat -std=c++98 %s +// RUN: %clang_cc1 -fsyntax-only -verify -pedantic -std=c++11 %s // // Tests explicit instantiation of templates. template<typename T, typename U = T> class X0 { }; @@ -25,8 +27,15 @@ // instantiations or declarations. template class X0<int, int>; // expected-error{{duplicate}} -template<> class X0<char> { }; // expected-note{{previous}} -template class X0<char>; // expected-warning{{ignored}} +template<> class X0<char> { }; +#if __cplusplus <= 199711L +// expected-note@-2 {{previous template specialization is here}} +#endif + +template class X0<char>; +#if __cplusplus <= 199711L +// expected-warning@-2 {{explicit instantiation of 'X0<char, char>' that occurs after an explicit specialization will be ignored (C++11 extension)}} +#endif void foo(X0<short>) { } template class X0<short>; @@ -98,7 +107,12 @@ template struct X5<float&>::Inner2; // expected-note{{instantiation}} namespace N3 { - template struct N2::X5<int>::Inner2; // expected-warning {{explicit instantiation of 'Inner2' not in a namespace enclosing 'N2'}} + template struct N2::X5<int>::Inner2; +#if __cplusplus <= 199711L +// expected-warning@-2 {{explicit instantiation of 'Inner2' not in a namespace enclosing 'N2'}} +#else +// expected-error@-4 {{explicit instantiation of 'Inner2' not in a namespace enclosing 'N2'}} +#endif } struct X6 { @@ -145,7 +159,17 @@ namespace N2 { using namespace N1; - template struct X7<double>; // expected-warning{{must occur in namespace}} - - template struct X9<float>; // expected-warning{{must occur at global scope}} + template struct X7<double>; +#if __cplusplus <= 199711L +// expected-warning@-2 {{explicit instantiation of 'N1::X7' must occur in namespace 'N1'}} +#else +// expected-error@-4 {{explicit instantiation of 'N1::X7' must occur in namespace 'N1'}} +#endif + + template struct X9<float>; +#if __cplusplus <= 199711L +// expected-warning@-2 {{explicit instantiation of 'X9' must occur at global scope}} +#else +// expected-error@-4 {{explicit instantiation of 'X9' must occur at global scope}} +#endif } Index: test/SemaTemplate/instantiate-c99.cpp =================================================================== --- test/SemaTemplate/instantiate-c99.cpp +++ test/SemaTemplate/instantiate-c99.cpp @@ -1,4 +1,6 @@ // RUN: %clang_cc1 -fsyntax-only -verify %s +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s // Test template instantiation for C99-specific features. @@ -9,8 +11,13 @@ struct DesigInit0 { void f(XType x, YType y) { T agg = { +#if __cplusplus <= 199711L .y = y, // expected-error{{does not refer}} .x = x // expected-error{{does not refer}} +#else + .y = static_cast<float>(y), // expected-error{{does not refer}} + .x = static_cast<float>(x) // expected-error{{does not refer}} +#endif }; } }; @@ -44,7 +51,11 @@ struct DesigArrayInit0 { void f(Val1 val1, Val2 val2) { T array = { +#if __cplusplus <= 199711L [Subscript1] = val1, +#else + [Subscript1] = static_cast<int>(val1), +#endif [Subscript2] = val2 // expected-error{{exceeds array bounds}} }; @@ -60,7 +71,11 @@ struct DesigArrayRangeInit0 { void f(Val1 val1) { T array = { +#if __cplusplus <= 199711L [Subscript1...Subscript2] = val1 // expected-error{{exceeds}} +#else + [Subscript1...Subscript2] = static_cast<int>(val1) // expected-error{{exceeds}} +#endif }; } }; @@ -74,7 +89,11 @@ template<typename T, typename Arg1, typename Arg2> struct CompoundLiteral0 { T f(Arg1 a1, Arg2 a2) { +#if __cplusplus <= 199711L return (T){a1, a2}; +#else + return (T){static_cast<float>(a1), a2}; +#endif } }; Index: test/SemaCXX/zero-length-arrays.cpp =================================================================== --- test/SemaCXX/zero-length-arrays.cpp +++ test/SemaCXX/zero-length-arrays.cpp @@ -1,5 +1,6 @@ // RUN: %clang_cc1 -fsyntax-only -verify %s -// expected-no-diagnostics +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s // <rdar://problem/10228639> class Foo { @@ -12,6 +13,9 @@ class Bar { int foo_count; Foo foos[0]; +#if __cplusplus >= 201103L +// expected-note@-2 {{copy constructor of 'Bar' is implicitly deleted because field 'foos' has an inaccessible copy constructor}} +#endif Foo foos2[0][2]; Foo foos3[2][0]; @@ -23,5 +27,10 @@ void testBar() { Bar b; Bar b2(b); +#if __cplusplus >= 201103L +// expected-error@-2 {{call to implicitly-deleted copy constructor of 'Bar}} +#else +// expected-no-diagnostics +#endif b = b2; } Index: test/SemaCXX/warn-bool-conversion.cpp =================================================================== --- test/SemaCXX/warn-bool-conversion.cpp +++ test/SemaCXX/warn-bool-conversion.cpp @@ -1,19 +1,66 @@ // RUN: %clang_cc1 -fsyntax-only -verify %s +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s namespace BooleanFalse { -int* j = false; // expected-warning{{initialization of pointer of type 'int *' to null from a constant boolean expression}} - -void foo(int* i, int *j=(false)) // expected-warning{{initialization of pointer of type 'int *' to null from a constant boolean expression}} +int* j = false; +#if __cplusplus <= 199711L +// expected-warning@-2 {{initialization of pointer of type 'int *' to null from a constant boolean expression}} +#else +// expected-error@-4 {{cannot initialize a variable of type 'int *' with an rvalue of type 'bool'}} +#endif + +#if __cplusplus <= 199711L +// expected-warning@+6 {{initialization of pointer of type 'int *' to null from a constant boolean expression}} +#else +// expected-error@+4 {{cannot initialize a parameter of type 'int *' with an rvalue of type 'bool'}} +// expected-note@+3 {{passing argument to parameter 'j' here}} +// expected-note@+2 6 {{candidate function not viable: requires 2 arguments, but 1 was provided}} +#endif +void foo(int* i, int *j=(false)) { - foo(false); // expected-warning{{initialization of pointer of type 'int *' to null from a constant boolean expression}} - foo((int*)false); // no-warning: explicit cast - foo(0); // no-warning: not a bool, even though its convertible to bool - - foo(false == true); // expected-warning{{initialization of pointer of type 'int *' to null from a constant boolean expression}} - foo((42 + 24) < 32); // expected-warning{{initialization of pointer of type 'int *' to null from a constant boolean expression}} + foo(false); +#if __cplusplus <= 199711L +// expected-warning@-2 {{initialization of pointer of type 'int *' to null from a constant boolean expression}} +#else +// expected-error@-4 {{no matching function for call to 'foo'}} +#endif + + foo((int*)false); +#if __cplusplus <= 199711L +// no-warning: explicit cast +#else +// expected-error@-4 {{no matching function for call to 'foo'}} +#endif + + foo(0); +#if __cplusplus <= 199711L +// no-warning: not a bool, even though its convertible to bool +#else +// expected-error@-4 {{no matching function for call to 'foo'}} +#endif + + foo(false == true); +#if __cplusplus <= 199711L +// expected-warning@-2 {{initialization of pointer of type 'int *' to null from a constant boolean expression}} +#else +// expected-error@-4 {{no matching function for call to 'foo'}} +#endif + + foo((42 + 24) < 32); +#if __cplusplus <= 199711L +// expected-warning@-2 {{initialization of pointer of type 'int *' to null from a constant boolean expression}} +#else +// expected-error@-4 {{no matching function for call to 'foo'}} +#endif const bool kFlag = false; - foo(kFlag); // expected-warning{{initialization of pointer of type 'int *' to null from a constant boolean expression}} + foo(kFlag); +#if __cplusplus <= 199711L +// expected-warning@-2 {{initialization of pointer of type 'int *' to null from a constant boolean expression}} +#else +// expected-error@-4 {{no matching function for call to 'foo'}} +#endif } char f(struct Undefined*); Index: test/SemaCXX/virtual-member-functions-key-function.cpp =================================================================== --- test/SemaCXX/virtual-member-functions-key-function.cpp +++ test/SemaCXX/virtual-member-functions-key-function.cpp @@ -1,20 +1,49 @@ // RUN: %clang_cc1 -fsyntax-only -verify %s +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s + struct A { virtual ~A(); +#if __cplusplus >= 201103L +// expected-note@-2 2 {{overridden virtual function is here}} +#endif }; -struct B : A { // expected-error {{no suitable member 'operator delete' in 'B'}} - B() { } // expected-note {{implicit destructor for 'B' first required here}} - void operator delete(void *, int); // expected-note {{'operator delete' declared here}} +struct B : A { +#if __cplusplus <= 199711L +// expected-error@-2 {{no suitable member 'operator delete' in 'B'}} +#else +// expected-error@-4 {{deleted function '~B' cannot override a non-deleted function}} +#endif + B() { } +#if __cplusplus <= 199711L +// expected-note@-2 {{implicit destructor for 'B' first required here}} +#endif + + void operator delete(void *, int); +#if __cplusplus <= 199711L +// expected-note@-2 {{'operator delete' declared here}} +#endif }; -struct C : A { // expected-error {{no suitable member 'operator delete' in 'C'}} - void operator delete(void *, int); // expected-note {{'operator delete' declared here}} +struct C : A { +#if __cplusplus <= 199711L +// expected-error@-2 {{no suitable member 'operator delete' in 'C'}} +#else +// expected-error@-4 {{deleted function '~C' cannot override a non-deleted function}} +#endif + void operator delete(void *, int); +#if __cplusplus <= 199711L +// expected-note@-2 {{'operator delete' declared here}} +#endif }; void f() { (void)new B; - (void)new C; // expected-note {{implicit destructor for 'C' first required here}} + (void)new C; +#if __cplusplus <= 199711L +// expected-note@-2 {{implicit destructor for 'C' first required here}} +#endif } // Make sure that the key-function computation is consistent when the Index: test/SemaCXX/no-wchar.cpp =================================================================== --- test/SemaCXX/no-wchar.cpp +++ test/SemaCXX/no-wchar.cpp @@ -1,4 +1,6 @@ // RUN: %clang_cc1 -triple i386-pc-win32 -fsyntax-only -fno-wchar -verify %s +// RUN: %clang_cc1 -triple i386-pc-win32 -fsyntax-only -fno-wchar -verify -std=c++98 %s +// RUN: %clang_cc1 -triple i386-pc-win32 -fsyntax-only -fno-wchar -verify -std=c++11 %s wchar_t x; // expected-error {{unknown type name 'wchar_t'}} typedef unsigned short wchar_t; @@ -9,7 +11,11 @@ } void foo1(wchar_t * t = L""); -// expected-warning@-1 {{conversion from string literal to 'wchar_t *' (aka 'unsigned short *') is deprecated}} +#if __cplusplus <= 199711L +// expected-warning@-2 {{conversion from string literal to 'wchar_t *' (aka 'unsigned short *') is deprecated}} +#else +// expected-warning@-4 {{ISO C++11 does not allow conversion from string literal to 'wchar_t *' (aka 'unsigned short *')}} +#endif short *a = L""; // expected-error@-1 {{cannot initialize a variable of type 'short *' with an lvalue of type 'const unsigned short [1]'}} Index: test/SemaCXX/new-delete.cpp =================================================================== --- test/SemaCXX/new-delete.cpp +++ test/SemaCXX/new-delete.cpp @@ -1,7 +1,12 @@ // RUN: %clang_cc1 -fsyntax-only -verify %s -triple=i686-pc-linux-gnu -Wno-new-returns-null +// RUN: %clang_cc1 -fsyntax-only -verify %s -triple=i686-pc-linux-gnu -Wno-new-returns-null -std=c++98 +// RUN: %clang_cc1 -fsyntax-only -verify %s -triple=i686-pc-linux-gnu -Wno-new-returns-null -std=c++11 #include <stddef.h> +#if __cplusplus >= 201103L +// expected-note@+2 {{candidate constructor (the implicit move constructor) not viable}} +#endif struct S // expected-note {{candidate}} { S(int, int, double); // expected-note {{candidate}} @@ -19,6 +24,9 @@ }; inline void operator delete(void *); // expected-warning {{replacement function 'operator delete' cannot be declared 'inline'}} +#if __cplusplus >= 201103L +// expected-warning@-2 {{function previously declared with an explicit exception specification redeclared with an implicit exception specification}} +#endif __attribute__((used)) inline void *operator new(size_t) { // no warning, due to __attribute__((used)) @@ -72,7 +80,13 @@ (void)new; // expected-error {{expected a type}} (void)new 4; // expected-error {{expected a type}} (void)new () int; // expected-error {{expected expression}} - (void)new int[1.1]; // expected-error {{array size expression must have integral or enumeration type, not 'double'}} + (void)new int[1.1]; +#if __cplusplus <= 199711L + // expected-error@-2 {{array size expression must have integral or enumeration type, not 'double'}} +#else + // expected-error@-4 {{array size expression must have integral or unscoped enumeration type, not 'double'}} +#endif + (void)new int[1][i]; // expected-error {{only the first dimension}} expected-note {{read of non-const variable 'i' is not allowed in a constant expression}} (void)new (int[1][i]); // expected-error {{only the first dimension}} expected-note {{read of non-const variable 'i' is not allowed in a constant expression}} (void)new (int[i]); // expected-warning {{when type is in parentheses}} @@ -83,9 +97,27 @@ (void)new const int; // expected-error {{default initialization of an object of const type 'const int'}} (void)new float*(ip); // expected-error {{cannot initialize a new value of type 'float *' with an lvalue of type 'int *'}} // Undefined, but clang should reject it directly. - (void)new int[-1]; // expected-error {{array size is negative}} - (void)new int[2000000000]; // expected-error {{array is too large}} - (void)new int[*(S*)0]; // expected-error {{array size expression must have integral or enumeration type, not 'S'}} + (void)new int[-1]; +#if __cplusplus <= 199711L + // expected-error@-2 {{array size is negative}} +#else + // expected-warning@-4 {{array size is negative}} +#endif + + (void)new int[2000000000]; +#if __cplusplus <= 199711L + // expected-error@-2 {{array is too large}} +#else + // expected-warning@-4 {{array is too large}} +#endif + + (void)new int[*(S*)0]; +#if __cplusplus <= 199711L + // expected-error@-2 {{array size expression must have integral or enumeration type, not 'S'}} +#else + // expected-error@-4 {{array size expression must have integral or unscoped enumeration type, not 'S'}} +#endif + (void)::S::new int; // expected-error {{expected unqualified-id}} (void)new (0, 0) int; // expected-error {{no matching function for call to 'operator new'}} (void)new (0L) int; // expected-error {{call to 'operator new' is ambiguous}} @@ -109,7 +141,12 @@ void bad_deletes() { delete 0; // expected-error {{cannot delete expression of type 'int'}} - delete [0] (int*)0; // expected-error {{expected expression}} + delete [0] (int*)0; +#if __cplusplus <= 199711L + // expected-error@-2 {{expected expression}} +#else + // expected-error@-4 {{expected variable name or 'this' in lambda capture list}} +#endif delete (void*)0; // expected-warning {{cannot delete expression with pointer-to-'void' type 'void *'}} delete (T*)0; // expected-warning {{deleting pointer to incomplete type}} ::S::delete (int*)0; // expected-error {{expected unqualified-id}} @@ -209,14 +246,31 @@ struct X10 { virtual ~X10(); -}; - -struct X11 : X10 { // expected-error {{no suitable member 'operator delete' in 'X11'}} - void operator delete(void*, int); // expected-note {{'operator delete' declared here}} +#if __cplusplus >= 201103L + // expected-note@-2 {{overridden virtual function is here}} +#endif +}; + +struct X11 : X10 { +#if __cplusplus <= 199711L +// expected-error@-2 {{no suitable member 'operator delete' in 'X11'}} +#else +// expected-error@-4 {{deleted function '~X11' cannot override a non-deleted function}} +// expected-note@-5 {{virtual destructor requires an unambiguous, accessible 'operator delete'}} +#endif + void operator delete(void*, int); +#if __cplusplus <= 199711L + // expected-note@-2 {{'operator delete' declared here}} +#endif }; void f() { - X11 x11; // expected-note {{implicit destructor for 'X11' first required here}} + X11 x11; +#if __cplusplus <= 199711L + // expected-note@-2 {{implicit destructor for 'X11' first required here}} +#else + // expected-error@-4 {{attempt to use a deleted function}} +#endif } struct X12 { @@ -398,10 +452,24 @@ } namespace ArrayNewNeedsDtor { - struct A { A(); private: ~A(); }; // expected-note {{declared private here}} - struct B { B(); A a; }; // expected-error {{field of type 'ArrayNewNeedsDtor::A' has private destructor}} + struct A { A(); private: ~A(); }; +#if __cplusplus <= 199711L + // expected-note@-2 {{declared private here}} +#endif + struct B { B(); A a; }; +#if __cplusplus <= 199711L + // expected-error@-2 {{field of type 'ArrayNewNeedsDtor::A' has private destructor}} +#else + // expected-note@-4 {{destructor of 'B' is implicitly deleted because field 'a' has an inaccessible destructor}} +#endif + B *test9() { - return new B[5]; // expected-note {{implicit destructor for 'ArrayNewNeedsDtor::B' first required here}} + return new B[5]; +#if __cplusplus <= 199711L + // expected-note@-2 {{implicit destructor for 'ArrayNewNeedsDtor::B' first required here}} +#else + // expected-error@-4 {{attempt to use a deleted function}} +#endif } } Index: test/SemaCXX/implicit-virtual-member-functions.cpp =================================================================== --- test/SemaCXX/implicit-virtual-member-functions.cpp +++ test/SemaCXX/implicit-virtual-member-functions.cpp @@ -1,33 +1,84 @@ // RUN: %clang_cc1 -fsyntax-only -triple %itanium_abi_triple -verify %s +// RUN: %clang_cc1 -fsyntax-only -triple %itanium_abi_triple -verify -std=c++98 %s +// RUN: %clang_cc1 -fsyntax-only -triple %itanium_abi_triple -verify -std=c++11 %s // RUN: %clang_cc1 -fsyntax-only -triple %ms_abi_triple -DMSABI -verify %s +// RUN: %clang_cc1 -fsyntax-only -triple %ms_abi_triple -DMSABI -verify -std=c++98 %s +// RUN: %clang_cc1 -fsyntax-only -triple %ms_abi_triple -DMSABI -verify -std=c++11 %s + struct A { virtual ~A(); +#if __cplusplus >= 201103L +// expected-note@-2 3 {{overridden virtual function is here}} +#endif }; -struct B : A { // expected-error {{no suitable member 'operator delete' in 'B'}} +struct B : A { +#if __cplusplus <= 199711L +// expected-error@-2 {{no suitable member 'operator delete' in 'B'}} +#else +// expected-error@-4 {{deleted function '~B' cannot override a non-deleted function}} +#ifdef MSABI +// expected-note@-6 {{virtual destructor requires an unambiguous, accessible 'operator delete'}} +#endif +#endif virtual void f(); - void operator delete (void *, int); // expected-note {{'operator delete' declared here}} + void operator delete (void *, int); +#if __cplusplus <= 199711L +// expected-note@-2 {{'operator delete' declared here}} +#endif }; #ifdef MSABI -B b; // expected-note {{implicit destructor for 'B' first required here}} +B b; +#if __cplusplus <= 199711L +// expected-note@-2 {{implicit destructor for 'B' first required here}} +#else +// expected-error@-4 {{attempt to use a deleted function}} +#endif + #else -void B::f() { // expected-note {{implicit destructor for 'B' first required here}} +void B::f() { +#if __cplusplus <= 199711L +// expected-note@-2 {{implicit destructor for 'B' first required here}} +#endif } #endif -struct C : A { // expected-error {{no suitable member 'operator delete' in 'C'}} +struct C : A { +#if __cplusplus <= 199711L +// expected-error@-2 {{no suitable member 'operator delete' in 'C'}} +#else +// expected-error@-4 {{deleted function '~C' cannot override a non-deleted function}} +#endif + C(); - void operator delete(void *, int); // expected-note {{'operator delete' declared here}} + void operator delete(void *, int); +#if __cplusplus <= 199711L +// expected-note@-2 {{'operator delete' declared here}} +#endif }; -C::C() { } // expected-note {{implicit destructor for 'C' first required here}} +C::C() { } +#if __cplusplus <= 199711L +// expected-note@-2 {{implicit destructor for 'C' first required here}} +#endif -struct D : A { // expected-error {{no suitable member 'operator delete' in 'D'}} - void operator delete(void *, int); // expected-note {{'operator delete' declared here}} +struct D : A { +#if __cplusplus <= 199711L +// expected-error@-2 {{no suitable member 'operator delete' in 'D'}} +#else +// expected-error@-4 {{deleted function '~D' cannot override a non-deleted function}} +#endif + void operator delete(void *, int); +#if __cplusplus <= 199711L +// expected-note@-2 {{'operator delete' declared here}} +#endif }; void f() { - new D; // expected-note {{implicit destructor for 'D' first required here}} + new D; +#if __cplusplus <= 199711L +// expected-note@-2 {{implicit destructor for 'D' first required here}} +#endif } Index: test/SemaCXX/i-c-e-cxx.cpp =================================================================== --- test/SemaCXX/i-c-e-cxx.cpp +++ test/SemaCXX/i-c-e-cxx.cpp @@ -1,4 +1,6 @@ // RUN: %clang_cc1 -fsyntax-only -verify -pedantic %s +// RUN: %clang_cc1 -fsyntax-only -verify -pedantic -std=gnu++98 %s +// RUN: %clang_cc1 -fsyntax-only -verify -pedantic -std=gnu++11 %s // C++-specific tests for integral constant expressions. @@ -16,9 +18,21 @@ } int a() { - const int t=t; // expected-note {{declared here}} expected-note {{read of object outside its lifetime}} - switch(1) { // expected-warning {{no case matching constant switch condition '1'}} - case t:; // expected-error {{not an integral constant expression}} expected-note {{initializer of 't' is not a constant expression}} + const int t=t; // expected-note {{declared here}} +#if __cplusplus <= 199711L + // expected-note@-2 {{read of object outside its lifetime}} +#endif + + switch(1) { +#if __cplusplus <= 199711L + // expected-warning@-2 {{no case matching constant switch condition '1'}} +#endif + case t:; // expected-note {{initializer of 't' is not a constant expression}} +#if __cplusplus <= 199711L + // expected-error@-2 {{not an integral constant expression}} +#else + // expected-error@-4 {{case value is not a constant expression}} +#endif } } @@ -48,7 +62,10 @@ namespace rdar9204520 { struct A { - static const int B = int(0.75 * 1000 * 1000); // expected-warning {{not a constant expression; folding it to a constant is a GNU extension}} + static const int B = int(0.75 * 1000 * 1000); +#if __cplusplus <= 199711L + // expected-warning@-2 {{not a constant expression; folding it to a constant is a GNU extension}} +#endif }; int foo() { return A::B; } @@ -59,10 +76,24 @@ int* y = reinterpret_cast<const char&>(x); // expected-error {{cannot initialize}} // This isn't an integral constant expression, but make sure it folds anyway. -struct PR8836 { char _; long long a; }; // expected-warning {{long long}} -int PR8836test[(__typeof(sizeof(int)))&reinterpret_cast<const volatile char&>((((PR8836*)0)->a))]; // expected-warning {{folded to constant array as an extension}} expected-note {{cast that performs the conversions of a reinterpret_cast is not allowed in a constant expression}} +struct PR8836 { char _; long long a; }; +#if __cplusplus <= 199711L +// expected-warning@-2 {{'long long' is a C++11 extension}} +#endif + +int PR8836test[(__typeof(sizeof(int)))&reinterpret_cast<const volatile char&>((((PR8836*)0)->a))]; +// expected-warning@-1 {{folded to constant array as an extension}} +// expected-note@-2 {{cast that performs the conversions of a reinterpret_cast is not allowed in a constant expression}} + +const int nonconst = 1.0; +#if __cplusplus <= 199711L +// expected-note@-2 {{declared here}} +#endif +int arr[nonconst]; +#if __cplusplus <= 199711L +// expected-warning@-2 {{folded to constant array as an extension}} +// expected-note@-3 {{initializer of 'nonconst' is not a constant expression}} +#endif -const int nonconst = 1.0; // expected-note {{declared here}} -int arr[nonconst]; // expected-warning {{folded to constant array as an extension}} expected-note {{initializer of 'nonconst' is not a constant expression}} const int castfloat = static_cast<int>(1.0); int arr2[castfloat]; // ok Index: test/OpenMP/target_parallel_for_ordered_messages.cpp =================================================================== --- test/OpenMP/target_parallel_for_ordered_messages.cpp +++ test/OpenMP/target_parallel_for_ordered_messages.cpp @@ -1,9 +1,14 @@ // RUN: %clang_cc1 -verify -fopenmp %s +// RUN: %clang_cc1 -verify -fopenmp -std=c++98 %s +// RUN: %clang_cc1 -verify -fopenmp -std=c++11 %s void foo() { } bool foobool(int argc) { +#if __cplusplus >= 201103L +// expected-note@-2 4 {{declared here}} +#endif return argc; } @@ -36,6 +41,9 @@ #pragma omp target parallel for ordered((ST > 0) ? 1 + ST : 2) // expected-note 2 {{as specified in 'ordered' clause}} for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i - ST]; // expected-error 2 {{expected 2 for loops after '#pragma omp target parallel for', but found only 1}} +#if __cplusplus >= 201103L +// expected-note@+5 2 {{non-constexpr function 'foobool' cannot be used in a constant expression}} +#endif // expected-error@+3 2 {{directive '#pragma omp target parallel for' cannot contain more than one 'ordered' clause}} // expected-error@+2 2 {{argument to 'ordered' clause must be a strictly positive integer value}} // expected-error@+1 2 {{expression is not an integral constant expression}} @@ -45,7 +53,11 @@ #pragma omp target parallel for ordered(S) // expected-error {{'S' does not refer to a value}} for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i - ST]; -// expected-error@+1 2 {{expression is not an integral constant expression}} +#if __cplusplus >= 201103L + // expected-error@+4 2 {{integral constant expression must have integral or unscoped enumeration type, not 'char *'}} +#else + // expected-error@+2 2 {{expression is not an integral constant expression}} +#endif #pragma omp target parallel for ordered(argv[1] = 2) // expected-error {{expected ')'}} expected-note {{to match this '('}} for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i - ST]; @@ -76,9 +88,15 @@ #pragma omp target parallel for ordered(2 + 2)) // expected-warning {{extra tokens at the end of '#pragma omp target parallel for' are ignored}} expected-note {{as specified in 'ordered' clause}} for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i - 4]; // expected-error {{expected 4 for loops after '#pragma omp target parallel for', but found only 1}} +#if __cplusplus >= 201103L +// expected-note@+2 {{non-constexpr function 'foobool' cannot be used in a constant expression}} +#endif #pragma omp target parallel for ordered(foobool(1) > 0 ? 1 : 2) // expected-error {{expression is not an integral constant expression}} for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i - 4]; +#if __cplusplus >= 201103L +// expected-note@+5 {{non-constexpr function 'foobool' cannot be used in a constant expression}} +#endif // expected-error@+3 {{expression is not an integral constant expression}} // expected-error@+2 2 {{directive '#pragma omp target parallel for' cannot contain more than one 'ordered' clause}} // expected-error@+1 2 {{argument to 'ordered' clause must be a strictly positive integer value}} @@ -88,7 +106,11 @@ #pragma omp target parallel for ordered(S1) // expected-error {{'S1' does not refer to a value}} for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i - 4]; -// expected-error@+1 {{expression is not an integral constant expression}} +#if __cplusplus >= 201103L + // expected-error@+4 {{integral constant expression must have integral or unscoped enumeration type, not 'char *'}} +#else + // expected-error@+2 {{expression is not an integral constant expression}} +#endif #pragma omp target parallel for ordered(argv[1] = 2) // expected-error {{expected ')'}} expected-note {{to match this '('}} for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i - 4]; Index: test/OpenMP/target_parallel_for_collapse_messages.cpp =================================================================== --- test/OpenMP/target_parallel_for_collapse_messages.cpp +++ test/OpenMP/target_parallel_for_collapse_messages.cpp @@ -1,9 +1,14 @@ // RUN: %clang_cc1 -verify -fopenmp %s +// RUN: %clang_cc1 -verify -fopenmp -std=c++98 %s +// RUN: %clang_cc1 -verify -fopenmp -std=c++11 %s void foo() { } bool foobool(int argc) { +#if __cplusplus >= 201103L +// expected-note@-2 4 {{declared here}} +#endif return argc; } @@ -33,10 +38,17 @@ // expected-error@+2 2 {{argument to 'collapse' clause must be a strictly positive integer value}} // expected-error@+1 2 {{expression is not an integral constant expression}} #pragma omp target parallel for collapse (foobool(argc)), collapse (true), collapse (-5) +#if __cplusplus >= 201103L +// expected-note@-2 2 {{non-constexpr function 'foobool' cannot be used in a constant expression}} +#endif for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST]; #pragma omp target parallel for collapse (S) // expected-error {{'S' does not refer to a value}} for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST]; - // expected-error@+1 2 {{expression is not an integral constant expression}} +#if __cplusplus >= 201103L + // expected-error@+4 2 {{integral constant expression must have integral or unscoped enumeration type, not 'char *'}} +#else + // expected-error@+2 2 {{expression is not an integral constant expression}} +#endif #pragma omp target parallel for collapse (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}} for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST]; #pragma omp target parallel for collapse (1) @@ -60,15 +72,25 @@ #pragma omp target parallel for collapse (2+2)) // expected-warning {{extra tokens at the end of '#pragma omp target parallel for' are ignored}} expected-note {{as specified in 'collapse' clause}} for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4]; // expected-error {{expected 4 for loops after '#pragma omp target parallel for', but found only 1}} #pragma omp target parallel for collapse (foobool(1) > 0 ? 1 : 2) // expected-error {{expression is not an integral constant expression}} +#if __cplusplus >= 201103L +// expected-note@-2 {{non-constexpr function 'foobool' cannot be used in a constant expression}} +#endif for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4]; // expected-error@+3 {{expression is not an integral constant expression}} // expected-error@+2 2 {{directive '#pragma omp target parallel for' cannot contain more than one 'collapse' clause}} // expected-error@+1 2 {{argument to 'collapse' clause must be a strictly positive integer value}} #pragma omp target parallel for collapse (foobool(argc)), collapse (true), collapse (-5) +#if __cplusplus >= 201103L +// expected-note@-2 {{non-constexpr function 'foobool' cannot be used in a constant expression}} +#endif for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4]; #pragma omp target parallel for collapse (S1) // expected-error {{'S1' does not refer to a value}} for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4]; - // expected-error@+1 {{expression is not an integral constant expression}} +#if __cplusplus >= 201103L + // expected-error@+4 {{integral constant expression must have integral or unscoped enumeration type, not 'char *'}} +#else + // expected-error@+2 {{expression is not an integral constant expression}} +#endif #pragma omp target parallel for collapse (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}} for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4]; // expected-error@+3 {{statement after '#pragma omp target parallel for' must be a for loop}} Index: test/OpenMP/ordered_messages.cpp =================================================================== --- test/OpenMP/ordered_messages.cpp +++ test/OpenMP/ordered_messages.cpp @@ -1,4 +1,6 @@ // RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 -o - %s +// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 -std=c++98 -o - %s +// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 -std=c++11 -o - %s int foo(); @@ -123,6 +125,9 @@ #pragma omp ordered depend(sink : j, i) // expected-error {{expected 'i' loop iteration variable}} expected-error {{expected 'j' loop iteration variable}} #pragma omp ordered depend(sink : i, j, k) // expected-error {{unexpected expression: number of expressions is larger than the number of associated loops}} #pragma omp ordered depend(sink : i+foo(), j/4) // expected-error {{expression is not an integral constant expression}} expected-error {{expected '+' or '-' operation}} +#if __cplusplus >= 201103L +// expected-note@-2 {{non-constexpr function 'foo' cannot be used in a constant expression}} +#endif #pragma omp ordered depend(sink : i*0, j-4)// expected-error {{expected '+' or '-' operation}} #pragma omp ordered depend(sink : i-0, j+sizeof(T)) depend(sink : i-0, j+sizeof(T)) #pragma omp ordered depend(sink : i-0, j+sizeof(T)) depend(source) // expected-error {{'depend(source)' clause cannot be mixed with 'depend(sink:vec)' clauses}} @@ -133,6 +138,9 @@ } int foo() { +#if __cplusplus >= 201103L +// expected-note@-2 2 {{declared here}} +#endif int k; #pragma omp for ordered for (int i = 0; i < 10; ++i) { @@ -252,6 +260,9 @@ #pragma omp ordered depend(sink : j, i) // expected-error {{expected 'i' loop iteration variable}} expected-error {{expected 'j' loop iteration variable}} #pragma omp ordered depend(sink : i, j, k) // expected-error {{unexpected expression: number of expressions is larger than the number of associated loops}} #pragma omp ordered depend(sink : i+foo(), j/4) // expected-error {{expression is not an integral constant expression}} expected-error {{expected '+' or '-' operation}} +#if __cplusplus >= 201103L +// expected-note@-2 {{non-constexpr function 'foo' cannot be used in a constant expression}} +#endif #pragma omp ordered depend(sink : i*0, j-4)// expected-error {{expected '+' or '-' operation}} #pragma omp ordered depend(sink : i-0, j+sizeof(int)) depend(sink : i-0, j+sizeof(int)) #pragma omp ordered depend(sink : i-0, j+sizeof(int)) depend(source) // expected-error {{'depend(source)' clause cannot be mixed with 'depend(sink:vec)' clauses}} Index: test/OpenMP/distribute_collapse_messages.cpp =================================================================== --- test/OpenMP/distribute_collapse_messages.cpp +++ test/OpenMP/distribute_collapse_messages.cpp @@ -1,8 +1,13 @@ // RUN: %clang_cc1 -verify -fopenmp %s +// RUN: %clang_cc1 -verify -fopenmp -std=c++98 %s +// RUN: %clang_cc1 -verify -fopenmp -std=c++11 %s void foo() { } +#if __cplusplus >= 201103L + // expected-note@+2 4 {{declared here}} +#endif bool foobool(int argc) { return argc; } @@ -29,14 +34,21 @@ for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST]; #pragma omp distribute collapse ((ST > 0) ? 1 + ST : 2) // expected-note 2 {{as specified in 'collapse' clause}} for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST]; // expected-error 2 {{expected 2 for loops after '#pragma omp distribute', but found only 1}} +#if __cplusplus >= 201103L + // expected-note@+5 2 {{non-constexpr function 'foobool' cannot be used in a constant expression}} +#endif // expected-error@+3 2 {{directive '#pragma omp distribute' cannot contain more than one 'collapse' clause}} // expected-error@+2 2 {{argument to 'collapse' clause must be a strictly positive integer value}} // expected-error@+1 2 {{expression is not an integral constant expression}} #pragma omp distribute collapse (foobool(argc)), collapse (true), collapse (-5) for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST]; #pragma omp distribute collapse (S) // expected-error {{'S' does not refer to a value}} for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST]; - // expected-error@+1 2 {{expression is not an integral constant expression}} +#if __cplusplus <= 199711L + // expected-error@+4 2 {{expression is not an integral constant expression}} +#else + // expected-error@+2 2 {{integral constant expression must have integral or unscoped enumeration type, not 'char *'}} +#endif #pragma omp distribute collapse (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}} for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST]; #pragma omp distribute collapse (1) @@ -59,16 +71,26 @@ for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4]; // expected-error {{expected 4 for loops after '#pragma omp distribute', but found only 1}} #pragma omp distribute collapse (2+2)) // expected-warning {{extra tokens at the end of '#pragma omp distribute' are ignored}} expected-note {{as specified in 'collapse' clause}} for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4]; // expected-error {{expected 4 for loops after '#pragma omp distribute', but found only 1}} +#if __cplusplus >= 201103L + // expected-note@+2 {{non-constexpr function 'foobool' cannot be used in a constant expression}} +#endif #pragma omp distribute collapse (foobool(1) > 0 ? 1 : 2) // expected-error {{expression is not an integral constant expression}} for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4]; +#if __cplusplus >= 201103L + // expected-note@+5 {{non-constexpr function 'foobool' cannot be used in a constant expression}} +#endif // expected-error@+3 {{expression is not an integral constant expression}} // expected-error@+2 2 {{directive '#pragma omp distribute' cannot contain more than one 'collapse' clause}} // expected-error@+1 2 {{argument to 'collapse' clause must be a strictly positive integer value}} #pragma omp distribute collapse (foobool(argc)), collapse (true), collapse (-5) for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4]; #pragma omp distribute collapse (S1) // expected-error {{'S1' does not refer to a value}} for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4]; - // expected-error@+1 {{expression is not an integral constant expression}} +#if __cplusplus <= 199711L + // expected-error@+4 {{expression is not an integral constant expression}} +#else + // expected-error@+2 {{integral constant expression must have integral or unscoped enumeration type, not 'char *'}} +#endif #pragma omp distribute collapse (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}} for (int i = 4; i < 12; i++) argv[0][i] = argv[0][i] - argv[0][i-4]; // expected-error@+3 {{statement after '#pragma omp distribute' must be a for loop}} Index: test/CodeGenCXX/dynamic-cast-hint.cpp =================================================================== --- test/CodeGenCXX/dynamic-cast-hint.cpp +++ test/CodeGenCXX/dynamic-cast-hint.cpp @@ -1,7 +1,9 @@ // RUN: %clang_cc1 -triple x86_64-apple-darwin12 -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin12 -emit-llvm -std=c++98 -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin12 -emit-llvm -std=c++11 -o - %s | FileCheck %s -class A { virtual ~A() {} }; -class B { virtual ~B() {} }; +class A { protected: virtual ~A() {} }; +class B { protected: virtual ~B() {} }; class C : A { char x; }; class D : public A { short y; }; Index: test/CodeGenCXX/debug-info-use-after-free.cpp =================================================================== --- test/CodeGenCXX/debug-info-use-after-free.cpp +++ test/CodeGenCXX/debug-info-use-after-free.cpp @@ -1,4 +1,6 @@ // RUN: %clang_cc1 -debug-info-kind=limited -triple %itanium_abi_triple -emit-llvm-only %s +// RUN: %clang_cc1 -debug-info-kind=limited -triple %itanium_abi_triple -emit-llvm-only -std=c++98 %s +// RUN: %clang_cc1 -debug-info-kind=limited -triple %itanium_abi_triple -emit-llvm-only -std=c++11 %s // Check that we don't crash. // PR12305, PR12315 @@ -233,6 +235,7 @@ namespace { class AAA { +protected: virtual ~ AAA () { }}; Index: test/CXX/temp/temp.spec/temp.explicit/p4.cpp =================================================================== --- test/CXX/temp/temp.spec/temp.explicit/p4.cpp +++ test/CXX/temp/temp.spec/temp.explicit/p4.cpp @@ -1,4 +1,6 @@ // RUN: %clang_cc1 -fsyntax-only -verify -pedantic %s +// RUN: %clang_cc1 -fsyntax-only -verify -pedantic -std=c++98 %s +// RUN: %clang_cc1 -fsyntax-only -verify -pedantic -std=c++11 %s template<typename T> void f0(T); // expected-note{{here}} template void f0(int); // expected-error{{explicit instantiation of undefined function template}} @@ -16,20 +18,50 @@ template int X0<int>::value; // expected-error{{explicit instantiation of undefined static data member}} -template<> void f0(long); // expected-note{{previous template specialization is here}} -template void f0(long); // expected-warning{{explicit instantiation of 'f0<long>' that occurs after an explicit specialization will be ignored}} - -template<> void X0<long>::f1(); // expected-note{{previous template specialization is here}} -template void X0<long>::f1(); // expected-warning{{explicit instantiation of 'f1' that occurs after an explicit specialization will be ignored}} - -template<> struct X0<long>::Inner; // expected-note{{previous template specialization is here}} -template struct X0<long>::Inner; // expected-warning{{explicit instantiation of 'Inner' that occurs after an explicit specialization will be ignored}} - -template<> long X0<long>::value; // expected-note{{previous template specialization is here}} -template long X0<long>::value; // expected-warning{{explicit instantiation of 'value' that occurs after an explicit specialization will be ignored}} - -template<> struct X0<double>; // expected-note{{previous template specialization is here}} -template struct X0<double>; // expected-warning{{explicit instantiation of 'X0<double>' that occurs after an explicit specialization will be ignored}} +template<> void f0(long); +#if __cplusplus <= 199711L +// expected-note@-2 {{previous template specialization is here}} +#endif +template void f0(long); +#if __cplusplus <= 199711L +// expected-warning@-2 {{explicit instantiation of 'f0<long>' that occurs after an explicit specialization will be ignored}} +#endif + +template<> void X0<long>::f1(); +#if __cplusplus <= 199711L +// expected-note@-2 {{previous template specialization is here}} +#endif +template void X0<long>::f1(); +#if __cplusplus <= 199711L +// expected-warning@-2 {{explicit instantiation of 'f1' that occurs after an explicit specialization will be ignored}} +#endif + +template<> struct X0<long>::Inner; +#if __cplusplus <= 199711L +// expected-note@-2 {{previous template specialization is here}} +#endif +template struct X0<long>::Inner; +#if __cplusplus <= 199711L +// expected-warning@-2 {{explicit instantiation of 'Inner' that occurs after an explicit specialization will be ignored}} +#endif + +template<> long X0<long>::value; +#if __cplusplus <= 199711L +// expected-note@-2 {{previous template specialization is here}} +#endif +template long X0<long>::value; +#if __cplusplus <= 199711L +// expected-warning@-2 {{explicit instantiation of 'value' that occurs after an explicit specialization will be ignored}} +#endif + +template<> struct X0<double>; +#if __cplusplus <= 199711L +// expected-note@-2 {{previous template specialization is here}} +#endif +template struct X0<double>; +#if __cplusplus <= 199711L +// expected-warning@-2 {{explicit instantiation of 'X0<double>' that occurs after an explicit specialization will be ignored}} +#endif // PR 6458 namespace test0 { @@ -43,6 +75,9 @@ // inappropriately instantiating this template. void *ptr = x; } - extern template class foo<char>; // expected-warning {{extern templates are a C++11 extension}} + extern template class foo<char>; +#if __cplusplus <= 199711L + // expected-warning@-2 {{extern templates are a C++11 extension}} +#endif template class foo<char>; } Index: test/CXX/temp/temp.spec/temp.expl.spec/p4.cpp =================================================================== --- test/CXX/temp/temp.spec/temp.expl.spec/p4.cpp +++ test/CXX/temp/temp.spec/temp.expl.spec/p4.cpp @@ -1,6 +1,13 @@ // RUN: %clang_cc1 -fsyntax-only -verify %s +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s -struct IntHolder { // expected-note{{here}} // expected-note 2{{candidate constructor (the implicit copy constructor)}} +struct IntHolder { // expected-note 2{{candidate constructor (the implicit copy constructor) not viable}} +#if __cplusplus <=199711L +// expected-note@-2 {{'IntHolder' declared here}} +#else +// expected-note@-4 2 {{candidate constructor (the implicit move constructor) not viable}} +#endif IntHolder(int); // expected-note 2{{candidate constructor}} }; @@ -12,8 +19,16 @@ void g() { } - struct Inner { // expected-error{{implicit default}} - T value; // expected-note {{member is declared here}} + struct Inner { +#if __cplusplus <=199711L + // expected-error@-2 {{implicit default constructor for 'X<IntHolder, int>::Inner' must explicitly initialize the member 'value' which does not have a default constructor}} +#endif + T value; +#if __cplusplus <=199711L + // expected-note@-2 {{member is declared here}} +#else + // expected-note@-4 {{default constructor of 'Inner' is implicitly deleted because field 'value' has no default constructor}} +#endif }; static T value; @@ -26,8 +41,13 @@ xih.g(); // okay xih.f(); // expected-note{{instantiation}} - X<IntHolder, int>::Inner inner; // expected-note {{first required here}} - + X<IntHolder, int>::Inner inner; +#if __cplusplus <=199711L + // expected-note@-2 {{implicit default constructor for 'X<IntHolder, int>::Inner' first required here}} +#else + // expected-error@-4 {{call to implicitly-deleted default constructor of 'X<IntHolder, int>::Inner'}} +#endif + return X<IntHolder, int>::value; // expected-note{{instantiation}} } Index: test/CXX/temp/temp.arg/temp.arg.nontype/p5.cpp =================================================================== --- test/CXX/temp/temp.arg/temp.arg.nontype/p5.cpp +++ test/CXX/temp/temp.arg/temp.arg.nontype/p5.cpp @@ -1,4 +1,6 @@ // RUN: %clang_cc1 -fsyntax-only -verify %s +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s // C++0x [temp.arg.nontype] p5: // The following conversions are performed on each expression used as @@ -48,12 +50,26 @@ template<X const *Ptr> struct A2; // expected-note{{template parameter is declared here}} X *X_ptr; +#if __cplusplus >= 201103L + // expected-note@-2 {{declared here}} +#endif + X an_X; X array_of_Xs[10]; - A2<X_ptr> *a12; // expected-error{{must have its address taken}} + A2<X_ptr> *a12; +#if __cplusplus <= 199711L + // expected-error@-2 {{non-type template argument for template parameter of pointer type 'const pointer_to_object_parameters::X *' must have its address taken}} +#else + // expected-error@-4 {{non-type template argument of type 'pointer_to_object_parameters::X *' is not a constant expression}} + // expected-note@-5 {{read of non-constexpr variable 'X_ptr' is not allowed in a constant expression}} +#endif + A2<array_of_Xs> *a13; A2<&an_X> *a13_2; - A2<(&an_X)> *a13_3; // expected-warning{{address non-type template argument cannot be surrounded by parentheses}} + A2<(&an_X)> *a13_3; +#if __cplusplus <= 199711L + // expected-warning@-2 {{address non-type template argument cannot be surrounded by parentheses}} +#endif // PR6244 struct X1 {} X1v; @@ -63,11 +79,31 @@ // PR6563 int *bar; +#if __cplusplus >= 201103L + // expected-note@-2 {{declared here}} +#endif + template <int *> struct zed {}; // expected-note 2{{template parameter is declared here}} - void g(zed<bar>*); // expected-error{{must have its address taken}} + void g(zed<bar>*); +#if __cplusplus <= 199711L + // expected-error@-2 {{non-type template argument for template parameter of pointer type 'int *' must have its address taken}} +#else + // expected-error@-4 {{non-type template argument of type 'int *' is not a constant expression}} + // expected-note@-5 {{read of non-constexpr variable 'bar' is not allowed in a constant expression}} +#endif int baz; - void g2(zed<baz>*); // expected-error{{must have its address taken}} +#if __cplusplus >= 201103L + // expected-note@-2 {{declared here}} +#endif + + void g2(zed<baz>*); +#if __cplusplus <= 199711L + // expected-error@-2 {{non-type template argument for template parameter of pointer type 'int *' must have its address taken}} +#else + // expected-error@-4 {{non-type template argument of type 'int' is not a constant expression}} + // expected-note@-5 {{read of non-const variable 'baz' is not allowed in a constant expression}} +#endif void g3(zed<&baz>*); // okay } @@ -143,11 +179,20 @@ int f(float); int g(float); int (*funcptr)(int); +#if __cplusplus >= 201103L + // expected-note@-2 {{declared here}} +#endif void x0a(X0<f>); void x0b(X0<&f>); void x0c(X0<g>); // expected-error{{non-type template argument of type 'int (float)' cannot be converted to a value of type 'int (*)(int)'}} void x0d(X0<&g>); // expected-error{{non-type template argument of type 'int (*)(float)' cannot be converted to a value of type 'int (*)(int)'}} - void x0e(X0<funcptr>); // expected-error{{must have its address taken}} + void x0e(X0<funcptr>); +#if __cplusplus <= 199711L + // expected-error@-2 {{non-type template argument for template parameter of pointer type 'int (*)(int)' must have its address taken}} +#else + // expected-error@-4 {{non-type template argument of type 'int (*)(int)' is not a constant expression}} + // expected-note@-5 {{read of non-constexpr variable 'funcptr' is not allowed in a constant expression}} +#endif } // -- For a non-type template-parameter of type reference to function, no Index: test/CXX/special/class.dtor/p9.cpp =================================================================== --- test/CXX/special/class.dtor/p9.cpp +++ test/CXX/special/class.dtor/p9.cpp @@ -1,5 +1,9 @@ // RUN: %clang_cc1 -fsyntax-only -triple %itanium_abi_triple -verify %s +// RUN: %clang_cc1 -fsyntax-only -triple %itanium_abi_triple -verify -std=gnu++98 %s +// RUN: %clang_cc1 -fsyntax-only -triple %itanium_abi_triple -verify -std=gnu++11 %s // RUN: %clang_cc1 -fsyntax-only -triple %ms_abi_triple -DMSABI -verify %s +// RUN: %clang_cc1 -fsyntax-only -triple %ms_abi_triple -DMSABI -verify -std=gnu++98 %s +// RUN: %clang_cc1 -fsyntax-only -triple %ms_abi_triple -DMSABI -verify -std=gnu++11 %s typedef typeof(sizeof(int)) size_t; @@ -64,11 +68,29 @@ B::~B() {} // expected-error {{no suitable member 'operator delete' in 'B'}} struct CBase { virtual ~CBase(); }; - struct C : CBase { // expected-error {{no suitable member 'operator delete' in 'C'}} - static void operator delete(void*, const int &); // expected-note {{declared here}} +#if __cplusplus >= 201103L + // expected-note@-2 {{overridden virtual function is here}} +#endif + + struct C : CBase { +#if __cplusplus <= 199711L + // expected-error@-2 {{no suitable member 'operator delete' in 'C'}} +#else + // expected-error@-4 {{deleted function '~C' cannot override a non-deleted function}} + // expected-note@-5 {{virtual destructor requires an unambiguous, accessible 'operator delete'}} +#endif + static void operator delete(void*, const int &); +#if __cplusplus <= 199711L + // expected-note@-2 {{member 'operator delete' declared her}} +#endif }; void test() { - C c; // expected-note {{first required here}} + C c; +#if __cplusplus <= 199711L + // expected-note@-2 {{implicit destructor for 'test2::C' first required here}} +#else + // expected-error@-4 {{attempt to use a deleted function}} +#endif } } Index: test/CXX/dcl.decl/dcl.init/p5.cpp =================================================================== --- test/CXX/dcl.decl/dcl.init/p5.cpp +++ test/CXX/dcl.decl/dcl.init/p5.cpp @@ -1,40 +1,90 @@ // RUN: %clang_cc1 -fsyntax-only -verify %s +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s // A program that calls for default-initialization or value-initialization of // an entity of reference type is illformed. If T is a cv-qualified type, the // cv-unqualified version of T is used for these definitions of // zero-initialization, default-initialization, and value-initialization. -struct S { // expected-error {{implicit default constructor for 'S' must explicitly initialize the reference member}} - int &x; // expected-note {{declared here}} expected-error 3{{reference to type 'int' requires an initializer}} +struct S { +#if __cplusplus <= 199711L +// expected-error@-2 {{implicit default constructor for 'S' must explicitly initialize the reference member}} +#endif + int &x; +#if __cplusplus <= 199711L +// expected-note@-2 {{declared here}} +// expected-error@-3 3{{reference to type 'int' requires an initializer}} +#else +// expected-note@-5 4 {{default constructor of 'S' is implicitly deleted because field 'x' of reference type 'int &' would not be initialized}} +#endif }; -S s; // expected-note {{implicit default constructor for 'S' first required here}} +S s; +#if __cplusplus <= 199711L +// expected-note@-2 {{implicit default constructor for 'S' first required here}} +#else +// expected-error@-4 {{call to implicitly-deleted default constructor of 'S'}} +#endif + S f() { - return S(); // expected-note {{in value-initialization of type 'S' here}} + return S(); +#if __cplusplus <= 199711L +// expected-note@-2 {{in value-initialization of type 'S' here}} +#else +// expected-error@-4 {{call to implicitly-deleted default constructor of 'S'}} +#endif } struct T - : S { // expected-note 2{{in value-initialization of type 'S' here}} + : S { +#if __cplusplus <= 199711L +// expected-note@-2 2 {{in value-initialization of type 'S' here}} +#else +// expected-note@-4 2 {{default constructor of 'T' is implicitly deleted because base class 'S' has a deleted default constructor}} +#endif }; -T t = T(); // expected-note {{in value-initialization of type 'T' here}} +T t = T(); +#if __cplusplus <= 199711L +// expected-note@-2 {{in value-initialization of type 'T' here}} +#else +// expected-error@-4 {{call to implicitly-deleted default constructor of 'T'}} +#endif + struct U { - T t[3]; // expected-note {{in value-initialization of type 'T' here}} + T t[3]; +#if __cplusplus <= 199711L +// expected-note@-2 {{in value-initialization of type 'T' here}} +#else +// expected-note@-4 {{default constructor of 'U' is implicitly deleted because field 't' has a deleted default constructor}} +#endif }; -U u = U(); // expected-note {{in value-initialization of type 'U' here}} +U u = U(); +#if __cplusplus <= 199711L +// expected-note@-2 {{in value-initialization of type 'U' here}} +#else +// expected-error@-4 {{call to implicitly-deleted default constructor of 'U'}} +#endif + // Ensure that we handle C++11 in-class initializers properly as an extension. // In this case, there is no user-declared default constructor, so we // recursively apply the value-initialization checks, but we will emit a // constructor call anyway, because the default constructor is not trivial. struct V { int n; - int &r = n; // expected-warning {{C++11}} + int &r = n; +#if __cplusplus <= 199711L + // expected-warning@-2 {{in-class initialization of non-static data member is a C++11 extension}} +#endif }; V v = V(); // ok struct W { int n; - S s = { n }; // expected-warning {{C++11}} + S s = { n }; +#if __cplusplus <= 199711L + // expected-warning@-2 {{in-class initialization of non-static data member is a C++11 extension}} +#endif }; W w = W(); // ok Index: test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-cxx03-extra-copy.cpp =================================================================== --- test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-cxx03-extra-copy.cpp +++ test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-cxx03-extra-copy.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -fdiagnostics-show-option -Wbind-to-temporary-copy -verify %s +// RUN: %clang_cc1 -fsyntax-only -fdiagnostics-show-option -Wbind-to-temporary-copy -verify -std=c++98 %s // C++03 requires that we check for a copy constructor when binding a // reference to a temporary, since we are allowed to make a copy, Even Index: test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x-fixits.cpp =================================================================== --- test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x-fixits.cpp +++ test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x-fixits.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -Wc++11-compat -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s +// RUN: %clang_cc1 -fsyntax-only -std=c++98 -Wc++11-compat -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s // Verify that the appropriate fixits are emitted for narrowing conversions in // initializer lists. Index: test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p4.cpp =================================================================== --- test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p4.cpp +++ test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p4.cpp @@ -1,4 +1,6 @@ // RUN: %clang_cc1 -fsyntax-only -verify %s +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s // C++03 [namespace.udecl]p4: // A using-declaration used as a member-declaration shall refer to a @@ -205,9 +207,19 @@ using Base::bar; // expected-error {{no member named 'bar'}} using Unrelated::foo; // expected-error {{not a base class}} using C::foo; // legal in C++03 +#if __cplusplus >= 201103L + // expected-error@-2 {{using declaration refers to its own class}} +#endif + using Subclass::foo; // legal in C++03 +#if __cplusplus >= 201103L + // expected-error@-2 {{using declaration refers into 'Subclass::', which is not a base class of 'C'}} +#endif - int bar(); //expected-note {{target of using declaration}} + int bar(); +#if __cplusplus <= 199711L + //expected-note@-2 {{target of using declaration}} +#endif using C::bar; // expected-error {{refers to its own class}} }; } Index: test/CXX/class.access/p4.cpp =================================================================== --- test/CXX/class.access/p4.cpp +++ test/CXX/class.access/p4.cpp @@ -1,4 +1,6 @@ // RUN: %clang_cc1 -fcxx-exceptions -fexceptions -fsyntax-only -verify %s +// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -fsyntax-only -verify -std=c++98 %s +// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -fsyntax-only -verify -std=c++11 %s // C++0x [class.access]p4: @@ -88,24 +90,49 @@ namespace test2 { class A { private: - A(); // expected-note 3 {{declared private here}} - + A(); +#if __cplusplus <= 199711L + // expected-note@-2 3 {{declared private here}} +#else + // expected-note@-4 {{declared private here}} +#endif static A foo; }; A a; // expected-error {{calling a private constructor}} A A::foo; // okay - class B : A { }; // expected-error {{base class 'test2::A' has private default constructor}} - B b; // expected-note{{implicit default constructor}} - + class B : A { }; +#if __cplusplus <= 199711L + // expected-error@-2 {{base class 'test2::A' has private default constructor}} +#else + // expected-note@-4 {{default constructor of 'B' is implicitly deleted because base class 'test2::A' has an inaccessible default constructor}} +#endif + B b; +#if __cplusplus <= 199711L + // expected-note@-2 {{implicit default constructor}} +#else + // expected-error@-4 {{call to implicitly-deleted default constructor of 'test2::B'}} +#endif + class C : virtual A { +#if __cplusplus >= 201103L + // expected-note@-2 {{default constructor of 'D' is implicitly deleted because base class 'test2::A' has an inaccessible default constructor}} +#endif public: C(); }; - class D : C { }; // expected-error {{inherited virtual base class 'test2::A' has private default constructor}} - D d; // expected-note{{implicit default constructor}} + class D : C { }; +#if __cplusplus <= 199711L + // expected-error@-2 {{inherited virtual base class 'test2::A' has private default constructor}} +#endif + D d; +#if __cplusplus <= 199711L + // expected-note@-2 {{implicit default constructor}} +#else + // expected-error@-4 {{call to implicitly-deleted default constructor of 'test2::D'}} +#endif } // Implicit destructor calls. @@ -123,11 +150,23 @@ A local; // expected-error {{variable of type 'test3::A' has private destructor}} } - template <unsigned N> class Base { ~Base(); }; // expected-note 14 {{declared private here}} - class Base2 : virtual Base<2> { ~Base2(); }; // expected-note 3 {{declared private here}} \ - // expected-error {{base class 'Base<2>' has private destructor}} - class Base3 : virtual Base<3> { public: ~Base3(); }; // expected-error {{base class 'Base<3>' has private destructor}} - + template <unsigned N> class Base { ~Base(); }; +#if __cplusplus <= 199711L + // expected-note@-2 14 {{declared private here}} +#else + // expected-note@-4 4 {{declared private here}} +#endif + class Base2 : virtual Base<2> { ~Base2(); }; +#if __cplusplus <= 199711L + // expected-note@-2 3 {{declared private here}} + // expected-error@-3 {{base class 'Base<2>' has private destructor}} +#else + // expected-note@-5 {{declared private here}} +#endif + class Base3 : virtual Base<3> { public: ~Base3(); }; +#if __cplusplus <= 199711L + // expected-error@-2 {{base class 'Base<3>' has private destructor}} +#endif // These don't cause diagnostics because we don't need the destructor. class Derived0 : Base<0> { ~Derived0(); }; class Derived1 : Base<1> { }; @@ -142,16 +181,35 @@ ~Derived2() {} }; - class Derived3 : // expected-error 2 {{inherited virtual base class 'Base<2>' has private destructor}} \ - // expected-error 2 {{inherited virtual base class 'Base<3>' has private destructor}} \ - // expected-note 2{{implicit default constructor}} - Base<0>, // expected-error 2 {{base class 'Base<0>' has private destructor}} - virtual Base<1>, // expected-error 2 {{base class 'Base<1>' has private destructor}} - Base2, // expected-error 2 {{base class 'test3::Base2' has private destructor}} + class Derived3 : +#if __cplusplus <= 199711L + // expected-error@-2 2 {{inherited virtual base class 'Base<2>' has private destructor}} + // expected-error@-3 2 {{inherited virtual base class 'Base<3>' has private destructor}} + // expected-note@-4 2{{implicit default constructor}} +#endif + Base<0>, +#if __cplusplus <= 199711L + // expected-error@-2 2 {{base class 'Base<0>' has private destructor}} +#else + // expected-note@-4 {{default constructor of 'Derived3' is implicitly deleted because base class 'Base<0>' has an inaccessible destructor}} +#endif + virtual Base<1>, +#if __cplusplus <= 199711L + // expected-error@-2 2 {{base class 'Base<1>' has private destructor}} +#endif + Base2, +#if __cplusplus <= 199711L + // expected-error@-2 2 {{base class 'test3::Base2' has private destructor}} +#endif virtual Base3 {}; - Derived3 d3; // expected-note {{implicit default constructor}}\ - // expected-note{{implicit destructor}}} + Derived3 d3; +#if __cplusplus <= 199711L + // expected-note@-2 {{implicit default constructor}} + // expected-note@-3 {{implicit destructor}}} +#else + // expected-error@-5 {{call to implicitly-deleted default constructor of 'test3::Derived3'}} +#endif } // Conversion functions. @@ -201,37 +259,83 @@ // Implicit copy assignment operator uses. namespace test5 { class A { - void operator=(const A &); // expected-note 2 {{implicitly declared private here}} + void operator=(const A &); +#if __cplusplus <= 199711L + // expected-note@-2 2 {{implicitly declared private here}} +#endif }; - class Test1 { A a; }; // expected-error {{private member}} + class Test1 { A a; }; +#if __cplusplus <= 199711L + // expected-error@-2 {{private member}} +#else + // expected-note@-4 {{copy assignment operator of 'Test1' is implicitly deleted because field 'a' has an inaccessible copy assignment operator}} +#endif void test1() { Test1 a; - a = Test1(); // expected-note{{implicit copy}} + a = Test1(); +#if __cplusplus <= 199711L + // expected-note@-2 {{implicit copy}} +#else + // expected-error@-4 {{object of type 'test5::Test1' cannot be assigned because its copy assignment operator is implicitly deleted}} +#endif } - class Test2 : A {}; // expected-error {{private member}} + class Test2 : A {}; +#if __cplusplus <= 199711L + // expected-error@-2 {{private member}} +#else + // expected-note@-4 {{copy assignment operator of 'Test2' is implicitly deleted because base class 'test5::A' has an inaccessible copy assignment operator}} +#endif void test2() { Test2 a; - a = Test2(); // expected-note{{implicit copy}} + a = Test2(); +#if __cplusplus <= 199711L + // expected-note@-2 {{implicit copy}} +#else + // expected-error@-4 {{object of type 'test5::Test2' cannot be assigned because its copy assignment operator is implicitly deleted}} +#endif } } // Implicit copy constructor uses. namespace test6 { class A { public: A(); - private: A(const A &); // expected-note 2 {{declared private here}} + private: A(const A &); +#if __cplusplus <= 199711L + // expected-note@-2 2 {{declared private here}} +#endif }; - class Test1 { A a; }; // expected-error {{field of type 'test6::A' has private copy constructor}} + class Test1 { A a; }; +#if __cplusplus <= 199711L + // expected-error@-2 {{field of type 'test6::A' has private copy constructor}} +#else + // expected-note@-4 {{copy constructor of 'Test1' is implicitly deleted because field 'a' has an inaccessible copy constructor}} +#endif void test1(const Test1 &t) { - Test1 a = t; // expected-note{{implicit copy}} + Test1 a = t; +#if __cplusplus <= 199711L + // expected-note@-2 {{implicit copy constructor for 'test6::Test1' first required here}} +#else + // expected-error@-4 {{call to implicitly-deleted copy constructor of 'test6::Test1'}} +#endif } - class Test2 : A {}; // expected-error {{base class 'test6::A' has private copy constructor}} + class Test2 : A {}; +#if __cplusplus <= 199711L + // expected-error@-2 {{base class 'test6::A' has private copy constructor}} +#else + // expected-note@-4 {{copy constructor of 'Test2' is implicitly deleted because base class 'test6::A' has an inaccessible copy constructor}} +#endif void test2(const Test2 &t) { - Test2 a = t; // expected-note{{implicit copy}} + Test2 a = t; +#if __cplusplus <= 199711L + // expected-note@-2 {{implicit copy constructor for 'test6::Test2' first required here}} +#else + // expected-error@-4 {{call to implicitly-deleted copy constructor of 'test6::Test2'}} +#endif } } Index: test/CXX/class.access/class.friend/p1.cpp =================================================================== --- test/CXX/class.access/class.friend/p1.cpp +++ test/CXX/class.access/class.friend/p1.cpp @@ -1,4 +1,6 @@ // RUN: %clang_cc1 -fsyntax-only -verify %s +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s // C++'0x [class.friend] p1: // A friend of a class is a function or class that is given permission to use @@ -214,17 +216,24 @@ // PR6207 namespace test6 { struct A {}; +#if __cplusplus >= 201103L + // expected-note@-2 {{previous declaration is here}} +#endif struct B { friend A::A(); +#if __cplusplus >= 201103L + // expected-error@-2 {{non-constexpr declaration of 'A' follows constexpr declaration}} +#endif friend A::~A(); friend A &A::operator=(const A&); }; } namespace test7 { template <class T> struct X { X(); + X(const X&); ~X(); void foo(); void bar(); Index: test/CXX/basic/basic.stc/basic.stc.dynamic/p2.cpp =================================================================== --- test/CXX/basic/basic.stc/basic.stc.dynamic/p2.cpp +++ test/CXX/basic/basic.stc/basic.stc.dynamic/p2.cpp @@ -1,4 +1,7 @@ // RUN: %clang_cc1 -fsyntax-only -fexceptions -fcxx-exceptions -verify %s +// RUN: %clang_cc1 -fsyntax-only -fexceptions -fcxx-exceptions -verify -std=c++98 %s +// RUN: %clang_cc1 -fsyntax-only -fexceptions -fcxx-exceptions -verify -std=c++11 %s + int *use_new(int N) { if (N == 1) return new int; @@ -19,10 +22,23 @@ typedef __SIZE_TYPE__ size_t; } -void* operator new(std::size_t) throw(std::bad_alloc); // expected-note{{previous declaration}} +void* operator new(std::size_t) throw(std::bad_alloc); +#if __cplusplus <= 199711L +// expected-note@-2 {{previous declaration is here}} +#endif + void* operator new[](std::size_t) throw(std::bad_alloc); void operator delete(void*) throw(); // expected-note{{previous declaration}} void operator delete[](void*) throw(); -void* operator new(std::size_t); // expected-warning{{'operator new' is missing exception specification 'throw(std::bad_alloc)'}} -void operator delete(void*); // expected-warning{{'operator delete' is missing exception specification 'throw()'}} +void* operator new(std::size_t); +#if __cplusplus <= 199711L +// expected-warning@-2 {{'operator new' is missing exception specification 'throw(std::bad_alloc)'}} +#endif + +void operator delete(void*); +#if __cplusplus <= 199711L +// expected-warning@-2 {{'operator delete' is missing exception specification 'throw()'}} +#else +// expected-warning@-4 {{function previously declared with an explicit exception specification redeclared with an implicit exception specification}} +#endif Index: test/CXX/basic/basic.stc/basic.stc.dynamic/p2-noexceptions.cpp =================================================================== --- test/CXX/basic/basic.stc/basic.stc.dynamic/p2-noexceptions.cpp +++ test/CXX/basic/basic.stc/basic.stc.dynamic/p2-noexceptions.cpp @@ -1,5 +1,7 @@ // RUN: %clang_cc1 -fsyntax-only -verify %s -// expected-no-diagnostics +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s + namespace std { class bad_alloc { }; @@ -11,4 +13,12 @@ void* operator new(std::size_t); void* operator new[](std::size_t); void operator delete(void*); +#if __cplusplus >= 201103L +// expected-warning@-2 {{function previously declared with an explicit exception specification redeclared with an implicit exception specificatio}} +#else +// expected-no-diagnostics +#endif void operator delete[](void*); +#if __cplusplus >= 201103L +// expected-warning@-2 {{function previously declared with an explicit exception specification redeclared with an implicit exception specificatio}} +#endif
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits