r296193 - [Test] Make Lit tests C++11 compatible #10

Charles Li via cfe-commits cfe-commits at lists.llvm.org
Fri Feb 24 15:23:53 PST 2017


Author: lcharles
Date: Fri Feb 24 17:23:53 2017
New Revision: 296193

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

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

Modified:
    cfe/trunk/test/Modules/Inputs/merge-using-decls/b.h
    cfe/trunk/test/Modules/merge-using-decls.cpp
    cfe/trunk/test/SemaCXX/PR9572.cpp
    cfe/trunk/test/SemaCXX/default-assignment-operator.cpp
    cfe/trunk/test/SemaCXX/default-constructor-initializers.cpp
    cfe/trunk/test/SemaCXX/warn-thread-safety-parsing.cpp

Modified: cfe/trunk/test/Modules/Inputs/merge-using-decls/b.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/merge-using-decls/b.h?rev=296193&r1=296192&r2=296193&view=diff
==============================================================================
--- cfe/trunk/test/Modules/Inputs/merge-using-decls/b.h (original)
+++ cfe/trunk/test/Modules/Inputs/merge-using-decls/b.h Fri Feb 24 17:23:53 2017
@@ -29,11 +29,13 @@ template<typename T> struct D : X, T {
   using typename X::t;
 };
 
+#if __cplusplus <= 199711L // C++11 does not allow access declerations
 template<typename T> struct E : X, T {
   // Mismatch in using/access-declaration-ness.
   T::value;
   X::v;
 };
+#endif
 
 template<typename T> struct F : X, T {
   // Mismatch in nested-name-specifier.
@@ -46,5 +48,9 @@ template<typename T> struct F : X, T {
 // Force instantiation.
 typedef C<YB>::type I;
 typedef D<YBRev>::t I;
+
+#if __cplusplus <= 199711L // C++11 does not allow access declerations
 typedef E<YB>::type I;
+#endif
+
 typedef F<YB>::type I;

Modified: cfe/trunk/test/Modules/merge-using-decls.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/merge-using-decls.cpp?rev=296193&r1=296192&r2=296193&view=diff
==============================================================================
--- cfe/trunk/test/Modules/merge-using-decls.cpp (original)
+++ cfe/trunk/test/Modules/merge-using-decls.cpp Fri Feb 24 17:23:53 2017
@@ -1,6 +1,10 @@
 // RUN: rm -rf %t
 // RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -x c++ -I%S/Inputs/merge-using-decls -verify %s -DORDER=1
+// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -x c++ -I%S/Inputs/merge-using-decls -verify -std=c++98 %s -DORDER=1
+// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -x c++ -I%S/Inputs/merge-using-decls -verify -std=c++11 %s -DORDER=1
 // RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -x c++ -I%S/Inputs/merge-using-decls -verify %s -DORDER=2
+// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -x c++ -I%S/Inputs/merge-using-decls -verify -std=c++98 %s -DORDER=2
+// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -x c++ -I%S/Inputs/merge-using-decls -verify -std=c++11 %s -DORDER=2
 
 #if ORDER == 1
 #include "a.h"
@@ -24,7 +28,11 @@ template<typename T> int Use() {
 }
 
 template<typename T> int UseAll() {
+#if __cplusplus <= 199711L // C++11 does not allow access declerations
   return Use<C<T> >() + Use<D<T> >() + Use<E<T> >() + Use<F<T> >(); // expected-note 0-2{{instantiation of}}
+#else
+  return Use<C<T> >() + Use<D<T> >() + Use<F<T> >(); // expected-note 0-2{{instantiation of}}
+#endif
 }
 
 template int UseAll<YA>();
@@ -37,8 +45,10 @@ template int UseAll<Y>();
 // Here, we're instantiating the definition from 'A' and merging the definition
 // from 'B' into it.
 
+#if __cplusplus <= 199711L // C++11 does not allow access declerations
 // expected-error at b.h:* {{'E::value' from module 'B' is not present in definition of 'E<T>' in module 'A'}}
 // expected-error at b.h:* {{'E::v' from module 'B' is not present in definition of 'E<T>' in module 'A'}}
+#endif
 
 // expected-error at b.h:* {{'F::type' from module 'B' is not present in definition of 'F<T>' in module 'A'}}
 // expected-error at b.h:* {{'F::t' from module 'B' is not present in definition of 'F<T>' in module 'A'}}
@@ -55,11 +65,14 @@ template int UseAll<Y>();
 // expected-error at b.h:* 2{{'typename' keyword used on a non-type}}
 // expected-error at b.h:* 2{{dependent using declaration resolved to type without 'typename'}}
 
+#if __cplusplus <= 199711L // C++11 does not allow access declerations
 // expected-error at a.h:* {{'E::type' from module 'A' is not present in definition of 'E<T>' in module 'B'}}
 // expected-error at a.h:* {{'E::t' from module 'A' is not present in definition of 'E<T>' in module 'B'}}
 // expected-error at a.h:* {{'E::value' from module 'A' is not present in definition of 'E<T>' in module 'B'}}
 // expected-error at a.h:* {{'E::v' from module 'A' is not present in definition of 'E<T>' in module 'B'}}
 // expected-note at b.h:* 2{{definition has no member}}
+#endif
+
 
 // expected-error at a.h:* {{'F::type' from module 'A' is not present in definition of 'F<T>' in module 'B'}}
 // expected-error at a.h:* {{'F::t' from module 'A' is not present in definition of 'F<T>' in module 'B'}}

Modified: cfe/trunk/test/SemaCXX/PR9572.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/PR9572.cpp?rev=296193&r1=296192&r2=296193&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/PR9572.cpp (original)
+++ cfe/trunk/test/SemaCXX/PR9572.cpp Fri Feb 24 17:23:53 2017
@@ -1,15 +1,50 @@
 // 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
+
 class Base {
-  virtual ~Base(); // expected-note {{implicitly declared private here}}
+  virtual ~Base();
+#if __cplusplus <= 199711L
+  // expected-note at -2 {{implicitly declared private here}}
+#else
+  // expected-note at -4 {{overridden virtual function is here}}
+#endif
 };
-struct Foo : public Base { // expected-error {{base class 'Base' has private destructor}}
-  const int kBlah = 3; // expected-warning {{is a C++11 extension}}
+
+struct Foo : public Base {
+#if __cplusplus <= 199711L
+// expected-error at -2 {{base class 'Base' has private destructor}}
+#else
+// expected-error at -4 {{deleted function '~Foo' cannot override a non-deleted function}}
+// expected-note at -5 {{overridden virtual function is here}}
+// expected-note at -6 3 {{destructor of 'Foo' is implicitly deleted because base class 'Base' has an inaccessible destructor}}
+#endif
+
+  const int kBlah = 3;
+#if __cplusplus <= 199711L
+  // expected-warning at -2 {{in-class initialization of non-static data member is a C++11 extension}}
+#endif
+
   Foo();
 };
+
 struct Bar : public Foo {
-  Bar() { } // expected-note {{implicit destructor for 'Foo' first required here}}
+#if __cplusplus >= 201103L
+// expected-error at -2 {{non-deleted function '~Bar' cannot override a deleted function}}
+// expected-note at -3 {{while declaring the implicit destructor for 'Bar'}}
+#endif
+  Bar() { }
+#if __cplusplus <= 199711L
+  // expected-note at -2 {{implicit destructor for 'Foo' first required here}}
+#else
+  // expected-error at -4 {{attempt to use a deleted function}}
+#endif
 };
+
 struct Baz {
   Foo f;
   Baz() { }
+#if __cplusplus >= 201103L
+  // expected-error at -2 {{attempt to use a deleted function}}
+#endif
 };

Modified: cfe/trunk/test/SemaCXX/default-assignment-operator.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/default-assignment-operator.cpp?rev=296193&r1=296192&r2=296193&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/default-assignment-operator.cpp (original)
+++ cfe/trunk/test/SemaCXX/default-assignment-operator.cpp Fri Feb 24 17:23:53 2017
@@ -1,16 +1,34 @@
 // 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
 
-class Base { // expected-error {{cannot define the implicit copy assignment operator for 'Base', because non-static reference member 'ref' cannot use copy assignment operator}} \
-  // expected-warning{{class 'Base' does not declare any constructor to initialize its non-modifiable members}}
-  int &ref;  // expected-note {{declared here}} \
-  // expected-note{{reference member 'ref' will never be initialized}}
+class Base { // expected-warning{{class 'Base' does not declare any constructor to initialize its non-modifiable members}}
+#if __cplusplus <= 199711L
+// expected-error at -2 {{cannot define the implicit copy assignment operator for 'Base', because non-static reference member 'ref' cannot use copy assignment operator}}
+#endif
+
+  int &ref; // expected-note{{reference member 'ref' will never be initialized}}
+#if __cplusplus <= 199711L
+  // expected-note at -2 {{declared here}}
+#else
+  // expected-note at -4 2 {{copy assignment operator of 'Base' is implicitly deleted because field 'ref' is of reference type 'int &'}}
+#endif
 };
 
-class X  : Base {  // // expected-error {{cannot define the implicit copy assignment operator for 'X', because non-static const member 'cint' cannot use copy assignment operator}} \
-// expected-note{{assignment operator for 'Base' first required here}}
+class X  : Base {
+#if __cplusplus <= 199711L
+// expected-note at -2 {{assignment operator for 'Base' first required here}}
+// expected-error at -3 {{cannot define the implicit copy assignment operator for 'X', because non-static const member 'cint' cannot use copy assignment operator}}
+#else
+// expected-note at -5 2 {{copy assignment operator of 'X' is implicitly deleted because base class 'Base' has a deleted copy assignment operator}}
+#endif
+
 public: 
   X();
-  const int cint;  // expected-note {{declared here}}
+  const int cint;
+#if __cplusplus <= 199711L
+// expected-note at -2 {{declared here}}
+#endif
 }; 
 
 struct Y  : X { 
@@ -28,8 +46,17 @@ Z z2;
 
 // Test1
 void f(X x, const X cx) {
-  x = cx; // expected-note{{assignment operator for 'X' first required here}}
   x = cx;
+#if __cplusplus <= 199711L
+  // expected-note at -2 {{assignment operator for 'X' first required here}}
+#else
+  // expected-error at -4 {{object of type 'X' cannot be assigned because its copy assignment operator is implicitly deleted}}
+#endif
+
+  x = cx;
+#if __cplusplus >= 201103L
+  // expected-error at -2 {{object of type 'X' cannot be assigned because its copy assignment operator is implicitly deleted}}
+#endif
   z1 = z2;
 }
 
@@ -73,36 +100,62 @@ void i() {
 
 // Test5
 
-class E1 { // expected-error{{cannot define the implicit copy assignment operator for 'E1', because non-static const member 'a' cannot use copy assignment operator}}
+class E1 {
+#if __cplusplus <= 199711L
+// expected-error at -2 {{cannot define the implicit copy assignment operator for 'E1', because non-static const member 'a' cannot use copy assignment operator}}
+#endif
 
 public:
-  const int a; // expected-note{{declared here}}
-  E1() : a(0) {}  
+  const int a;
+#if __cplusplus <= 199711L
+// expected-note at -2 {{declared here}}
+#else
+// expected-note at -4 {{copy assignment operator of 'E1' is implicitly deleted because field 'a' is of const-qualified type 'const int'}}
+#endif
+  E1() : a(0) {}
 
 };
 
 E1 e1, e2;
 
 void j() {
-  e1 = e2; // expected-note{{assignment operator for 'E1' first required here}}
+  e1 = e2;
+#if __cplusplus <= 199711L
+  // expected-note at -2 {{assignment operator for 'E1' first required here}}
+#else
+  // expected-error at -4 {{object of type 'E1' cannot be assigned because its copy assignment operator is implicitly deleted}}
+#endif
 }
 
 namespace ProtectedCheck {
   struct X {
   protected:
-    X &operator=(const X&); // expected-note{{declared protected here}}
+    X &operator=(const X&);
+#if __cplusplus <= 199711L
+    // expected-note at -2 {{declared protected here}}
+#endif
   };
 
   struct Y : public X { };
 
   void f(Y y) { y = y; }
 
-  struct Z { // expected-error{{'operator=' is a protected member of 'ProtectedCheck::X'}}
+  struct Z {
+#if __cplusplus <= 199711L
+  // expected-error at -2 {{'operator=' is a protected member of 'ProtectedCheck::X'}}
+#endif
     X x;
+#if __cplusplus >= 201103L
+    // expected-note at -2 {{copy assignment operator of 'Z' is implicitly deleted because field 'x' has an inaccessible copy assignment operator}}
+#endif
   };
 
-  void f(Z z) { z = z; }  // expected-note{{implicit copy assignment operator}}
-
+  void f(Z z) { z = z; }
+#if __cplusplus <= 199711L
+  // expected-note at -2 {{implicit copy assignment operator}}
+#else
+  // expected-error at -4 {{object of type 'ProtectedCheck::Z' cannot be assigned because its copy assignment operator is implicitly deleted}}
+#endif
 }
 
 namespace MultiplePaths {

Modified: cfe/trunk/test/SemaCXX/default-constructor-initializers.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/default-constructor-initializers.cpp?rev=296193&r1=296192&r2=296193&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/default-constructor-initializers.cpp (original)
+++ cfe/trunk/test/SemaCXX/default-constructor-initializers.cpp Fri Feb 24 17:23:53 2017
@@ -1,26 +1,59 @@
 // 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 X1 { // has no implicit default constructor
    X1(int);
 };
 
-struct X2  : X1 {  // expected-note 2 {{'X2' declared here}}
-   X2(int);
-};
-
-struct X3 : public X2 { // expected-error {{implicit default constructor for 'X3' must explicitly initialize the base class 'X2' which does not have a default constructor}}
-};
-X3 x3; // expected-note {{first required here}}
+struct X2  : X1 {
+#if __cplusplus <= 199711L
+// expected-note at -2 2 {{'X2' declared here}}
+#endif
 
-
-struct X4 { // expected-error {{must explicitly initialize the member 'x2'}} \
-            // expected-error {{must explicitly initialize the reference member 'rx2'}}
-  X2 x2; 	// expected-note {{member is declared here}}
-  X2 & rx2; // expected-note {{declared here}}
+   X2(int);
 };
 
-X4 x4; // expected-note {{first required here}}
-
+struct X3 : public X2 {
+#if __cplusplus <= 199711L
+// expected-error at -2 {{implicit default constructor for 'X3' must explicitly initialize the base class 'X2' which does not have a default constructor}}
+#else
+// expected-note at -4 {{default constructor of 'X3' is implicitly deleted because base class 'X2' has no default constructor}}
+#endif
+};
+
+X3 x3;
+#if __cplusplus <= 199711L
+// expected-note at -2 {{first required here}}
+#else
+// expected-error at -4 {{call to implicitly-deleted default constructor of 'X3'}}
+#endif
+
+struct X4 {
+#if __cplusplus <= 199711L
+// expected-error at -2 {{must explicitly initialize the member 'x2'}}
+// expected-error at -3 {{must explicitly initialize the reference member 'rx2'}}
+#endif
+
+  X2 x2;
+#if __cplusplus <= 199711L
+  // expected-note at -2 {{member is declared here}}
+#else
+  // expected-note at -4 {{default constructor of 'X4' is implicitly deleted because field 'x2' has no default constructor}}
+#endif
+
+  X2 & rx2;
+#if __cplusplus <= 199711L
+  // expected-note at -2 {{declared here}}
+#endif
+};
+
+X4 x4;
+#if __cplusplus <= 199711L
+// expected-note at -2 {{first required here}}
+#else
+// expected-error at -4 {{call to implicitly-deleted default constructor of 'X4'}}
+#endif
 
 struct Y1 { // has no implicit default constructor
    Y1(int);
@@ -43,15 +76,33 @@ Y4 y4;
 
 // More tests
 
-struct Z1 { // expected-error {{must explicitly initialize the reference member 'z'}} \
-            // expected-error {{must explicitly initialize the const member 'c1'}}
-  int& z;       // expected-note {{declared here}}
-  const int c1; // expected-note {{declared here}}
+struct Z1 {
+#if __cplusplus <= 199711L
+// expected-error at -2 {{must explicitly initialize the reference member 'z'}}
+// expected-error at -3 {{must explicitly initialize the const member 'c1'}}
+#endif
+
+  int& z;
+#if __cplusplus <= 199711L
+  // expected-note at -2 {{declared here}}
+#else
+  // expected-note at -4 {{default constructor of 'Z1' is implicitly deleted because field 'z' of reference type 'int &' would not be initialized}}
+#endif
+
+  const int c1;
+#if __cplusplus <= 199711L
+  // expected-note at -2 {{declared here}}
+#endif
   volatile int v1;
 };
 
 // Test default initialization which *requires* a constructor call for non-POD.
-Z1 z1; // expected-note {{first required here}}
+Z1 z1;
+#if __cplusplus <= 199711L
+// expected-note at -2 {{first required here}}
+#else
+// expected-error at -4 {{call to implicitly-deleted default constructor of 'Z1'}}
+#endif
 
 // Ensure that value initialization doesn't use trivial implicit constructors.
 namespace PR7948 {

Modified: cfe/trunk/test/SemaCXX/warn-thread-safety-parsing.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-thread-safety-parsing.cpp?rev=296193&r1=296192&r2=296193&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/warn-thread-safety-parsing.cpp (original)
+++ cfe/trunk/test/SemaCXX/warn-thread-safety-parsing.cpp Fri Feb 24 17:23:53 2017
@@ -1,4 +1,6 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -Wthread-safety %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wthread-safety -std=c++98 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wthread-safety -std=c++11 %s
 
 #define LOCKABLE            __attribute__ ((lockable))
 #define SCOPED_LOCKABLE     __attribute__ ((scoped_lockable))
@@ -1266,8 +1268,11 @@ public:
   void foo3(FooLate *f) EXCLUSIVE_LOCKS_REQUIRED(f->mu) { }
   void foo4(FooLate *f) EXCLUSIVE_LOCKS_REQUIRED(f->mu);
 
-  static void foo5()    EXCLUSIVE_LOCKS_REQUIRED(mu); // \
-    // expected-error {{invalid use of member 'mu' in static member function}}
+  static void foo5()    EXCLUSIVE_LOCKS_REQUIRED(mu);
+//FIXME: Bug 32066 - Error should be emitted irrespective of C++ dialect
+#if __cplusplus <= 199711L
+  // expected-error at -3 {{invalid use of member 'mu' in static member function}}
+#endif
 
   template <class T>
   void foo6() EXCLUSIVE_LOCKS_REQUIRED(T::statmu) { }
@@ -1461,15 +1466,24 @@ class Foo {
   mutable Mutex mu;
   int a GUARDED_BY(mu);
 
-  static int si GUARDED_BY(mu); // \
-    // expected-error {{invalid use of non-static data member 'mu'}}
+  static int si GUARDED_BY(mu);
+//FIXME: Bug 32066 - Error should be emitted irrespective of C++ dialect
+#if __cplusplus <= 199711L
+  // expected-error at -3 {{invalid use of non-static data member 'mu'}}
+#endif
 
-  static void foo() EXCLUSIVE_LOCKS_REQUIRED(mu); // \
-    // expected-error {{invalid use of member 'mu' in static member function}}
+  static void foo() EXCLUSIVE_LOCKS_REQUIRED(mu);
+//FIXME: Bug 32066 - Error should be emitted irrespective of C++ dialect
+#if __cplusplus <= 199711L
+  // expected-error at -3 {{invalid use of member 'mu' in static member function}}
+#endif
 
   friend FooStream& operator<<(FooStream& s, const Foo& f)
-    EXCLUSIVE_LOCKS_REQUIRED(mu); // \
-    // expected-error {{invalid use of non-static data member 'mu'}}
+    EXCLUSIVE_LOCKS_REQUIRED(mu);
+//FIXME: Bug 32066 - Error should be emitted irrespective of C++ dialect
+#if __cplusplus <= 199711L
+    // expected-error at -3 {{invalid use of non-static data member 'mu'}}
+#endif
 };
 
 




More information about the cfe-commits mailing list