[PATCH] D21626: Lit C++11 Compatibility Patch #10
This revision was automatically updated to reflect the committed changes. Closed by commit rL296193: [Test] Make Lit tests C++11 compatible #10 (authored by lcharles). Changed prior to commit: https://reviews.llvm.org/D21626?vs=89736=89737#toc Repository: rL LLVM https://reviews.llvm.org/D21626 Files: 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 Index: cfe/trunk/test/SemaCXX/warn-thread-safety-parsing.cpp === --- cfe/trunk/test/SemaCXX/warn-thread-safety-parsing.cpp +++ cfe/trunk/test/SemaCXX/warn-thread-safety-parsing.cpp @@ -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 @@ 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@-3 {{invalid use of member 'mu' in static member function}} +#endif template void foo6() EXCLUSIVE_LOCKS_REQUIRED(T::statmu) { } @@ -1461,15 +1466,24 @@ 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@-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@-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@-3 {{invalid use of non-static data member 'mu'}} +#endif }; Index: cfe/trunk/test/SemaCXX/default-constructor-initializers.cpp === --- cfe/trunk/test/SemaCXX/default-constructor-initializers.cpp +++ cfe/trunk/test/SemaCXX/default-constructor-initializers.cpp @@ -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@-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@-2 {{implicit default constructor for 'X3' must explicitly initialize the base class 'X2' which does not have a default constructor}} +#else +// expected-note@-4 {{default constructor of 'X3' is implicitly deleted because base class 'X2' has no default constructor}} +#endif +}; + +X3 x3; +#if __cplusplus <= 199711L +// expected-note@-2 {{first required here}} +#else +// expected-error@-4 {{call to implicitly-deleted default constructor of 'X3'}} +#endif + +struct X4 { +#if __cplusplus <= 199711L +// expected-error@-2 {{must explicitly initialize the member 'x2'}} +// expected-error@-3 {{must explicitly initialize the reference member 'rx2'}} +#endif + + X2 x2; +#if
[PATCH] D21626: Lit C++11 Compatibility Patch #10
tigerleapgorge marked 2 inline comments as done. tigerleapgorge added inline comments. Comment at: test/SemaCXX/PR9572.cpp:34 +// expected-error@-2 {{non-deleted function '~Bar' cannot override a deleted function}} +// expected-note@-3 {{while declaring the implicit destructor for 'Bar'}} +#endif Clang added this note quite recently. https://reviews.llvm.org/D21626 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D21626: Lit C++11 Compatibility Patch #10
tigerleapgorge updated this revision to Diff 89736. tigerleapgorge added a comment. Updated patch in accordance to Richard Smith's comments. https://reviews.llvm.org/D21626 Files: test/Modules/Inputs/merge-using-decls/b.h test/Modules/merge-using-decls.cpp test/SemaCXX/PR9572.cpp test/SemaCXX/default-assignment-operator.cpp test/SemaCXX/default-constructor-initializers.cpp test/SemaCXX/warn-thread-safety-parsing.cpp Index: test/SemaCXX/warn-thread-safety-parsing.cpp === --- test/SemaCXX/warn-thread-safety-parsing.cpp +++ test/SemaCXX/warn-thread-safety-parsing.cpp @@ -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 @@ 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@-3 {{invalid use of member 'mu' in static member function}} +#endif template void foo6() EXCLUSIVE_LOCKS_REQUIRED(T::statmu) { } @@ -1461,15 +1466,24 @@ 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@-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@-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@-3 {{invalid use of non-static data member 'mu'}} +#endif }; Index: test/SemaCXX/default-constructor-initializers.cpp === --- test/SemaCXX/default-constructor-initializers.cpp +++ test/SemaCXX/default-constructor-initializers.cpp @@ -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@-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@-2 {{implicit default constructor for 'X3' must explicitly initialize the base class 'X2' which does not have a default constructor}} +#else +// expected-note@-4 {{default constructor of 'X3' is implicitly deleted because base class 'X2' has no default constructor}} +#endif +}; + +X3 x3; +#if __cplusplus <= 199711L +// expected-note@-2 {{first required here}} +#else +// expected-error@-4 {{call to implicitly-deleted default constructor of 'X3'}} +#endif + +struct X4 { +#if __cplusplus <= 199711L +// expected-error@-2 {{must explicitly initialize the member 'x2'}} +// expected-error@-3 {{must explicitly initialize the reference member 'rx2'}} +#endif + + X2 x2; +#if __cplusplus <= 199711L + // expected-note@-2 {{member is declared here}} +#else + // expected-note@-4 {{default constructor of 'X4' is implicitly deleted because field 'x2' has no default constructor}} +#endif + + X2 & rx2; +#if __cplusplus <=
[PATCH] D21626: Lit C++11 Compatibility Patch #10
rsmith accepted this revision. rsmith added a comment. This revision is now accepted and ready to land. LGTM with a couple of changes. Comment at: test/Modules/Inputs/merge-using-decls/a.h:25 +#if __cplusplus <= 199711L // C++11 does not allow access declerations template struct E : X, T { I don't see a reason to `#ifdef` this portion, which should work either way, and likewise for the other change to this file. (The changes to the other header and to the cpp file look fine and appropriate, though.) Comment at: test/SemaCXX/warn-thread-safety-parsing.cpp:1273 +#if __cplusplus <= 199711L + // expected-error@-2 {{invalid use of member 'mu' in static member function}} +#endif Please add FIXMEs to this test. These cases are not supposed to be permitted. https://reviews.llvm.org/D21626 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D21626: Lit C++11 Compatibility Patch #10
tigerleapgorge updated this revision to Diff 88232. tigerleapgorge edited the summary of this revision. tigerleapgorge added a comment. Remove 2 tests reviewed in https://reviews.llvm.org/D29685 https://reviews.llvm.org/D21626 Files: test/Modules/Inputs/merge-using-decls/a.h test/Modules/Inputs/merge-using-decls/b.h test/Modules/merge-using-decls.cpp test/SemaCXX/PR9572.cpp test/SemaCXX/default-assignment-operator.cpp test/SemaCXX/default-constructor-initializers.cpp test/SemaCXX/warn-thread-safety-parsing.cpp Index: test/SemaCXX/warn-thread-safety-parsing.cpp === --- test/SemaCXX/warn-thread-safety-parsing.cpp +++ test/SemaCXX/warn-thread-safety-parsing.cpp @@ -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,10 @@ 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); +#if __cplusplus <= 199711L + // expected-error@-2 {{invalid use of member 'mu' in static member function}} +#endif template void foo6() EXCLUSIVE_LOCKS_REQUIRED(T::statmu) { } @@ -1461,15 +1465,21 @@ 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); +#if __cplusplus <= 199711L + // expected-error@-2 {{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); +#if __cplusplus <= 199711L + // expected-error@-2 {{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); +#if __cplusplus <= 199711L +// expected-error@-2 {{invalid use of non-static data member 'mu'}} +#endif }; Index: test/SemaCXX/default-constructor-initializers.cpp === --- test/SemaCXX/default-constructor-initializers.cpp +++ test/SemaCXX/default-constructor-initializers.cpp @@ -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@-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@-2 {{implicit default constructor for 'X3' must explicitly initialize the base class 'X2' which does not have a default constructor}} +#else +// expected-note@-4 {{default constructor of 'X3' is implicitly deleted because base class 'X2' has no default constructor}} +#endif +}; + +X3 x3; +#if __cplusplus <= 199711L +// expected-note@-2 {{first required here}} +#else +// expected-error@-4 {{call to implicitly-deleted default constructor of 'X3'}} +#endif + +struct X4 { +#if __cplusplus <= 199711L +// expected-error@-2 {{must explicitly initialize the member 'x2'}} +// expected-error@-3 {{must explicitly initialize the reference member 'rx2'}} +#endif + + X2 x2; +#if __cplusplus <= 199711L + // expected-note@-2 {{member is declared here}} +#else + // expected-note@-4 {{default constructor of 'X4' is implicitly deleted because field 'x2' has no default constructor}} +#endif + + X2 & rx2; +#if __cplusplus <= 199711L + // expected-note@-2 {{declared here}} +#endif +}; + +X4 x4; +#if __cplusplus <= 199711L +// expected-note@-2 {{first required here}} +#else +// expected-error@-4 {{call to
[PATCH] D21626: Lit C++11 Compatibility Patch #10
tigerleapgorge updated this revision to Diff 87711. tigerleapgorge edited the summary of this revision. tigerleapgorge added a comment. Remove 2 OpenMP tests reviewed via https://reviews.llvm.org/D29725 https://reviews.llvm.org/D21626 Files: test/Modules/Inputs/merge-using-decls/a.h test/Modules/Inputs/merge-using-decls/b.h test/Modules/merge-using-decls.cpp test/SemaCXX/PR9572.cpp test/SemaCXX/default-assignment-operator.cpp test/SemaCXX/default-constructor-initializers.cpp test/SemaCXX/format-strings.cpp test/SemaCXX/printf-cstr.cpp test/SemaCXX/warn-thread-safety-parsing.cpp Index: test/SemaCXX/warn-thread-safety-parsing.cpp === --- test/SemaCXX/warn-thread-safety-parsing.cpp +++ test/SemaCXX/warn-thread-safety-parsing.cpp @@ -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,10 @@ 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); +#if __cplusplus <= 199711L + // expected-error@-2 {{invalid use of member 'mu' in static member function}} +#endif template void foo6() EXCLUSIVE_LOCKS_REQUIRED(T::statmu) { } @@ -1461,15 +1465,21 @@ 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); +#if __cplusplus <= 199711L + // expected-error@-2 {{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); +#if __cplusplus <= 199711L + // expected-error@-2 {{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); +#if __cplusplus <= 199711L +// expected-error@-2 {{invalid use of non-static data member 'mu'}} +#endif }; Index: test/SemaCXX/printf-cstr.cpp === --- test/SemaCXX/printf-cstr.cpp +++ test/SemaCXX/printf-cstr.cpp @@ -1,4 +1,6 @@ // RUN: %clang_cc1 -fsyntax-only -Wformat -verify %s -Wno-error=non-pod-varargs +// RUN: %clang_cc1 -fsyntax-only -Wformat -verify -std=c++98 %s -Wno-error=non-pod-varargs +// RUN: %clang_cc1 -fsyntax-only -Wformat -verify -std=c++11 %s -Wno-error=non-pod-varargs #include @@ -31,12 +33,39 @@ int n = 10; printf("%d: %s\n", n, hcs.c_str()); - printf("%d: %s\n", n, hcs); // expected-warning{{cannot pass non-POD object of type 'HasCStr' to variadic function; expected type from format string was 'char *'}} expected-note{{did you mean to call the c_str() method?}} - printf("%d: %s\n", n, hncs); // expected-warning{{cannot pass non-POD object of type 'HasNoCStr' to variadic function; expected type from format string was 'char *'}} - sprintf(str, "%d: %s", n, hcs); // expected-warning{{cannot pass non-POD object of type 'HasCStr' to variadic function; expected type from format string was 'char *'}} expected-note{{did you mean to call the c_str() method?}} - - printf(formatString, hcs, hncs); // expected-warning{{cannot pass object of non-POD type 'HasCStr' through variadic function}} expected-warning{{cannot pass object of non-POD type 'HasNoCStr' through variadic function}} - printf(extstr, hcs, n); // expected-warning{{cannot pass object of non-POD type 'HasCStr' through variadic function}} + printf("%d: %s\n", n, hcs); +#if __cplusplus <= 199711L + // expected-warning@-2 {{cannot pass non-POD object of type 'HasCStr' to variadic function; expected type from format string was 'char *'}} + // expected-note@-3 {{did you mean to call the c_str() method?}} +#else + // expected-warning@-5 {{format specifies type 'char *' but the argument has type 'HasCStr'}} +#endif + + printf("%d: %s\n", n, hncs); +#if __cplusplus <= 199711L + // expected-warning@-2 {{cannot pass non-POD object of type 'HasNoCStr' to variadic function; expected type from format string was 'char *'}} +#else + // expected-warning@-4 {{format specifies type 'char *' but the argument has type 'HasNoCStr'}} +#endif + + sprintf(str, "%d: %s", n, hcs); +#if __cplusplus <= 199711L + // expected-warning@-2 {{cannot pass non-POD object of type 'HasCStr' to
[PATCH] D21626: Lit C++11 Compatibility Patch #10
tigerleapgorge updated this revision to Diff 87312. tigerleapgorge added a comment. Remove 2 tests reviewed under https://reviews.llvm.org/D29520. https://reviews.llvm.org/D21626 Files: test/Modules/Inputs/merge-using-decls/a.h test/Modules/Inputs/merge-using-decls/b.h test/Modules/merge-using-decls.cpp test/OpenMP/declare_reduction_messages.cpp test/OpenMP/openmp_check.cpp test/SemaCXX/PR9572.cpp test/SemaCXX/default-assignment-operator.cpp test/SemaCXX/default-constructor-initializers.cpp test/SemaCXX/format-strings.cpp test/SemaCXX/printf-cstr.cpp test/SemaCXX/warn-thread-safety-parsing.cpp Index: test/SemaCXX/warn-thread-safety-parsing.cpp === --- test/SemaCXX/warn-thread-safety-parsing.cpp +++ test/SemaCXX/warn-thread-safety-parsing.cpp @@ -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,10 @@ 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); +#if __cplusplus <= 199711L + // expected-error@-2 {{invalid use of member 'mu' in static member function}} +#endif template void foo6() EXCLUSIVE_LOCKS_REQUIRED(T::statmu) { } @@ -1461,15 +1465,21 @@ 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); +#if __cplusplus <= 199711L + // expected-error@-2 {{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); +#if __cplusplus <= 199711L + // expected-error@-2 {{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); +#if __cplusplus <= 199711L +// expected-error@-2 {{invalid use of non-static data member 'mu'}} +#endif }; Index: test/SemaCXX/printf-cstr.cpp === --- test/SemaCXX/printf-cstr.cpp +++ test/SemaCXX/printf-cstr.cpp @@ -1,4 +1,6 @@ // RUN: %clang_cc1 -fsyntax-only -Wformat -verify %s -Wno-error=non-pod-varargs +// RUN: %clang_cc1 -fsyntax-only -Wformat -verify -std=c++98 %s -Wno-error=non-pod-varargs +// RUN: %clang_cc1 -fsyntax-only -Wformat -verify -std=c++11 %s -Wno-error=non-pod-varargs #include @@ -31,12 +33,39 @@ int n = 10; printf("%d: %s\n", n, hcs.c_str()); - printf("%d: %s\n", n, hcs); // expected-warning{{cannot pass non-POD object of type 'HasCStr' to variadic function; expected type from format string was 'char *'}} expected-note{{did you mean to call the c_str() method?}} - printf("%d: %s\n", n, hncs); // expected-warning{{cannot pass non-POD object of type 'HasNoCStr' to variadic function; expected type from format string was 'char *'}} - sprintf(str, "%d: %s", n, hcs); // expected-warning{{cannot pass non-POD object of type 'HasCStr' to variadic function; expected type from format string was 'char *'}} expected-note{{did you mean to call the c_str() method?}} - - printf(formatString, hcs, hncs); // expected-warning{{cannot pass object of non-POD type 'HasCStr' through variadic function}} expected-warning{{cannot pass object of non-POD type 'HasNoCStr' through variadic function}} - printf(extstr, hcs, n); // expected-warning{{cannot pass object of non-POD type 'HasCStr' through variadic function}} + printf("%d: %s\n", n, hcs); +#if __cplusplus <= 199711L + // expected-warning@-2 {{cannot pass non-POD object of type 'HasCStr' to variadic function; expected type from format string was 'char *'}} + // expected-note@-3 {{did you mean to call the c_str() method?}} +#else + // expected-warning@-5 {{format specifies type 'char *' but the argument has type 'HasCStr'}} +#endif + + printf("%d: %s\n", n, hncs); +#if __cplusplus <= 199711L + // expected-warning@-2 {{cannot pass non-POD object of type 'HasNoCStr' to variadic function; expected type from format string was 'char *'}} +#else + // expected-warning@-4 {{format specifies type 'char *' but the argument has type 'HasNoCStr'}} +#endif + + sprintf(str, "%d: %s", n, hcs); +#if __cplusplus <= 199711L + // expected-warning@-2 {{cannot pass non-POD object of
[PATCH] D21626: Lit C++11 Compatibility Patch #10
tigerleapgorge updated this revision to Diff 81817. tigerleapgorge added a comment. Previous update contain typos in the RUN lines of test/SemaCXX/virtual-base-used.cpp This has been corrected in this latest revision. https://reviews.llvm.org/D21626 Files: test/Modules/Inputs/merge-using-decls/a.h test/Modules/Inputs/merge-using-decls/b.h test/Modules/merge-using-decls.cpp test/OpenMP/declare_reduction_messages.cpp test/OpenMP/openmp_check.cpp test/SemaCXX/MicrosoftExtensions.cpp test/SemaCXX/PR9572.cpp test/SemaCXX/default-assignment-operator.cpp test/SemaCXX/default-constructor-initializers.cpp test/SemaCXX/format-strings.cpp test/SemaCXX/printf-cstr.cpp test/SemaCXX/virtual-base-used.cpp test/SemaCXX/warn-thread-safety-parsing.cpp Index: test/SemaCXX/warn-thread-safety-parsing.cpp === --- test/SemaCXX/warn-thread-safety-parsing.cpp +++ test/SemaCXX/warn-thread-safety-parsing.cpp @@ -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,10 @@ 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); +#if __cplusplus <= 199711L + // expected-error@-2 {{invalid use of member 'mu' in static member function}} +#endif template void foo6() EXCLUSIVE_LOCKS_REQUIRED(T::statmu) { } @@ -1461,15 +1465,21 @@ 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); +#if __cplusplus <= 199711L + // expected-error@-2 {{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); +#if __cplusplus <= 199711L + // expected-error@-2 {{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); +#if __cplusplus <= 199711L +// expected-error@-2 {{invalid use of non-static data member 'mu'}} +#endif }; Index: test/SemaCXX/virtual-base-used.cpp === --- test/SemaCXX/virtual-base-used.cpp +++ test/SemaCXX/virtual-base-used.cpp @@ -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@-2 3 {{declared private here}} #ifdef MSABI -// expected-note@+2 3 {{declared private here}} +// expected-note@-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@-2 3 {{overridden virtual function is here}} +#endif }; +struct B : public virtual A { +#if __cplusplus >= 201103L +// expected-error@-2 {{deleted function '~B' cannot override a non-deleted function}} +// expected-note@-3 {{overridden virtual function is here}} +#endif + + NoDestroy x; +#if __cplusplus <= 199711L + // expected-error@-2 {{field of type 'NoDestroy' has private destructor}} #ifdef MSABI -// expected-error@+3 {{field of type 'NoDestroy' has private destructor}} + // expected-error@-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@-7 {{destructor of 'B' is implicitly deleted because field 'x' has an inaccessible destructor}} #ifdef MSABI -// expected-note@+3 {{implicit default constructor for 'B' first required here}} -//
[PATCH] D21626: Lit C++11 Compatibility Patch #10
tigerleapgorge updated this revision to Diff 81810. tigerleapgorge added a comment. Update patch to match latest Clang C++11 diagnostics. 2 tests are changed. test/SemaCXX/PR9572.cpp Expect the following additional Note following existing Error. destructor of 'Foo' is implicitly deleted because base class 'Base' has an inaccessible destructor test/SemaCXX/virtual-base-used.cpp Expect the following additional Notes following existing Errors. destructor of 'B' is implicitly deleted because field 'x' has an inaccessible destructor destructor of 'E' is implicitly deleted because field 'x' has an inaccessible destructor destructor of 'H' is implicitly deleted because field 'x' has an inaccessible destructor https://reviews.llvm.org/D21626 Files: test/Modules/Inputs/merge-using-decls/a.h test/Modules/Inputs/merge-using-decls/b.h test/Modules/merge-using-decls.cpp test/OpenMP/declare_reduction_messages.cpp test/OpenMP/openmp_check.cpp test/SemaCXX/MicrosoftExtensions.cpp test/SemaCXX/PR9572.cpp test/SemaCXX/default-assignment-operator.cpp test/SemaCXX/default-constructor-initializers.cpp test/SemaCXX/format-strings.cpp test/SemaCXX/printf-cstr.cpp test/SemaCXX/virtual-base-used.cpp test/SemaCXX/warn-thread-safety-parsing.cpp Index: test/SemaCXX/warn-thread-safety-parsing.cpp === --- test/SemaCXX/warn-thread-safety-parsing.cpp +++ test/SemaCXX/warn-thread-safety-parsing.cpp @@ -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,10 @@ 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); +#if __cplusplus <= 199711L + // expected-error@-2 {{invalid use of member 'mu' in static member function}} +#endif template void foo6() EXCLUSIVE_LOCKS_REQUIRED(T::statmu) { } @@ -1461,15 +1465,21 @@ 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); +#if __cplusplus <= 199711L + // expected-error@-2 {{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); +#if __cplusplus <= 199711L + // expected-error@-2 {{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); +#if __cplusplus <= 199711L +// expected-error@-2 {{invalid use of non-static data member 'mu'}} +#endif }; Index: test/SemaCXX/virtual-base-used.cpp === --- test/SemaCXX/virtual-base-used.cpp +++ test/SemaCXX/virtual-base-used.cpp @@ -1,89 +1,215 @@ -// RUN: %clang_cc1 -fsyntax-only -triple %itanium_abi_triple -verify %s -// RUN: %clang_cc1 -fsyntax-only -triple %ms_abi_triple -DMSABI -verify %s +// UN: %clang_cc1 -fsyntax-only -triple %itanium_abi_triple -verify %s +// UN: %clang_cc1 -fsyntax-only -triple %itanium_abi_triple -verify -std=c++98 %s +// UN: %clang_cc1 -fsyntax-only -triple %itanium_abi_triple -verify -std=c++11 %s +// UN: %clang_cc1 -fsyntax-only -triple %ms_abi_triple -DMSABI -verify %s +// UN: %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@-2 3 {{declared private here}} #ifdef MSABI -// expected-note@+2 3 {{declared private here}} +// expected-note@-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@-2 3 {{overridden virtual function is here}} +#endif }; +struct B : public virtual A { +#if __cplusplus >= 201103L +// expected-error@-2 {{deleted function '~B' cannot override a non-deleted function}} +// expected-note@-3 {{overridden virtual
[PATCH] D21626: Lit C++11 Compatibility Patch #10
tigerleapgorge created this revision. tigerleapgorge added a reviewer: rsmith. tigerleapgorge added a subscriber: cfe-commits. Hi Everyone, I am continuing with updating the Lit tests for C++11 compatibility. 11 tests this time. test/Modules/Inputs/merge-using-decls/a.h test/Modules/Inputs/merge-using-decls/b.h test/Modules/merge-using-decls.cpp This test verifies the interaction between Modules and Using declarations. Part of this test, template struct “E” checks for mismatch between using declarations in a.h and Access declarations in b.h. Since C++11 has deprecated Access declarations, module “B” will fail to build. Therefore, I have restricted this part of the test to only use C++98. test/OpenMP/declare_reduction_messages.cpp In C++11, an opening square bracket is the start of a lambda capture. Therefore, a unmatched opening square bracket will cause the following diagnostics change. C++98: error: expected '(' after 'initializer' error: expected expression warning: extra tokens at the end of '#pragma omp declare reduction' are ignored [-Wextra-tokens] C++11: error: expected '(' after 'initializer' error: expected variable name or 'this' in lambda capture list error: expected ')' note: to match this '(' test/OpenMP/openmp_check.cpp This test is created in response to bug 25221, where C++11 code running under C++98 causes the parser to go into an infinite loop. Since this is C++11 code, all expected diagnostics will go away when compiling at C++11. Therefore, guard all of the following diagnostics under C++98. C++98: warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions] error: expected expression error: expected ';' at end of declaration C++98: error: C++ requires a type specifier for all declarations C++98: error: expected unqualified-id C++98: error: extraneous closing brace ('}') test/SemaCXX/MicrosoftExtensions.cpp This test checks for Microsoft extensions. Portions of this test check for unsupported C++11 features when compiling at C++98. Guard all such diagnostics under C++98. Base destructor being marked with “throw()”, derived destructor is not. This no longer results in the following diagnostics in C++11. C++98: warning: exception specification of overriding function is more lax than base version [-Wmicrosoft-exception-spec] note: overridden virtual function is here Enum with underlying type is now supported in C++11. Guard the following under C++98. C++98: warning: enumeration types with a fixed underlying type are a C++11 extension [-Wc++11-extensions] C++98: warning: enumeration types with a fixed underlying type are a C++11 extension [-Wc++11-extensions] “override” is now supported in C++11. Guard the following under C++98. C++98: warning: 'override' keyword is a C++11 extension [-Wc++11-extensions] test/SemaCXX/PR9572.cpp This test verifies 2 types of diagnostics. Type 1: Warning for unsupported C++11 feature when compiling at C++98. Guard the following Warning under C++98. C++98: warning: in-class initialization of non-static data member is a C++11 extension [-Wc++11-extensions] Type 2: Errors when derived class inherit a private virtual destructor in the base class. Class Base has a private virtual destructor. Struct Foo inherits Base. Foo does not explicitly declare a destructor. Struct Bar inherits Foo. Bar explicitly declares a destructor. Struct Baz contains an instance of Foo as its member. Because C++11 introduced ‘delete’, this results in the following changes in diagnostics. C++98 issues 1 Error on Base’s private destructor. C++11 issues 4 Errors at all points of the inheritance chain where the destructor is implicitly deleted. C++98: error: base class 'Base' has private destructor note: implicitly declared private here note: implicit destructor for 'Foo' first required here C++11: error: deleted function '~Foo' cannot override a non-deleted function note: overridden virtual function is here C++11: error: non-deleted function '~Bar' cannot override a deleted function note: overridden virtual function is here C++11: error: attempt to use a deleted function note: destructor of 'Foo' is implicitly deleted because base class 'Base' has an inaccessible destructor C++11: error: attempt to use a deleted function note: destructor of 'Foo' is implicitly deleted because base class 'Base' has an inaccessible destructor test/SemaCXX/default-assignment-operator.cpp C++11 introduced ‘delete’. Change in diagnostics regarding implicitly deleted copy assignment operator. This test change contains 3 parts: Test1, Test5, ProtectedCheck. Test1 Class Base has a member “int ” that is never initialized. Class X is derived from Base. Neither Base nor X