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 &ref” that is never initialized.
Class X is derived from Base.
Neither Base nor X explicitly declare their copy assignment operator.
In C++98, Clang issues one error for each implicit class copy assignment
operator definition failure (“Base” and “X”).
In C++11, Clang issues one error for each assignment statement of the class
instance. (“x = cx;” and “x = cx;”)
And since there are 2 copy assignments of x, there are 2 sets of
identical diagnostics in C++11.
C++98: error: cannot define the implicit copy assignment operator for
'Base', because non-static reference member 'ref' cannot use copy assignment
operator
note: declared here
note: implicit copy assignment operator for 'Base' first required
here
error: cannot define the implicit copy assignment operator for
'X', because non-static const member 'cint' cannot use copy assignment operator
note: declared here
note: implicit copy assignment operator for 'X' first required here
C++11: error: object of type 'X' cannot be assigned because its copy
assignment operator is implicitly deleted
note: copy assignment operator of 'X' is implicitly deleted
because base class 'Base' has a deleted copy assignment operator
note: copy assignment operator of 'Base' is implicitly deleted
because field 'ref' is of reference type 'int &'
error: object of type 'X' cannot be assigned because its copy
assignment operator is implicitly deleted
note: copy assignment operator of 'X' is implicitly deleted
because base class 'Base' has a deleted copy assignment operator
note: copy assignment operator of 'Base' is implicitly deleted
because field 'ref' is of reference type 'int &'
Test5
Class E1 has a constant integer member ‘a’. E1 has a default constructor
“E1() : a(0) {}”.
Two instances of E1 are created, e1 and e2. e2 is assigned to e1.
Change in diagnostics messages.
C++98: error: cannot define the implicit copy assignment operator for
'E1', because non-static const member 'a' cannot use copy assignment operator
note: declared here
note: implicit copy assignment operator for 'E1' first required
here
C++11: error: object of type 'E1' cannot be assigned because its copy
assignment operator is implicitly deleted
note: copy assignment operator of 'E1' is implicitly deleted
because field 'a' is of const-qualified type 'const int'
ProtectedCheck
Class X has a protected copy assignment operator.
Struct Z contains an instance of X.
An instance of Z, z, is copy assigned to itself (z = z).
C++98 and C++11 issues different diagnostics.
C++98: error: 'operator=' is a protected member of 'ProtectedCheck::X'
note: declared protected here
note: implicit copy assignment operator for 'ProtectedCheck::Z'
first required here
C++11: error: object of type 'ProtectedCheck::Z' cannot be assigned
because its copy assignment operator is implicitly deleted
note: copy assignment operator of 'Z' is implicitly deleted
because field 'x' has an inaccessible copy assignment operator
test/SemaCXX/default-constructor-initializers.cpp
C++11 introduced ‘delete’.
As a result, implicitly deleted default constructor diagnostics changed.
http://en.cppreference.com/w/cpp/language/default_constructor
Part 1
X1 has no implicitly default constructor.
X2 inherits X1.
X3 inherits X2.
X3 is instantiated.
C++98: error: implicit default constructor for 'X3' must explicitly
initialize the base class 'X2' which does not have a default constructor
note: 'X2' declared here
note: implicit default constructor for 'X3' first required here
C++11: error: call to implicitly-deleted default constructor of 'X3'
note: default constructor of 'X3' is implicitly deleted because base
class 'X2' has no default constructor
Part 2.
X4 contains an instance of X2 and a reference of X2.
C++98 issues 2 Errors, one for each member of the class.
C++11 issues 1 Error, for the instantiation of the class.
C++98: error: implicit default constructor for 'X4' must explicitly
initialize the member 'x2' which does not have a default constructor
note: member is declared here
note: 'X2' declared here
C++98: error: implicit default constructor for 'X4' must explicitly
initialize the reference member 'rx2'
note: declared here
note: implicit default constructor for 'X4' first required here
C++11: error: call to implicitly-deleted default constructor of 'X4'
note: default constructor of 'X4' is implicitly deleted because
field 'x2' has no default constructor
Part 3.
Z1 has 3 members: integer reference z, constant integer c1 and volatile
integer v1.
None of which are explicitly initialized.
Therefore, Z1 has no implicitly default constructor.
C++98 issues 2 Errors. One for the integer reference member. One for the
constant integer member.
C++11 issues 1 Error for the instantiation of the class.
C++98: error: implicit default constructor for 'Z1' must explicitly
initialize the reference member 'z'
note: declared here
error: implicit default constructor for 'Z1' must explicitly
initialize the const member 'c1'
note: declared here
note: implicit default constructor for 'Z1' first required here
C++11: error: call to implicitly-deleted default constructor of 'Z1'
note: default constructor of 'Z1' is implicitly deleted because
field 'z' of reference type 'int &' would not be initialized
test/SemaCXX/format-strings.cpp
This test verifies format specifiers.
This test contains 2 parts.
Part 1.
C++11 added Scanf floating-point format specifier “a”.
http://en.cppreference.com/w/c/io/fscanf
The Scanf format specifier “%as” expects type “float *”. However, the actual
argument is type “char **”.
Change in diagnostics.
C++98: warning: 'a' length modifier is not supported by ISO C
[-Wformat-non-iso]
C++11: warning: format specifies type 'float *' but the argument has type
'char **' [-Wformat]
Part 2.
Function test_null_format() expects a const char * as its first formal
argument,
but is instead given a Boolean literal as its first actual argument.
Type conversion from const bool to const char * is a Warning in C++98, but an
Error in C++11.
Change in diagnostics.
C++98: warning: initialization of pointer of type 'const char *' to null
from a constant boolean expression [-Wbool-conversion]
C++11: error: no matching function for call to 'test_null_format'
note: candidate function not viable: no known conversion from 'bool'
to 'const char *' for 1st argument
test/SemaCXX/printf-cstr.cpp
This tests verifies type mismatches between printf format specifiers and the
type of the actual arguments.
This test change contains 4 parts.
Diagnostics changed for mismatch between “%s” and actual arguments of non-POD
class instance.
In C++98, non-POD objects are not allowed as variadic arguments.
In C++11, non-POD is allowed (5.2.2/7).
However, since the format specifier %s expects a char pointer not
an object, Clang will issue a Warning on that.
If the class has a c_str() method, Clang will issue a accompanying
Note to prompt the use to invoke it.
Part 1
A class object that has a c_str() method is passed in.
In C++98, Clang issues a Warning and an accompanying Note.
In C++11, Clang issues a Warning.
Expect the following change in diagnostics. (3 instances)
C++98: warning: cannot pass non-POD object of type 'HasCStr' to variadic
constructor; expected type from format string was 'char *' [-Wnon-pod-varargs]
note: did you mean to call the c_str() method?
C++11: warning: format specifies type 'char *' but the argument has type
'HasCStr' [-Wformat]
Part 2
A class object that does not have a c_str() method is passed in.
The accompanying note prompting the user to use the c_str() has no reason be
there.
Change in Warning diagnostics. (1 instance)
C++98: warning: cannot pass non-POD object of type 'HasNoCStr' to variadic
function; expected type from format string was 'char *' [-Wnon-pod-varargs]
C++11: warning: format specifies type 'char *' but the argument has type
'HasNoCStr' [-Wformat]
Part 3
printf format string is passed in as a pointer instead of a string literal.
In both C++98 and C++11, Clang is unable to determine type mismatch at
compile type.
However, in C++98, non-POD type is not allowed inside variadic arguments.(2
instances)
C++98: warning: cannot pass object of non-POD type 'HasCStr' through
variadic function; call will abort at runtime [-Wnon-pod-varargs]
C++11: (None)
Part 4
printf format string is passed in as a pointer instead of a string literal.
In both C++98 and C++11, Clang is unable to determine type mismatch at
compile type.
However, in C++98, non-POD type is not allowed inside variadic arguments. (1
instance)
C++98: warning: cannot pass object of non-POD type 'HasNoCStr' through
variadic function; call will abort at runtime [-Wnon-pod-varargs]
C++11: (None)
test/SemaCXX/virtual-base-used.cpp
The base class explicitly declares a public virtual destructor.
The derived class does not explicitly declare a destructor.
The derived class contains a member with an inaccessible private destructor.
In C++98, Clang Warns about the private destructor then gives a Note at class
instantiation (MSABI) or class method definition.
In C++11, The derived class having a member that can not be destroyed means
the derived class’s own implicit destructor is deleted.
Therefore, Clang issues an Error on the derived class’s deleted
destructor trying to overwrite base class’s non-deleted destructor.
Furthermore, Clang also issues Errors on classes further down the
inheritance chain with explicitly declared destructors trying to
overwrite first derived class’s implicitly deleted destructor.
This test is subdivide into three sections. Each section has its own
inheritance chain.
Section 1:
A is the base struct with a virtual destructor.
B derives from A. B has a member class instance ‘x’ with an inaccessible
destructor.
D derives from B. D has an explicitly declared destructor.
In C++98, Clang issues an Error about B’s x having no accessible
destructor.
In C++11, Clang issues 2 Errors.
First Error on B’s implicitly deleted destructor inheriting A’s
explicitly declared destructor.
Second Error on D’s explicitly declared destructor inheriting
B’s implicitly deleted destructor.
C++98: error: field of type 'NoDestroy' has private destructor
note: implicitly declared private 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
error: non-deleted function '~D' cannot override a deleted function
note: overridden virtual function is here
Section 2:
A is the base struct with a virtual destructor.
E derives A. E also has a member class instance x with no destructor.
F derives from E and has no explicitly declared destructor.
G derives from F and has an explicitly declared destructor.
In C++98, Clang issues an Error about E’s x having no accessible
destructor.
In C++11, Clang issues 3 Errors.
First Error about E’s implicitly deleted destructor inheriting
A’s explicitly declared destructor.
Second Error about F’s implicitly declared destructor
inheriting E’s implicitly deleted destructor.
Third Error about G’s explicitly declared destructor inheriting
F’s now implicitly deleted destructor.
C++98: error: field of type 'NoDestroy' has private destructor
note: implicitly declared private here
note: implicit destructor for 'E' first required here
C++11: error: deleted function '~E' cannot override a non-deleted function
note: overridden virtual function is here
error: non-deleted function '~F' cannot override a deleted function
note: overridden virtual function is here
error: non-deleted function '~G' cannot override a deleted function
note: overridden virtual function is here
Section 3:
A is a struct with a virtual destructor.
H derives from A. H has a member x with an inaccessible destructor.
I derives from H.
J derives from I. J has a member function foo() definition.
In C++98, Clang issues an error on the H’s member X having an private
destructor.
In C++11, Clang issues 2 errors.
First Error on H’s implicitly deleted destructor inheriting
A’s explicitly declared destructor.
Second Error on I’s explicitly declared destructor inheriting
H’s implicitly deleted destructor.
C++98: error: field of type 'NoDestroy' has private destructor
note: implicitly declared private here
note: implicit destructor for 'H' first required here
C++11: error: deleted function '~H' cannot override a non-deleted function
note: overridden virtual function is here
error: non-deleted function '~I' cannot override a deleted function
note: overridden virtual function is here
test/SemaCXX/warn-thread-safety-parsing.cpp
In C++11, does not issue Errors for thread safety attributes applied to
static members.
http://clang.llvm.org/docs/ThreadSafetyAnalysis.html
This may be a side effect of C++11’s relaxation on in-class member
initializers.
http://www.stroustrup.com/C++11FAQ.html#member-init
Restrict the following diagnostics to C++98. (2 instances each)
C++98: error: invalid use of non-static data member 'mu'
C++98: error: invalid use of member 'mu' in static member function
Cheers,
Charles Li
http://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 <class T>
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,212 @@
// 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
#ifdef MSABI
-// expected-note@+3 {{implicit default constructor for 'B' first required here}}
-// expected-note@+2 {{implicit destructor for 'B' first required here}}
+ // expected-note@-8 {{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@-3 {{implicit default constructor for 'B' first required here}}
+// expected-note@-4 {{implicit destructor for 'B' first required here}}
+#endif
+#else
+#ifdef MSABI
+// expected-note@-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@-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@-2 {{implicit default constructor for 'D' first required here}}
#else
-void D::foo() { // expected-note {{implicit destructor for 'B' first required here}}
+// expected-error@-4 {{call to implicitly-deleted default constructor of 'D'}}
+#endif
+#else
+void D::foo() {
+#if __cplusplus <= 199711L
+// expected-note@-2 {{implicit destructor for 'B' first required here}}
+#endif
}
#endif
+struct E : public virtual A {
+#if __cplusplus >= 201103L
+// expected-error@-2 {{deleted function '~E' 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 E : public virtual A {
- NoDestroy x; // expected-error {{field of type 'NoDestroy' has private destructor}}
-};
+#else
#ifdef MSABI
-// expected-note@+2 {{implicit default constructor for 'E' first required here}}
+ // expected-note@-8 {{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@-2 {{implicit destructor for 'E' first required here}}
#ifdef MSABI
-// expected-note@+2 {{implicit default constructor for 'F' first required here}}
+// expected-note@-4 {{implicit default constructor for 'E' first required here}}
+#endif
+#else
+// expected-error@-7 {{non-deleted function '~F' cannot override a deleted function}}
+// expected-note@-8 {{overridden virtual function is here}}
+#ifdef MSABI
+// expected-note@-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@-3 {{implicit default constructor for 'F' first required here}}
+#else
+// expected-note@-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@-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@-2 {{implicit default constructor for 'G' first required here}}
+#else
+// expected-error@-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@-2 {{implicit destructor for 'F' first required here}}
+#endif
}
#endif
+struct H : public virtual A {
+#if __cplusplus >= 201103L
+// expected-error@-2 {{deleted function '~H' cannot override a non-deleted function}}
+// expected-note@-3 {{overridden virtual function is here}}
+#else
#ifdef MSABI
-// expected-note@+3 {{'H' declared here}}
-// expected-error@+3 {{field of type 'NoDestroy' has private destructor}}
+// expected-note@-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@-2 {{field of type 'NoDestroy' has private destructor}}
#ifdef MSABI
-// expected-error@+3 {{implicit default constructor for 'I' must explicitly initialize the base class 'H' which does not have a default constructor}}
-// expected-note@+2 {{implicit destructor for 'H' first required here}}
+ // expected-error@-4 {{field of type 'NoDestroy' has private destructor}}
+#endif
+#else
+#ifdef MSABI
+ // expected-note@-8 {{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@-3 {{implicit default constructor for 'I' must explicitly initialize the base class 'H' which does not have a default constructor}}
+// expected-note@-4 {{implicit destructor for 'H' first required here}}
+#else
+// expected-note@-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@-2 {{non-deleted function '~I' cannot override a deleted function}}
+#endif
};
+
+struct J : public I {
#ifdef MSABI
-// expected-note@+3 {{implicit default constructor for 'H' first required here}}
-// expected-note@+2 {{implicit default constructor for 'I' first required here}}
+#if __cplusplus <= 199711L
+// expected-note@-3 {{implicit default constructor for 'H' first required here}}
+// expected-note@-4 {{implicit default constructor for 'I' first required here}}
+#else
+// expected-note@-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@-2 {{implicit default constructor for 'J' first required here}}
#else
-void J::foo() { // expected-note {{implicit destructor for 'H' first required here}}
+// expected-error@-4 {{call to implicitly-deleted default constructor of 'J'}}
+#endif
+
+#else
+void J::foo() {
+#if __cplusplus <= 199711L
+// expected-note@-2 {{implicit destructor for 'H' first required here}}
+#endif
}
#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 <stdarg.h>
@@ -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 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(formatString, hcs, hncs);
+#if __cplusplus <= 199711L
+ // expected-warning@-2 {{cannot pass object of non-POD type 'HasCStr' through variadic function}}
+ // expected-warning@-3 {{cannot pass object of non-POD type 'HasNoCStr' through variadic function}}
+#endif
+
+ printf(extstr, hcs, n);
+#if __cplusplus <= 199711L
+ // expected-warning@-2 {{cannot pass object of non-POD type 'HasCStr' through variadic function}}
+#endif
}
struct Printf {
@@ -49,5 +78,11 @@
const char str[] = "test";
HasCStr hcs(str);
Printf p("%s %d %s", str, 10, 10); // expected-warning {{format specifies type 'char *' but the argument has type 'int'}}
- Printf q("%s %d", hcs, 10); // expected-warning {{cannot pass non-POD object of type 'HasCStr' to variadic constructor; expected type from format string was 'char *'}} expected-note{{did you mean to call the c_str() method?}}
+ Printf q("%s %d", hcs, 10);
+#if __cplusplus <= 199711L
+ // expected-warning@-2 {{cannot pass non-POD object of type 'HasCStr' to variadic constructor; 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
}
Index: test/SemaCXX/format-strings.cpp
===================================================================
--- test/SemaCXX/format-strings.cpp
+++ test/SemaCXX/format-strings.cpp
@@ -1,4 +1,6 @@
// RUN: %clang_cc1 -fsyntax-only -verify -Wformat-nonliteral -Wformat-non-iso -fblocks %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wformat-nonliteral -Wformat-non-iso -fblocks -std=c++98 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wformat-nonliteral -Wformat-non-iso -fblocks -std=c++11 %s
#include <stdarg.h>
@@ -9,9 +11,13 @@
}
void f(char **sp, float *fp) {
- scanf("%as", sp); // expected-warning{{'a' length modifier is not supported by ISO C}}
+ scanf("%as", sp);
+#if __cplusplus <= 199711L
+ // expected-warning@-2 {{'a' length modifier is not supported by ISO C}}
+#else
+ // expected-warning@-4 {{format specifies type 'float *' but the argument has type 'char **'}}
+#endif
- // TODO: Warn that the 'a' conversion specifier is a C++11 feature.
printf("%a", 1.0);
scanf("%afoobar", fp);
}
@@ -46,11 +52,19 @@
// Test handling __null for format string literal checking.
extern "C" {
int test_null_format(const char *format, ...) __attribute__((__format__ (__printf__, 1, 2)));
+#if __cplusplus >= 201103L
+ // expected-note@-2 {{candidate function not viable: no known conversion from 'bool' to 'const char *' for 1st argument}}
+#endif
}
void rdar8269537(const char *f)
{
- test_null_format(false); // expected-warning {{null from a constant boolean}}
+ test_null_format(false);
+#if __cplusplus <= 199711L
+ // expected-warning@-2 {{null from a constant boolean}}
+#else
+ // expected-error@-4 {{no matching function for call to 'test_null_format'}}
+#endif
test_null_format(0); // no-warning
test_null_format(__null); // no-warning
test_null_format(f); // expected-warning {{not a string literal}}
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 implicitly-deleted default constructor of 'X4'}}
+#endif
struct Y1 { // has no implicit default constructor
Y1(int);
@@ -43,15 +76,33 @@
// 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@-2 {{must explicitly initialize the reference member 'z'}}
+// expected-error@-3 {{must explicitly initialize the const member 'c1'}}
+#endif
+
+ int& z;
+#if __cplusplus <= 199711L
+ // expected-note@-2 {{declared here}}
+#else
+ // expected-note@-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@-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@-2 {{first required here}}
+#else
+// expected-error@-4 {{call to implicitly-deleted default constructor of 'Z1'}}
+#endif
// Ensure that value initialization doesn't use trivial implicit constructors.
namespace PR7948 {
Index: test/SemaCXX/default-assignment-operator.cpp
===================================================================
--- test/SemaCXX/default-assignment-operator.cpp
+++ test/SemaCXX/default-assignment-operator.cpp
@@ -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@-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@-2 {{declared here}}
+#else
+ // expected-note@-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@-2 {{assignment operator for 'Base' first required here}}
+// expected-error@-3 {{cannot define the implicit copy assignment operator for 'X', because non-static const member 'cint' cannot use copy assignment operator}}
+#else
+// expected-note@-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@-2 {{declared here}}
+#endif
};
struct Y : X {
@@ -28,8 +46,17 @@
// 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@-2 {{assignment operator for 'X' first required here}}
+#else
+ // expected-error@-4 {{object of type 'X' cannot be assigned because its copy assignment operator is implicitly deleted}}
+#endif
+
+ x = cx;
+#if __cplusplus >= 201103L
+ // expected-error@-2 {{object of type 'X' cannot be assigned because its copy assignment operator is implicitly deleted}}
+#endif
z1 = z2;
}
@@ -73,36 +100,62 @@
// 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@-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@-2 {{declared here}}
+#else
+// expected-note@-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@-2 {{assignment operator for 'E1' first required here}}
+#else
+ // expected-error@-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@-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@-2 {{'operator=' is a protected member of 'ProtectedCheck::X'}}
+#endif
X x;
+#if __cplusplus >= 201103L
+ // expected-note@-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@-2 {{implicit copy assignment operator}}
+#else
+ // expected-error@-4 {{object of type 'ProtectedCheck::Z' cannot be assigned because its copy assignment operator is implicitly deleted}}
+#endif
}
namespace MultiplePaths {
Index: test/SemaCXX/PR9572.cpp
===================================================================
--- test/SemaCXX/PR9572.cpp
+++ test/SemaCXX/PR9572.cpp
@@ -1,15 +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
+
class Base {
- virtual ~Base(); // expected-note {{implicitly declared private here}}
+ virtual ~Base();
+#if __cplusplus <= 199711L
+ // expected-note@-2 {{implicitly declared private here}}
+#else
+ // expected-note@-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@-2 {{base class 'Base' has private destructor}}
+#else
+// expected-error@-4 {{deleted function '~Foo' cannot override a non-deleted function}}
+// expected-note@-5 {{overridden virtual function is here}}
+// expected-note@-6 2 {{destructor of 'Foo' is implicitly deleted because base class 'Base' has an inaccessible destructor}}
+#endif
+
+ const int kBlah = 3;
+#if __cplusplus <= 199711L
+ // expected-warning@-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@-2 {{non-deleted function '~Bar' cannot override a deleted function}}
+#endif
+ Bar() { }
+#if __cplusplus <= 199711L
+ // expected-note@-2 {{implicit destructor for 'Foo' first required here}}
+#else
+ // expected-error@-4 {{attempt to use a deleted function}}
+#endif
};
+
struct Baz {
Foo f;
Baz() { }
+#if __cplusplus >= 201103L
+ // expected-error@-2 {{attempt to use a deleted function}}
+#endif
};
Index: test/SemaCXX/MicrosoftExtensions.cpp
===================================================================
--- test/SemaCXX/MicrosoftExtensions.cpp
+++ test/SemaCXX/MicrosoftExtensions.cpp
@@ -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 @@
};
class A {
- virtual ~A() throw(); // expected-note {{overridden virtual function is here}}
+ virtual ~A() throw();
+#if __cplusplus <= 199711L
+ // expected-note@-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@-2 {{exception specification of overriding function is more lax than base version}}
+#endif
};
}
@@ -177,11 +185,18 @@
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@-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@+2 {{enumeration types with a fixed underlying type are a C++11 extension}}
+#endif
+enum : long long {
SomeValue = 0x100000000
};
@@ -453,7 +468,9 @@
// 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@+1 {{'override' keyword is a C++11 extension}}
+#if __cplusplus <= 199711L
+ // expected-warning@+2 {{'override' keyword is a C++11 extension}}
+#endif
virtual void OverrideMe() override;
};
Index: test/OpenMP/openmp_check.cpp
===================================================================
--- test/OpenMP/openmp_check.cpp
+++ test/OpenMP/openmp_check.cpp
@@ -1,15 +1,35 @@
// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 %s
+// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 -std=c++98 %s
+// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 -std=c++11 %s
+
int nested(int a) {
#pragma omp parallel
++a;
- auto F = [&]() { // expected-error {{expected expression}} expected-error {{expected ';' at end of declaration}} expected-warning {{'auto' type specifier is a C++11 extension}}
+ auto F = [&]() {
+#if __cplusplus <= 199711L
+ // expected-warning@-2 {{'auto' type specifier is a C++11 extension}}
+ // expected-error@-3 {{expected expression}}
+ // expected-error@-4 {{expected ';' at end of declaration}}
+#else
+ // expected-no-diagnostics
+#endif
+
#pragma omp parallel
{
#pragma omp target
++a;
}
};
- F(); // expected-error {{C++ requires a type specifier for all declarations}}
- return a; // expected-error {{expected unqualified-id}}
-}// expected-error {{extraneous closing brace ('}')}}
+ F();
+#if __cplusplus <= 199711L
+ // expected-error@-2 {{C++ requires a type specifier for all declarations}}
+#endif
+ return a;
+#if __cplusplus <= 199711L
+ // expected-error@-2 {{expected unqualified-id}}
+#endif
+}
+#if __cplusplus <= 199711L
+// expected-error@-2 {{extraneous closing brace ('}')}}
+#endif
Index: test/OpenMP/declare_reduction_messages.cpp
===================================================================
--- test/OpenMP/declare_reduction_messages.cpp
+++ test/OpenMP/declare_reduction_messages.cpp
@@ -1,4 +1,6 @@
// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 %s
+// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 -std=c++98 %s
+// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 -std=c++11 %s
int temp; // expected-note 7 {{'temp' declared here}}
@@ -51,7 +53,17 @@
#pragma omp declare reduction(fun222 : long : omp_out += omp_in) // expected-error {{redefinition of user-defined reduction for type 'long'}}
#pragma omp declare reduction(fun1 : long : omp_out += omp_in) initializer // expected-error {{expected '(' after 'initializer'}}
#pragma omp declare reduction(fun2 : long : omp_out += omp_in) initializer { // expected-error {{expected '(' after 'initializer'}} expected-error {{expected expression}} expected-warning {{extra tokens at the end of '#pragma omp declare reduction' are ignored}}
-#pragma omp declare reduction(fun3 : long : omp_out += omp_in) initializer[ // expected-error {{expected '(' after 'initializer'}} expected-error {{expected expression}} expected-warning {{extra tokens at the end of '#pragma omp declare reduction' are ignored}}
+#pragma omp declare reduction(fun3 : long : omp_out += omp_in) initializer[
+#if __cplusplus <= 199711L
+// expected-error@-2 {{expected '(' after 'initializer'}}
+// expected-error@-3 {{expected expression}}
+// expected-warning@-4 {{extra tokens at the end of '#pragma omp declare reduction' are ignored}}
+#else
+// expected-error@-6 {{expected '(' after 'initializer'}}
+// expected-error@-7 {{expected variable name or 'this' in lambda capture list}}
+// expected-error@-8 {{expected ')'}}
+// expected-note@-9 {{to match this '('}}
+#endif
#pragma omp declare reduction(fun4 : long : omp_out += omp_in) initializer() // expected-error {{expected expression}}
#pragma omp declare reduction(fun5 : long : omp_out += omp_in) initializer(temp) // expected-error {{only 'omp_priv' or 'omp_orig' variables are allowed in initializer expression}}
#pragma omp declare reduction(fun6 : long : omp_out += omp_in) initializer(omp_orig // expected-error {{expected ')'}} expected-note {{to match this '('}}
Index: test/Modules/merge-using-decls.cpp
===================================================================
--- test/Modules/merge-using-decls.cpp
+++ test/Modules/merge-using-decls.cpp
@@ -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 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 @@
// 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
// [email protected]:* {{'E::value' from module 'B' is not present in definition of 'E<T>' in module 'A'}}
// [email protected]:* {{'E::v' from module 'B' is not present in definition of 'E<T>' in module 'A'}}
+#endif
// [email protected]:* {{'F::type' from module 'B' is not present in definition of 'F<T>' in module 'A'}}
// [email protected]:* {{'F::t' from module 'B' is not present in definition of 'F<T>' in module 'A'}}
@@ -55,11 +65,14 @@
// [email protected]:* 2{{'typename' keyword used on a non-type}}
// [email protected]:* 2{{dependent using declaration resolved to type without 'typename'}}
+#if __cplusplus <= 199711L // C++11 does not allow access declerations
// [email protected]:* {{'E::type' from module 'A' is not present in definition of 'E<T>' in module 'B'}}
// [email protected]:* {{'E::t' from module 'A' is not present in definition of 'E<T>' in module 'B'}}
// [email protected]:* {{'E::value' from module 'A' is not present in definition of 'E<T>' in module 'B'}}
// [email protected]:* {{'E::v' from module 'A' is not present in definition of 'E<T>' in module 'B'}}
// [email protected]:* 2{{definition has no member}}
+#endif
+
// [email protected]:* {{'F::type' from module 'A' is not present in definition of 'F<T>' in module 'B'}}
// [email protected]:* {{'F::t' from module 'A' is not present in definition of 'F<T>' in module 'B'}}
Index: test/Modules/Inputs/merge-using-decls/b.h
===================================================================
--- test/Modules/Inputs/merge-using-decls/b.h
+++ test/Modules/Inputs/merge-using-decls/b.h
@@ -29,11 +29,13 @@
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 @@
// 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;
Index: test/Modules/Inputs/merge-using-decls/a.h
===================================================================
--- test/Modules/Inputs/merge-using-decls/a.h
+++ test/Modules/Inputs/merge-using-decls/a.h
@@ -22,12 +22,14 @@
using typename X::t;
};
+#if __cplusplus <= 199711L // C++11 does not allow access declerations
template<typename T> struct E : X, T {
using T::value;
using typename T::type;
using X::v;
using typename X::t;
};
+#endif
template<typename T> struct F : X, T {
using T::value;
@@ -39,5 +41,9 @@
// Force instantiation.
typedef C<YA>::type I;
typedef D<YA>::type I;
+
+#if __cplusplus <= 199711L // C++11 does not allow access declerations
typedef E<YA>::type I;
+#endif
+
typedef F<YA>::type I;
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits