r294225 - [Lit Test] Make tests C++11 compatible - Microsoft diagnostics

Charles Li via cfe-commits cfe-commits at lists.llvm.org
Mon Feb 6 11:32:38 PST 2017


Author: lcharles
Date: Mon Feb  6 13:32:38 2017
New Revision: 294225

URL: http://llvm.org/viewvc/llvm-project?rev=294225&view=rev
Log:
[Lit Test] Make tests C++11 compatible - Microsoft diagnostics

Differential Revision: https://reviews.llvm.org/D29520

Modified:
    cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp
    cfe/trunk/test/SemaCXX/implicit-virtual-member-functions.cpp
    cfe/trunk/test/SemaCXX/virtual-base-used.cpp
    cfe/trunk/test/SemaTemplate/virtual-member-functions.cpp

Modified: cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp?rev=294225&r1=294224&r2=294225&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp (original)
+++ cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp Mon Feb  6 13:32:38 2017
@@ -1,4 +1,6 @@
 // RUN: %clang_cc1 %s -triple i686-pc-win32 -fsyntax-only -Wmicrosoft -Wc++11-extensions -Wno-long-long -verify -fms-extensions -fexceptions -fcxx-exceptions -DTEST1
+// RUN: %clang_cc1 -std=c++98 %s -triple i686-pc-win32 -fsyntax-only -Wmicrosoft -Wc++11-extensions -Wno-long-long -verify -fms-extensions -fexceptions -fcxx-exceptions -DTEST1
+// RUN: %clang_cc1 -std=c++11 %s -triple i686-pc-win32 -fsyntax-only -Wmicrosoft -Wc++11-extensions -Wno-long-long -verify -fms-extensions -fexceptions -fcxx-exceptions -DTEST1
 // RUN: %clang_cc1 %s -triple i686-pc-win32 -fsyntax-only -Wmicrosoft -Wc++11-extensions -Wno-long-long -verify -fexceptions -fcxx-exceptions -DTEST2
 
 #if TEST1
@@ -23,11 +25,17 @@ struct Derived : Base {
 };
 
 class A {
-  virtual ~A() throw();  // expected-note {{overridden virtual function is here}}
+  virtual ~A() throw();
+#if __cplusplus <= 199711L
+  // expected-note at -2 {{overridden virtual function is here}}
+#endif
 };
 
 class B : public A {
-  virtual ~B();  // expected-warning {{exception specification of overriding function is more lax than base version}}
+  virtual ~B();
+#if __cplusplus <= 199711L
+  // expected-warning at -2 {{exception specification of overriding function is more lax than base version}}
+#endif
 };
 
 }
@@ -174,11 +182,18 @@ const int seventeen = 17;
 typedef int Int;
 
 struct X0 {
-  enum E1 : Int { SomeOtherValue } field; // expected-warning{{enumeration types with a fixed underlying type are a C++11 extension}}
+  enum E1 : Int { SomeOtherValue } field;
+#if __cplusplus <= 199711L
+  // expected-warning at -2 {{enumeration types with a fixed underlying type are a C++11 extension}}
+#endif
+
   enum E1 : seventeen;
 };
 
-enum : long long {  // expected-warning{{enumeration types with a fixed underlying type are a C++11 extension}}
+#if __cplusplus <= 199711L
+// expected-warning at +2 {{enumeration types with a fixed underlying type are a C++11 extension}}
+#endif
+enum : long long {
   SomeValue = 0x100000000
 };
 
@@ -450,7 +465,9 @@ struct SealedType sealed : SomeBase {
   // FIXME. warning can be suppressed if we're also issuing error for overriding a 'final' function.
   virtual void SealedFunction(); // expected-warning {{'SealedFunction' overrides a member function but is not marked 'override'}}
 
-  // expected-warning at +1 {{'override' keyword is a C++11 extension}}
+#if __cplusplus <= 199711L
+  // expected-warning at +2 {{'override' keyword is a C++11 extension}}
+#endif
   virtual void OverrideMe() override;
 };
 

Modified: cfe/trunk/test/SemaCXX/implicit-virtual-member-functions.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/implicit-virtual-member-functions.cpp?rev=294225&r1=294224&r2=294225&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/implicit-virtual-member-functions.cpp (original)
+++ cfe/trunk/test/SemaCXX/implicit-virtual-member-functions.cpp Mon Feb  6 13:32:38 2017
@@ -1,33 +1,87 @@
 // 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 at -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 at -2 {{no suitable member 'operator delete' in 'B'}}
+#else
+// expected-error at -4 {{deleted function '~B' cannot override a non-deleted function}}
+// expected-note at -5  {{virtual destructor requires an unambiguous, accessible 'operator delete'}}
+#ifdef MSABI
+// expected-note at -7 {{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 at -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 at -2 {{implicit destructor for 'B' first required here}}
+#else
+// expected-error at -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 at -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 at -2 {{no suitable member 'operator delete' in 'C'}}
+#else
+// expected-error at -4 {{deleted function '~C' cannot override a non-deleted function}}
+// expected-note at -5  {{virtual destructor requires an unambiguous, accessible 'operator delete'}}
+#endif
+
   C();
-  void operator delete(void *, int); // expected-note {{'operator delete' declared here}}
+  void operator delete(void *, int);
+#if __cplusplus <= 199711L
+// expected-note at -2 {{'operator delete' declared here}}
+#endif
 };
 
-C::C() { }  // expected-note {{implicit destructor for 'C' first required here}}
+C::C() { }
+#if __cplusplus <= 199711L
+// expected-note at -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 at -2 {{no suitable member 'operator delete' in 'D'}}
+#else
+// expected-error at -4 {{deleted function '~D' cannot override a non-deleted function}}
+// expected-note at -5  {{virtual destructor requires an unambiguous, accessible 'operator delete'}}
+#endif
+  void operator delete(void *, int);
+#if __cplusplus <= 199711L
+// expected-note at -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 at -2 {{implicit destructor for 'D' first required here}}
+#endif
 }

Modified: cfe/trunk/test/SemaCXX/virtual-base-used.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/virtual-base-used.cpp?rev=294225&r1=294224&r2=294225&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/virtual-base-used.cpp (original)
+++ cfe/trunk/test/SemaCXX/virtual-base-used.cpp Mon Feb  6 13:32:38 2017
@@ -1,89 +1,215 @@
 // 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
 // PR7800
 
 // The Microsoft ABI doesn't have the concept of key functions, so we have different
 // expectations about when functions are first required for that case.
 
+class NoDestroy { ~NoDestroy(); };
+#if __cplusplus <= 199711L
+// expected-note at -2 3 {{declared private here}}
 #ifdef MSABI
-// expected-note at +2 3 {{declared private here}}
+// expected-note at -4 3 {{declared private here}}
 #endif
-class NoDestroy { ~NoDestroy(); }; // expected-note 3 {{declared private here}}
+#endif
+
 struct A {
   virtual ~A();
+#if __cplusplus >= 201103L
+  // expected-note at -2 3 {{overridden virtual function is here}}
+#endif
 };
 
+struct B : public virtual A {
+#if __cplusplus >= 201103L
+// expected-error at -2 {{deleted function '~B' cannot override a non-deleted function}}
+// expected-note at -3 {{overridden virtual function is here}}
+#endif
+
+  NoDestroy x;
+#if __cplusplus <= 199711L
+  // expected-error at -2 {{field of type 'NoDestroy' has private destructor}}
 #ifdef MSABI
-// expected-error at +3 {{field of type 'NoDestroy' has private destructor}}
+  // expected-error at -4 {{field of type 'NoDestroy' has private destructor}}
 #endif
-struct B : public virtual A {
-  NoDestroy x; // expected-error {{field of type 'NoDestroy' has private destructor}}
-};
+#else
+  // expected-note at -7 {{destructor of 'B' is implicitly deleted because field 'x' has an inaccessible destructor}}
 #ifdef MSABI
-// expected-note at +3 {{implicit default constructor for 'B' first required here}}
-// expected-note at +2 {{implicit destructor for 'B' first required here}}
+  // expected-note at -9 {{default constructor of 'B' is implicitly deleted because field 'x' has an inaccessible destructor}}
+#endif
 #endif
+};
+
 struct D : public virtual B {
+#if __cplusplus <= 199711L
+#ifdef MSABI
+// expected-note at -3 {{implicit default constructor for 'B' first required here}}
+// expected-note at -4 {{implicit destructor for 'B' first required here}}
+#endif
+#else
+#ifdef MSABI
+// expected-note at -8 {{default constructor of 'D' is implicitly deleted because base class 'B' has a deleted default constructor}}
+#endif
+#endif
   virtual void foo();
   ~D();
+#if __cplusplus >= 201103L
+  //expected-error at -2 {{non-deleted function '~D' cannot override a deleted function}}
+#endif
 };
+
 #ifdef MSABI
-D d; // expected-note {{implicit default constructor for 'D' first required here}}
+D d;
+#if __cplusplus <= 199711L
+// expected-note at -2 {{implicit default constructor for 'D' first required here}}
 #else
-void D::foo() { // expected-note {{implicit destructor for 'B' first required here}}
+// expected-error at -4 {{call to implicitly-deleted default constructor of 'D'}}
+#endif
+#else
+void D::foo() {
+#if __cplusplus <= 199711L
+// expected-note at -2 {{implicit destructor for 'B' first required here}}
+#endif
 }
 #endif
 
+struct E : public virtual A {
+#if __cplusplus >= 201103L
+// expected-error at -2 {{deleted function '~E' cannot override a non-deleted function}}
+// expected-note at -3 {{overridden virtual function is here}}
+#endif
+
+  NoDestroy x;
+#if __cplusplus <= 199711L
+  // expected-error at -2 {{field of type 'NoDestroy' has private destructor}}
 #ifdef MSABI
-// expected-error at +3 {{field of type 'NoDestroy' has private destructor}}
+  // expected-error at -4 {{field of type 'NoDestroy' has private destructor}}
 #endif
-struct E : public virtual A {
-  NoDestroy x; // expected-error {{field of type 'NoDestroy' has private destructor}}
-};
+#else
+  // expected-note at -7 {{destructor of 'E' is implicitly deleted because field 'x' has an inaccessible destructor}}
 #ifdef MSABI
-// expected-note at +2 {{implicit default constructor for 'E' first required here}}
+  // expected-note at -9 {{default constructor of 'E' is implicitly deleted because field 'x' has an inaccessible destructor}}
+#endif
 #endif
-struct F : public E { // expected-note {{implicit destructor for 'E' first required here}}
 };
+
+struct F : public E {
+#if __cplusplus <= 199711L
+// expected-note at -2 {{implicit destructor for 'E' first required here}}
 #ifdef MSABI
-// expected-note at +2 {{implicit default constructor for 'F' first required here}}
+// expected-note at -4 {{implicit default constructor for 'E' first required here}}
+#endif
+#else
+// expected-error at -7 {{non-deleted function '~F' cannot override a deleted function}}
+// expected-note at -8 {{overridden virtual function is here}}
+#ifdef MSABI
+// expected-note at -10 {{default constructor of 'F' is implicitly deleted because base class 'E' has a deleted default constructor}}
+#endif
 #endif
+};
+
+
 struct G : public virtual F {
+#ifdef MSABI
+#if __cplusplus <= 199711L
+// expected-note at -3 {{implicit default constructor for 'F' first required here}}
+#else
+// expected-note at -5 {{default constructor of 'G' is implicitly deleted because base class 'F' has a deleted default constructor}}
+#endif
+#endif
+
   virtual void foo();
   ~G();
+#if __cplusplus >= 201103L
+  //expected-error at -2 {{non-deleted function '~G' cannot override a deleted function}}
+#endif
 };
+
 #ifdef MSABI
-G g; // expected-note {{implicit default constructor for 'G' first required here}}
+G g;
+#if __cplusplus <= 199711L
+// expected-note at -2 {{implicit default constructor for 'G' first required here}}
+#else
+// expected-error at -4 {{call to implicitly-deleted default constructor of 'G'}}
+#endif
 #else
-void G::foo() { // expected-note {{implicit destructor for 'F' first required here}}
+void G::foo() {
+#if __cplusplus <= 199711L
+// expected-note at -2 {{implicit destructor for 'F' first required here}}
+#endif
 }
 #endif
 
+struct H : public virtual A {
+#if __cplusplus >= 201103L
+// expected-error at -2 {{deleted function '~H' cannot override a non-deleted function}}
+// expected-note at -3 {{overridden virtual function is here}}
+#else
 #ifdef MSABI
-// expected-note at +3 {{'H' declared here}}
-// expected-error at +3 {{field of type 'NoDestroy' has private destructor}}
+// expected-note at -6 {{'H' declared here}}
 #endif
-struct H : public virtual A {
-  NoDestroy x; // expected-error {{field of type 'NoDestroy' has private destructor}}
-};
+#endif
+
+  NoDestroy x;
+#if __cplusplus <= 199711L
+  // expected-error at -2 {{field of type 'NoDestroy' has private destructor}}
 #ifdef MSABI
-// expected-error at +3 {{implicit default constructor for 'I' must explicitly initialize the base class 'H' which does not have a default constructor}}
-// expected-note at +2 {{implicit destructor for 'H' first required here}}
+  // expected-error at -4 {{field of type 'NoDestroy' has private destructor}}
+#endif
+#else
+  // expected-note at -7 {{destructor of 'H' is implicitly deleted because field 'x' has an inaccessible destructor}}
+#ifdef MSABI
+  // expected-note at -9 {{default constructor of 'H' is implicitly deleted because field 'x' has an inaccessible destructor}}
+#endif
 #endif
+};
+
 struct I : public virtual H {
+#ifdef MSABI
+#if __cplusplus <= 199711L
+// expected-error at -3 {{implicit default constructor for 'I' must explicitly initialize the base class 'H' which does not have a default constructor}}
+// expected-note at -4 {{implicit destructor for 'H' first required here}}
+#else
+// expected-note at -6 {{default constructor of 'I' is implicitly deleted because base class 'H' has a deleted default constructor}}
+#endif
+#endif
+
   ~I();
+#if __cplusplus >= 201103L
+// expected-error at -2 {{non-deleted function '~I' cannot override a deleted function}}
+#endif
 };
+
+struct J : public I {
 #ifdef MSABI
-// expected-note at +3 {{implicit default constructor for 'H' first required here}}
-// expected-note at +2 {{implicit default constructor for 'I' first required here}}
+#if __cplusplus <= 199711L
+// expected-note at -3 {{implicit default constructor for 'H' first required here}}
+// expected-note at -4 {{implicit default constructor for 'I' first required here}}
+#else
+// expected-note at -6 {{default constructor of 'J' is implicitly deleted because base class 'I' has a deleted default constructor}}
 #endif
-struct J : public I {
+#endif
+
   virtual void foo();
   ~J();
 };
+
 #ifdef MSABI
-J j; // expected-note {{implicit default constructor for 'J' first required here}}
+J j;
+#if __cplusplus <= 199711L
+// expected-note at -2 {{implicit default constructor for 'J' first required here}}
 #else
-void J::foo() { // expected-note {{implicit destructor for 'H' first required here}}
+// expected-error at -4 {{call to implicitly-deleted default constructor of 'J'}}
+#endif
+
+#else
+void J::foo() {
+#if __cplusplus <= 199711L
+// expected-note at -2 {{implicit destructor for 'H' first required here}}
+#endif
 }
 #endif

Modified: cfe/trunk/test/SemaTemplate/virtual-member-functions.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/virtual-member-functions.cpp?rev=294225&r1=294224&r2=294225&view=diff
==============================================================================
--- cfe/trunk/test/SemaTemplate/virtual-member-functions.cpp (original)
+++ cfe/trunk/test/SemaTemplate/virtual-member-functions.cpp Mon Feb  6 13:32:38 2017
@@ -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,76 @@ namespace std {
 }
 
 namespace PR7114 {
-  class A { virtual ~A(); }; // expected-note{{declared private here}}
+  class A { virtual ~A(); };
+#if __cplusplus <= 199711L
+  // expected-note at -2{{declared private here}}
+#else
+  // expected-note at -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 at -2{{base class 'PR7114::A' has private destructor}}
+#else
+// expected-error at -4 2 {{deleted function '~Inner' cannot override a non-deleted function}}
+// expected-note at -5 2 {{destructor of 'Inner' is implicitly deleted because base class 'PR7114::A' has an inaccessible destructor}}
+#ifdef MSABI
+// expected-note at -7 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 at -2 {{in instantiation of member class 'PR7114::B<int>::Inner' requested here}}
+// expected-note at -3 {{in instantiation of member class 'PR7114::B<float>::Inner' requested here}}
+#endif
   };
 
   int f() { return B<int>::value; }
+#if __cplusplus >= 201103L
+// expected-note at -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 at -2 {{implicit destructor}}
+#else
+// expected-error at -4 {{attempt to use a deleted function}}
+// expected-note at -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 at -2 {{in instantiation of template class 'PR7114::B<float>' requested here}}
+#endif
+    (void)typeid(bfi);
+#if __cplusplus <= 199711L
+// expected-note at -2 {{implicit destructor}}
+#endif
 #endif
   }
 
   template<typename T>
   struct X : A {
+#if __cplusplus >= 201103L
+// expected-error at -2 {{deleted function '~X' cannot override a non-deleted function}}
+// expected-note at -3  {{destructor of 'X<int>' is implicitly deleted because base class 'PR7114::A' has an inaccessible destructor}}
+#endif
     void f() { }
   };
 
   void test_X(X<int> &xi, X<float> &xf) {
     xi.f();
+#if __cplusplus >= 201103L
+// expected-note at -2 {{in instantiation of template class 'PR7114::X<int>' requested here}}
+#endif
   }
 }
 




More information about the cfe-commits mailing list