aboutsummaryrefslogtreecommitdiff
path: root/test/SemaCXX
diff options
context:
space:
mode:
Diffstat (limited to 'test/SemaCXX')
-rw-r--r--test/SemaCXX/MicrosoftCompatibility-cxx98.cpp9
-rw-r--r--test/SemaCXX/MicrosoftCompatibility.cpp15
-rw-r--r--test/SemaCXX/MicrosoftExtensions.cpp28
-rw-r--r--test/SemaCXX/PR16677.cpp16
-rw-r--r--test/SemaCXX/PR20334-std_initializer_list_diagnosis_assertion.cpp20
-rw-r--r--test/SemaCXX/abstract.cpp4
-rw-r--r--test/SemaCXX/addr-of-overloaded-function.cpp17
-rw-r--r--test/SemaCXX/alias-template.cpp11
-rw-r--r--test/SemaCXX/ast-print.cpp12
-rw-r--r--test/SemaCXX/attr-deprecated.cpp16
-rw-r--r--test/SemaCXX/attr-disable-tail-calls.cpp8
-rw-r--r--test/SemaCXX/attr-no-sanitize-address.cpp14
-rw-r--r--test/SemaCXX/attr-no-sanitize-memory.cpp14
-rw-r--r--test/SemaCXX/attr-no-sanitize-thread.cpp14
-rw-r--r--test/SemaCXX/attr-notail.cpp16
-rw-r--r--test/SemaCXX/attr-print.cpp3
-rw-r--r--test/SemaCXX/auto-cxx0x.cpp3
-rw-r--r--test/SemaCXX/auto-type-from-cxx.cpp19
-rw-r--r--test/SemaCXX/bitfield-layout.cpp8
-rw-r--r--test/SemaCXX/calling-conv-compat.cpp13
-rw-r--r--test/SemaCXX/cdtor-fn-try-block.cpp97
-rw-r--r--test/SemaCXX/condition.cpp8
-rw-r--r--test/SemaCXX/const-cast.cpp13
-rw-r--r--test/SemaCXX/constant-expression-cxx11.cpp23
-rw-r--r--test/SemaCXX/constant-expression-cxx1y.cpp4
-rw-r--r--test/SemaCXX/constant-expression.cpp2
-rw-r--r--test/SemaCXX/constexpr-printing.cpp4
-rw-r--r--test/SemaCXX/constructor-initializer.cpp19
-rw-r--r--test/SemaCXX/conversion-function.cpp2
-rw-r--r--test/SemaCXX/convert-to-bool.cpp18
-rw-r--r--test/SemaCXX/converting-constructor.cpp9
-rw-r--r--test/SemaCXX/copy-initialization.cpp8
-rw-r--r--test/SemaCXX/coroutines.cpp268
-rw-r--r--test/SemaCXX/crashes.cpp8
-rw-r--r--test/SemaCXX/cxx0x-initializer-aggregates.cpp4
-rw-r--r--test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp31
-rw-r--r--test/SemaCXX/cxx0x-return-init-list.cpp2
-rw-r--r--test/SemaCXX/cxx11-ast-print.cpp14
-rw-r--r--test/SemaCXX/cxx11-user-defined-literals.cpp10
-rw-r--r--test/SemaCXX/cxx1y-generic-lambdas.cpp2
-rw-r--r--test/SemaCXX/cxx1y-init-captures.cpp6
-rw-r--r--test/SemaCXX/cxx1y-variable-templates_in_class.cpp11
-rw-r--r--test/SemaCXX/cxx1y-variable-templates_top_level.cpp4
-rw-r--r--test/SemaCXX/cxx98-compat.cpp3
-rw-r--r--test/SemaCXX/decl-expr-ambiguity.cpp5
-rw-r--r--test/SemaCXX/decl-microsoft-call-conv.cpp7
-rw-r--r--test/SemaCXX/decltype-crash.cpp2
-rw-r--r--test/SemaCXX/default-assignment-operator.cpp6
-rw-r--r--test/SemaCXX/default1.cpp9
-rw-r--r--test/SemaCXX/deleted-function-access.cpp6
-rw-r--r--test/SemaCXX/deprecated.cpp21
-rw-r--r--test/SemaCXX/destructor.cpp12
-rw-r--r--test/SemaCXX/direct-initializer.cpp12
-rw-r--r--test/SemaCXX/dllexport.cpp13
-rw-r--r--test/SemaCXX/dllimport.cpp17
-rw-r--r--test/SemaCXX/enable_if.cpp143
-rw-r--r--test/SemaCXX/enum.cpp17
-rw-r--r--test/SemaCXX/err_typecheck_assign_const.cpp7
-rw-r--r--test/SemaCXX/exception-spec.cpp7
-rw-r--r--test/SemaCXX/expressions.cpp5
-rw-r--r--test/SemaCXX/gnu-flags.cpp26
-rw-r--r--test/SemaCXX/init-priority-attr.cpp2
-rw-r--r--test/SemaCXX/internal_linkage.cpp47
-rw-r--r--test/SemaCXX/invalid-member-expr.cpp12
-rw-r--r--test/SemaCXX/libstdcxx_explicit_init_list_hack.cpp5
-rw-r--r--test/SemaCXX/literal-operators.cpp12
-rw-r--r--test/SemaCXX/make_integer_seq.cpp49
-rw-r--r--test/SemaCXX/many-template-parameter-lists.cpp36
-rw-r--r--test/SemaCXX/member-expr.cpp8
-rw-r--r--test/SemaCXX/member-pointer.cpp9
-rw-r--r--test/SemaCXX/microsoft-super.cpp49
-rw-r--r--test/SemaCXX/ms-inline-asm.cpp54
-rw-r--r--test/SemaCXX/ms-interface.cpp4
-rw-r--r--test/SemaCXX/ms-novtable.cpp2
-rw-r--r--test/SemaCXX/ms-property-error.cpp37
-rw-r--r--test/SemaCXX/ms-property.cpp60
-rw-r--r--test/SemaCXX/ms-unsupported.cpp5
-rw-r--r--test/SemaCXX/ms_integer_suffix.cpp3
-rw-r--r--test/SemaCXX/ms_struct.cpp8
-rw-r--r--test/SemaCXX/ms_wide_bitfield.cpp7
-rw-r--r--test/SemaCXX/namespace-alias.cpp43
-rw-r--r--test/SemaCXX/namespace.cpp12
-rw-r--r--test/SemaCXX/new-array-size-conv.cpp13
-rw-r--r--test/SemaCXX/nullability.cpp32
-rw-r--r--test/SemaCXX/offsetof.cpp2
-rw-r--r--test/SemaCXX/overload-call-copycon.cpp10
-rw-r--r--test/SemaCXX/overload-call.cpp47
-rw-r--r--test/SemaCXX/overloaded-builtin-operators.cpp12
-rw-r--r--test/SemaCXX/pass-object-size.cpp122
-rw-r--r--test/SemaCXX/pragma-init_seg.cpp7
-rw-r--r--test/SemaCXX/pragma-vtordisp.cpp38
-rw-r--r--test/SemaCXX/printf-block.cpp10
-rw-r--r--test/SemaCXX/redefine_extname.cpp6
-rw-r--r--test/SemaCXX/rval-references.cpp2
-rw-r--r--test/SemaCXX/sourceranges.cpp17
-rw-r--r--test/SemaCXX/type-convert-construct.cpp2
-rw-r--r--test/SemaCXX/type-traits.cpp81
-rw-r--r--test/SemaCXX/typo-correction-blocks.c12
-rw-r--r--test/SemaCXX/typo-correction-delayed.cpp8
-rw-r--r--test/SemaCXX/typo-correction.cpp25
-rw-r--r--test/SemaCXX/undefined-internal.cpp11
-rw-r--r--test/SemaCXX/underlying_type.cpp2
-rw-r--r--test/SemaCXX/unknown-type-name.cpp8
-rw-r--r--test/SemaCXX/using-decl-1.cpp17
-rw-r--r--test/SemaCXX/vector-casts.cpp26
-rw-r--r--test/SemaCXX/vector-no-lax.cpp2
-rw-r--r--test/SemaCXX/vector.cpp8
-rw-r--r--test/SemaCXX/warn-logical-not-compare.cpp100
-rw-r--r--test/SemaCXX/warn-pure-virtual-call-from-ctor-dtor.cpp12
-rw-r--r--test/SemaCXX/warn-pure-virtual-kext.cpp8
-rw-r--r--test/SemaCXX/warn-sign-conversion.cpp2
-rw-r--r--test/SemaCXX/warn-thread-safety-analysis.cpp98
-rw-r--r--test/SemaCXX/warn-unused-local-typedef-serialize.cpp1
-rw-r--r--test/SemaCXX/writable-strings-deprecated.cpp30
114 files changed, 2125 insertions, 255 deletions
diff --git a/test/SemaCXX/MicrosoftCompatibility-cxx98.cpp b/test/SemaCXX/MicrosoftCompatibility-cxx98.cpp
index bfda837e9590..3b80d0937e23 100644
--- a/test/SemaCXX/MicrosoftCompatibility-cxx98.cpp
+++ b/test/SemaCXX/MicrosoftCompatibility-cxx98.cpp
@@ -12,3 +12,12 @@ void (*PR23733_1)() = static_cast<FnPtrTy>((void *)0); // expected-warning {{sta
void (*PR23733_2)() = FnPtrTy((void *)0);
void (*PR23733_3)() = (FnPtrTy)((void *)0);
void (*PR23733_4)() = reinterpret_cast<FnPtrTy>((void *)0);
+
+long function_prototype(int a);
+long (*function_ptr)(int a);
+
+void function_to_voidptr_conv() {
+ void *a1 = function_prototype; // expected-warning {{implicit conversion between pointer-to-function and pointer-to-object is a Microsoft extension}}
+ void *a2 = &function_prototype; // expected-warning {{implicit conversion between pointer-to-function and pointer-to-object is a Microsoft extension}}
+ void *a3 = function_ptr; // expected-warning {{implicit conversion between pointer-to-function and pointer-to-object is a Microsoft extension}}
+}
diff --git a/test/SemaCXX/MicrosoftCompatibility.cpp b/test/SemaCXX/MicrosoftCompatibility.cpp
index 1536007a6478..fe8e8f77accb 100644
--- a/test/SemaCXX/MicrosoftCompatibility.cpp
+++ b/test/SemaCXX/MicrosoftCompatibility.cpp
@@ -9,11 +9,18 @@ typedef unsigned short char16_t;
typedef unsigned int char32_t;
#endif
-#if _MSC_VER >= 1900
_Atomic(int) z;
-#else
-struct _Atomic {};
-#endif
+template <typename T>
+struct _Atomic {
+ _Atomic() {}
+ ~_Atomic() {}
+};
+template <typename T>
+struct atomic : _Atomic<T> {
+ typedef _Atomic<T> TheBase;
+ TheBase field;
+};
+_Atomic(int) alpha;
typename decltype(3) a; // expected-warning {{expected a qualified name after 'typename'}}
diff --git a/test/SemaCXX/MicrosoftExtensions.cpp b/test/SemaCXX/MicrosoftExtensions.cpp
index db5e4586daf5..22cf2be7c1ac 100644
--- a/test/SemaCXX/MicrosoftExtensions.cpp
+++ b/test/SemaCXX/MicrosoftExtensions.cpp
@@ -153,16 +153,6 @@ static void static_func() // expected-warning {{redeclaring non-static 'static_f
extern const int static_var; // expected-note {{previous declaration is here}}
static const int static_var = 3; // expected-warning {{redeclaring non-static 'static_var' as static is a Microsoft extension}}
-long function_prototype(int a);
-long (*function_ptr)(int a);
-
-void function_to_voidptr_conv() {
- void *a1 = function_prototype;
- void *a2 = &function_prototype;
- void *a3 = function_ptr;
-}
-
-
void pointer_to_integral_type_conv(char* ptr) {
char ch = (char)ptr;
short sh = (short)ptr;
@@ -412,3 +402,21 @@ void AfterClassBody() {
_Static_assert(__alignof(s1) == 8, "");
_Static_assert(__alignof(s2) == 4, "");
}
+
+namespace PR24246 {
+template <typename TX> struct A {
+ template <bool> struct largest_type_select;
+ // expected-warning@+1 {{explicit specialization of 'largest_type_select' within class scope is a Microsoft extension}}
+ template <> struct largest_type_select<false> {
+ blah x; // expected-error {{unknown type name 'blah'}}
+ };
+};
+}
+
+namespace PR25265 {
+struct S {
+ int fn() throw(); // expected-note {{previous declaration is here}}
+};
+
+int S::fn() { return 0; } // expected-warning {{is missing exception specification}}
+}
diff --git a/test/SemaCXX/PR16677.cpp b/test/SemaCXX/PR16677.cpp
new file mode 100644
index 000000000000..7140ac79f089
--- /dev/null
+++ b/test/SemaCXX/PR16677.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s
+
+class Class_With_Destructor {
+ ~Class_With_Destructor() { }
+};
+
+template <class T>
+class Base { };
+
+template<class T, // Should be angle bracket instead of comma
+class Derived : public Base<T> { // expected-error{{'Derived' cannot be defined in a type specifier}}
+ Class_With_Destructor member;
+}; // expected-error{{a non-type template parameter cannot have type 'class Derived'}}
+ // expected-error@-1{{expected ',' or '>' in template-parameter-list}}
+ // expected-warning@-2{{declaration does not declare anything}}
+
diff --git a/test/SemaCXX/PR20334-std_initializer_list_diagnosis_assertion.cpp b/test/SemaCXX/PR20334-std_initializer_list_diagnosis_assertion.cpp
new file mode 100644
index 000000000000..ec672089b84a
--- /dev/null
+++ b/test/SemaCXX/PR20334-std_initializer_list_diagnosis_assertion.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -std=c++11 -verify -emit-llvm-only %s
+// RUN: %clang_cc1 -std=c++98 -fsyntax-only -verify %s -DCPP98
+
+namespace std {
+ template <class _E>
+ class initializer_list
+ {};
+}
+
+template<class E> int f(std::initializer_list<E> il);
+
+
+int F = f({1, 2, 3});
+#ifdef CPP98
+//expected-error@-2{{expected expression}}
+#else
+//expected-error@-4{{cannot compile}}
+#endif
+
+
diff --git a/test/SemaCXX/abstract.cpp b/test/SemaCXX/abstract.cpp
index b521196c23b6..ffd36be5b797 100644
--- a/test/SemaCXX/abstract.cpp
+++ b/test/SemaCXX/abstract.cpp
@@ -8,6 +8,10 @@
typedef int __CONCAT(__sa, __LINE__)[__b ? 1 : -1]
#endif
+union IncompleteUnion;
+
+static_assert(!__is_abstract(IncompleteUnion), "unions are never abstract");
+
class C {
virtual void f() = 0; // expected-note {{unimplemented pure virtual method 'f'}}
};
diff --git a/test/SemaCXX/addr-of-overloaded-function.cpp b/test/SemaCXX/addr-of-overloaded-function.cpp
index 6d055037735e..cca847b4d2c3 100644
--- a/test/SemaCXX/addr-of-overloaded-function.cpp
+++ b/test/SemaCXX/addr-of-overloaded-function.cpp
@@ -1,4 +1,6 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
int f(double); // expected-note{{candidate function}}
int f(int); // expected-note{{candidate function}}
@@ -79,7 +81,10 @@ struct C {
void q3(); // expected-note{{possible target for call}}
template<typename T1, typename T2>
void q4(); // expected-note{{possible target for call}}
- template<typename T1 = int> // expected-warning{{default template arguments for a function template are a C++11 extension}}
+ template<typename T1 = int>
+#if __cplusplus <= 199711L // C++03 or earlier modes
+ // expected-warning@-2{{default template arguments for a function template are a C++11 extension}}
+#endif
void q5(); // expected-note{{possible target for call}}
void h() {
@@ -125,13 +130,9 @@ namespace PR7971 {
}
namespace PR8033 {
- template <typename T1, typename T2> int f(T1 *, const T2 *); // expected-note {{candidate function [with T1 = const int, T2 = int]}} \
- // expected-note{{candidate function}}
- template <typename T1, typename T2> int f(const T1 *, T2 *); // expected-note {{candidate function [with T1 = int, T2 = const int]}} \
- // expected-note{{candidate function}}
- int (*p)(const int *, const int *) = f; // expected-error{{address of overloaded function 'f' is ambiguous}} \
- // expected-error{{address of overloaded function 'f' is ambiguous}}
-
+ template <typename T1, typename T2> int f(T1 *, const T2 *); // expected-note {{candidate function [with T1 = const int, T2 = int]}}
+ template <typename T1, typename T2> int f(const T1 *, T2 *); // expected-note {{candidate function [with T1 = int, T2 = const int]}}
+ int (*p)(const int *, const int *) = f; // expected-error{{address of overloaded function 'f' is ambiguous}}
}
namespace PR8196 {
diff --git a/test/SemaCXX/alias-template.cpp b/test/SemaCXX/alias-template.cpp
index d5eb27a66132..bcfe428c69dd 100644
--- a/test/SemaCXX/alias-template.cpp
+++ b/test/SemaCXX/alias-template.cpp
@@ -168,3 +168,14 @@ namespace SFINAE {
fail1<int> f1; // expected-note {{here}}
fail2<E> f2; // expected-note {{here}}
}
+
+namespace PR24212 {
+struct X {};
+template <int I>
+struct S {
+ template <int J>
+ using T = X[J];
+ using U = T<I>;
+};
+static_assert(__is_same(S<3>::U, X[2]), ""); // expected-error {{static_assert failed}}
+}
diff --git a/test/SemaCXX/ast-print.cpp b/test/SemaCXX/ast-print.cpp
index 1b57406a64f1..39a52ab8d7e8 100644
--- a/test/SemaCXX/ast-print.cpp
+++ b/test/SemaCXX/ast-print.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -ast-print %s -std=gnu++11 | FileCheck %s
+// RUN: %clang_cc1 -triple %ms_abi_triple -ast-print %s -std=gnu++11 | FileCheck %s
// CHECK: r;
// CHECK-NEXT: (r->method());
@@ -66,7 +66,7 @@ template <class S> void test7()
template <typename T> void test8(T t) { t.~T(); }
-// CHECK: enum E {
+// CHECK: enum E
// CHECK-NEXT: A,
// CHECK-NEXT: B,
// CHECK-NEXT: C
@@ -219,3 +219,11 @@ struct CXXFunctionalCastExprPrint {} fce = CXXFunctionalCastExprPrint{};
// CHECK: struct CXXTemporaryObjectExprPrint toe = CXXTemporaryObjectExprPrint{};
struct CXXTemporaryObjectExprPrint { CXXTemporaryObjectExprPrint(); } toe = CXXTemporaryObjectExprPrint{};
+
+namespace PR24872 {
+// CHECK: template <typename T> struct Foo : T {
+// CHECK: using T::operator-;
+template <typename T> struct Foo : T {
+ using T::operator-;
+};
+}
diff --git a/test/SemaCXX/attr-deprecated.cpp b/test/SemaCXX/attr-deprecated.cpp
index d28eb75cca65..eab5a1c0ec08 100644
--- a/test/SemaCXX/attr-deprecated.cpp
+++ b/test/SemaCXX/attr-deprecated.cpp
@@ -26,12 +26,12 @@ void A::h(A* a)
}
struct B {
- virtual void f() __attribute__((deprecated)); // expected-note 4 {{'f' has been explicitly marked deprecated here}}
+ virtual void f() __attribute__((deprecated)); // expected-note 6 {{'f' has been explicitly marked deprecated here}}
void g();
};
void B::g() {
- f();
+ f(); // expected-warning{{'f' is deprecated}}
B::f(); // expected-warning{{'f' is deprecated}}
}
@@ -47,7 +47,7 @@ void C::g() {
}
void f(B* b, C *c) {
- b->f();
+ b->f(); // expected-warning{{'f' is deprecated}}
b->B::f(); // expected-warning{{'f' is deprecated}}
c->f();
@@ -57,12 +57,18 @@ void f(B* b, C *c) {
struct D {
virtual void f() __attribute__((deprecated));
+ virtual void f(int) __attribute__((deprecated));
+ virtual void f(int, int) __attribute__((deprecated));
};
-void D::f() { }
+void D::f() { } // expected-note{{'f' has been explicitly marked deprecated here}}
+void D::f(int v) { } // expected-note{{'f' has been explicitly marked deprecated here}}
+void D::f(int v1, int v2) { } // expected-note{{'f' has been explicitly marked deprecated here}}
void f(D* d) {
- d->f();
+ d->f(); // expected-warning{{'f' is deprecated}}
+ d->f(42); // expected-warning{{'f' is deprecated}}
+ d->f(42, 24); // expected-warning{{'f' is deprecated}}
}
diff --git a/test/SemaCXX/attr-disable-tail-calls.cpp b/test/SemaCXX/attr-disable-tail-calls.cpp
new file mode 100644
index 000000000000..d442aa6d4409
--- /dev/null
+++ b/test/SemaCXX/attr-disable-tail-calls.cpp
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+// expected-no-diagnostics
+
+class B {
+public:
+ [[clang::disable_tail_calls]] virtual int foo1() { return 1; }
+ [[clang::disable_tail_calls]] int foo2() { return 2; }
+};
diff --git a/test/SemaCXX/attr-no-sanitize-address.cpp b/test/SemaCXX/attr-no-sanitize-address.cpp
index 9ca28630552b..0aafe06af980 100644
--- a/test/SemaCXX/attr-no-sanitize-address.cpp
+++ b/test/SemaCXX/attr-no-sanitize-address.cpp
@@ -5,12 +5,14 @@
#if !__has_attribute(no_sanitize_address)
#error "Should support no_sanitize_address"
#endif
-
-void noanal_fun() NO_SANITIZE_ADDRESS;
-
-void noanal_fun_args() __attribute__((no_sanitize_address(1))); // \
- // expected-error {{'no_sanitize_address' attribute takes no arguments}}
-
+
+void noanal_fun() NO_SANITIZE_ADDRESS;
+
+void noanal_fun_alt() __attribute__((__no_sanitize_address__));
+
+void noanal_fun_args() __attribute__((no_sanitize_address(1))); // \
+ // expected-error {{'no_sanitize_address' attribute takes no arguments}}
+
int noanal_testfn(int y) NO_SANITIZE_ADDRESS;
int noanal_testfn(int y) {
diff --git a/test/SemaCXX/attr-no-sanitize-memory.cpp b/test/SemaCXX/attr-no-sanitize-memory.cpp
index 9cbcb03d6ecf..8a8d847562af 100644
--- a/test/SemaCXX/attr-no-sanitize-memory.cpp
+++ b/test/SemaCXX/attr-no-sanitize-memory.cpp
@@ -5,12 +5,14 @@
#if !__has_attribute(no_sanitize_memory)
#error "Should support no_sanitize_memory"
#endif
-
-void noanal_fun() NO_SANITIZE_MEMORY;
-
-void noanal_fun_args() __attribute__((no_sanitize_memory(1))); // \
- // expected-error {{'no_sanitize_memory' attribute takes no arguments}}
-
+
+void noanal_fun() NO_SANITIZE_MEMORY;
+
+void noanal_fun_alt() __attribute__((__no_sanitize_memory__));
+
+void noanal_fun_args() __attribute__((no_sanitize_memory(1))); // \
+ // expected-error {{'no_sanitize_memory' attribute takes no arguments}}
+
int noanal_testfn(int y) NO_SANITIZE_MEMORY;
int noanal_testfn(int y) {
diff --git a/test/SemaCXX/attr-no-sanitize-thread.cpp b/test/SemaCXX/attr-no-sanitize-thread.cpp
index 6cb9c715bf6c..92a3fa96194c 100644
--- a/test/SemaCXX/attr-no-sanitize-thread.cpp
+++ b/test/SemaCXX/attr-no-sanitize-thread.cpp
@@ -5,12 +5,14 @@
#if !__has_attribute(no_sanitize_thread)
#error "Should support no_sanitize_thread"
#endif
-
-void noanal_fun() NO_SANITIZE_THREAD;
-
-void noanal_fun_args() __attribute__((no_sanitize_thread(1))); // \
- // expected-error {{'no_sanitize_thread' attribute takes no arguments}}
-
+
+void noanal_fun() NO_SANITIZE_THREAD;
+
+void noanal_fun_alt() __attribute__((__no_sanitize_thread__));
+
+void noanal_fun_args() __attribute__((no_sanitize_thread(1))); // \
+ // expected-error {{'no_sanitize_thread' attribute takes no arguments}}
+
int noanal_testfn(int y) NO_SANITIZE_THREAD;
int noanal_testfn(int y) {
diff --git a/test/SemaCXX/attr-notail.cpp b/test/SemaCXX/attr-notail.cpp
new file mode 100644
index 000000000000..2f39746dc85b
--- /dev/null
+++ b/test/SemaCXX/attr-notail.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+class Base {
+public:
+ [[clang::not_tail_called]] virtual int foo1(); // expected-error {{'not_tail_called' attribute cannot be applied to virtual functions}}
+ virtual int foo2();
+ [[clang::not_tail_called]] int foo3();
+ virtual ~Base() {}
+};
+
+class Derived1 : public Base {
+public:
+ int foo1() override;
+ [[clang::not_tail_called]] int foo2() override; // expected-error {{'not_tail_called' attribute cannot be applied to virtual functions}}
+ [[clang::not_tail_called]] int foo4();
+};
diff --git a/test/SemaCXX/attr-print.cpp b/test/SemaCXX/attr-print.cpp
index 337a6fb69ba3..f40d803e94cb 100644
--- a/test/SemaCXX/attr-print.cpp
+++ b/test/SemaCXX/attr-print.cpp
@@ -26,6 +26,9 @@ int small __attribute__((mode(byte)));
// CHECK: int v __attribute__((visibility("hidden")));
int v __attribute__((visibility("hidden")));
+// CHECK: char *PR24565() __attribute__((malloc))
+char *PR24565() __attribute__((__malloc__));
+
// CHECK: class __attribute__((consumable("unknown"))) AttrTester1
class __attribute__((consumable(unknown))) AttrTester1 {
// CHECK: void callableWhen() __attribute__((callable_when("unconsumed", "consumed")));
diff --git a/test/SemaCXX/auto-cxx0x.cpp b/test/SemaCXX/auto-cxx0x.cpp
index a8f9e84423a7..f3daf1a19f3c 100644
--- a/test/SemaCXX/auto-cxx0x.cpp
+++ b/test/SemaCXX/auto-cxx0x.cpp
@@ -1,5 +1,8 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++1y
void f() {
auto int a; // expected-warning {{'auto' storage class specifier is not permitted in C++11, and will not be supported in future releases}}
int auto b; // expected-error{{cannot combine with previous 'int' declaration specifier}}
}
+
+typedef auto PR25449(); // expected-error {{'auto' not allowed in typedef}}
diff --git a/test/SemaCXX/auto-type-from-cxx.cpp b/test/SemaCXX/auto-type-from-cxx.cpp
new file mode 100644
index 000000000000..961402f7d933
--- /dev/null
+++ b/test/SemaCXX/auto-type-from-cxx.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -std=c++14 -fsyntax-only -verify %s
+
+struct A {
+ operator __auto_type() {} // expected-error {{'__auto_type' not allowed in conversion function type}}
+};
+
+__auto_type a() -> int; // expected-error {{'__auto_type' not allowed in function return type}}
+template <typename T>
+__auto_type b() { return T::x; } // expected-error {{'__auto_type' not allowed in function return type}}
+auto c() -> __auto_type { __builtin_unreachable(); } // expected-error {{'__auto_type' not allowed in function return type}}
+int d() {
+ decltype(__auto_type) e = 1; // expected-error {{expected expression}}
+ auto _ = [](__auto_type f) {}; // expected-error {{'__auto_type' not allowed in lambda parameter}}
+ __auto_type g = 2;
+ struct BitField { int field:2; };
+ __auto_type h = BitField{1}.field; // (should work from C++)
+ new __auto_type; // expected-error {{'__auto_type' not allowed in type allocated by 'new'}}
+}
+
diff --git a/test/SemaCXX/bitfield-layout.cpp b/test/SemaCXX/bitfield-layout.cpp
index adecf55a8774..25aa82229925 100644
--- a/test/SemaCXX/bitfield-layout.cpp
+++ b/test/SemaCXX/bitfield-layout.cpp
@@ -5,25 +5,25 @@
// Simple tests.
struct Test1 {
- char c : 9; // expected-warning {{size of bit-field 'c' (9 bits) exceeds the size of its type; value will be truncated to 8 bits}}
+ char c : 9; // expected-warning {{width of bit-field 'c' (9 bits) exceeds the width of its type; value will be truncated to 8 bits}}
};
CHECK_SIZE(Test1, 2);
CHECK_ALIGN(Test1, 1);
struct Test2 {
- char c : 16; // expected-warning {{size of bit-field 'c' (16 bits) exceeds the size of its type; value will be truncated to 8 bits}}
+ char c : 16; // expected-warning {{width of bit-field 'c' (16 bits) exceeds the width of its type; value will be truncated to 8 bits}}
};
CHECK_SIZE(Test2, 2);
CHECK_ALIGN(Test2, 2);
struct Test3 {
- char c : 32; // expected-warning {{size of bit-field 'c' (32 bits) exceeds the size of its type; value will be truncated to 8 bits}}
+ char c : 32; // expected-warning {{width of bit-field 'c' (32 bits) exceeds the width of its type; value will be truncated to 8 bits}}
};
CHECK_SIZE(Test3, 4);
CHECK_ALIGN(Test3, 4);
struct Test4 {
- char c : 64; // expected-warning {{size of bit-field 'c' (64 bits) exceeds the size of its type; value will be truncated to 8 bits}}
+ char c : 64; // expected-warning {{width of bit-field 'c' (64 bits) exceeds the width of its type; value will be truncated to 8 bits}}
};
CHECK_SIZE(Test4, 8);
CHECK_ALIGN(Test4, 8);
diff --git a/test/SemaCXX/calling-conv-compat.cpp b/test/SemaCXX/calling-conv-compat.cpp
index cebac9fad6cd..20d93b41e1d2 100644
--- a/test/SemaCXX/calling-conv-compat.cpp
+++ b/test/SemaCXX/calling-conv-compat.cpp
@@ -370,6 +370,19 @@ X<fun_cdecl >::p tmpl6 = &A::method_thiscall;
X<fun_stdcall >::p tmpl7 = &A::method_stdcall;
X<fun_fastcall>::p tmpl8 = &A::method_fastcall;
+// Make sure we adjust thiscall to cdecl when extracting the function type from
+// a member pointer.
+template <typename> struct Y;
+
+template <typename Fn, typename C>
+struct Y<Fn C::*> {
+ typedef Fn *p;
+};
+
+void __cdecl f_cdecl();
+Y<decltype(&A::method_thiscall)>::p tmpl9 = &f_cdecl;
+
+
} // end namespace MemberPointers
// Test that lambdas that capture nothing convert to cdecl function pointers.
diff --git a/test/SemaCXX/cdtor-fn-try-block.cpp b/test/SemaCXX/cdtor-fn-try-block.cpp
new file mode 100644
index 000000000000..d4d8d829ecdb
--- /dev/null
+++ b/test/SemaCXX/cdtor-fn-try-block.cpp
@@ -0,0 +1,97 @@
+// RUN: %clang_cc1 -fsyntax-only -fcxx-exceptions -verify %s -std=c++14
+
+int FileScope;
+
+struct A {
+ int I;
+ void f();
+ A() try {
+ } catch (...) {
+ I = 12; // expected-warning {{cannot refer to a non-static member from the handler of a constructor function try block}}
+ f(); // expected-warning {{cannot refer to a non-static member from the handler of a constructor function try block}}
+
+ FileScope = 12; // ok
+ A a;
+ a.I = 12; // ok
+ }
+};
+
+struct B {
+ int I;
+ void f();
+};
+
+struct C : B {
+ C() try {
+ } catch (...) {
+ I = 12; // expected-warning {{cannot refer to a non-static member from the handler of a constructor function try block}}
+ f(); // expected-warning {{cannot refer to a non-static member from the handler of a constructor function try block}}
+ }
+};
+
+struct D {
+ static int I;
+ static void f();
+
+ D() try {
+ } catch (...) {
+ I = 12; // ok
+ f(); // ok
+ }
+};
+int D::I;
+
+struct E {
+ int I;
+ void f();
+ static int J;
+ static void g();
+
+ ~E() try {
+ } catch (...) {
+ I = 12; // expected-warning {{cannot refer to a non-static member from the handler of a destructor function try block}}
+ f(); // expected-warning {{cannot refer to a non-static member from the handler of a destructor function try block}}
+
+ J = 12; // ok
+ g(); // ok
+ }
+};
+int E::J;
+
+struct F {
+ static int I;
+ static void f();
+};
+int F::I;
+
+struct G : F {
+ G() try {
+ } catch (...) {
+ I = 12; // ok
+ f(); // ok
+ }
+};
+
+struct H {
+ struct A {};
+ enum {
+ E
+ };
+
+ H() try {
+ } catch (...) {
+ H::A a; // ok
+ int I = E; // ok
+ }
+};
+
+struct I {
+ int J;
+
+ I() {
+ try { // not a function-try-block
+ } catch (...) {
+ J = 12; // ok
+ }
+ }
+}; \ No newline at end of file
diff --git a/test/SemaCXX/condition.cpp b/test/SemaCXX/condition.cpp
index 73f3dceef64e..b757fcb8cd5c 100644
--- a/test/SemaCXX/condition.cpp
+++ b/test/SemaCXX/condition.cpp
@@ -17,9 +17,9 @@ void test() {
switch (s) {} // expected-error {{statement requires expression of integer type ('struct S' invalid)}}
while (struct NewS *x=0) ;
- while (struct S {} *x=0) ; // expected-error {{types may not be defined in conditions}}
- while (struct {} *x=0) ; // expected-error {{types may not be defined in conditions}}
- switch (enum {E} x=0) ; // expected-error {{types may not be defined in conditions}}
+ while (struct S {} *x=0) ; // expected-error {{'S' cannot be defined in a condition}}
+ while (struct {} *x=0) ; // expected-error-re {{'(anonymous struct at {{.*}})' cannot be defined in a condition}}
+ switch (enum {E} x=0) ; // expected-error-re {{'(anonymous enum at {{.*}})' cannot be defined in a condition}}
if (int x=0) { // expected-note 2 {{previous definition is here}}
int x; // expected-error {{redefinition of 'x'}}
@@ -59,7 +59,7 @@ void test4(bool (&x)(void)) {
template <class>
void test5() {
- if (struct S {}* p = 0) // expected-error {{types may not be defined in conditions}}
+ if (struct S {}* p = 0) // expected-error {{'S' cannot be defined in a condition}}
;
}
void test5_inst() {
diff --git a/test/SemaCXX/const-cast.cpp b/test/SemaCXX/const-cast.cpp
index 330e18661b19..87df61cbc7b2 100644
--- a/test/SemaCXX/const-cast.cpp
+++ b/test/SemaCXX/const-cast.cpp
@@ -1,4 +1,6 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
struct A {};
@@ -38,8 +40,10 @@ char ***good_const_cast_test(ccvpcvpp var)
f *fpp = const_cast<f*>(&fp);
int const A::* const A::*icapcap = 0;
int A::* A::* iapap = const_cast<int A::* A::*>(icapcap);
- (void)const_cast<A&&>(A()); // expected-warning {{C++11}}
-
+ (void)const_cast<A&&>(A());
+#if __cplusplus <= 199711L // C++03 or earlier modes
+ // expected-warning@-2 {{rvalue references are a C++11 extension}}
+#endif
return var4;
}
@@ -61,7 +65,10 @@ short *bad_const_cast_test(char const *volatile *const volatile *var)
f fp2 = const_cast<f>(fp1); // expected-error {{const_cast to 'f' (aka 'int (*)(int)'), which is not a reference, pointer-to-object, or pointer-to-data-member}}
void (A::*mfn)() = 0;
(void)const_cast<void (A::*)()>(mfn); // expected-error-re {{const_cast to 'void (A::*)(){{( __attribute__\(\(thiscall\)\))?}}', which is not a reference, pointer-to-object, or pointer-to-data-member}}
- (void)const_cast<int&&>(0); // expected-error {{const_cast from rvalue to reference type 'int &&'}} expected-warning {{C++11}}
+ (void)const_cast<int&&>(0); // expected-error {{const_cast from rvalue to reference type 'int &&'}}
+#if __cplusplus <= 199711L // C++03 or earlier modes
+ // expected-warning@-2 {{rvalue references are a C++11 extension}}
+#endif
return **var3;
}
diff --git a/test/SemaCXX/constant-expression-cxx11.cpp b/test/SemaCXX/constant-expression-cxx11.cpp
index 3a1f6c6bd1a6..7b9d0150e1e8 100644
--- a/test/SemaCXX/constant-expression-cxx11.cpp
+++ b/test/SemaCXX/constant-expression-cxx11.cpp
@@ -327,7 +327,7 @@ struct Str {
};
extern char externalvar[];
-constexpr bool constaddress = (void *)externalvar == (void *)0x4000UL; // expected-error {{must be initialized by a constant expression}}
+constexpr bool constaddress = (void *)externalvar == (void *)0x4000UL; // expected-error {{must be initialized by a constant expression}} expected-note {{reinterpret_cast}}
constexpr bool litaddress = "foo" == "foo"; // expected-error {{must be initialized by a constant expression}} expected-warning {{unspecified}}
static_assert(0 != "foo", "");
@@ -1802,8 +1802,8 @@ namespace Bitfields {
unsigned u : 5;
int n : 5;
bool b2 : 3;
- unsigned u2 : 74; // expected-warning {{exceeds the size of its type}}
- int n2 : 81; // expected-warning {{exceeds the size of its type}}
+ unsigned u2 : 74; // expected-warning {{exceeds the width of its type}}
+ int n2 : 81; // expected-warning {{exceeds the width of its type}}
};
constexpr A a = { false, 33, 31, false, 0xffffffff, 0x7fffffff }; // expected-warning 2{{truncation}}
@@ -1874,10 +1874,9 @@ namespace NeverConstantTwoWays {
0;
}
- // FIXME: We should diagnose the cast to long here, not the division by zero.
constexpr int n = // expected-error {{must be initialized by a constant expression}}
- (int *)(long)&n == &n ?
- 1 / 0 : // expected-warning {{division by zero}} expected-note {{division by zero}}
+ (int *)(long)&n == &n ? // expected-note {{reinterpret_cast}}
+ 1 / 0 : // expected-warning {{division by zero}}
0;
}
@@ -1994,3 +1993,15 @@ namespace PR17938 {
static constexpr auto z = f(Z());
}
+
+namespace PR24597 {
+ struct A {
+ int x, *p;
+ constexpr A() : x(0), p(&x) {}
+ constexpr A(const A &a) : x(a.x), p(&x) {}
+ };
+ constexpr A f() { return A(); }
+ constexpr A g() { return f(); }
+ constexpr int a = *f().p;
+ constexpr int b = *g().p;
+}
diff --git a/test/SemaCXX/constant-expression-cxx1y.cpp b/test/SemaCXX/constant-expression-cxx1y.cpp
index e8925f3f84aa..e9ecbe83b3da 100644
--- a/test/SemaCXX/constant-expression-cxx1y.cpp
+++ b/test/SemaCXX/constant-expression-cxx1y.cpp
@@ -462,7 +462,7 @@ namespace loops {
if ((c % 7) == 0) break;
} while (c != 21);
- return a == 10 && b == 12 & c == 14;
+ return a == 10 && b == 12 && c == 14;
}
static_assert(breaks_work(), "");
@@ -872,7 +872,7 @@ namespace Lifetime {
namespace Bitfields {
struct A {
- bool b : 3;
+ bool b : 1;
int n : 4;
unsigned u : 5;
};
diff --git a/test/SemaCXX/constant-expression.cpp b/test/SemaCXX/constant-expression.cpp
index e01acdd46f93..f82a69209379 100644
--- a/test/SemaCXX/constant-expression.cpp
+++ b/test/SemaCXX/constant-expression.cpp
@@ -141,3 +141,5 @@ namespace rdar16064952 {
unsigned w = ({int a = b.val[sizeof(0)]; 0; }); // expected-warning {{use of GNU statement expression extension}}
}
}
+
+char PR17381_ice = 1000000 * 1000000; // expected-warning {{overflow}} expected-warning {{changes value}}
diff --git a/test/SemaCXX/constexpr-printing.cpp b/test/SemaCXX/constexpr-printing.cpp
index e545f45d6011..7f6a9c6a82f0 100644
--- a/test/SemaCXX/constexpr-printing.cpp
+++ b/test/SemaCXX/constexpr-printing.cpp
@@ -90,10 +90,12 @@ constexpr wchar_t wc = get(L"test\0\\\"\t\a\b\234\u1234\xffffffff"); // \
constexpr char32_t c32_err = get(U"\U00110000"); // expected-error {{invalid universal character}}
+#define fold(x) (__builtin_constant_p(x) ? (x) : (x))
+
typedef decltype(sizeof(int)) LabelDiffTy;
constexpr LabelDiffTy mulBy3(LabelDiffTy x) { return x * 3; } // expected-note {{subexpression}}
void LabelDiffTest() {
- static_assert(mulBy3((LabelDiffTy)&&a-(LabelDiffTy)&&b) == 3, ""); // expected-error {{constant expression}} expected-note {{call to 'mulBy3(&&a - &&b)'}}
+ static_assert(mulBy3(fold((LabelDiffTy)&&a-(LabelDiffTy)&&b)) == 3, ""); // expected-error {{constant expression}} expected-note {{call to 'mulBy3(&&a - &&b)'}}
a:b:return;
}
diff --git a/test/SemaCXX/constructor-initializer.cpp b/test/SemaCXX/constructor-initializer.cpp
index e3ab610da7ca..c5de33cedb90 100644
--- a/test/SemaCXX/constructor-initializer.cpp
+++ b/test/SemaCXX/constructor-initializer.cpp
@@ -1,4 +1,7 @@
// RUN: %clang_cc1 -Wreorder -fsyntax-only -verify %s
+// RUN: %clang_cc1 -Wreorder -fsyntax-only -verify -std=c++98 %s
+// RUN: %clang_cc1 -Wreorder -fsyntax-only -verify -std=c++11 %s
+
class A {
int m;
public:
@@ -98,9 +101,11 @@ struct Current : Derived {
// expected-error {{member initializer 'NonExisting' does not name a non-static data member or}}
};
-struct M { // expected-note 2 {{candidate constructor (the implicit copy constructor)}} \
- // expected-note {{declared here}} \
- // expected-note {{declared here}}
+struct M { // expected-note 2 {{candidate constructor (the implicit copy constructor)}}
+#if __cplusplus >= 201103L // C++11 or later
+// expected-note@-2 2 {{candidate constructor (the implicit move constructor) not viable}}
+#endif
+// expected-note@-4 2 {{'M' declared here}}
M(int i, int j); // expected-note 2 {{candidate constructor}}
};
@@ -233,7 +238,13 @@ namespace PR7402 {
// <rdar://problem/8308215>: don't crash.
// Lots of questionable recovery here; errors can change.
namespace test3 {
- class A : public std::exception {}; // expected-error {{undeclared identifier}} expected-error {{expected class name}} expected-note 2 {{candidate}}
+ class A : public std::exception {}; // expected-error {{undeclared identifier}} expected-error {{expected class name}}
+ // expected-note@-1 {{candidate constructor (the implicit copy constructor) not viable}}
+#if __cplusplus >= 201103L // C++11 or later
+ // expected-note@-3 {{candidate constructor (the implicit move constructor) not viable}}
+#endif
+ // expected-note@-5 {{candidate constructor (the implicit default constructor) not viable}}
+
class B : public A {
public:
B(const String& s, int e=0) // expected-error {{unknown type name}}
diff --git a/test/SemaCXX/conversion-function.cpp b/test/SemaCXX/conversion-function.cpp
index 077e4d9f3cce..649f6b4dce94 100644
--- a/test/SemaCXX/conversion-function.cpp
+++ b/test/SemaCXX/conversion-function.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -Wbind-to-temporary-copy -verify %s
+// RUN: %clang_cc1 -triple %itanium_abi_triple -fsyntax-only -Wbind-to-temporary-copy -verify %s
class X {
public:
operator bool();
diff --git a/test/SemaCXX/convert-to-bool.cpp b/test/SemaCXX/convert-to-bool.cpp
index b52f11c93d39..117b50899b7e 100644
--- a/test/SemaCXX/convert-to-bool.cpp
+++ b/test/SemaCXX/convert-to-bool.cpp
@@ -1,4 +1,7 @@
// 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 ConvToBool {
operator bool() const;
};
@@ -8,7 +11,10 @@ struct ConvToInt {
};
struct ExplicitConvToBool {
- explicit operator bool(); // expected-warning{{explicit conversion functions are a C++11 extension}}
+ explicit operator bool();
+#if __cplusplus <= 199711L // C++03 or earlier modes
+ // expected-warning@-2{{explicit conversion functions are a C++11 extension}}
+#endif
};
void test_conv_to_bool(ConvToBool ctb, ConvToInt cti, ExplicitConvToBool ecb) {
@@ -39,7 +45,10 @@ void test_conv_to_bool(ConvToBool ctb, ConvToInt cti, ExplicitConvToBool ecb) {
void accepts_bool(bool) { } // expected-note{{candidate function}}
struct ExplicitConvToRef {
- explicit operator int&(); // expected-warning{{explicit conversion functions are a C++11 extension}}
+ explicit operator int&();
+#if (__cplusplus <= 199711L) // C++03 or earlier modes
+ // expected-warning@-2{{explicit conversion functions are a C++11 extension}}
+#endif
};
void test_explicit_bool(ExplicitConvToBool ecb) {
@@ -56,7 +65,10 @@ void test_explicit_conv_to_ref(ExplicitConvToRef ecr) {
struct A { };
struct B { };
struct C {
- explicit operator A&(); // expected-warning{{explicit conversion functions are a C++11 extension}}
+ explicit operator A&();
+#if __cplusplus <= 199711L // C++03 or earlier modes
+// expected-warning@-2{{explicit conversion functions are a C++11 extension}}
+#endif
operator B&(); // expected-note{{candidate}}
};
diff --git a/test/SemaCXX/converting-constructor.cpp b/test/SemaCXX/converting-constructor.cpp
index 1688e51e73fd..75002fa585b8 100644
--- a/test/SemaCXX/converting-constructor.cpp
+++ b/test/SemaCXX/converting-constructor.cpp
@@ -1,4 +1,7 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
class Z { };
class Y {
@@ -28,6 +31,10 @@ public:
};
class FromShortExplicitly { // expected-note{{candidate constructor (the implicit copy constructor)}}
+#if __cplusplus >= 201103L // C++11 or later
+// expected-note@-2 {{candidate constructor (the implicit move constructor) not viable}}
+#endif
+
public:
explicit FromShortExplicitly(short s);
};
diff --git a/test/SemaCXX/copy-initialization.cpp b/test/SemaCXX/copy-initialization.cpp
index ea2db0c68e85..d219ee508f03 100644
--- a/test/SemaCXX/copy-initialization.cpp
+++ b/test/SemaCXX/copy-initialization.cpp
@@ -1,4 +1,7 @@
// 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 X {
public:
explicit X(const X&); // expected-note {{candidate constructor}}
@@ -58,7 +61,10 @@ namespace DR5 {
namespace Ex2 {
struct S {
- S(S&&); // expected-warning {{C++11}}
+ S(S&&);
+#if __cplusplus <= 199711L // C++03 or earlier modes
+ // expected-warning@-2 {{rvalue references are a C++11 extension}}
+#endif
S(int);
};
const S a(0);
diff --git a/test/SemaCXX/coroutines.cpp b/test/SemaCXX/coroutines.cpp
new file mode 100644
index 000000000000..e82cb62f12d4
--- /dev/null
+++ b/test/SemaCXX/coroutines.cpp
@@ -0,0 +1,268 @@
+// RUN: %clang_cc1 -std=c++14 -fcoroutines -verify %s
+
+struct awaitable {
+ bool await_ready();
+ void await_suspend(); // FIXME: coroutine_handle
+ void await_resume();
+} a;
+
+struct suspend_always {
+ bool await_ready() { return false; }
+ void await_suspend() {}
+ void await_resume() {}
+};
+
+struct suspend_never {
+ bool await_ready() { return true; }
+ void await_suspend() {}
+ void await_resume() {}
+};
+
+void no_coroutine_traits() {
+ co_await a; // expected-error {{need to include <coroutine>}}
+}
+
+namespace std {
+ template<typename ...T> struct coroutine_traits; // expected-note {{declared here}}
+};
+
+template<typename Promise> struct coro {};
+template<typename Promise, typename... Ps>
+struct std::coroutine_traits<coro<Promise>, Ps...> {
+ using promise_type = Promise;
+};
+
+void no_specialization() {
+ co_await a; // expected-error {{implicit instantiation of undefined template 'std::coroutine_traits<void>'}}
+}
+
+template<typename ...T> struct std::coroutine_traits<int, T...> {};
+
+int no_promise_type() {
+ co_await a; // expected-error {{this function cannot be a coroutine: 'std::coroutine_traits<int>' has no member named 'promise_type'}}
+}
+
+template<> struct std::coroutine_traits<double, double> { typedef int promise_type; };
+double bad_promise_type(double) {
+ co_await a; // expected-error {{this function cannot be a coroutine: 'std::coroutine_traits<double, double>::promise_type' (aka 'int') is not a class}}
+}
+
+template<> struct std::coroutine_traits<double, int> {
+ struct promise_type {};
+};
+double bad_promise_type_2(int) {
+ co_yield 0; // expected-error {{no member named 'yield_value' in 'std::coroutine_traits<double, int>::promise_type'}}
+}
+
+struct promise; // expected-note 2{{forward declaration}}
+template<typename ...T> struct std::coroutine_traits<void, T...> { using promise_type = promise; };
+
+ // FIXME: This diagnostic is terrible.
+void undefined_promise() { // expected-error {{variable has incomplete type 'promise_type'}}
+ // FIXME: This diagnostic doesn't make any sense.
+ // expected-error@-2 {{incomplete definition of type 'promise'}}
+ co_await a;
+}
+
+struct yielded_thing { const char *p; short a, b; };
+
+struct not_awaitable {};
+
+struct promise {
+ void get_return_object();
+ suspend_always initial_suspend();
+ suspend_always final_suspend();
+ awaitable yield_value(int); // expected-note 2{{candidate}}
+ awaitable yield_value(yielded_thing); // expected-note 2{{candidate}}
+ not_awaitable yield_value(void()); // expected-note 2{{candidate}}
+ void return_void();
+ void return_value(int); // expected-note 2{{here}}
+};
+
+void yield() {
+ co_yield 0;
+ co_yield {"foo", 1, 2};
+ co_yield {1e100}; // expected-error {{cannot be narrowed}} expected-note {{explicit cast}} expected-warning {{changes value}} expected-warning {{braces around scalar}}
+ co_yield {"foo", __LONG_LONG_MAX__}; // expected-error {{cannot be narrowed}} expected-note {{explicit cast}} expected-warning {{changes value}}
+ co_yield {"foo"};
+ co_yield "foo"; // expected-error {{no matching}}
+ co_yield 1.0;
+ co_yield yield; // expected-error {{no member named 'await_ready' in 'not_awaitable'}}
+}
+
+void coreturn(int n) {
+ co_await a;
+ if (n == 0)
+ co_return 3;
+ if (n == 1)
+ co_return {4};
+ if (n == 2)
+ co_return "foo"; // expected-error {{cannot initialize a parameter of type 'int' with an lvalue of type 'const char [4]'}}
+ co_return;
+}
+
+void mixed_yield() {
+ co_yield 0; // expected-note {{use of 'co_yield'}}
+ return; // expected-error {{not allowed in coroutine}}
+}
+
+void mixed_await() {
+ co_await a; // expected-note {{use of 'co_await'}}
+ return; // expected-error {{not allowed in coroutine}}
+}
+
+void only_coreturn() {
+ co_return; // expected-warning {{'co_return' used in a function that uses neither 'co_await' nor 'co_yield'}}
+}
+
+void mixed_coreturn(bool b) {
+ if (b)
+ // expected-warning@+1 {{'co_return' used in a function that uses neither}}
+ co_return; // expected-note {{use of 'co_return'}}
+ else
+ return; // expected-error {{not allowed in coroutine}}
+}
+
+struct CtorDtor {
+ CtorDtor() {
+ co_yield 0; // expected-error {{'co_yield' cannot be used in a constructor}}
+ }
+ CtorDtor(awaitable a) {
+ // The spec doesn't say this is ill-formed, but it must be.
+ co_await a; // expected-error {{'co_await' cannot be used in a constructor}}
+ }
+ ~CtorDtor() {
+ co_return 0; // expected-error {{'co_return' cannot be used in a destructor}}
+ }
+ // FIXME: The spec says this is ill-formed.
+ void operator=(CtorDtor&) {
+ co_yield 0;
+ }
+};
+
+void unevaluated() {
+ decltype(co_await a); // expected-error {{cannot be used in an unevaluated context}}
+ sizeof(co_await a); // expected-error {{cannot be used in an unevaluated context}}
+ typeid(co_await a); // expected-error {{cannot be used in an unevaluated context}}
+ decltype(co_yield a); // expected-error {{cannot be used in an unevaluated context}}
+ sizeof(co_yield a); // expected-error {{cannot be used in an unevaluated context}}
+ typeid(co_yield a); // expected-error {{cannot be used in an unevaluated context}}
+}
+
+constexpr void constexpr_coroutine() {
+ co_yield 0; // expected-error {{'co_yield' cannot be used in a constexpr function}}
+}
+
+void varargs_coroutine(const char *, ...) {
+ co_await a; // expected-error {{'co_await' cannot be used in a varargs function}}
+}
+
+struct outer {};
+
+namespace dependent_operator_co_await_lookup {
+ template<typename T> void await_template(T t) {
+ // no unqualified lookup results
+ co_await t; // expected-error {{no member named 'await_ready' in 'dependent_operator_co_await_lookup::not_awaitable'}}
+ // expected-error@-1 {{call to function 'operator co_await' that is neither visible in the template definition nor found by argument-dependent lookup}}
+ };
+ template void await_template(awaitable);
+
+ struct indirectly_awaitable { indirectly_awaitable(outer); };
+ awaitable operator co_await(indirectly_awaitable); // expected-note {{should be declared prior to}}
+ template void await_template(indirectly_awaitable);
+
+ struct not_awaitable {};
+ template void await_template(not_awaitable); // expected-note {{instantiation}}
+
+ template<typename T> void await_template_2(T t) {
+ // one unqualified lookup result
+ co_await t;
+ };
+ template void await_template(outer); // expected-note {{instantiation}}
+ template void await_template_2(outer);
+}
+
+struct yield_fn_tag {};
+template<> struct std::coroutine_traits<void, yield_fn_tag> {
+ struct promise_type {
+ // FIXME: add an await_transform overload for functions
+ awaitable yield_value(int());
+ void return_value(int());
+
+ suspend_never initial_suspend();
+ suspend_never final_suspend();
+ void get_return_object();
+ };
+};
+
+namespace placeholder {
+ awaitable f(), f(int); // expected-note 4{{possible target}}
+ int g(), g(int); // expected-note 2{{candidate}}
+ void x() {
+ co_await f; // expected-error {{reference to overloaded function}}
+ }
+ void y() {
+ co_yield g; // expected-error {{no matching member function for call to 'yield_value'}}
+ }
+ void z() {
+ co_await a;
+ co_return g; // expected-error {{address of overloaded function 'g' does not match required type 'int'}}
+ }
+
+ void x(yield_fn_tag) {
+ co_await f; // expected-error {{reference to overloaded function}}
+ }
+ void y(yield_fn_tag) {
+ co_yield g;
+ }
+ void z(yield_fn_tag) {
+ co_await a;
+ co_return g;
+ }
+}
+
+struct bad_promise_1 {
+ suspend_always initial_suspend();
+ suspend_always final_suspend();
+};
+coro<bad_promise_1> missing_get_return_object() { // expected-error {{no member named 'get_return_object' in 'bad_promise_1'}}
+ co_await a;
+}
+
+struct bad_promise_2 {
+ coro<bad_promise_2> get_return_object();
+ // FIXME: We shouldn't offer a typo-correction here!
+ suspend_always final_suspend(); // expected-note {{here}}
+};
+coro<bad_promise_2> missing_initial_suspend() { // expected-error {{no member named 'initial_suspend' in 'bad_promise_2'}}
+ co_await a;
+}
+
+struct bad_promise_3 {
+ coro<bad_promise_3> get_return_object();
+ // FIXME: We shouldn't offer a typo-correction here!
+ suspend_always initial_suspend(); // expected-note {{here}}
+};
+coro<bad_promise_3> missing_final_suspend() { // expected-error {{no member named 'final_suspend' in 'bad_promise_3'}}
+ co_await a;
+}
+
+struct bad_promise_4 {
+ coro<bad_promise_4> get_return_object();
+ not_awaitable initial_suspend();
+ suspend_always final_suspend();
+};
+// FIXME: This diagnostic is terrible.
+coro<bad_promise_4> bad_initial_suspend() { // expected-error {{no member named 'await_ready' in 'not_awaitable'}}
+ co_await a;
+}
+
+struct bad_promise_5 {
+ coro<bad_promise_5> get_return_object();
+ suspend_always initial_suspend();
+ not_awaitable final_suspend();
+};
+// FIXME: This diagnostic is terrible.
+coro<bad_promise_5> bad_final_suspend() { // expected-error {{no member named 'await_ready' in 'not_awaitable'}}
+ co_await a;
+}
diff --git a/test/SemaCXX/crashes.cpp b/test/SemaCXX/crashes.cpp
index 12251bba95a4..926d13ab4533 100644
--- a/test/SemaCXX/crashes.cpp
+++ b/test/SemaCXX/crashes.cpp
@@ -1,4 +1,6 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
// <rdar://problem/8124080>
template<typename _Alloc> class allocator;
@@ -31,7 +33,11 @@ template<typename T> struct a : T {
namespace rdar8605381 {
struct X {};
-struct Y { // expected-note{{candidate}}
+struct Y { // expected-note{{candidate constructor (the implicit copy constructor) not viable}}
+#if __cplusplus >= 201103L // C++11 or later
+// expected-note@-2 {{candidate constructor (the implicit move constructor) not viable}}
+#endif
+
Y();
};
diff --git a/test/SemaCXX/cxx0x-initializer-aggregates.cpp b/test/SemaCXX/cxx0x-initializer-aggregates.cpp
index 0e9a97d5bb07..1b01a351f781 100644
--- a/test/SemaCXX/cxx0x-initializer-aggregates.cpp
+++ b/test/SemaCXX/cxx0x-initializer-aggregates.cpp
@@ -129,3 +129,7 @@ namespace array_addressof {
using T = int[5];
T *p = &T{1,2,3,4,5}; // expected-error {{taking the address of a temporary object of type 'T' (aka 'int [5]')}}
}
+
+namespace PR24816 {
+ struct { int i; } ne = {{0, 1}}; // expected-error{{excess elements in scalar initializer}}
+}
diff --git a/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp b/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp
index 9456dd713aa8..060a0f236b4e 100644
--- a/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp
+++ b/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp
@@ -117,8 +117,10 @@ void argument_deduction() {
void auto_deduction() {
auto l = {1, 2, 3, 4};
- auto l2 {1, 2, 3, 4}; // expected-warning {{will change meaning in a future version of Clang}}
+ auto l2 {1, 2, 3, 4}; // expected-error {{initializer for variable 'l2' with type 'auto' contains multiple expressions}}
+ auto l3 {1};
static_assert(same_type<decltype(l), std::initializer_list<int>>::value, "");
+ static_assert(same_type<decltype(l3), int>::value, "");
auto bl = {1, 2.0}; // expected-error {{cannot deduce}}
for (int i : {1, 2, 3, 4}) {}
@@ -190,7 +192,7 @@ namespace rdar11948732 {
}
namespace PR14272 {
- auto x { { 0, 0 } }; // expected-error {{cannot deduce actual type for variable 'x' with type 'auto' from initializer list}}
+ auto x { { 0, 0 } }; // expected-error {{cannot deduce type for variable 'x' with type 'auto' from nested initializer list}}
}
namespace initlist_of_array {
@@ -282,3 +284,28 @@ namespace ParameterPackNestedInitializerLists_PR23904c3 {
void foo() { f({{0}}, {{'\0'}}); }
}
+
+namespace update_rbrace_loc_crash {
+ // We used to crash-on-invalid on this example when updating the right brace
+ // location.
+ template <typename T, T>
+ struct A {};
+ template <typename T, typename F, int... I>
+ std::initializer_list<T> ExplodeImpl(F p1, A<int, I...>) {
+ // expected-error@+1 {{reference to type 'const update_rbrace_loc_crash::Incomplete' could not bind to an rvalue of type 'void'}}
+ return {p1(I)...};
+ }
+ template <typename T, int N, typename F>
+ void Explode(F p1) {
+ // expected-note@+1 {{in instantiation of function template specialization}}
+ ExplodeImpl<T>(p1, A<int, N>());
+ }
+ class Incomplete;
+ struct ContainsIncomplete {
+ const Incomplete &obstacle;
+ };
+ void f() {
+ // expected-note@+1 {{in instantiation of function template specialization}}
+ Explode<ContainsIncomplete, 4>([](int) {});
+ }
+}
diff --git a/test/SemaCXX/cxx0x-return-init-list.cpp b/test/SemaCXX/cxx0x-return-init-list.cpp
index 84bd89b210fc..2aeec7bff7c8 100644
--- a/test/SemaCXX/cxx0x-return-init-list.cpp
+++ b/test/SemaCXX/cxx0x-return-init-list.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
// Test that a very basic variation of generalized initializer returns (that
// required for libstdc++ 4.5) is supported in C++98.
diff --git a/test/SemaCXX/cxx11-ast-print.cpp b/test/SemaCXX/cxx11-ast-print.cpp
index 27726dedb496..1eeb67a3d9b3 100644
--- a/test/SemaCXX/cxx11-ast-print.cpp
+++ b/test/SemaCXX/cxx11-ast-print.cpp
@@ -1,21 +1,21 @@
// RUN: %clang_cc1 -std=c++11 -ast-print %s | FileCheck %s
-// CHECK: auto operator "" _foo(const char *p, decltype(sizeof(int))) -> decltype(nullptr);
+// CHECK: auto operator""_foo(const char *p, decltype(sizeof(int))) -> decltype(nullptr);
auto operator"" _foo(const char *p, decltype(sizeof(int))) -> decltype(nullptr);
-// CHECK: decltype(""_foo) operator "" _bar(unsigned long long);
+// CHECK: decltype(""_foo) operator""_bar(unsigned long long);
decltype(""_foo) operator"" _bar(unsigned long long);
-// CHECK: decltype(42_bar) operator "" _baz(long double);
+// CHECK: decltype(42_bar) operator""_baz(long double);
decltype(42_bar) operator"" _baz(long double);
-// CHECK: decltype(4.5_baz) operator "" _baz(char);
+// CHECK: decltype(4.5_baz) operator""_baz(char);
decltype(4.5_baz) operator"" _baz(char);
-// CHECK: const char *operator "" _quux(const char *);
+// CHECK: const char *operator""_quux(const char *);
const char *operator"" _quux(const char *);
-// CHECK: template <char ...> const char *operator "" _fritz();
+// CHECK: template <char ...> const char *operator""_fritz();
template<char...> const char *operator"" _fritz();
// CHECK: const char *p1 = "bar1"_foo;
@@ -40,7 +40,7 @@ const char *p9 = 0x42e3F_fritz;
const char *p10 = 3.300e+15_fritz;
template <class C, C...> const char *operator"" _suffix();
-// CHECK: const char *PR23120 = operator "" _suffix<char32_t, 66615>();
+// CHECK: const char *PR23120 = operator""_suffix<char32_t, 66615>();
const char *PR23120 = U"𐐷"_suffix;
// CHECK: ;
diff --git a/test/SemaCXX/cxx11-user-defined-literals.cpp b/test/SemaCXX/cxx11-user-defined-literals.cpp
index cb7796418ee3..b5d4d9976c13 100644
--- a/test/SemaCXX/cxx11-user-defined-literals.cpp
+++ b/test/SemaCXX/cxx11-user-defined-literals.cpp
@@ -70,7 +70,7 @@ namespace Using {
namespace M {
int operator"" _using(char);
}
- int k1 = 'x'_using; // expected-error {{no matching literal operator for call to 'operator "" _using'}}
+ int k1 = 'x'_using; // expected-error {{no matching literal operator for call to 'operator""_using'}}
using M::operator "" _using;
int k2 = 'x'_using;
@@ -80,7 +80,7 @@ namespace AmbiguousRawTemplate {
int operator"" _ambig1(const char *); // expected-note {{candidate}}
template<char...> int operator"" _ambig1(); // expected-note {{candidate}}
- int k1 = 123_ambig1; // expected-error {{call to 'operator "" _ambig1' is ambiguous}}
+ int k1 = 123_ambig1; // expected-error {{call to 'operator""_ambig1' is ambiguous}}
namespace Inner {
template<char...> int operator"" _ambig2(); // expected-note 3{{candidate}}
@@ -88,7 +88,7 @@ namespace AmbiguousRawTemplate {
int operator"" _ambig2(const char *); // expected-note 3{{candidate}}
using Inner::operator"" _ambig2;
- int k2 = 123_ambig2; // expected-error {{call to 'operator "" _ambig2' is ambiguous}}
+ int k2 = 123_ambig2; // expected-error {{call to 'operator""_ambig2' is ambiguous}}
namespace N {
using Inner::operator"" _ambig2;
@@ -133,13 +133,13 @@ namespace Namespace {
int k = _x(); // expected-error {{undeclared identifier '_x'}}
int _y(unsigned long long);
- int k2 = 123_y; // expected-error {{no matching literal operator for call to 'operator "" _y'}}
+ int k2 = 123_y; // expected-error {{no matching literal operator for call to 'operator""_y'}}
}
namespace PR14950 {
template<...> // expected-error {{expected template parameter}}
int operator"" _b(); // expected-error {{no function template matches function template specialization}}
- int main() { return 0_b; } // expected-error {{no matching literal operator for call to 'operator "" _b'}}
+ int main() { return 0_b; } // expected-error {{no matching literal operator for call to 'operator""_b'}}
}
namespace bad_names {
diff --git a/test/SemaCXX/cxx1y-generic-lambdas.cpp b/test/SemaCXX/cxx1y-generic-lambdas.cpp
index c937c6728c2b..3774e8d3834b 100644
--- a/test/SemaCXX/cxx1y-generic-lambdas.cpp
+++ b/test/SemaCXX/cxx1y-generic-lambdas.cpp
@@ -859,7 +859,7 @@ namespace ns1 {
struct X1 {
struct X2 {
enum { E = [](auto i) { return i; }(3) }; //expected-error{{inside of a constant expression}}\
- //expected-error{{not an integral constant}}\
+ //expected-error{{constant}}\
//expected-note{{non-literal type}}
int L = ([] (int i) { return i; })(2);
void foo(int i = ([] (int i) { return i; })(2)) { }
diff --git a/test/SemaCXX/cxx1y-init-captures.cpp b/test/SemaCXX/cxx1y-init-captures.cpp
index 203e28d7c3f9..d36882d8e5d1 100644
--- a/test/SemaCXX/cxx1y-init-captures.cpp
+++ b/test/SemaCXX/cxx1y-init-captures.cpp
@@ -190,3 +190,9 @@ int run() {
}
}
+
+namespace N3922 {
+ struct X { X(); explicit X(const X&); int n; };
+ auto a = [x{X()}] { return x.n; }; // ok
+ auto b = [x = {X()}] {}; // expected-error{{<initializer_list>}}
+}
diff --git a/test/SemaCXX/cxx1y-variable-templates_in_class.cpp b/test/SemaCXX/cxx1y-variable-templates_in_class.cpp
index 123fcfff7f7a..65e2d6b608c2 100644
--- a/test/SemaCXX/cxx1y-variable-templates_in_class.cpp
+++ b/test/SemaCXX/cxx1y-variable-templates_in_class.cpp
@@ -327,3 +327,14 @@ struct S {
static int f : I; // expected-error {{static member 'f' cannot be a bit-field}}
};
}
+
+namespace b20896909 {
+ // This used to crash.
+ template<typename T> struct helper {};
+ template<typename T> class A {
+ template <typename> static helper<typename T::error> x; // expected-error {{type 'int' cannot be used prior to '::' because it has no members}}
+ };
+ void test() {
+ A<int> ai; // expected-note {{in instantiation of}}
+ }
+}
diff --git a/test/SemaCXX/cxx1y-variable-templates_top_level.cpp b/test/SemaCXX/cxx1y-variable-templates_top_level.cpp
index 145bc49fff1f..787868fae176 100644
--- a/test/SemaCXX/cxx1y-variable-templates_top_level.cpp
+++ b/test/SemaCXX/cxx1y-variable-templates_top_level.cpp
@@ -90,8 +90,8 @@ namespace odr_tmpl {
}
namespace pvt_diff_params {
- template<typename T, typename> T v; // expected-note {{previous template declaration is here}}
- template<typename T> T v; // expected-error {{too few template parameters in template redeclaration}} expected-note {{previous template declaration is here}}
+ template<typename T, typename> T v; // expected-note 2{{previous template declaration is here}}
+ template<typename T> T v; // expected-error {{too few template parameters in template redeclaration}}
template<typename T, typename, typename> T v; // expected-error {{too many template parameters in template redeclaration}}
}
diff --git a/test/SemaCXX/cxx98-compat.cpp b/test/SemaCXX/cxx98-compat.cpp
index 4227272d14e4..25a086d9bcd3 100644
--- a/test/SemaCXX/cxx98-compat.cpp
+++ b/test/SemaCXX/cxx98-compat.cpp
@@ -100,6 +100,9 @@ struct RefQualifier {
};
auto f() -> int; // expected-warning {{trailing return types are incompatible with C++98}}
+#ifdef CXX14COMPAT
+auto ff() { return 5; } // expected-warning {{'auto' type specifier is incompatible with C++98}}
+#endif
void RangeFor() {
int xs[] = {1, 2, 3};
diff --git a/test/SemaCXX/decl-expr-ambiguity.cpp b/test/SemaCXX/decl-expr-ambiguity.cpp
index 6abfb2f32874..1b1f7dc8a70e 100644
--- a/test/SemaCXX/decl-expr-ambiguity.cpp
+++ b/test/SemaCXX/decl-expr-ambiguity.cpp
@@ -1,4 +1,6 @@
// RUN: %clang_cc1 -Wno-int-to-pointer-cast -fsyntax-only -verify -pedantic-errors %s
+// RUN: %clang_cc1 -Wno-int-to-pointer-cast -fsyntax-only -verify -pedantic-errors -std=gnu++98 %s
+// RUN: %clang_cc1 -Wno-int-to-pointer-cast -fsyntax-only -verify -pedantic-errors -std=gnu++11 %s
// RUN: %clang_cc1 -Wno-int-to-pointer-cast -fsyntax-only -verify -pedantic-errors -x objective-c++ %s
void f() {
@@ -60,6 +62,9 @@ namespace N {
func(); // expected-warning {{function declaration}} expected-note {{replace parentheses with an initializer}}
S s(); // expected-warning {{function declaration}}
+#if __cplusplus >= 201103L
+ // expected-note@-2 {{replace parentheses with an initializer to declare a variable}}
+#endif
}
void nonEmptyParens() {
int f = 0, // g = 0; expected-note {{change this ',' to a ';' to call 'func2'}}
diff --git a/test/SemaCXX/decl-microsoft-call-conv.cpp b/test/SemaCXX/decl-microsoft-call-conv.cpp
index 6c392ea9420d..acd9b0720b62 100644
--- a/test/SemaCXX/decl-microsoft-call-conv.cpp
+++ b/test/SemaCXX/decl-microsoft-call-conv.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -std=c++14 -triple i686-pc-win32 -fms-extensions -verify %s
+// RUN: %clang_cc1 -std=c++14 -triple i686-pc-win32 -fms-extensions -DMSABI -verify %s
// RUN: %clang_cc1 -std=c++14 -triple i686-pc-mingw32 -verify %s
// RUN: %clang_cc1 -std=c++14 -triple i686-pc-mingw32 -fms-extensions -verify %s
@@ -74,6 +74,11 @@ struct S {
static void static_member_variadic_default(int x, ...);
static void __cdecl static_member_variadic_cdecl(int x, ...);
+
+ // Structors can't be other than default in MS ABI environment
+#ifdef MSABI
+ __vectorcall S(); // expected-warning {{vectorcall calling convention ignored on constructor/destructor}}
+#endif
};
void __cdecl S::member_default1() {} // expected-error {{function declared 'cdecl' here was previously declared without calling convention}}
diff --git a/test/SemaCXX/decltype-crash.cpp b/test/SemaCXX/decltype-crash.cpp
index 002bd4cfe737..1cebfcd72c86 100644
--- a/test/SemaCXX/decltype-crash.cpp
+++ b/test/SemaCXX/decltype-crash.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -Wc++11-compat %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wc++11-compat -std=c++98 %s
int& a();
diff --git a/test/SemaCXX/default-assignment-operator.cpp b/test/SemaCXX/default-assignment-operator.cpp
index f202b61e109e..e57a898f2f10 100644
--- a/test/SemaCXX/default-assignment-operator.cpp
+++ b/test/SemaCXX/default-assignment-operator.cpp
@@ -1,12 +1,12 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
-class Base { // expected-error {{cannot define the implicit copy assignment operator for 'Base', because non-static reference member 'ref' can't use copy assignment operator}} \
+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 X : Base { // // expected-error {{cannot define the implicit copy assignment operator for 'X', because non-static const member 'cint' can't use copy assignment operator}} \
+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}}
public:
X();
@@ -73,7 +73,7 @@ void i() {
// Test5
-class E1 { // expected-error{{cannot define the implicit copy assignment operator for 'E1', because non-static const member 'a' can't use copy assignment operator}}
+class E1 { // expected-error{{cannot define the implicit copy assignment operator for 'E1', because non-static const member 'a' cannot use copy assignment operator}}
public:
const int a; // expected-note{{declared here}}
diff --git a/test/SemaCXX/default1.cpp b/test/SemaCXX/default1.cpp
index 6001001b11eb..fcaa2c839d6c 100644
--- a/test/SemaCXX/default1.cpp
+++ b/test/SemaCXX/default1.cpp
@@ -1,4 +1,7 @@
// 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
+
void f(int i);
void f(int i = 0); // expected-note {{previous definition is here}}
void f(int i = 17); // expected-error {{redefinition of default argument}}
@@ -23,7 +26,11 @@ struct X {
void j(X x = 17); // expected-note{{'::j' declared here}}
-struct Y { // expected-note 2{{candidate}}
+struct Y { // expected-note 2{{candidate constructor (the implicit copy constructor) not viable}}
+#if __cplusplus >= 201103L // C++11 or later
+// expected-note@-2 2 {{candidate constructor (the implicit move constructor) not viable}}
+#endif
+
explicit Y(int);
};
diff --git a/test/SemaCXX/deleted-function-access.cpp b/test/SemaCXX/deleted-function-access.cpp
new file mode 100644
index 000000000000..f355e41ae6c4
--- /dev/null
+++ b/test/SemaCXX/deleted-function-access.cpp
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s
+
+struct S {
+ virtual void f() = delete; //expected-note{{'f' has been explicitly marked deleted here}}
+ void g() { f(); } //expected-error{{attempt to use a deleted function}}
+};
diff --git a/test/SemaCXX/deprecated.cpp b/test/SemaCXX/deprecated.cpp
index 5fcf2130d36f..4ce058968742 100644
--- a/test/SemaCXX/deprecated.cpp
+++ b/test/SemaCXX/deprecated.cpp
@@ -1,6 +1,7 @@
// RUN: %clang_cc1 -std=c++98 %s -Wdeprecated -verify -triple x86_64-linux-gnu
// RUN: %clang_cc1 -std=c++11 %s -Wdeprecated -verify -triple x86_64-linux-gnu
// RUN: %clang_cc1 -std=c++1y %s -Wdeprecated -verify -triple x86_64-linux-gnu
+// RUN: %clang_cc1 -std=c++1z %s -Wdeprecated -verify -triple x86_64-linux-gnu
// RUN: %clang_cc1 -std=c++1y %s -Wdeprecated -verify -triple x86_64-linux-gnu -Wno-deprecated-register -DNO_DEPRECATED_FLAGS
@@ -17,15 +18,29 @@ void h() throw(...);
void stuff() {
register int n;
-#if __cplusplus >= 201103L && !defined(NO_DEPRECATED_FLAGS)
- // expected-warning@-2 {{'register' storage class specifier is deprecated}}
+#if __cplusplus > 201402L
+ // expected-error@-2 {{ISO C++1z does not allow 'register' storage class specifier}}
+#elif __cplusplus >= 201103L && !defined(NO_DEPRECATED_FLAGS)
+ // expected-warning@-4 {{'register' storage class specifier is deprecated}}
#endif
register int m asm("rbx"); // no-warning
int k = to_int(n); // no-warning
bool b;
- ++b; // expected-warning {{incrementing expression of type bool is deprecated}}
+ ++b;
+#if __cplusplus > 201402L
+ // expected-error@-2 {{ISO C++1z does not allow incrementing expression of type bool}}
+#else
+ // expected-warning@-4 {{incrementing expression of type bool is deprecated}}
+#endif
+
+ b++;
+#if __cplusplus > 201402L
+ // expected-error@-2 {{ISO C++1z does not allow incrementing expression of type bool}}
+#else
+ // expected-warning@-4 {{incrementing expression of type bool is deprecated}}
+#endif
char *p = "foo";
#if __cplusplus < 201103L
diff --git a/test/SemaCXX/destructor.cpp b/test/SemaCXX/destructor.cpp
index 60cb0ef09089..e7323f90b3f7 100644
--- a/test/SemaCXX/destructor.cpp
+++ b/test/SemaCXX/destructor.cpp
@@ -217,8 +217,8 @@ class simple_ptr {
public:
simple_ptr(T* t): _ptr(t) {}
~simple_ptr() { delete _ptr; } // \
- // expected-warning {{delete called on 'dnvd::B' that has virtual functions but non-virtual destructor}} \
- // expected-warning {{delete called on 'dnvd::D' that has virtual functions but non-virtual destructor}}
+ // expected-warning {{delete called on non-final 'dnvd::B' that has virtual functions but non-virtual destructor}} \
+ // expected-warning {{delete called on non-final 'dnvd::D' that has virtual functions but non-virtual destructor}}
T& operator*() const { return *_ptr; }
private:
T* _ptr;
@@ -228,7 +228,7 @@ template <typename T>
class simple_ptr2 {
public:
simple_ptr2(T* t): _ptr(t) {}
- ~simple_ptr2() { delete _ptr; } // expected-warning {{delete called on 'dnvd::B' that has virtual functions but non-virtual destructor}}
+ ~simple_ptr2() { delete _ptr; } // expected-warning {{delete called on non-final 'dnvd::B' that has virtual functions but non-virtual destructor}}
T& operator*() const { return *_ptr; }
private:
T* _ptr;
@@ -314,15 +314,15 @@ void nowarn0() {
void warn0() {
{
B* b = new B();
- delete b; // expected-warning {{delete called on 'dnvd::B' that has virtual functions but non-virtual destructor}}
+ delete b; // expected-warning {{delete called on non-final 'dnvd::B' that has virtual functions but non-virtual destructor}}
}
{
B* b = new D();
- delete b; // expected-warning {{delete called on 'dnvd::B' that has virtual functions but non-virtual destructor}}
+ delete b; // expected-warning {{delete called on non-final 'dnvd::B' that has virtual functions but non-virtual destructor}}
}
{
D* d = new D();
- delete d; // expected-warning {{delete called on 'dnvd::D' that has virtual functions but non-virtual destructor}}
+ delete d; // expected-warning {{delete called on non-final 'dnvd::D' that has virtual functions but non-virtual destructor}}
}
}
diff --git a/test/SemaCXX/direct-initializer.cpp b/test/SemaCXX/direct-initializer.cpp
index a7899c75e4dc..947622c4e34c 100644
--- a/test/SemaCXX/direct-initializer.cpp
+++ b/test/SemaCXX/direct-initializer.cpp
@@ -1,4 +1,6 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
int x(1);
int (x2)(1);
@@ -14,6 +16,10 @@ public: explicit Y(float);
};
class X { // expected-note{{candidate constructor (the implicit copy constructor)}}
+#if __cplusplus >= 201103L // C++11 or later
+// expected-note@-2 {{candidate constructor (the implicit move constructor) not viable}}
+#endif
+
public:
explicit X(int); // expected-note{{candidate constructor}}
X(float, float, float); // expected-note{{candidate constructor}}
@@ -21,6 +27,10 @@ public:
};
class Z { // expected-note{{candidate constructor (the implicit copy constructor)}}
+#if __cplusplus >= 201103L // C++11 or later
+// expected-note@-2 {{candidate constructor (the implicit move constructor) not viable}}
+#endif
+
public:
Z(int); // expected-note{{candidate constructor}}
};
diff --git a/test/SemaCXX/dllexport.cpp b/test/SemaCXX/dllexport.cpp
index badb9e259597..a32ba44442d7 100644
--- a/test/SemaCXX/dllexport.cpp
+++ b/test/SemaCXX/dllexport.cpp
@@ -71,6 +71,10 @@ __declspec(dllexport) auto ExternalAutoTypeGlobal = External();
// Thread local variables are invalid.
__declspec(dllexport) __thread int ThreadLocalGlobal; // expected-error{{'ThreadLocalGlobal' cannot be thread local when declared 'dllexport'}}
+// But a static local TLS var in an export function is OK.
+inline void __declspec(dllexport) ExportedInlineWithThreadLocal() {
+ static __thread int OK; // no-error
+}
// Export in local scope.
void functionScope() {
@@ -1079,3 +1083,12 @@ template<typename T> template<typename U> __declspec(dllexport) constexpr int CT
#endif // __has_feature(cxx_variable_templates)
// FIXME: Precedence rules seem to be different for classes.
+
+//===----------------------------------------------------------------------===//
+// Lambdas
+//===----------------------------------------------------------------------===//
+// The MS ABI doesn't provide a stable mangling for lambdas, so they can't be imported or exported.
+#ifdef MS
+// expected-error@+2{{lambda cannot be declared 'dllexport'}}
+#endif
+auto Lambda = []() __declspec(dllexport) -> bool { return true; };
diff --git a/test/SemaCXX/dllimport.cpp b/test/SemaCXX/dllimport.cpp
index 2fa10756da48..5d8ce78f6cdc 100644
--- a/test/SemaCXX/dllimport.cpp
+++ b/test/SemaCXX/dllimport.cpp
@@ -93,6 +93,12 @@ __declspec(dllimport) auto InternalAutoTypeGlobal = Internal(); // expected-erro
// Thread local variables are invalid.
__declspec(dllimport) __thread int ThreadLocalGlobal; // expected-error{{'ThreadLocalGlobal' cannot be thread local when declared 'dllimport'}}
+// This doesn't work on MinGW, because there, dllimport on the inline function is ignored.
+#ifndef GNU
+inline void __declspec(dllimport) ImportedInlineWithThreadLocal() {
+ static __thread int OK; // no-error
+}
+#endif
// Import in local scope.
__declspec(dllimport) float LocalRedecl1; // expected-note{{previous declaration is here}}
@@ -1333,3 +1339,14 @@ struct __declspec(dllimport) DerivedFromExplicitlyImportInstantiatedTemplate : p
template <typename T> struct ExplicitInstantiationDeclTemplateBase { void func() {} };
extern template struct ExplicitInstantiationDeclTemplateBase<int>;
struct __declspec(dllimport) DerivedFromExplicitInstantiationDeclTemplateBase : public ExplicitInstantiationDeclTemplateBase<int> {};
+
+//===----------------------------------------------------------------------===//
+// Lambdas
+//===----------------------------------------------------------------------===//
+// The MS ABI doesn't provide a stable mangling for lambdas, so they can't be imported or exported.
+#ifdef MS
+// expected-error@+4{{lambda cannot be declared 'dllimport'}}
+#else
+// expected-warning@+2{{'dllimport' attribute ignored on inline function}}
+#endif
+auto Lambda = []() __declspec(dllimport) -> bool { return true; };
diff --git a/test/SemaCXX/enable_if.cpp b/test/SemaCXX/enable_if.cpp
index 99545e09820e..cd8241808c94 100644
--- a/test/SemaCXX/enable_if.cpp
+++ b/test/SemaCXX/enable_if.cpp
@@ -2,6 +2,8 @@
typedef int (*fp)(int);
int surrogate(int);
+struct Incomplete; // expected-note{{forward declaration of 'Incomplete'}} \
+ // expected-note {{forward declaration of 'Incomplete'}}
struct X {
X() = default; // expected-note{{candidate constructor not viable: requires 0 arguments, but 1 was provided}}
@@ -9,24 +11,31 @@ struct X {
X(bool b) __attribute__((enable_if(b, "chosen when 'b' is true"))); // expected-note{{candidate disabled: chosen when 'b' is true}}
void f(int n) __attribute__((enable_if(n == 0, "chosen when 'n' is zero")));
- void f(int n) __attribute__((enable_if(n == 1, "chosen when 'n' is one"))); // expected-note{{member declaration nearly matches}} expected-note{{candidate disabled: chosen when 'n' is one}}
+ void f(int n) __attribute__((enable_if(n == 1, "chosen when 'n' is one"))); // expected-note{{member declaration nearly matches}} expected-note 2{{candidate disabled: chosen when 'n' is one}}
+
+ void g(int n) __attribute__((enable_if(n == 0, "chosen when 'n' is zero"))); // expected-note{{candidate disabled: chosen when 'n' is zero}}
+
+ void h(int n, int m = 0) __attribute__((enable_if(m == 0, "chosen when 'm' is zero"))); // expected-note{{candidate disabled: chosen when 'm' is zero}}
static void s(int n) __attribute__((enable_if(n == 0, "chosen when 'n' is zero"))); // expected-note2{{candidate disabled: chosen when 'n' is zero}}
void conflict(int n) __attribute__((enable_if(n+n == 10, "chosen when 'n' is five"))); // expected-note{{candidate function}}
void conflict(int n) __attribute__((enable_if(n*2 == 10, "chosen when 'n' is five"))); // expected-note{{candidate function}}
+ void hidden_by_argument_conversion(Incomplete n, int m = 0) __attribute__((enable_if(m == 10, "chosen when 'm' is ten")));
+ Incomplete hidden_by_incomplete_return_value(int n = 0) __attribute__((enable_if(n == 10, "chosen when 'n' is ten"))); // expected-note{{'hidden_by_incomplete_return_value' declared here}}
+
operator long() __attribute__((enable_if(true, "chosen on your platform")));
operator int() __attribute__((enable_if(false, "chosen on other platform")));
operator fp() __attribute__((enable_if(false, "never enabled"))) { return surrogate; } // expected-note{{conversion candidate of type 'int (*)(int)'}} // FIXME: the message is not displayed
};
-void X::f(int n) __attribute__((enable_if(n == 0, "chosen when 'n' is zero"))) // expected-note{{member declaration nearly matches}} expected-note{{candidate disabled: chosen when 'n' is zero}}
+void X::f(int n) __attribute__((enable_if(n == 0, "chosen when 'n' is zero"))) // expected-note{{member declaration nearly matches}} expected-note 2{{candidate disabled: chosen when 'n' is zero}}
{
}
-void X::f(int n) __attribute__((enable_if(n == 2, "chosen when 'n' is two"))) // expected-error{{out-of-line definition of 'f' does not match any declaration in 'X'}} expected-note{{candidate disabled: chosen when 'n' is two}}
+void X::f(int n) __attribute__((enable_if(n == 2, "chosen when 'n' is two"))) // expected-error{{out-of-line definition of 'f' does not match any declaration in 'X'}}
{
}
@@ -40,6 +49,15 @@ void deprec2(int i) __attribute__((enable_if(old() == 0, "chosen when old() is z
void overloaded(int);
void overloaded(long);
+struct Int {
+ constexpr Int(int i) : i(i) { }
+ constexpr operator int() const { return i; }
+ int i;
+};
+
+void default_argument(int n, int m = 0) __attribute__((enable_if(m == 0, "chosen when 'm' is zero"))); // expected-note{{candidate disabled: chosen when 'm' is zero}}
+void default_argument_promotion(int n, int m = Int(0)) __attribute__((enable_if(m == 0, "chosen when 'm' is zero"))); // expected-note{{candidate disabled: chosen when 'm' is zero}}
+
struct Nothing { };
template<typename T> void typedep(T t) __attribute__((enable_if(t, ""))); // expected-note{{candidate disabled:}} expected-error{{value of type 'Nothing' is not contextually convertible to 'bool'}}
template<int N> void valuedep() __attribute__((enable_if(N == 1, "")));
@@ -55,9 +73,15 @@ void test() {
X x;
x.f(0);
x.f(1);
- x.f(2); // no error, suppressed by erroneous out-of-line definition
+ x.f(2); // expected-error{{no matching member function for call to 'f'}}
x.f(3); // expected-error{{no matching member function for call to 'f'}}
+ x.g(0);
+ x.g(1); // expected-error{{no matching member function for call to 'g'}}
+
+ x.h(0);
+ x.h(1, 2); // expected-error{{no matching member function for call to 'h'}}
+
x.s(0);
x.s(1); // expected-error{{no matching member function for call to 's'}}
@@ -66,10 +90,19 @@ void test() {
x.conflict(5); // expected-error{{call to member function 'conflict' is ambiguous}}
+ x.hidden_by_argument_conversion(10); // expected-error{{argument type 'Incomplete' is incomplete}}
+ x.hidden_by_incomplete_return_value(10); // expected-error{{calling 'hidden_by_incomplete_return_value' with incomplete return type 'Incomplete'}}
+
deprec2(0);
overloaded(x);
+ default_argument(0);
+ default_argument(1, 2); // expected-error{{no matching function for call to 'default_argument'}}
+
+ default_argument_promotion(0);
+ default_argument_promotion(1, 2); // expected-error{{no matching function for call to 'default_argument_promotion'}}
+
int i = x(1); // expected-error{{no matching function for call to object of type 'X'}}
Nothing n;
@@ -88,6 +121,18 @@ template <class T> void test3() {
fn3(sizeof(T) == 1);
}
+template <typename T>
+struct Y {
+ T h(int n, int m = 0) __attribute__((enable_if(m == 0, "chosen when 'm' is zero"))); // expected-note{{candidate disabled: chosen when 'm' is zero}}
+};
+
+void test4() {
+ Y<int> y;
+
+ int t0 = y.h(0);
+ int t1 = y.h(1, 2); // expected-error{{no matching member function for call to 'h'}}
+}
+
// FIXME: issue an error (without instantiation) because ::h(T()) is not
// convertible to bool, because return types aren't overloadable.
void h(int);
@@ -118,3 +163,93 @@ namespace PR20988 {
fn3(sizeof(T) == 1);
}
}
+
+namespace FnPtrs {
+ int ovlFoo(int m) __attribute__((enable_if(m > 0, "")));
+ int ovlFoo(int m);
+
+ void test() {
+ // Assignment gives us a different code path than declarations, and `&foo`
+ // gives us a different code path than `foo`
+ int (*p)(int) = ovlFoo;
+ int (*p2)(int) = &ovlFoo;
+ int (*a)(int);
+ a = ovlFoo;
+ a = &ovlFoo;
+ }
+
+ int ovlBar(int) __attribute__((enable_if(true, "")));
+ int ovlBar(int m) __attribute__((enable_if(false, "")));
+ void test2() {
+ int (*p)(int) = ovlBar;
+ int (*p2)(int) = &ovlBar;
+ int (*a)(int);
+ a = ovlBar;
+ a = &ovlBar;
+ }
+
+ int ovlConflict(int m) __attribute__((enable_if(true, "")));
+ int ovlConflict(int m) __attribute__((enable_if(1, "")));
+ void test3() {
+ int (*p)(int) = ovlConflict; // expected-error{{address of overloaded function 'ovlConflict' is ambiguous}} expected-note@191{{candidate function}} expected-note@192{{candidate function}}
+ int (*p2)(int) = &ovlConflict; // expected-error{{address of overloaded function 'ovlConflict' is ambiguous}} expected-note@191{{candidate function}} expected-note@192{{candidate function}}
+ int (*a)(int);
+ a = ovlConflict; // expected-error{{assigning to 'int (*)(int)' from incompatible type '<overloaded function type>'}} expected-note@191{{candidate function}} expected-note@192{{candidate function}}
+ a = &ovlConflict; // expected-error{{assigning to 'int (*)(int)' from incompatible type '<overloaded function type>'}} expected-note@191{{candidate function}} expected-note@192{{candidate function}}
+ }
+
+ template <typename T>
+ T templated(T m) __attribute__((enable_if(true, ""))) { return T(); }
+ template <typename T>
+ T templated(T m) __attribute__((enable_if(false, ""))) { return T(); }
+ void test4() {
+ int (*p)(int) = templated<int>;
+ int (*p2)(int) = &templated<int>;
+ int (*a)(int);
+ a = templated<int>;
+ a = &templated<int>;
+ }
+
+ template <typename T>
+ T templatedBar(T m) __attribute__((enable_if(m > 0, ""))) { return T(); }
+ void test5() {
+ int (*p)(int) = templatedBar<int>; // expected-error{{address of overloaded function 'templatedBar' does not match required type 'int (int)'}} expected-note@214{{candidate function made ineligible by enable_if}}
+ int (*p2)(int) = &templatedBar<int>; // expected-error{{address of overloaded function 'templatedBar' does not match required type 'int (int)'}} expected-note@214{{candidate function made ineligible by enable_if}}
+ int (*a)(int);
+ a = templatedBar<int>; // expected-error{{assigning to 'int (*)(int)' from incompatible type '<overloaded function type>'}} expected-note@214{{candidate function made ineligible by enable_if}}
+ a = &templatedBar<int>; // expected-error{{assigning to 'int (*)(int)' from incompatible type '<overloaded function type>'}} expected-note@214{{candidate function made ineligible by enable_if}}
+ }
+
+ template <typename T>
+ T templatedConflict(T m) __attribute__((enable_if(false, ""))) { return T(); }
+ template <typename T>
+ T templatedConflict(T m) __attribute__((enable_if(true, ""))) { return T(); }
+ template <typename T>
+ T templatedConflict(T m) __attribute__((enable_if(1, ""))) { return T(); }
+ void test6() {
+ int (*p)(int) = templatedConflict<int>; // expected-error{{address of overloaded function 'templatedConflict' is ambiguous}} expected-note@224{{candidate function made ineligible by enable_if}} expected-note@226{{candidate function}} expected-note@228{{candidate function}}
+ int (*p0)(int) = &templatedConflict<int>; // expected-error{{address of overloaded function 'templatedConflict' is ambiguous}} expected-note@224{{candidate function made ineligible by enable_if}} expected-note@226{{candidate function}} expected-note@228{{candidate function}}
+ int (*a)(int);
+ a = templatedConflict<int>; // expected-error{{assigning to 'int (*)(int)' from incompatible type '<overloaded function type>'}} expected-note@226{{candidate function}} expected-note@228{{candidate function}}
+ a = &templatedConflict<int>; // expected-error{{assigning to 'int (*)(int)' from incompatible type '<overloaded function type>'}} expected-note@226{{candidate function}} expected-note@228{{candidate function}}
+ }
+
+ int ovlNoCandidate(int m) __attribute__((enable_if(false, "")));
+ int ovlNoCandidate(int m) __attribute__((enable_if(0, "")));
+ void test7() {
+ int (*p)(int) = ovlNoCandidate; // expected-error{{address of overloaded function 'ovlNoCandidate' does not match required type}} expected-note@237{{made ineligible by enable_if}} expected-note@238{{made ineligible by enable_if}}
+ int (*p2)(int) = &ovlNoCandidate; // expected-error{{address of overloaded function 'ovlNoCandidate' does not match required type}} expected-note@237{{made ineligible by enable_if}} expected-note@238{{made ineligible by enable_if}}
+ int (*a)(int);
+ a = ovlNoCandidate; // expected-error{{assigning to 'int (*)(int)' from incompatible type '<overloaded function type>'}} expected-note@237{{made ineligible by enable_if}} expected-note@238{{made ineligible by enable_if}}
+ a = &ovlNoCandidate; // expected-error{{assigning to 'int (*)(int)' from incompatible type '<overloaded function type>'}} expected-note@237{{made ineligible by enable_if}} expected-note@238{{made ineligible by enable_if}}
+ }
+
+ int noOvlNoCandidate(int m) __attribute__((enable_if(false, "")));
+ void test8() {
+ int (*p)(int) = noOvlNoCandidate; // expected-error{{cannot take address of function 'noOvlNoCandidate' becuase it has one or more non-tautological enable_if conditions}}
+ int (*p2)(int) = &noOvlNoCandidate; // expected-error{{cannot take address of function 'noOvlNoCandidate' becuase it has one or more non-tautological enable_if conditions}}
+ int (*a)(int);
+ a = noOvlNoCandidate; // expected-error{{cannot take address of function 'noOvlNoCandidate' becuase it has one or more non-tautological enable_if conditions}}
+ a = &noOvlNoCandidate; // expected-error{{cannot take address of function 'noOvlNoCandidate' becuase it has one or more non-tautological enable_if conditions}}
+ }
+}
diff --git a/test/SemaCXX/enum.cpp b/test/SemaCXX/enum.cpp
index 370e1c34d29c..6b0824b75144 100644
--- a/test/SemaCXX/enum.cpp
+++ b/test/SemaCXX/enum.cpp
@@ -1,4 +1,5 @@
// RUN: %clang_cc1 -fsyntax-only -pedantic -std=c++98 -verify -triple x86_64-apple-darwin %s
+// RUN: %clang_cc1 -fsyntax-only -pedantic -std=c++11 -verify -triple x86_64-apple-darwin %s
enum E { // expected-note{{previous definition is here}}
Val1,
Val2
@@ -88,10 +89,24 @@ typedef enum { }; // expected-warning{{typedef requires a name}}
// PR7921
enum PR7921E {
- PR7921V = (PR7921E)(123) // expected-error {{expression is not an integral constant expression}}
+ PR7921V = (PR7921E)(123)
+#if __cplusplus < 201103L
+// expected-error@-2 {{expression is not an integral constant expression}}
+#else
+// expected-error@-4 {{must have integral or unscoped enumeration type}}
+// FIXME: The above diagnostic isn't very good; we should instead complain about the type being incomplete.
+#endif
};
void PR8089() {
enum E; // expected-error{{ISO C++ forbids forward references to 'enum' types}}
int a = (E)3; // expected-error{{cannot initialize a variable of type 'int' with an rvalue of type 'E'}}
}
+
+// This is accepted as a GNU extension. In C++98, there was no provision for
+// expressions with UB to be non-constant.
+enum { overflow = 123456 * 234567 };
+#if __cplusplus >= 201103L
+// expected-warning@-2 {{not an integral constant expression}}
+// expected-note@-3 {{value 28958703552 is outside the range of representable values}}
+#endif
diff --git a/test/SemaCXX/err_typecheck_assign_const.cpp b/test/SemaCXX/err_typecheck_assign_const.cpp
index 376b6e649159..7e2812565144 100644
--- a/test/SemaCXX/err_typecheck_assign_const.cpp
+++ b/test/SemaCXX/err_typecheck_assign_const.cpp
@@ -122,3 +122,10 @@ void test12(H h) {
h.a = 1; // expected-error {{cannot assign to non-static data member 'a' with const-qualified type 'const int'}}
h.b = 2; // expected-error {{cannot assign to non-static data member 'b' with const-qualified type 'const int &'}}
}
+
+void test() {
+ typedef const int &Func();
+
+ Func &bar();
+ bar()() = 0; // expected-error {{read-only variable is not assignable}}
+}
diff --git a/test/SemaCXX/exception-spec.cpp b/test/SemaCXX/exception-spec.cpp
new file mode 100644
index 000000000000..f301a63503dd
--- /dev/null
+++ b/test/SemaCXX/exception-spec.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -fcxx-exceptions -std=c++11 %s
+
+namespace MissingOnTemplate {
+ template<typename T> void foo(T) noexcept(true); // expected-note {{previous}}
+ template<typename T> void foo(T); // expected-error {{missing exception specification 'noexcept(true)'}}
+ void test() { foo(0); }
+}
diff --git a/test/SemaCXX/expressions.cpp b/test/SemaCXX/expressions.cpp
index 1a50c99c5904..5a0d6dd0670c 100644
--- a/test/SemaCXX/expressions.cpp
+++ b/test/SemaCXX/expressions.cpp
@@ -1,4 +1,6 @@
// RUN: %clang_cc1 -fsyntax-only -verify -Wno-constant-conversion %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-constant-conversion -std=c++98 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-constant-conversion -std=c++11 %s
void choice(int);
int choice(bool);
@@ -12,6 +14,9 @@ void test() {
void f0() {
extern void f0_1(int*);
register int x;
+#if __cplusplus >= 201103L // C++11 or later
+ // expected-warning@-2 {{'register' storage class specifier is deprecated}}
+#endif
f0_1(&x);
}
diff --git a/test/SemaCXX/gnu-flags.cpp b/test/SemaCXX/gnu-flags.cpp
index 05770c53704e..3cd18cabe970 100644
--- a/test/SemaCXX/gnu-flags.cpp
+++ b/test/SemaCXX/gnu-flags.cpp
@@ -1,13 +1,37 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s -DNONE -Wno-gnu
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s -DNONE -Wno-gnu
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s -DNONE -Wno-gnu
+
// RUN: %clang_cc1 -fsyntax-only -verify %s -DALL -Wgnu
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s -DALL -Wgnu
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s -DALL -Wgnu
+
// RUN: %clang_cc1 -fsyntax-only -verify %s -DALL -Wno-gnu \
// RUN: -Wgnu-anonymous-struct -Wredeclared-class-member \
// RUN: -Wgnu-flexible-array-union-member -Wgnu-folding-constant \
// RUN: -Wgnu-empty-struct
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s -DALL -Wno-gnu \
+// RUN: -Wgnu-anonymous-struct -Wredeclared-class-member \
+// RUN: -Wgnu-flexible-array-union-member -Wgnu-folding-constant \
+// RUN: -Wgnu-empty-struct
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s -DALL -Wno-gnu \
+// RUN: -Wgnu-anonymous-struct -Wredeclared-class-member \
+// RUN: -Wgnu-flexible-array-union-member -Wgnu-folding-constant \
+// RUN: -Wgnu-empty-struct
+
// RUN: %clang_cc1 -fsyntax-only -verify %s -DNONE -Wgnu \
// RUN: -Wno-gnu-anonymous-struct -Wno-redeclared-class-member \
// RUN: -Wno-gnu-flexible-array-union-member -Wno-gnu-folding-constant \
// RUN: -Wno-gnu-empty-struct
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s -DNONE -Wgnu \
+// RUN: -Wno-gnu-anonymous-struct -Wno-redeclared-class-member \
+// RUN: -Wno-gnu-flexible-array-union-member -Wno-gnu-folding-constant \
+// RUN: -Wno-gnu-empty-struct
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s -DNONE -Wgnu \
+// RUN: -Wno-gnu-anonymous-struct -Wno-redeclared-class-member \
+// RUN: -Wno-gnu-flexible-array-union-member -Wno-gnu-folding-constant \
+// RUN: -Wno-gnu-empty-struct
+
// Additional disabled tests:
// %clang_cc1 -fsyntax-only -verify %s -DANONYMOUSSTRUCT -Wno-gnu -Wgnu-anonymous-struct
// %clang_cc1 -fsyntax-only -verify %s -DREDECLAREDCLASSMEMBER -Wno-gnu -Wredeclared-class-member
@@ -59,7 +83,7 @@ struct faum {
};
-#if ALL || FOLDINGCONSTANT
+#if (ALL || FOLDINGCONSTANT) && (__cplusplus <= 199711L) // C++03 or earlier modes
// expected-warning@+4 {{in-class initializer for static data member is not a constant expression; folding it to a constant is a GNU extension}}
#endif
diff --git a/test/SemaCXX/init-priority-attr.cpp b/test/SemaCXX/init-priority-attr.cpp
index a2e6df26ba1b..8f31e2fd62d0 100644
--- a/test/SemaCXX/init-priority-attr.cpp
+++ b/test/SemaCXX/init-priority-attr.cpp
@@ -21,7 +21,7 @@ Two foo __attribute__((init_priority(101))) ( 5, 6 );
Two goo __attribute__((init_priority(2,3))) ( 5, 6 ); // expected-error {{'init_priority' attribute takes one argument}}
-Two coo[2] __attribute__((init_priority(3))); // expected-error {{init_priority attribute requires integer constant between 101 and 65535 inclusive}}
+Two coo[2] __attribute__((init_priority(3))); // expected-error {{'init_priority' attribute requires integer constant between 101 and 65535 inclusive}}
Two koo[4] __attribute__((init_priority(1.13))); // expected-error {{'init_priority' attribute requires an integer constant}}
diff --git a/test/SemaCXX/internal_linkage.cpp b/test/SemaCXX/internal_linkage.cpp
new file mode 100644
index 000000000000..d5cc6767392d
--- /dev/null
+++ b/test/SemaCXX/internal_linkage.cpp
@@ -0,0 +1,47 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+int f() __attribute__((internal_linkage));
+
+class A;
+class __attribute__((internal_linkage)) A {
+public:
+ int x __attribute__((internal_linkage)); // expected-warning{{'internal_linkage' attribute only applies to variables, functions and classes}}
+ static int y __attribute__((internal_linkage));
+ void f1() __attribute__((internal_linkage));
+ void f2() __attribute__((internal_linkage)) {}
+ static void f3() __attribute__((internal_linkage)) {}
+ void f4(); // expected-note{{previous definition is here}}
+ static int zz; // expected-note{{previous definition is here}}
+ A() __attribute__((internal_linkage)) {}
+ ~A() __attribute__((internal_linkage)) {}
+ A& operator=(const A&) __attribute__((internal_linkage)) { return *this; }
+ struct {
+ int z __attribute__((internal_linkage)); // expected-warning{{'internal_linkage' attribute only applies to variables, functions and classes}}
+ };
+};
+
+__attribute__((internal_linkage)) void A::f4() {} // expected-error{{'internal_linkage' attribute does not appear on the first declaration of 'f4'}}
+
+__attribute__((internal_linkage)) int A::zz; // expected-error{{'internal_linkage' attribute does not appear on the first declaration of 'zz'}}
+
+namespace Z __attribute__((internal_linkage)) { // expected-warning{{'internal_linkage' attribute only applies to variables, functions and classes}}
+}
+
+__attribute__((internal_linkage("foo"))) int g() {} // expected-error{{'internal_linkage' attribute takes no arguments}}
+
+[[clang::internal_linkage]] int h() {}
+
+enum struct __attribute__((internal_linkage)) E { // expected-warning{{'internal_linkage' attribute only applies to variables, functions and classes}}
+ a = 1,
+ b = 2
+};
+
+int A::y;
+
+void A::f1() {
+}
+
+void g(int a [[clang::internal_linkage]]) { // expected-warning{{'internal_linkage' attribute only applies to variables, functions and classes}}
+ int x [[clang::internal_linkage]]; // expected-warning{{'internal_linkage' attribute on a non-static local variable is ignored}}
+ static int y [[clang::internal_linkage]];
+}
diff --git a/test/SemaCXX/invalid-member-expr.cpp b/test/SemaCXX/invalid-member-expr.cpp
index 87da79a27c0c..172be6b8266d 100644
--- a/test/SemaCXX/invalid-member-expr.cpp
+++ b/test/SemaCXX/invalid-member-expr.cpp
@@ -1,4 +1,6 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
class X {};
@@ -23,9 +25,17 @@ void test2() {
// PR6327
namespace test3 {
template <class A, class B> struct pair {};
+ template <class _E> class initializer_list {};
+ template <typename _Tp> pair<_Tp, _Tp> minmax(initializer_list<_Tp> __l) {};
void test0() {
- pair<int, int> z = minmax({}); // expected-error {{expected expression}}
+ pair<int, int> z = minmax({});
+#if __cplusplus <= 199711L // C++03 or earlier modes
+ // expected-error@-2 {{expected expression}}
+#else
+ // expected-error@-4 {{no matching function for call to 'minmax'}}
+ // expected-note@-8 {{candidate template ignored: couldn't infer template argument '_Tp'}}
+#endif
}
struct string {
diff --git a/test/SemaCXX/libstdcxx_explicit_init_list_hack.cpp b/test/SemaCXX/libstdcxx_explicit_init_list_hack.cpp
index 774745777c17..f9e0a5c0a1f0 100644
--- a/test/SemaCXX/libstdcxx_explicit_init_list_hack.cpp
+++ b/test/SemaCXX/libstdcxx_explicit_init_list_hack.cpp
@@ -9,7 +9,7 @@ namespace __debug {
template <class T>
class vector {
public:
- explicit vector() {} // expected-warning{{should not be explicit}}
+ explicit vector() {} // expected-warning 2 {{should not be explicit}}
};
}
}
@@ -19,5 +19,6 @@ public:
#include __FILE__
struct { int a, b; std::__debug::vector<int> c; } e[] = { {1, 1} }; // expected-note{{used in initialization here}}
-
+// expected-warning@+1 {{expression with side effects has no effect in an unevaluated context}}
+decltype(new std::__debug::vector<int>[1]{}) x; // expected-note{{used in initialization here}}
#endif
diff --git a/test/SemaCXX/literal-operators.cpp b/test/SemaCXX/literal-operators.cpp
index f4c5c35a2bcb..ba571788b962 100644
--- a/test/SemaCXX/literal-operators.cpp
+++ b/test/SemaCXX/literal-operators.cpp
@@ -1,9 +1,9 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++14 %s
#include <stddef.h>
struct tag {
- void operator "" _tag_bad (const char *); // expected-error {{literal operator 'operator "" _tag_bad' must be in a namespace or global scope}}
+ void operator "" _tag_bad (const char *); // expected-error {{literal operator 'operator""_tag_bad' must be in a namespace or global scope}}
friend void operator "" _tag_good (const char *);
};
@@ -35,10 +35,14 @@ typedef const char c;
void operator "" _good (c*);
// Check extra cv-qualifiers
-void operator "" _cv_good (volatile const char *, const size_t); // expected-error {{parameter declaration for literal operator 'operator "" _cv_good' is not valid}}
+void operator "" _cv_good (volatile const char *, const size_t); // expected-error {{parameter declaration for literal operator 'operator""_cv_good' is not valid}}
// Template declaration
template <char...> void operator "" _good ();
// FIXME: Test some invalid decls that might crop up.
-template <typename...> void operator "" _invalid(); // expected-error {{parameter declaration for literal operator 'operator "" _invalid' is not valid}}
+template <typename...> void operator "" _invalid(); // expected-error {{parameter declaration for literal operator 'operator""_invalid' is not valid}}
+
+_Complex float operator""if(long double); // expected-warning {{reserved}}
+_Complex float test_if_1() { return 2.0f + 1.5if; };
+void test_if_2() { "foo"if; } // expected-error {{no matching literal operator for call to 'operator""if'}}
diff --git a/test/SemaCXX/make_integer_seq.cpp b/test/SemaCXX/make_integer_seq.cpp
new file mode 100644
index 000000000000..4e15414cbe67
--- /dev/null
+++ b/test/SemaCXX/make_integer_seq.cpp
@@ -0,0 +1,49 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+static_assert(__has_builtin(__make_integer_seq), "");
+
+template <class T, T... I>
+struct Seq {
+ static constexpr T PackSize = sizeof...(I);
+};
+
+template <typename T, T N>
+using MakeSeq = __make_integer_seq<Seq, T, N>;
+
+static_assert(__is_same(MakeSeq<int, 0>, Seq<int>), "");
+static_assert(__is_same(MakeSeq<int, 1>, Seq<int, 0>), "");
+static_assert(__is_same(MakeSeq<int, 2>, Seq<int, 0, 1>), "");
+static_assert(__is_same(MakeSeq<int, 3>, Seq<int, 0, 1, 2>), "");
+static_assert(__is_same(MakeSeq<int, 4>, Seq<int, 0, 1, 2, 3>), "");
+
+static_assert(__is_same(MakeSeq<unsigned int, 0U>, Seq<unsigned int>), "");
+static_assert(__is_same(MakeSeq<unsigned int, 1U>, Seq<unsigned int, 0U>), "");
+static_assert(__is_same(MakeSeq<unsigned int, 2U>, Seq<unsigned int, 0U, 1U>), "");
+static_assert(__is_same(MakeSeq<unsigned int, 3U>, Seq<unsigned int, 0U, 1U, 2U>), "");
+static_assert(__is_same(MakeSeq<unsigned int, 4U>, Seq<unsigned int, 0U, 1U, 2U, 3U>), "");
+
+static_assert(__is_same(MakeSeq<long long, 0LL>, Seq<long long>), "");
+static_assert(__is_same(MakeSeq<long long, 1LL>, Seq<long long, 0LL>), "");
+static_assert(__is_same(MakeSeq<long long, 2LL>, Seq<long long, 0LL, 1LL>), "");
+static_assert(__is_same(MakeSeq<long long, 3LL>, Seq<long long, 0LL, 1LL, 2LL>), "");
+static_assert(__is_same(MakeSeq<long long, 4LL>, Seq<long long, 0LL, 1LL, 2LL, 3LL>), "");
+
+static_assert(__is_same(MakeSeq<unsigned long long, 0ULL>, Seq<unsigned long long>), "");
+static_assert(__is_same(MakeSeq<unsigned long long, 1ULL>, Seq<unsigned long long, 0ULL>), "");
+static_assert(__is_same(MakeSeq<unsigned long long, 2ULL>, Seq<unsigned long long, 0ULL, 1ULL>), "");
+static_assert(__is_same(MakeSeq<unsigned long long, 3ULL>, Seq<unsigned long long, 0ULL, 1ULL, 2ULL>), "");
+static_assert(__is_same(MakeSeq<unsigned long long, 4ULL>, Seq<unsigned long long, 0ULL, 1ULL, 2ULL, 3ULL>), "");
+
+template <typename T, T N>
+using ErrorSeq = __make_integer_seq<Seq, T, N>; // expected-error{{must have non-negative sequence length}} \
+ expected-error{{must have integral element type}}
+
+enum Color : int { Red,
+ Green,
+ Blue };
+using illformed1 = ErrorSeq<Color, Blue>; // expected-note{{in instantiation}}
+
+using illformed2 = ErrorSeq<int, -5>;
+
+template <typename T, T N> void f() {}
+__make_integer_seq<f, int, 0> x; // expected-error{{template template parameter must be a class template or type alias template}}
diff --git a/test/SemaCXX/many-template-parameter-lists.cpp b/test/SemaCXX/many-template-parameter-lists.cpp
new file mode 100644
index 000000000000..f98005c7e6fb
--- /dev/null
+++ b/test/SemaCXX/many-template-parameter-lists.cpp
@@ -0,0 +1,36 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// This is not well-formed C++ but used to crash in sema.
+
+template <class T>
+struct X {
+ template <class U>
+ struct A { // expected-note {{not-yet-instantiated member is declared here}}
+ template <class V>
+ struct B {
+ template <class W>
+ struct C {
+ template <class X>
+ struct D {
+ template <class Y>
+ struct E {
+ template <class Z>
+ void operator+=(Z);
+ };
+ };
+ };
+ };
+ };
+
+ template <class U>
+ template <class V>
+ template <class W>
+ template <class X>
+ template <class Y>
+ template <class Z>
+ friend void A<U>::template B<V>::template C<W>::template D<X>::template E<Y>::operator+=(Z); // expected-warning {{not supported}} expected-error {{no member 'A' in 'X<int>'; it has not yet been instantiated}}
+};
+
+void test() {
+ X<int>::A<int>::B<int>::C<int>::D<int>::E<int>() += 1.0; // expected-note {{in instantiation of template class 'X<int>' requested here}}
+}
diff --git a/test/SemaCXX/member-expr.cpp b/test/SemaCXX/member-expr.cpp
index 5b3393efc0cc..3571fa748b81 100644
--- a/test/SemaCXX/member-expr.cpp
+++ b/test/SemaCXX/member-expr.cpp
@@ -1,4 +1,6 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
class X{
public:
@@ -116,8 +118,10 @@ namespace rdar8231724 {
void f(Y *y) {
y->N::X1<int>; // expected-error{{'rdar8231724::N::X1' is not a member of class 'rdar8231724::Y'}}
y->Z<int>::n; // expected-error{{'rdar8231724::Z<int>::n' is not a member of class 'rdar8231724::Y'}}
- y->template Z<int>::n; // expected-error{{'rdar8231724::Z<int>::n' is not a member of class 'rdar8231724::Y'}} \
- // expected-warning{{'template' keyword outside of a template}}
+ y->template Z<int>::n; // expected-error{{'rdar8231724::Z<int>::n' is not a member of class 'rdar8231724::Y'}}
+#if __cplusplus <= 199711L // C++03 or earlier modes
+ // expected-warning@-2{{'template' keyword outside of a template}}
+#endif
}
}
diff --git a/test/SemaCXX/member-pointer.cpp b/test/SemaCXX/member-pointer.cpp
index afb7455921e7..f3adb95977a1 100644
--- a/test/SemaCXX/member-pointer.cpp
+++ b/test/SemaCXX/member-pointer.cpp
@@ -1,4 +1,6 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
struct A {};
enum B { Dummy };
@@ -14,8 +16,11 @@ int (::A::*pdi2);
int (A::*pfi)(int);
void (*A::*ppfie)() throw(); // expected-error {{exception specifications are not allowed beyond a single level of indirection}}
-int B::*pbi; // expected-warning{{use of enumeration in a nested name specifier is a C++11 extension}} \
- // expected-error {{'pbi' does not point into a class}}
+int B::*pbi;
+#if __cplusplus <= 199711L // C++03 or earlier modes
+// expected-warning@-2 {{use of enumeration in a nested name specifier is a C++11 extension}}
+#endif
+// expected-error@-4 {{'pbi' does not point into a class}}
int C::*pci; // expected-error {{'pci' does not point into a class}}
void A::*pdv; // expected-error {{'pdv' declared as a member pointer to void}}
int& A::*pdr; // expected-error {{'pdr' declared as a member pointer to a reference}}
diff --git a/test/SemaCXX/microsoft-super.cpp b/test/SemaCXX/microsoft-super.cpp
new file mode 100644
index 000000000000..bfa9d17dbc21
--- /dev/null
+++ b/test/SemaCXX/microsoft-super.cpp
@@ -0,0 +1,49 @@
+// RUN: %clang_cc1 -fms-extensions -verify %s
+
+// rdar://22464808
+
+namespace test0 {
+ class A {
+ private:
+ void foo(int*);
+ public:
+ void foo(long*);
+ };
+ class B : public A {
+ void test() {
+ __super::foo((long*) 0);
+ }
+ };
+}
+
+namespace test1 {
+ struct A {
+ static void foo(); // expected-note {{member is declared here}}
+ };
+ struct B : private A { // expected-note {{constrained by private inheritance here}}
+ void test() {
+ __super::foo();
+ }
+ };
+ struct C : public B {
+ void test() {
+ __super::foo(); // expected-error {{'foo' is a private member of 'test1::A'}}
+ }
+ };
+}
+
+namespace test2 {
+ struct A {
+ static void foo();
+ };
+ struct B : public A {
+ void test() {
+ __super::foo();
+ }
+ };
+ struct C : private B {
+ void test() {
+ __super::foo();
+ }
+ };
+}
diff --git a/test/SemaCXX/ms-inline-asm.cpp b/test/SemaCXX/ms-inline-asm.cpp
new file mode 100644
index 000000000000..3e445b80f887
--- /dev/null
+++ b/test/SemaCXX/ms-inline-asm.cpp
@@ -0,0 +1,54 @@
+// REQUIRES: x86-registered-target
+// RUN: %clang_cc1 %s -triple i386-apple-darwin10 -fasm-blocks -verify
+
+struct A {
+ int a1;
+ int a2;
+ struct B {
+ int b1;
+ int b2;
+ enum { kValue = 42 };
+ } a3;
+ struct {
+ int indirect_field;
+ };
+};
+
+namespace asdf {
+A a_global;
+}
+
+// The parser combines adjacent __asm blocks into one. Avoid that by calling
+// this.
+void split_inline_asm_call();
+
+void test_field_lookup() {
+ __asm mov eax, asdf::a_global.a3.b2
+ split_inline_asm_call();
+
+ // FIXME: These diagnostics are crap.
+
+ // expected-error@+1 {{undeclared label}}
+ __asm mov eax, asdf::a_global.not_a_field.b2
+ split_inline_asm_call();
+
+ // expected-error@+1 {{undeclared label}}
+ __asm mov eax, asdf::a_global.a3.not_a_field
+ split_inline_asm_call();
+
+ __asm mov eax, A::B::kValue
+ split_inline_asm_call();
+
+ // expected-error@+1 {{undeclared label}}
+ __asm mov eax, asdf::a_global.a3.kValue
+ split_inline_asm_call();
+
+ __asm mov eax, asdf :: a_global.a3.b2
+ split_inline_asm_call();
+
+ __asm mov eax, asdf::a_global . a3 . b2
+ split_inline_asm_call();
+
+ __asm mov eax, asdf::a_global.indirect_field
+ split_inline_asm_call();
+}
diff --git a/test/SemaCXX/ms-interface.cpp b/test/SemaCXX/ms-interface.cpp
index e7386ce5b8e7..4a1c13ddcbba 100644
--- a/test/SemaCXX/ms-interface.cpp
+++ b/test/SemaCXX/ms-interface.cpp
@@ -58,10 +58,12 @@ __interface I6 : X {
struct S { };
class C { };
__interface I { };
+union U;
static_assert(!__is_interface_class(S), "oops");
static_assert(!__is_interface_class(C), "oops");
-static_assert(__is_interface_class(I), "oops");
+static_assert(!__is_interface_class(I), "oops");
+static_assert(!__is_interface_class(U), "oops");
// expected-error@55 {{interface type cannot inherit from 'struct S'}}
// expected-note@+1 {{in instantiation of template class 'I6<S>' requested here}}
diff --git a/test/SemaCXX/ms-novtable.cpp b/test/SemaCXX/ms-novtable.cpp
index 2d55c48df3c7..31975b3b4a84 100644
--- a/test/SemaCXX/ms-novtable.cpp
+++ b/test/SemaCXX/ms-novtable.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -fsyntax-only -verify -fms-extensions -Wno-microsoft -std=c++11
+// RUN: %clang_cc1 -triple i386-pc-win32 %s -fsyntax-only -verify -fms-extensions -Wno-microsoft -std=c++11
struct __declspec(novtable) S {};
enum __declspec(novtable) E {}; // expected-warning{{'novtable' attribute only applies to classes}}
diff --git a/test/SemaCXX/ms-property-error.cpp b/test/SemaCXX/ms-property-error.cpp
new file mode 100644
index 000000000000..ca52538f3a67
--- /dev/null
+++ b/test/SemaCXX/ms-property-error.cpp
@@ -0,0 +1,37 @@
+// RUN: %clang_cc1 -verify -fms-compatibility %s -fsyntax-only -o -
+
+class S {
+public:
+ __declspec(property(get=GetX,put=PutX)) int x[];
+ int GetX(int i, int j) { return i+j; } // expected-note {{'GetX' declared here}}
+ void PutX(int i, int j, int k) { j = i = k; } // expected-note {{'PutX' declared here}}
+};
+
+char *ptr;
+template <typename T>
+class St {
+public:
+ __declspec(property(get=GetX,put=PutX)) T x[];
+ T GetX(T i, T j) { return i+j; } // expected-note 3 {{'GetX' declared here}}
+ T PutX(T i, T j, T k) { return j = i = k; } // expected-note 2 {{'PutX' declared here}}
+ ~St() {
+ x[1] = 0; // expected-error {{too few arguments to function call, expected 3, have 2}}
+ x[2][3] = 4;
+ ++x[2][3];
+ x[1][2] = x[3][4][5]; // expected-error {{too many arguments to function call, expected 2, have 3}}
+ ptr = x[1][2] = x[3][4]; // expected-error {{assigning to 'char *' from incompatible type 'int'}}
+ }
+};
+
+// CHECK-LABEL: main
+int main(int argc, char **argv) {
+ S *p1 = 0;
+ St<float> *p2 = 0;
+ St<int> a; // expected-note {{in instantiation of member function 'St<int>::~St' requested here}}
+ int j = (p1->x)[223][11][2]; // expected-error {{too many arguments to function call, expected 2, have 3}}
+ (p1->x[23]) = argc; // expected-error {{too few arguments to function call, expected 3, have 2}}
+ float j1 = (p2->x); // expected-error {{too few arguments to function call, expected 2, have 0}}
+ ((p2->x)[23])[1][2] = *argv; // expected-error {{too many arguments to function call, expected 3, have 4}}
+ argv = p2->x[11][22] = argc; // expected-error {{assigning to 'char **' from incompatible type 'float'}}
+ return ++(((p2->x)[23])); // expected-error {{too few arguments to function call, expected 2, have 1}}
+}
diff --git a/test/SemaCXX/ms-property.cpp b/test/SemaCXX/ms-property.cpp
new file mode 100644
index 000000000000..d33dbf0a0ded
--- /dev/null
+++ b/test/SemaCXX/ms-property.cpp
@@ -0,0 +1,60 @@
+// RUN: %clang_cc1 -ast-print -verify -triple=x86_64-pc-win32 -fms-compatibility %s -o - | FileCheck %s
+// RUN: %clang_cc1 -triple=x86_64-pc-win32 -fms-compatibility -emit-pch -o %t %s
+// RUN: %clang_cc1 -triple=x86_64-pc-win32 -fms-compatibility -include-pch %t -verify %s -ast-print -o - | FileCheck %s
+// expected-no-diagnostics
+
+#ifndef HEADER
+#define HEADER
+
+class Test1 {
+private:
+ int x_;
+
+public:
+ Test1(int x) : x_(x) {}
+ __declspec(property(get = get_x)) int X;
+ int get_x() const { return x_; }
+ static Test1 *GetTest1() { return new Test1(10); }
+};
+
+class S {
+public:
+ __declspec(property(get=GetX,put=PutX)) int x[];
+ int GetX(int i, int j) { return i+j; }
+ void PutX(int i, int j, int k) { j = i = k; }
+};
+
+template <typename T>
+class St {
+public:
+ __declspec(property(get=GetX,put=PutX)) T x[];
+ T GetX(T i, T j) { return i+j; }
+ T PutX(T i, T j, T k) { return j = i = k; }
+ ~St() { x[0][0] = x[1][1]; }
+};
+
+// CHECK: this->x[0][0] = this->x[1][1];
+// CHECK: this->x[0][0] = this->x[1][1];
+
+// CHECK-LABEL: main
+int main(int argc, char **argv) {
+ S *p1 = 0;
+ St<float> *p2 = 0;
+ // CHECK: St<int> a;
+ St<int> a;
+ // CHECK-NEXT: int j = (p1->x)[223][11];
+ int j = (p1->x)[223][11];
+ // CHECK-NEXT: (p1->x[23])[1] = j;
+ (p1->x[23])[1] = j;
+ // CHECK-NEXT: float j1 = (p2->x[223][11]);
+ float j1 = (p2->x[223][11]);
+ // CHECK-NEXT: ((p2->x)[23])[1] = j1;
+ ((p2->x)[23])[1] = j1;
+ // CHECK-NEXT: ++(((p2->x)[23])[1]);
+ ++(((p2->x)[23])[1]);
+ // CHECK-NEXT: j1 = ((p2->x)[23])[1] = j1;
+ j1 = ((p2->x)[23])[1] = j1;
+ // CHECK-NEXT: return Test1::GetTest1()->X;
+ return Test1::GetTest1()->X;
+}
+#endif // HEADER
diff --git a/test/SemaCXX/ms-unsupported.cpp b/test/SemaCXX/ms-unsupported.cpp
new file mode 100644
index 000000000000..559d703f3673
--- /dev/null
+++ b/test/SemaCXX/ms-unsupported.cpp
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -triple x86_64-pc-windows-gnu %s -fsyntax-only -verify -fms-extensions -Wno-microsoft -std=c++11
+
+// "novtable" is ignored except with the Microsoft C++ ABI.
+// MinGW uses the Itanium C++ ABI so check that it is ignored there.
+struct __declspec(novtable) S {}; // expected-warning{{__declspec attribute 'novtable' is not supported}}
diff --git a/test/SemaCXX/ms_integer_suffix.cpp b/test/SemaCXX/ms_integer_suffix.cpp
index d65e7f463432..aa2f13099d3b 100644
--- a/test/SemaCXX/ms_integer_suffix.cpp
+++ b/test/SemaCXX/ms_integer_suffix.cpp
@@ -18,6 +18,3 @@ static_assert(sizeof(0i32) == __SIZEOF_INT32__, "");
#ifdef __SIZEOF_INT64__
static_assert(sizeof(0i64) == __SIZEOF_INT64__, "");
#endif
-#ifdef __SIZEOF_INT128__
-static_assert(sizeof(0i128) == __SIZEOF_INT128__, "");
-#endif
diff --git a/test/SemaCXX/ms_struct.cpp b/test/SemaCXX/ms_struct.cpp
index 2832b5620f3b..414b56b491c6 100644
--- a/test/SemaCXX/ms_struct.cpp
+++ b/test/SemaCXX/ms_struct.cpp
@@ -11,9 +11,9 @@ struct A {
struct B : public A {
#ifdef TEST_FOR_ERROR
- // expected-error@-2 {{ms_struct may not produce MSVC-compatible layouts for classes with base classes or virtual functions}}
+ // expected-error@-2 {{ms_struct may not produce Microsoft-compatible layouts for classes with base classes or virtual functions}}
#else
- // expected-warning@-4 {{ms_struct may not produce MSVC-compatible layouts for classes with base classes or virtual functions}}
+ // expected-warning@-4 {{ms_struct may not produce Microsoft-compatible layouts for classes with base classes or virtual functions}}
#endif
unsigned long c:16;
int d;
@@ -26,9 +26,9 @@ static_assert(__builtin_offsetof(B, d) == 12,
// rdar://16178895
struct C {
#ifdef TEST_FOR_ERROR
- // expected-error@-2 {{ms_struct may not produce MSVC-compatible layouts for classes with base classes or virtual functions}}
+ // expected-error@-2 {{ms_struct may not produce Microsoft-compatible layouts for classes with base classes or virtual functions}}
#else
- // expected-warning@-4 {{ms_struct may not produce MSVC-compatible layouts for classes with base classes or virtual functions}}
+ // expected-warning@-4 {{ms_struct may not produce Microsoft-compatible layouts for classes with base classes or virtual functions}}
#endif
virtual void foo();
long long n;
diff --git a/test/SemaCXX/ms_wide_bitfield.cpp b/test/SemaCXX/ms_wide_bitfield.cpp
index d917390ef14c..b634e78c70ce 100644
--- a/test/SemaCXX/ms_wide_bitfield.cpp
+++ b/test/SemaCXX/ms_wide_bitfield.cpp
@@ -1,9 +1,10 @@
// RUN: %clang_cc1 -fno-rtti -emit-llvm-only -triple i686-pc-win32 -fdump-record-layouts -fsyntax-only -mms-bitfields -verify %s 2>&1
struct A {
- char a : 9; // expected-error{{size of bit-field 'a' (9 bits) exceeds size of its type (8 bits)}}
- int b : 33; // expected-error{{size of bit-field 'b' (33 bits) exceeds size of its type (32 bits)}}
- bool c : 9; // expected-error{{size of bit-field 'c' (9 bits) exceeds size of its type (8 bits)}}
+ char a : 9; // expected-error{{width of bit-field 'a' (9 bits) exceeds size of its type (8 bits)}}
+ int b : 33; // expected-error{{width of bit-field 'b' (33 bits) exceeds size of its type (32 bits)}}
+ bool c : 9; // expected-error{{width of bit-field 'c' (9 bits) exceeds size of its type (8 bits)}}
+ bool d : 3;
};
int a[sizeof(A) == 1 ? 1 : -1];
diff --git a/test/SemaCXX/namespace-alias.cpp b/test/SemaCXX/namespace-alias.cpp
index 63615ecbd352..281ee9962e8b 100644
--- a/test/SemaCXX/namespace-alias.cpp
+++ b/test/SemaCXX/namespace-alias.cpp
@@ -125,3 +125,46 @@ namespace PR7014 {
namespace Y = X::Y;
}
+
+namespace PR25731 {
+ void f() {
+ namespace X = PR25731;
+ namespace X = PR25731;
+ X::f();
+ }
+}
+
+namespace MultipleUnambiguousLookupResults {
+ namespace A { int y; }
+ namespace B {
+ namespace X { int x; }
+ namespace Y = A;
+ namespace Z = A; // expected-note {{candidate}}
+ }
+ namespace C {
+ namespace X = B::X;
+ namespace Y = A;
+ namespace Z = X; // expected-note {{candidate}}
+ }
+ using namespace B;
+ using namespace C;
+ int x1 = X::x; // ok, unambiguous
+ int y1 = Y::y; // ok, unambiguous
+ int z1 = Z::x; // expected-error {{ambiguous}}
+
+ namespace X = C::X;
+ namespace Y = A;
+ int x2 = X::x; // ok, unambiguous
+ int y2 = Y::y; // ok, unambiguous
+}
+
+namespace RedeclOfNonNamespace {
+ int a; // expected-note {{previous}}
+ namespace X { int b; }
+ using X::b; // expected-note {{previous}}
+ namespace c {} // expected-note {{previous}}
+
+ namespace a = X; // expected-error {{different kind}}
+ namespace b = X; // expected-error {{different kind}}
+ namespace c = X; // expected-error-re {{redefinition of 'c'{{$}}}}
+}
diff --git a/test/SemaCXX/namespace.cpp b/test/SemaCXX/namespace.cpp
index d47b7076cec2..e2c1516ac3aa 100644
--- a/test/SemaCXX/namespace.cpp
+++ b/test/SemaCXX/namespace.cpp
@@ -1,4 +1,7 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
namespace A { // expected-note 2 {{previous definition is here}}
int A;
void f() { A = 0; }
@@ -8,8 +11,11 @@ void f() { A = 0; } // expected-error {{unexpected namespace name 'A': expected
int A; // expected-error {{redefinition of 'A' as different kind of symbol}}
class A; // expected-error {{redefinition of 'A' as different kind of symbol}}
-class B {}; // expected-note {{previous definition is here}} \
- // expected-note{{candidate function (the implicit copy assignment operator)}}
+class B {}; // expected-note {{previous definition is here}}
+// expected-note@-1 {{candidate function (the implicit copy assignment operator) not viable}}
+#if __cplusplus >= 201103L // C++11 or later
+// expected-note@-3 {{candidate function (the implicit move assignment operator) not viable}}
+#endif
void C(); // expected-note {{previous definition is here}}
namespace C {} // expected-error {{redefinition of 'C' as different kind of symbol}}
diff --git a/test/SemaCXX/new-array-size-conv.cpp b/test/SemaCXX/new-array-size-conv.cpp
index c987c2820adf..dbdd4bd8951e 100644
--- a/test/SemaCXX/new-array-size-conv.cpp
+++ b/test/SemaCXX/new-array-size-conv.cpp
@@ -1,4 +1,6 @@
// RUN: %clang_cc1 -fsyntax-only -pedantic -verify %s
+// RUN: %clang_cc1 -fsyntax-only -pedantic -verify -std=c++98 %s
+// RUN: %clang_cc1 -fsyntax-only -pedantic -verify -std=c++11 %s
struct ValueInt
{
@@ -20,8 +22,15 @@ struct TwoValueInts : ValueInt, IndirectValueInt { }; // expected-warning{{direc
void test() {
- (void)new int[ValueInt(10)]; // expected-warning{{implicit conversion from array size expression of type 'ValueInt' to integral type 'int' is a C++11 extension}}
- (void)new int[ValueEnum()]; // expected-warning{{implicit conversion from array size expression of type 'ValueEnum' to enumeration type 'E' is a C++11 extension}}
+ (void)new int[ValueInt(10)];
+#if __cplusplus <= 199711L // C++03 or earlier modes
+ // expected-warning@-2{{implicit conversion from array size expression of type 'ValueInt' to integral type 'int' is a C++11 extension}}
+#endif
+
+ (void)new int[ValueEnum()];
+#if __cplusplus <= 199711L
+// expected-warning@-2{{implicit conversion from array size expression of type 'ValueEnum' to enumeration type 'E' is a C++11 extension}}
+#endif
(void)new int[ValueBoth()]; // expected-error{{ambiguous conversion of array size expression of type 'ValueBoth' to an integral or enumeration type}}
(void)new int[TwoValueInts()]; // expected-error{{ambiguous conversion of array size expression of type 'TwoValueInts' to an integral or enumeration type}}
diff --git a/test/SemaCXX/nullability.cpp b/test/SemaCXX/nullability.cpp
index edce6b057bd3..c73c01a0a862 100644
--- a/test/SemaCXX/nullability.cpp
+++ b/test/SemaCXX/nullability.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -std=c++11 -fsyntax-only -Wno-nullability-declspec %s -verify
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -Wno-nullability-declspec %s -verify -Wnullable-to-nonnull-conversion
#if __has_feature(nullability)
#else
@@ -67,3 +67,33 @@ void test_accepts_nonnull_null_pointer_literal_template() {
}
template void test_accepts_nonnull_null_pointer_literal_template<&accepts_nonnull_4>(); // expected-note{{instantiation of function template specialization}}
+
+void TakeNonnull(void *_Nonnull);
+// Check different forms of assignment to a nonull type from a nullable one.
+void AssignAndInitNonNull() {
+ void *_Nullable nullable;
+ void *_Nonnull p(nullable); // expected-warning{{implicit conversion from nullable pointer 'void * _Nullable' to non-nullable pointer type 'void * _Nonnull'}}
+ void *_Nonnull p2{nullable}; // expected-warning{{implicit conversion from nullable pointer 'void * _Nullable' to non-nullable pointer type 'void * _Nonnull'}}
+ void *_Nonnull p3 = {nullable}; // expected-warning{{implicit conversion from nullable pointer 'void * _Nullable' to non-nullable pointer type 'void * _Nonnull'}}
+ void *_Nonnull p4 = nullable; // expected-warning{{implicit conversion from nullable pointer 'void * _Nullable' to non-nullable pointer type 'void * _Nonnull'}}
+ void *_Nonnull nonnull;
+ nonnull = nullable; // expected-warning{{implicit conversion from nullable pointer 'void * _Nullable' to non-nullable pointer type 'void * _Nonnull'}}
+ nonnull = {nullable}; // expected-warning{{implicit conversion from nullable pointer 'void * _Nullable' to non-nullable pointer type 'void * _Nonnull'}}
+
+ TakeNonnull(nullable); //expected-warning{{implicit conversion from nullable pointer 'void * _Nullable' to non-nullable pointer type 'void * _Nonnull}}
+ TakeNonnull(nonnull); // OK
+}
+
+void *_Nullable ReturnNullable();
+
+void AssignAndInitNonNullFromFn() {
+ void *_Nonnull p(ReturnNullable()); // expected-warning{{implicit conversion from nullable pointer 'void * _Nullable' to non-nullable pointer type 'void * _Nonnull'}}
+ void *_Nonnull p2{ReturnNullable()}; // expected-warning{{implicit conversion from nullable pointer 'void * _Nullable' to non-nullable pointer type 'void * _Nonnull'}}
+ void *_Nonnull p3 = {ReturnNullable()}; // expected-warning{{implicit conversion from nullable pointer 'void * _Nullable' to non-nullable pointer type 'void * _Nonnull'}}
+ void *_Nonnull p4 = ReturnNullable(); // expected-warning{{implicit conversion from nullable pointer 'void * _Nullable' to non-nullable pointer type 'void * _Nonnull'}}
+ void *_Nonnull nonnull;
+ nonnull = ReturnNullable(); // expected-warning{{implicit conversion from nullable pointer 'void * _Nullable' to non-nullable pointer type 'void * _Nonnull'}}
+ nonnull = {ReturnNullable()}; // expected-warning{{implicit conversion from nullable pointer 'void * _Nullable' to non-nullable pointer type 'void * _Nonnull'}}
+
+ TakeNonnull(ReturnNullable()); //expected-warning{{implicit conversion from nullable pointer 'void * _Nullable' to non-nullable pointer type 'void * _Nonnull}}
+}
diff --git a/test/SemaCXX/offsetof.cpp b/test/SemaCXX/offsetof.cpp
index e6069ac9c0a0..c4b288aa05d4 100644
--- a/test/SemaCXX/offsetof.cpp
+++ b/test/SemaCXX/offsetof.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10.0.0 -fsyntax-only -verify %s -Winvalid-offsetof
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10.0.0 -fsyntax-only -verify %s -Winvalid-offsetof -std=c++98
struct NonPOD {
virtual void f();
diff --git a/test/SemaCXX/overload-call-copycon.cpp b/test/SemaCXX/overload-call-copycon.cpp
index 6720cb695338..84971024acd8 100644
--- a/test/SemaCXX/overload-call-copycon.cpp
+++ b/test/SemaCXX/overload-call-copycon.cpp
@@ -1,6 +1,12 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s -Wnon-pod-varargs
-class X { }; // expected-note {{the implicit copy constructor}} \
- // expected-note{{the implicit default constructor}}
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s -Wnon-pod-varargs
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s -Wnon-pod-varargs
+
+class X { }; // expected-note {{the implicit copy constructor}}
+// expected-note@-1 {{the implicit default constructor}}
+#if __cplusplus >= 201103L // C++11 or later
+// expected-note@-3 {{candidate constructor (the implicit move constructor) not viable}}
+#endif
int& copycon(X x); // expected-note{{passing argument to parameter}}
float& copycon(...);
diff --git a/test/SemaCXX/overload-call.cpp b/test/SemaCXX/overload-call.cpp
index 19ce14481f8e..3d286a94a045 100644
--- a/test/SemaCXX/overload-call.cpp
+++ b/test/SemaCXX/overload-call.cpp
@@ -1,4 +1,7 @@
-// RUN: %clang_cc1 -pedantic -verify %s
+// RUN: %clang_cc1 -triple %itanium_abi_triple -pedantic -verify %s
+// RUN: %clang_cc1 -triple %itanium_abi_triple -pedantic -verify -std=c++98 %s
+// RUN: %clang_cc1 -triple %itanium_abi_triple -pedantic -verify -std=c++11 %s
+
int* f(int) { return 0; }
float* f(float) { return 0; }
void f();
@@ -53,8 +56,19 @@ int* k(char*);
double* k(bool);
void test_k() {
- int* ip1 = k("foo"); // expected-warning{{conversion from string literal to 'char *' is deprecated}}
- int* ip2 = k(("foo")); // expected-warning{{conversion from string literal to 'char *' is deprecated}}
+ int* ip1 = k("foo");
+#if __cplusplus <= 199711L
+ // expected-warning@-2 {{conversion from string literal to 'char *' is deprecated}}
+#else
+ // expected-error@-4 {{cannot initialize a variable of type 'int *' with an rvalue of type 'double *'}}
+#endif
+
+ int* ip2 = k(("foo"));
+#if __cplusplus <= 199711L
+ // expected-warning@-2 {{conversion from string literal to 'char *' is deprecated}}
+#else
+ // expected-error@-4 {{cannot initialize a variable of type 'int *' with an rvalue of type 'double *'}}
+#endif
double* dp1 = k(L"foo");
}
@@ -62,7 +76,12 @@ int* l(wchar_t*);
double* l(bool);
void test_l() {
- int* ip1 = l(L"foo"); // expected-warning{{conversion from string literal to 'wchar_t *' is deprecated}}
+ int* ip1 = l(L"foo");
+#if __cplusplus <= 199711L
+ // expected-warning@-2 {{conversion from string literal to 'wchar_t *' is deprecated}}
+#else
+ // expected-error@-4 {{cannot initialize a variable of type 'int *' with an rvalue of type 'double *'}}
+#endif
double* dp1 = l("foo");
}
@@ -80,8 +99,12 @@ class E;
void test_n(E* e) {
char ca[7];
int* ip1 = n(ca);
- int* ip2 = n("foo"); // expected-warning{{conversion from string literal to 'char *' is deprecated}}
-
+ int* ip2 = n("foo");
+#if __cplusplus <= 199711L
+ // expected-warning@-2 {{conversion from string literal to 'char *' is deprecated}}
+#else
+ // expected-warning@-4 {{ISO C++11 does not allow conversion from string literal to 'char *'}}
+#endif
float fa[7];
double* dp1 = n(fa);
@@ -593,8 +616,16 @@ void test5() {
namespace PR20218 {
void f(void (*const &)()); // expected-note 2{{candidate}}
- void f(void (&&)()) = delete; // expected-note 2{{candidate}} expected-warning 2{{extension}}
- void g(void (&&)()) = delete; // expected-note 2{{candidate}} expected-warning 2{{extension}}
+ void f(void (&&)()) = delete; // expected-note 2{{candidate}}
+#if __cplusplus <= 199711L
+ // expected-warning@-2 {{rvalue references are a C++11 extension}}
+ // expected-warning@-3 {{deleted function definitions are a C++11 extension}}
+#endif
+ void g(void (&&)()) = delete; // expected-note 2{{candidate}}
+#if __cplusplus <= 199711L
+ // expected-warning@-2 {{rvalue references are a C++11 extension}}
+ // expected-warning@-3 {{deleted function definitions are a C++11 extension}}
+#endif
void g(void (*const &)()); // expected-note 2{{candidate}}
void x();
diff --git a/test/SemaCXX/overloaded-builtin-operators.cpp b/test/SemaCXX/overloaded-builtin-operators.cpp
index 7899403e2ce3..4c2953b0b3fe 100644
--- a/test/SemaCXX/overloaded-builtin-operators.cpp
+++ b/test/SemaCXX/overloaded-builtin-operators.cpp
@@ -1,4 +1,6 @@
// RUN: %clang_cc1 -fsyntax-only -fshow-overloads=best -verify -triple x86_64-linux-gnu %s
+// RUN: %clang_cc1 -fsyntax-only -fshow-overloads=best -verify -triple x86_64-linux-gnu -std=c++98 %s
+// RUN: %clang_cc1 -fsyntax-only -fshow-overloads=best -verify -triple x86_64-linux-gnu -std=c++11 %s
struct yes;
struct no;
@@ -60,7 +62,10 @@ void f(Short s, Long l, Enum1 e1, Enum2 e2, Xpmf pmf) {
// FIXME: should pass (void)static_cast<no&>(islong(e1 % e2));
}
-struct ShortRef { // expected-note{{candidate function (the implicit copy assignment operator)}}
+struct ShortRef { // expected-note{{candidate function (the implicit copy assignment operator) not viable}}
+#if __cplusplus >= 201103L // C++11 or later
+// expected-note@-2 {{candidate function (the implicit move assignment operator) not viable}}
+#endif
operator short&();
};
@@ -68,7 +73,10 @@ struct LongRef {
operator volatile long&();
};
-struct XpmfRef { // expected-note{{candidate function (the implicit copy assignment operator)}}
+struct XpmfRef { // expected-note{{candidate function (the implicit copy assignment operator) not viable}}
+#if __cplusplus >= 201103L // C++11 or later
+// expected-note@-2 {{candidate function (the implicit move assignment operator) not viable}}
+#endif
operator pmf&();
};
diff --git a/test/SemaCXX/pass-object-size.cpp b/test/SemaCXX/pass-object-size.cpp
new file mode 100644
index 000000000000..bec0c1c55f29
--- /dev/null
+++ b/test/SemaCXX/pass-object-size.cpp
@@ -0,0 +1,122 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11
+
+namespace simple {
+int Foo(void *const p __attribute__((pass_object_size(0))));
+
+int OvlFoo(void *const p __attribute__((pass_object_size(0))));
+int OvlFoo(void *const p, int);
+
+struct Statics {
+ static int Foo(void *const p __attribute__((pass_object_size(0))));
+ static int OvlFoo(void *const p __attribute__((pass_object_size(0))));
+ static int OvlFoo(void *const p __attribute__((pass_object_size(1)))); // expected-error{{conflicting pass_object_size attributes on parameters}} expected-note@-1{{previous declaration is here}}
+ static int OvlFoo(double *p);
+};
+
+struct Members {
+ int Foo(void *const p __attribute__((pass_object_size(0))));
+ int OvlFoo(void *const p __attribute__((pass_object_size(0))));
+ int OvlFoo(void *const p, int);
+};
+
+void Decls() {
+ int (*A)(void *) = &Foo; //expected-error{{cannot take address of function 'Foo' because parameter 1 has pass_object_size attribute}}
+ int (*B)(void *) = Foo; //expected-error{{cannot take address of function 'Foo' because parameter 1 has pass_object_size attribute}}
+
+ int (*C)(void *) = &OvlFoo; //expected-error{{address of overloaded function 'OvlFoo' does not match required type 'int (void *)'}} expected-note@6{{candidate address cannot be taken because parameter 1 has pass_object_size attribute}} expected-note@7{{candidate function has different number of parameters (expected 1 but has 2)}}
+ int (*D)(void *) = OvlFoo; //expected-error{{address of overloaded function 'OvlFoo' does not match required type 'int (void *)'}} expected-note@6{{candidate address cannot be taken because parameter 1 has pass_object_size attribute}} expected-note@7{{candidate function has different number of parameters (expected 1 but has 2)}}
+
+ int (*E)(void *) = &Statics::Foo; //expected-error{{cannot take address of function 'Foo' because parameter 1 has pass_object_size attribute}}
+ int (*F)(void *) = &Statics::OvlFoo; //expected-error{{address of overloaded function 'OvlFoo' does not match required type 'int (void *)'}} expected-note@11{{candidate address cannot be taken because parameter 1 has pass_object_size attribute}} expected-note@13{{candidate function has type mismatch at 1st parameter (expected 'void *' but has 'double *')}}
+
+ int (*G)(void *) = &Members::Foo; //expected-error{{cannot take address of function 'Foo' because parameter 1 has pass_object_size attribute}}
+ int (*H)(void *) = &Members::OvlFoo; //expected-error{{address of overloaded function 'OvlFoo' does not match required type 'int (void *)'}} expected-note@18{{candidate address cannot be taken because parameter 1 has pass_object_size attribute}} expected-note@19{{candidate function has different number of parameters (expected 1 but has 2)}}
+}
+
+void Assigns() {
+ int (*A)(void *);
+ A = &Foo; //expected-error{{cannot take address of function 'Foo' because parameter 1 has pass_object_size attribute}}
+ A = Foo; //expected-error{{cannot take address of function 'Foo' because parameter 1 has pass_object_size attribute}}
+
+ A = &OvlFoo; //expected-error{{assigning to 'int (*)(void *)' from incompatible type '<overloaded function type>'}} expected-note@6{{candidate address cannot be taken because parameter 1 has pass_object_size attribute}} expected-note@7{{candidate function has different number of parameters (expected 1 but has 2)}}
+ A = OvlFoo; //expected-error{{assigning to 'int (*)(void *)' from incompatible type '<overloaded function type>'}} expected-note@6{{candidate address cannot be taken because parameter 1 has pass_object_size attribute}} expected-note@7{{candidate function has different number of parameters (expected 1 but has 2)}}
+
+ A = &Statics::Foo; //expected-error{{cannot take address of function 'Foo' because parameter 1 has pass_object_size attribute}}
+ A = &Statics::OvlFoo; //expected-error{{assigning to 'int (*)(void *)' from incompatible type '<overloaded function type>'}} expected-note@11{{candidate address cannot be taken because parameter 1 has pass_object_size attribute}} expected-note@13{{candidate function has type mismatch at 1st parameter (expected 'void *' but has 'double *')}}
+
+ int (Members::*M)(void *);
+ M = &Members::Foo; //expected-error{{cannot take address of function 'Foo' because parameter 1 has pass_object_size attribute}}
+ M = &Members::OvlFoo; //expected-error-re{{assigning to '{{.*}}' from incompatible type '<overloaded function type>'}} expected-note@18{{candidate address cannot be taken because parameter 1 has pass_object_size attribute}} expected-note@19{{candidate function has different number of parameters (expected 1 but has 2)}}
+}
+
+} // namespace simple
+
+namespace templates {
+template <typename T>
+int Foo(void *const __attribute__((pass_object_size(0)))) {
+ return 0;
+}
+
+template <typename T> struct Bar {
+ template <typename U>
+ int Foo(void *const __attribute__((pass_object_size(0)))) {
+ return 0;
+ }
+};
+
+void Decls() {
+ int (*A)(void *) = &Foo<void*>; //expected-error{{address of overloaded function 'Foo' does not match required type 'int (void *)'}} expected-note@56{{candidate address cannot be taken because parameter 1 has pass_object_size attribute}}
+ int (Bar<int>::*B)(void *) = &Bar<int>::Foo<double>; //expected-error{{address of overloaded function 'Foo' does not match required type}} expected-note@62{{candidate address cannot be taken because parameter 1 has pass_object_size attribute}}
+}
+
+void Assigns() {
+ int (*A)(void *);
+ A = &Foo<void*>; // expected-error{{assigning to 'int (*)(void *)' from incompatible type '<overloaded function type>'}} expected-note@56{{candidate address cannot be taken because parameter 1 has pass_object_size attribute}}
+ int (Bar<int>::*B)(void *) = &Bar<int>::Foo<double>; //expected-error{{address of overloaded function 'Foo' does not match required type}} expected-note@62{{candidate address cannot be taken because parameter 1 has pass_object_size attribute}}
+}
+} // namespace templates
+
+namespace virt {
+struct Foo {
+ virtual void DoIt(void *const p __attribute__((pass_object_size(0))));
+};
+
+struct Bar : public Foo {
+ void DoIt(void *const p __attribute__((pass_object_size(0)))) override; // OK
+};
+
+struct Baz : public Foo {
+ void DoIt(void *const p) override; //expected-error{{non-virtual member function marked 'override' hides virtual member function}} expected-note@81{{hidden overloaded virtual function 'virt::Foo::DoIt' declared here}}
+};
+}
+
+namespace why {
+void TakeFn(void (*)(int, void *));
+void ObjSize(int, void *const __attribute__((pass_object_size(0))));
+
+void Check() {
+ TakeFn(ObjSize); //expected-error{{cannot take address of function 'ObjSize' because parameter 2 has pass_object_size attribute}}
+ TakeFn(&ObjSize); //expected-error{{cannot take address of function 'ObjSize' because parameter 2 has pass_object_size attribute}}
+ TakeFn(*ObjSize); //expected-error{{cannot take address of function 'ObjSize' because parameter 2 has pass_object_size attribute}}
+ TakeFn(*****ObjSize); //expected-error{{cannot take address of function 'ObjSize' because parameter 2 has pass_object_size attribute}}
+ TakeFn(*****&ObjSize); //expected-error{{cannot take address of function 'ObjSize' because parameter 2 has pass_object_size attribute}}
+
+ void (*P)(int, void *) = ****ObjSize; //expected-error{{cannot take address of function 'ObjSize' because parameter 2 has pass_object_size attribute}}
+ P = ****ObjSize; //expected-error{{cannot take address of function 'ObjSize' because parameter 2 has pass_object_size attribute}}
+
+ TakeFn((ObjSize)); //expected-error{{cannot take address of function 'ObjSize' because parameter 2 has pass_object_size attribute}}
+ TakeFn((void*)ObjSize); //expected-error{{cannot take address of function 'ObjSize' because parameter 2 has pass_object_size attribute}}
+ TakeFn((decltype(P))((void*)ObjSize)); //expected-error{{cannot take address of function 'ObjSize' because parameter 2 has pass_object_size attribute}}
+}
+}
+
+namespace constexpr_support {
+constexpr int getObjSizeType() { return 0; }
+void Foo(void *p __attribute__((pass_object_size(getObjSizeType()))));
+}
+
+namespace lambdas {
+void Bar() {
+ (void)+[](void *const p __attribute__((pass_object_size(0)))) {}; //expected-error-re{{invalid argument type '(lambda at {{.*}})' to unary expression}}
+}
+}
diff --git a/test/SemaCXX/pragma-init_seg.cpp b/test/SemaCXX/pragma-init_seg.cpp
index e18d0e6814af..1b22939f18e3 100644
--- a/test/SemaCXX/pragma-init_seg.cpp
+++ b/test/SemaCXX/pragma-init_seg.cpp
@@ -1,5 +1,9 @@
// RUN: %clang_cc1 -fsyntax-only -verify -fms-extensions %s -triple x86_64-pc-win32
+// RUN: %clang_cc1 -fsyntax-only -verify -fms-extensions -std=c++98 %s -triple x86_64-pc-win32
+// RUN: %clang_cc1 -fsyntax-only -verify -fms-extensions -std=c++11 %s -triple x86_64-pc-win32
// RUN: %clang_cc1 -fsyntax-only -verify -fms-extensions %s -triple i386-apple-darwin13.3.0
+// RUN: %clang_cc1 -fsyntax-only -verify -fms-extensions -std=c++98 %s -triple i386-apple-darwin13.3.0
+// RUN: %clang_cc1 -fsyntax-only -verify -fms-extensions -std=c++11 %s -triple i386-apple-darwin13.3.0
#ifndef __APPLE__
#pragma init_seg(L".my_seg") // expected-warning {{expected 'compiler', 'lib', 'user', or a string literal}}
@@ -19,3 +23,6 @@
int f();
int __declspec(thread) x = f(); // expected-error {{initializer for thread-local variable must be a constant expression}}
+#if __cplusplus >= 201103L
+// expected-note@-2 {{use 'thread_local' to allow this}}
+#endif
diff --git a/test/SemaCXX/pragma-vtordisp.cpp b/test/SemaCXX/pragma-vtordisp.cpp
index 49841c51ef05..649c0ee9e686 100644
--- a/test/SemaCXX/pragma-vtordisp.cpp
+++ b/test/SemaCXX/pragma-vtordisp.cpp
@@ -32,9 +32,41 @@ struct B : virtual A { int b; };
#pragma vtordisp(), stuff // expected-warning {{extra tokens}}
struct C {
-// FIXME: Our implementation based on token insertion makes it impossible for
-// the pragma to appear everywhere we should support it.
-//#pragma vtordisp()
+#pragma vtordisp()
struct D : virtual A {
};
};
+
+struct E {
+ virtual ~E();
+ virtual void f();
+};
+
+#pragma vtordisp(pop) // expected-warning {{#pragma vtordisp(pop, ...) failed: stack empty}}
+
+void g() {
+ #pragma vtordisp(push, 2)
+ struct F : virtual E {
+ virtual ~F();
+ virtual void f();
+ };
+}
+
+#pragma vtordisp(pop) // OK because of local vtordisp(2) in g().
+
+struct G {
+ void f() {
+ #pragma vtordisp(push, 2) // Method-local pragma - stack will be restored on exit.
+ }
+};
+
+// Stack is restored on exit from G::f(), nothing to pop.
+#pragma vtordisp(pop) // expected-warning {{#pragma vtordisp(pop, ...) failed: stack empty}}
+
+int g2()
+// FIXME: Our implementation based on token insertion makes it impossible for
+// the pragma to appear everywhere we should support it.
+// #pragma vtordisp()
+{
+ return 0;
+}
diff --git a/test/SemaCXX/printf-block.cpp b/test/SemaCXX/printf-block.cpp
index 4a580037e731..b9d06d6c4fe7 100644
--- a/test/SemaCXX/printf-block.cpp
+++ b/test/SemaCXX/printf-block.cpp
@@ -1,4 +1,6 @@
// RUN: %clang_cc1 -fsyntax-only -fblocks -Wformat -verify %s -Wno-error=non-pod-varargs
+// RUN: %clang_cc1 -fsyntax-only -fblocks -Wformat -verify %s -Wno-error=non-pod-varargs -std=c++98
+// RUN: %clang_cc1 -fsyntax-only -fblocks -Wformat -verify %s -Wno-error=non-pod-varargs -std=c++11
int (^block) (int, const char *,...) __attribute__((__format__(__printf__,2,3))) = ^ __attribute__((__format__(__printf__,2,3))) (int arg, const char *format,...) {return 5;};
@@ -14,5 +16,11 @@ void test_block() {
HasNoCStr hncs(str);
int n = 4;
block(n, "%s %d", str, n); // no-warning
- block(n, "%s %s", hncs, n); // expected-warning{{cannot pass non-POD object of type 'HasNoCStr' to variadic block; expected type from format string was 'char *'}} expected-warning{{format specifies type 'char *' but the argument has type 'int'}}
+ block(n, "%s %s", hncs, n);
+#if __cplusplus <= 199711L // C++03 or earlier modes
+ // expected-warning@-2{{cannot pass non-POD object of type 'HasNoCStr' to variadic block; expected type from format string was 'char *'}}
+#else
+ // expected-warning@-4{{format specifies type 'char *' but the argument has type 'HasNoCStr'}}
+#endif
+ // expected-warning@-6{{format specifies type 'char *' but the argument has type 'int'}}
}
diff --git a/test/SemaCXX/redefine_extname.cpp b/test/SemaCXX/redefine_extname.cpp
new file mode 100644
index 000000000000..460df4ba1b4d
--- /dev/null
+++ b/test/SemaCXX/redefine_extname.cpp
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -triple=x86_64-unknown-linux -Wpragmas -verify %s
+
+// Check that pragma redefine_extname applies to C code only, and shouldn't be
+// applied to C++.
+#pragma redefine_extname foo_cpp bar_cpp
+extern int foo_cpp() { return 1; } // expected-warning {{#pragma redefine_extname is applicable to external C declarations only; not applied to function 'foo_cpp'}}
diff --git a/test/SemaCXX/rval-references.cpp b/test/SemaCXX/rval-references.cpp
index fc341e87f4a4..9c79ad7b0b97 100644
--- a/test/SemaCXX/rval-references.cpp
+++ b/test/SemaCXX/rval-references.cpp
@@ -90,5 +90,5 @@ MoveOnly returningNonEligible() {
else if (0) // Copy from reference can't be elided
return r; // expected-error {{call to deleted constructor}}
else // Construction from different type can't be elided
- return i; // expected-error {{no viable conversion from 'int' to 'MoveOnly'}}
+ return i; // expected-error {{no viable conversion from returned value of type 'int' to function return type 'MoveOnly'}}
}
diff --git a/test/SemaCXX/sourceranges.cpp b/test/SemaCXX/sourceranges.cpp
index 9ba003aa204a..2f8eb2f2b96c 100644
--- a/test/SemaCXX/sourceranges.cpp
+++ b/test/SemaCXX/sourceranges.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -ast-dump %s | FileCheck %s
+// RUN: %clang_cc1 -triple i686-mingw32 -ast-dump %s | FileCheck %s
template<class T>
class P {
@@ -7,7 +7,7 @@ class P {
};
namespace foo {
-class A { public: A() {} };
+class A { public: A(int = 0) {} };
enum B {};
typedef int C;
}
@@ -37,3 +37,16 @@ void destruct(foo::A *a1, foo::A *a2, P<int> *p1) {
// CHECK: MemberExpr {{0x[0-9a-fA-F]+}} <col:3, col:13> '<bound member function type>' ->~P
p1->~P<int>();
}
+
+struct D {
+ D(int);
+ ~D();
+};
+
+void construct() {
+ using namespace foo;
+ A a = A(12);
+ // CHECK: CXXConstructExpr {{0x[0-9a-fA-F]+}} <col:9, col:13> 'class foo::A' 'void (int){{( __attribute__\(\(thiscall\)\))?}}'
+ D d = D(12);
+ // CHECK: CXXConstructExpr {{0x[0-9a-fA-F]+}} <col:9, col:13> 'struct D' 'void (int){{( __attribute__\(\(thiscall\)\))?}}'
+}
diff --git a/test/SemaCXX/type-convert-construct.cpp b/test/SemaCXX/type-convert-construct.cpp
index 479af21476be..2dec50abebf2 100644
--- a/test/SemaCXX/type-convert-construct.cpp
+++ b/test/SemaCXX/type-convert-construct.cpp
@@ -5,6 +5,8 @@ void f() {
int v2 = typeof(int)(1,2); // expected-error {{excess elements in scalar initializer}}
typedef int arr[];
int v3 = arr(); // expected-error {{array types cannot be value-initialized}}
+ typedef void fn_ty();
+ fn_ty(); // expected-error {{function types cannot be value-initialized}}
int v4 = int();
int v5 = int; // expected-error {{expected '(' for function-style cast or type construction}}
typedef int T;
diff --git a/test/SemaCXX/type-traits.cpp b/test/SemaCXX/type-traits.cpp
index 2265c284763f..69760fd6bd06 100644
--- a/test/SemaCXX/type-traits.cpp
+++ b/test/SemaCXX/type-traits.cpp
@@ -14,6 +14,7 @@ typedef Int IntAr[10];
typedef Int IntArNB[];
class Statics { static int priv; static NonPOD np; };
union EmptyUnion {};
+union IncompleteUnion;
union Union { int i; float f; };
struct HasFunc { void f (); };
struct HasOp { void operator *(); };
@@ -150,6 +151,18 @@ struct VariadicCtor {
template<typename...T> VariadicCtor(T...);
};
+struct ThrowingDtor {
+ ~ThrowingDtor() throw(int);
+};
+
+struct NoExceptDtor {
+ ~NoExceptDtor() noexcept(true);
+};
+
+struct NoThrowDtor {
+ ~NoThrowDtor() throw();
+};
+
void is_pod()
{
{ int arr[T(__is_pod(int))]; }
@@ -223,6 +236,7 @@ void is_empty()
{ int arr[F(__is_empty(Int))]; }
{ int arr[F(__is_empty(POD))]; }
{ int arr[F(__is_empty(EmptyUnion))]; }
+ { int arr[F(__is_empty(IncompleteUnion))]; }
{ int arr[F(__is_empty(EmptyAr))]; }
{ int arr[F(__is_empty(HasRef))]; }
{ int arr[F(__is_empty(HasVirt))]; }
@@ -301,8 +315,23 @@ struct PotentiallyFinal<T*> final { };
template<>
struct PotentiallyFinal<int> final { };
+struct SealedClass sealed {
+};
+
+template<typename T>
+struct PotentiallySealed { };
+
+template<typename T>
+struct PotentiallySealed<T*> sealed { };
+
+template<>
+struct PotentiallySealed<int> sealed { };
+
void is_final()
{
+ { int arr[T(__is_final(SealedClass))]; }
+ { int arr[T(__is_final(PotentiallySealed<float*>))]; }
+ { int arr[T(__is_final(PotentiallySealed<int>))]; }
{ int arr[T(__is_final(FinalClass))]; }
{ int arr[T(__is_final(PotentiallyFinal<float*>))]; }
{ int arr[T(__is_final(PotentiallyFinal<int>))]; }
@@ -318,25 +347,17 @@ void is_final()
{ int arr[F(__is_final(IntArNB))]; }
{ int arr[F(__is_final(HasAnonymousUnion))]; }
{ int arr[F(__is_final(PotentiallyFinal<float>))]; }
+ { int arr[F(__is_final(PotentiallySealed<float>))]; }
}
-struct SealedClass sealed {
-};
-
-template<typename T>
-struct PotentiallySealed { };
-
-template<typename T>
-struct PotentiallySealed<T*> sealed { };
-
-template<>
-struct PotentiallySealed<int> sealed { };
-
void is_sealed()
{
{ int arr[T(__is_sealed(SealedClass))]; }
{ int arr[T(__is_sealed(PotentiallySealed<float*>))]; }
{ int arr[T(__is_sealed(PotentiallySealed<int>))]; }
+ { int arr[T(__is_sealed(FinalClass))]; }
+ { int arr[T(__is_sealed(PotentiallyFinal<float*>))]; }
+ { int arr[T(__is_sealed(PotentiallyFinal<int>))]; }
{ int arr[F(__is_sealed(int))]; }
{ int arr[F(__is_sealed(Union))]; }
@@ -349,6 +370,7 @@ void is_sealed()
{ int arr[F(__is_sealed(IntArNB))]; }
{ int arr[F(__is_sealed(HasAnonymousUnion))]; }
{ int arr[F(__is_sealed(PotentiallyFinal<float>))]; }
+ { int arr[F(__is_sealed(PotentiallySealed<float>))]; }
}
typedef HasVirt Polymorph;
@@ -361,6 +383,7 @@ void is_polymorphic()
{ int arr[F(__is_polymorphic(int))]; }
{ int arr[F(__is_polymorphic(Union))]; }
+ { int arr[F(__is_polymorphic(IncompleteUnion))]; }
{ int arr[F(__is_polymorphic(Int))]; }
{ int arr[F(__is_polymorphic(IntAr))]; }
{ int arr[F(__is_polymorphic(UnionAr))]; }
@@ -1979,6 +2002,9 @@ void constructible_checks() {
// PR20228
{ int arr[T(__is_constructible(VariadicCtor,
int, int, int, int, int, int, int, int, int))]; }
+
+ // PR25513
+ { int arr[F(__is_constructible(int(int)))]; }
}
// Instantiation of __is_trivially_constructible
@@ -2019,3 +2045,34 @@ void array_extent() {
int t02[T(__array_extent(ConstIntArAr, 0) == 4)];
int t03[T(__array_extent(ConstIntArAr, 1) == 10)];
}
+
+void is_destructible_test() {
+ { int arr[T(__is_destructible(int))]; }
+ { int arr[T(__is_destructible(int[2]))]; }
+ { int arr[F(__is_destructible(int[]))]; }
+ { int arr[F(__is_destructible(void))]; }
+ { int arr[T(__is_destructible(int &))]; }
+ { int arr[T(__is_destructible(HasDest))]; }
+ { int arr[F(__is_destructible(AllPrivate))]; }
+ { int arr[T(__is_destructible(SuperNonTrivialStruct))]; }
+ { int arr[T(__is_destructible(AllDefaulted))]; }
+ { int arr[F(__is_destructible(AllDeleted))]; }
+ { int arr[T(__is_destructible(ThrowingDtor))]; }
+ { int arr[T(__is_destructible(NoThrowDtor))]; }
+}
+
+void is_nothrow_destructible_test() {
+ { int arr[T(__is_nothrow_destructible(int))]; }
+ { int arr[T(__is_nothrow_destructible(int[2]))]; }
+ { int arr[F(__is_nothrow_destructible(int[]))]; }
+ { int arr[F(__is_nothrow_destructible(void))]; }
+ { int arr[T(__is_nothrow_destructible(int &))]; }
+ { int arr[T(__is_nothrow_destructible(HasDest))]; }
+ { int arr[F(__is_nothrow_destructible(AllPrivate))]; }
+ { int arr[T(__is_nothrow_destructible(SuperNonTrivialStruct))]; }
+ { int arr[T(__is_nothrow_destructible(AllDefaulted))]; }
+ { int arr[F(__is_nothrow_destructible(AllDeleted))]; }
+ { int arr[F(__is_nothrow_destructible(ThrowingDtor))]; }
+ { int arr[T(__is_nothrow_destructible(NoExceptDtor))]; }
+ { int arr[T(__is_nothrow_destructible(NoThrowDtor))]; }
+}
diff --git a/test/SemaCXX/typo-correction-blocks.c b/test/SemaCXX/typo-correction-blocks.c
new file mode 100644
index 000000000000..300a5be3969d
--- /dev/null
+++ b/test/SemaCXX/typo-correction-blocks.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -triple i386-apple-macosx -fblocks -fsyntax-only -verify %s
+
+extern int h(int *);
+extern void g(int, void (^)(void));
+extern int fuzzys; // expected-note {{'fuzzys' declared here}}
+
+static void f(void *v) {
+ g(fuzzy, ^{ // expected-error {{did you mean 'fuzzys'}}
+ int i = h(v);
+ });
+}
+
diff --git a/test/SemaCXX/typo-correction-delayed.cpp b/test/SemaCXX/typo-correction-delayed.cpp
index 121863d172bd..610d43971381 100644
--- a/test/SemaCXX/typo-correction-delayed.cpp
+++ b/test/SemaCXX/typo-correction-delayed.cpp
@@ -1,4 +1,6 @@
// RUN: %clang_cc1 -fsyntax-only -verify -Wno-c++11-extensions %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 -Wno-c++11-extensions %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
struct A {};
struct B {};
@@ -109,8 +111,10 @@ S<1> s;
namespace foo {}
void test_paren_suffix() {
- foo::bar({5, 6}); // expected-error-re {{no member named 'bar' in namespace 'foo'{{$}}}} \
- // expected-error {{expected expression}}
+ foo::bar({5, 6}); // expected-error-re {{no member named 'bar' in namespace 'foo'{{$}}}}
+#if __cplusplus <= 199711L
+ // expected-error@-2 {{expected expression}}
+#endif
}
const int kNum = 10; // expected-note {{'kNum' declared here}}
diff --git a/test/SemaCXX/typo-correction.cpp b/test/SemaCXX/typo-correction.cpp
index 174b1403e2db..07c1634431ea 100644
--- a/test/SemaCXX/typo-correction.cpp
+++ b/test/SemaCXX/typo-correction.cpp
@@ -307,14 +307,21 @@ struct A {
void CreateBar(float, float);
};
struct B : A {
- using A::CreateFoo;
+ using A::CreateFoo; // expected-note {{'CreateFoo' declared here}}
void CreateFoo(int, int); // expected-note {{'CreateFoo' declared here}}
};
void f(B &x) {
x.Createfoo(0,0); // expected-error {{no member named 'Createfoo' in 'PR13387::B'; did you mean 'CreateFoo'?}}
+ x.Createfoo(0.f,0.f); // expected-error {{no member named 'Createfoo' in 'PR13387::B'; did you mean 'CreateFoo'?}}
}
}
+namespace using_decl {
+ namespace somewhere { int foobar; }
+ using somewhere::foobar; // expected-note {{declared here}}
+ int k = goobar; // expected-error {{did you mean 'foobar'?}}
+}
+
struct DataStruct {void foo();};
struct T {
DataStruct data_struct;
@@ -640,3 +647,19 @@ int has_include(int); // expected-note {{'has_include' declared here}}
// expected-error@+1 {{__has_include must be used within a preprocessing directive}}
int foo = __has_include(42); // expected-error {{use of undeclared identifier '__has_include'; did you mean 'has_include'?}}
}
+
+namespace PR24781_using_crash {
+namespace A {
+namespace B {
+class Foofoo {}; // expected-note {{'A::B::Foofoo' declared here}}
+}
+}
+
+namespace C {
+namespace D {
+class Bar : public A::B::Foofoo {};
+}
+}
+
+using C::D::Foofoo; // expected-error {{no member named 'Foofoo' in namespace 'PR24781_using_crash::C::D'; did you mean 'A::B::Foofoo'?}}
+}
diff --git a/test/SemaCXX/undefined-internal.cpp b/test/SemaCXX/undefined-internal.cpp
index 0138967ef80c..29ca5de6d41c 100644
--- a/test/SemaCXX/undefined-internal.cpp
+++ b/test/SemaCXX/undefined-internal.cpp
@@ -1,7 +1,11 @@
// RUN: %clang_cc1 -fsyntax-only -verify -Wbind-to-temporary-copy %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wbind-to-temporary-copy -std=c++98 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wbind-to-temporary-copy -std=c++11 %s
// Make sure we don't produce invalid IR.
// RUN: %clang_cc1 -emit-llvm-only %s
+// RUN: %clang_cc1 -emit-llvm-only -std=c++98 %s
+// RUN: %clang_cc1 -emit-llvm-only -std=c++11 %s
namespace test1 {
static void foo(); // expected-warning {{function 'test1::foo' has internal linkage but is not defined}}
@@ -119,7 +123,12 @@ namespace PR9323 {
}
void f(const Uncopyable&) {}
void test() {
- f(Uncopyable()); // expected-warning {{C++98 requires an accessible copy constructor}}
+ f(Uncopyable());
+#if __cplusplus <= 199711L // C++03 or earlier modes
+ // expected-warning@-2 {{C++98 requires an accessible copy constructor}}
+#else
+ // expected-warning@-4 {{copying parameter of type 'PR9323::(anonymous namespace)::Uncopyable' when binding a reference to a temporary would invoke an inaccessible constructor in C++98}}
+#endif
};
}
diff --git a/test/SemaCXX/underlying_type.cpp b/test/SemaCXX/underlying_type.cpp
index 2a972b174e86..61208c72af04 100644
--- a/test/SemaCXX/underlying_type.cpp
+++ b/test/SemaCXX/underlying_type.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -ffreestanding -fsyntax-only -verify -std=c++11 %s
+// RUN: %clang_cc1 -triple %itanium_abi_triple -ffreestanding -fsyntax-only -verify -std=c++11 %s
#include "limits.h"
diff --git a/test/SemaCXX/unknown-type-name.cpp b/test/SemaCXX/unknown-type-name.cpp
index 9d28c310ed97..2a9748e3ab67 100644
--- a/test/SemaCXX/unknown-type-name.cpp
+++ b/test/SemaCXX/unknown-type-name.cpp
@@ -1,4 +1,6 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
// PR3990
namespace N {
@@ -95,7 +97,11 @@ template<typename T> int h(T::type x, char); // expected-error{{missing 'typenam
template<typename T> int junk1(T::junk); // expected-warning{{variable templates are a C++14 extension}}
template<typename T> int junk2(T::junk) throw(); // expected-error{{missing 'typename'}}
-template<typename T> int junk3(T::junk) = delete; // expected-error{{missing 'typename'}} expected-warning{{C++11}}
+template<typename T> int junk3(T::junk) = delete; // expected-error{{missing 'typename'}}
+#if __cplusplus <= 199711L
+//expected-warning@-2 {{deleted function definitions are a C++11 extension}}
+#endif
+
template<typename T> int junk4(T::junk j); // expected-error{{missing 'typename'}}
// FIXME: We can tell this was intended to be a function because it does not
diff --git a/test/SemaCXX/using-decl-1.cpp b/test/SemaCXX/using-decl-1.cpp
index ca532692c1cb..ec45b3109a0b 100644
--- a/test/SemaCXX/using-decl-1.cpp
+++ b/test/SemaCXX/using-decl-1.cpp
@@ -30,9 +30,7 @@ struct X0 {
};
struct X1 : X0 {
- // FIXME: give this operator() a 'float' parameter to test overloading
- // behavior. It currently fails.
- void operator()();
+ void operator()(float&);
using X0::operator();
void test() {
@@ -327,3 +325,16 @@ namespace PR24033 {
using PR24033::st; // expected-error {{target of using declaration conflicts with declaration already in scope}}
}
}
+
+namespace field_use {
+struct A { int field; };
+struct B : A {
+ // Previously Clang rejected this valid C++11 code because it didn't look
+ // through the UsingShadowDecl.
+ using A::field;
+#if __cplusplus < 201103L
+ // expected-error@+2 {{invalid use of non-static data member 'field'}}
+#endif
+ enum { X = sizeof(field) };
+};
+}
diff --git a/test/SemaCXX/vector-casts.cpp b/test/SemaCXX/vector-casts.cpp
index 2ccd5979c7f7..a3d9de6fff84 100644
--- a/test/SemaCXX/vector-casts.cpp
+++ b/test/SemaCXX/vector-casts.cpp
@@ -1,18 +1,22 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-unknown -fsyntax-only -verify %s
typedef int __v2si __attribute__((__vector_size__(8)));
typedef short __v4hi __attribute__((__vector_size__(8)));
typedef short __v8hi __attribute__((__vector_size__(16)));
typedef short __v3hi __attribute__((__ext_vector_type__(3)));
-struct S { }; // expected-note 2 {{candidate constructor}}
+struct S { }; // expected-note 3 {{candidate constructor}}
+
+enum E : long long { Evalue };
void f() {
__v2si v2si;
+ __v3hi v3hi;
__v4hi v4hi;
__v8hi v8hi;
unsigned long long ll;
unsigned char c;
S s;
+ E e;
(void)reinterpret_cast<__v2si>(v4hi);
(void)(__v2si)v4hi;
@@ -23,6 +27,11 @@ void f() {
(void)reinterpret_cast<__v2si>(ll);
(void)(__v2si)(ll);
+ (void)(E)v2si; // expected-error {{C-style cast from '__v2si' (vector of 2 'int' values) to 'E' is not allowed}}
+ (void)(__v2si)e; // expected-error {{C-style cast from 'E' to '__v2si' (vector of 2 'int' values)}}
+ (void)reinterpret_cast<E>(v2si); // expected-error {{reinterpret_cast from '__v2si' (vector of 2 'int' values) to 'E' is not allowed}}
+ (void)reinterpret_cast<__v2si>(e); // expected-error {{reinterpret_cast from 'E' to '__v2si' (vector of 2 'int' values)}}
+
(void)reinterpret_cast<S>(v2si); // expected-error {{reinterpret_cast from '__v2si' (vector of 2 'int' values) to 'S' is not allowed}}
(void)(S)v2si; // expected-error {{no matching conversion for C-style cast from '__v2si' (vector of 2 'int' values) to 'S'}}
(void)reinterpret_cast<__v2si>(s); // expected-error {{reinterpret_cast from 'S' to '__v2si' (vector of 2 'int' values) is not allowed}}
@@ -36,15 +45,24 @@ void f() {
(void)(__v8hi)v4hi; // expected-error {{C-style cast from vector '__v4hi' (vector of 4 'short' values) to vector '__v8hi' (vector of 8 'short' values) of different size}}
(void)reinterpret_cast<__v4hi>(v8hi); // expected-error {{reinterpret_cast from vector '__v8hi' (vector of 8 'short' values) to vector '__v4hi' (vector of 4 'short' values) of different size}}
(void)(__v4hi)v8hi; // expected-error {{C-style cast from vector '__v8hi' (vector of 8 'short' values) to vector '__v4hi' (vector of 4 'short' values) of different size}}
+
+ (void)(__v3hi)v4hi; // expected-error {{C-style cast from vector '__v4hi' (vector of 4 'short' values) to vector '__v3hi' (vector of 3 'short' values) of different size}}
+ (void)(__v3hi)v2si; // expected-error {{C-style cast from vector '__v2si' (vector of 2 'int' values) to vector '__v3hi' (vector of 3 'short' values) of different size}}
+ (void)(__v4hi)v3hi; // expected-error {{C-style cast from vector '__v3hi' (vector of 3 'short' values) to vector '__v4hi' (vector of 4 'short' values) of different size}}
+ (void)(__v2si)v3hi; // expected-error {{C-style cast from vector '__v3hi' (vector of 3 'short' values) to vector '__v2si' (vector of 2 'int' values) of different size}}
+ (void)reinterpret_cast<__v3hi>(v4hi); // expected-error {{reinterpret_cast from vector '__v4hi' (vector of 4 'short' values) to vector '__v3hi' (vector of 3 'short' values) of different size}}
+ (void)reinterpret_cast<__v3hi>(v2si); // expected-error {{reinterpret_cast from vector '__v2si' (vector of 2 'int' values) to vector '__v3hi' (vector of 3 'short' values) of different size}}
+ (void)reinterpret_cast<__v4hi>(v3hi); // expected-error {{reinterpret_cast from vector '__v3hi' (vector of 3 'short' values) to vector '__v4hi' (vector of 4 'short' values) of different size}}
+ (void)reinterpret_cast<__v2si>(v3hi); // expected-error {{reinterpret_cast from vector '__v3hi' (vector of 3 'short' values) to vector '__v2si' (vector of 2 'int' values) of different size}}
}
struct testvec {
__v2si v;
void madd(const testvec& rhs) {
- v = v + rhs; // expected-error {{can't convert between vector and non-scalar values}}
+ v = v + rhs; // expected-error {{cannot convert between vector and non-scalar values}}
}
void madd2(testvec rhs) {
- v = v + rhs; // expected-error {{can't convert between vector and non-scalar values}}
+ v = v + rhs; // expected-error {{cannot convert between vector and non-scalar values}}
}
};
diff --git a/test/SemaCXX/vector-no-lax.cpp b/test/SemaCXX/vector-no-lax.cpp
index 32dcacfb45d8..a85f7f9db060 100644
--- a/test/SemaCXX/vector-no-lax.cpp
+++ b/test/SemaCXX/vector-no-lax.cpp
@@ -4,6 +4,6 @@ typedef int __attribute__((vector_size (16))) vSInt32;
vSInt32 foo (vUInt32 a) {
vSInt32 b = { 0, 0, 0, 0 };
- b += a; // expected-error{{can't convert between vector values}}
+ b += a; // expected-error{{cannot convert between vector values}}
return b;
}
diff --git a/test/SemaCXX/vector.cpp b/test/SemaCXX/vector.cpp
index bcd7fedb4df2..9b272444a23f 100644
--- a/test/SemaCXX/vector.cpp
+++ b/test/SemaCXX/vector.cpp
@@ -1,4 +1,7 @@
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify -std=c++98 %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify -std=c++11 %s
+
typedef char char16 __attribute__ ((__vector_size__ (16)));
typedef long long longlong16 __attribute__ ((__vector_size__ (16)));
typedef char char16_e __attribute__ ((__ext_vector_type__ (16)));
@@ -101,7 +104,10 @@ void casts(longlong16 ll16, longlong16_e ll16e) {
}
template<typename T>
-struct convertible_to { // expected-note 3 {{candidate function (the implicit copy assignment operator)}}
+struct convertible_to { // expected-note 3 {{candidate function (the implicit copy assignment operator) not viable}}
+#if __cplusplus >= 201103L // C++11 or later
+// expected-note@-2 3 {{candidate function (the implicit move assignment operator) not viable}}
+#endif
operator T() const;
};
diff --git a/test/SemaCXX/warn-logical-not-compare.cpp b/test/SemaCXX/warn-logical-not-compare.cpp
index 3ecce474f149..280ab22d7235 100644
--- a/test/SemaCXX/warn-logical-not-compare.cpp
+++ b/test/SemaCXX/warn-logical-not-compare.cpp
@@ -11,67 +11,73 @@ bool test1(int i1, int i2, bool b1, bool b2) {
// expected-warning@-1 {{logical not is only applied to the left hand side of this comparison}}
// expected-note@-2 {{add parentheses after the '!' to evaluate the comparison first}}
// expected-note@-3 {{add parentheses around left hand side expression to silence this warning}}
+ // CHECK: warn-logical-not-compare.cpp:[[line:[0-9]*]]:9: warning
// CHECK: to evaluate the comparison first
- // CHECK: fix-it:"{{.*}}":{10:10-10:10}:"("
- // CHECK: fix-it:"{{.*}}":{10:18-10:18}:")"
+ // CHECK: fix-it:"{{.*}}":{[[line]]:10-[[line]]:10}:"("
+ // CHECK: fix-it:"{{.*}}":{[[line]]:18-[[line]]:18}:")"
// CHECK: to silence this warning
- // CHECK: fix-it:"{{.*}}":{10:9-10:9}:"("
- // CHECK: fix-it:"{{.*}}":{10:12-10:12}:")"
+ // CHECK: fix-it:"{{.*}}":{[[line]]:9-[[line]]:9}:"("
+ // CHECK: fix-it:"{{.*}}":{[[line]]:12-[[line]]:12}:")"
ret = !i1 != i2;
//expected-warning@-1 {{logical not is only applied to the left hand side of this comparison}}
// expected-note@-2 {{add parentheses after the '!' to evaluate the comparison first}}
// expected-note@-3 {{add parentheses around left hand side expression to silence this warning}}
+ // CHECK: warn-logical-not-compare.cpp:[[line:[0-9]*]]:9: warning
// CHECK: to evaluate the comparison first
- // CHECK: fix-it:"{{.*}}":{21:10-21:10}:"("
- // CHECK: fix-it:"{{.*}}":{21:18-21:18}:")"
+ // CHECK: fix-it:"{{.*}}":{[[line]]:10-[[line]]:10}:"("
+ // CHECK: fix-it:"{{.*}}":{[[line]]:18-[[line]]:18}:")"
// CHECK: to silence this warning
- // CHECK: fix-it:"{{.*}}":{21:9-21:9}:"("
- // CHECK: fix-it:"{{.*}}":{21:12-21:12}:")"
+ // CHECK: fix-it:"{{.*}}":{[[line]]:9-[[line]]:9}:"("
+ // CHECK: fix-it:"{{.*}}":{[[line]]:12-[[line]]:12}:")"
ret = !i1 < i2;
//expected-warning@-1 {{logical not is only applied to the left hand side of this comparison}}
// expected-note@-2 {{add parentheses after the '!' to evaluate the comparison first}}
// expected-note@-3 {{add parentheses around left hand side expression to silence this warning}}
+ // CHECK: warn-logical-not-compare.cpp:[[line:[0-9]*]]:9: warning
// CHECK: to evaluate the comparison first
- // CHECK: fix-it:"{{.*}}":{32:10-32:10}:"("
- // CHECK: fix-it:"{{.*}}":{32:17-32:17}:")"
+ // CHECK: fix-it:"{{.*}}":{[[line]]:10-[[line]]:10}:"("
+ // CHECK: fix-it:"{{.*}}":{[[line]]:17-[[line]]:17}:")"
// CHECK: to silence this warning
- // CHECK: fix-it:"{{.*}}":{32:9-32:9}:"("
- // CHECK: fix-it:"{{.*}}":{32:12-32:12}:")"
+ // CHECK: fix-it:"{{.*}}":{[[line]]:9-[[line]]:9}:"("
+ // CHECK: fix-it:"{{.*}}":{[[line]]:12-[[line]]:12}:")"
ret = !i1 > i2;
//expected-warning@-1 {{logical not is only applied to the left hand side of this comparison}}
// expected-note@-2 {{add parentheses after the '!' to evaluate the comparison first}}
// expected-note@-3 {{add parentheses around left hand side expression to silence this warning}}
+ // CHECK: warn-logical-not-compare.cpp:[[line:[0-9]*]]:9: warning
// CHECK: to evaluate the comparison first
- // CHECK: fix-it:"{{.*}}":{43:10-43:10}:"("
- // CHECK: fix-it:"{{.*}}":{43:17-43:17}:")"
+ // CHECK: fix-it:"{{.*}}":{[[line]]:10-[[line]]:10}:"("
+ // CHECK: fix-it:"{{.*}}":{[[line]]:17-[[line]]:17}:")"
// CHECK: to silence this warning
- // CHECK: fix-it:"{{.*}}":{43:9-43:9}:"("
- // CHECK: fix-it:"{{.*}}":{43:12-43:12}:")"
+ // CHECK: fix-it:"{{.*}}":{[[line]]:9-[[line]]:9}:"("
+ // CHECK: fix-it:"{{.*}}":{[[line]]:12-[[line]]:12}:")"
ret = !i1 <= i2;
//expected-warning@-1 {{logical not is only applied to the left hand side of this comparison}}
// expected-note@-2 {{add parentheses after the '!' to evaluate the comparison first}}
// expected-note@-3 {{add parentheses around left hand side expression to silence this warning}}
+ // CHECK: warn-logical-not-compare.cpp:[[line:[0-9]*]]:9: warning
// CHECK: to evaluate the comparison first
- // CHECK: fix-it:"{{.*}}":{54:10-54:10}:"("
- // CHECK: fix-it:"{{.*}}":{54:18-54:18}:")"
+ // CHECK: fix-it:"{{.*}}":{[[line]]:10-[[line]]:10}:"("
+ // CHECK: fix-it:"{{.*}}":{[[line]]:18-[[line]]:18}:")"
// CHECK: to silence this warning
- // CHECK: fix-it:"{{.*}}":{54:9-54:9}:"("
- // CHECK: fix-it:"{{.*}}":{54:12-54:12}:")"
+ // CHECK: fix-it:"{{.*}}":{[[line]]:9-[[line]]:9}:"("
+ // CHECK: fix-it:"{{.*}}":{[[line]]:12-[[line]]:12}:")"
ret = !i1 >= i2;
//expected-warning@-1 {{logical not is only applied to the left hand side of this comparison}}
// expected-note@-2 {{add parentheses after the '!' to evaluate the comparison first}}
// expected-note@-3 {{add parentheses around left hand side expression to silence this warning}}
+ // CHECK: warn-logical-not-compare.cpp:[[line:[0-9]*]]:9: warning
// CHECK: to evaluate the comparison first
- // CHECK: fix-it:"{{.*}}":{65:10-65:10}:"("
- // CHECK: fix-it:"{{.*}}":{65:18-65:18}:")"
+ // CHECK: fix-it:"{{.*}}":{[[line]]:10-[[line]]:10}:"("
+ // CHECK: fix-it:"{{.*}}":{[[line]]:18-[[line]]:18}:")"
// CHECK: to silence this warning
- // CHECK: fix-it:"{{.*}}":{65:9-65:9}:"("
- // CHECK: fix-it:"{{.*}}":{65:12-65:12}:")"
+ // CHECK: fix-it:"{{.*}}":{[[line]]:9-[[line]]:9}:"("
+ // CHECK: fix-it:"{{.*}}":{[[line]]:12-[[line]]:12}:")"
ret = i1 == i2;
ret = i1 != i2;
@@ -99,12 +105,13 @@ bool test1(int i1, int i2, bool b1, bool b2) {
// expected-warning@-1 {{logical not is only applied to the left hand side of this comparison}}
// expected-note@-2 {{add parentheses after the '!' to evaluate the comparison first}}
// expected-note@-3 {{add parentheses around left hand side expression to silence this warning}}
+ // CHECK: warn-logical-not-compare.cpp:[[line:[0-9]*]]:9: warning
// CHECK: to evaluate the comparison first
- // CHECK: fix-it:"{{.*}}":{98:10-98:10}:"("
- // CHECK: fix-it:"{{.*}}":{98:24-98:24}:")"
+ // CHECK: fix-it:"{{.*}}":{[[line]]:10-[[line]]:10}:"("
+ // CHECK: fix-it:"{{.*}}":{[[line]]:24-[[line]]:24}:")"
// CHECK: to silence this warning
- // CHECK: fix-it:"{{.*}}":{98:9-98:9}:"("
- // CHECK: fix-it:"{{.*}}":{98:18-98:18}:")"
+ // CHECK: fix-it:"{{.*}}":{[[line]]:9-[[line]]:9}:"("
+ // CHECK: fix-it:"{{.*}}":{[[line]]:18-[[line]]:18}:")"
ret = (!getInt()) == i1;
ret = !getBool() == b1;
@@ -125,45 +132,49 @@ bool test2 (E e) {
// expected-warning@-1 {{logical not is only applied to the left hand side of this comparison}}
// expected-note@-2 {{add parentheses after the '!' to evaluate the comparison first}}
// expected-note@-3 {{add parentheses around left hand side expression to silence this warning}}
+ // CHECK: warn-logical-not-compare.cpp:[[line:[0-9]*]]:9: warning
// CHECK: to evaluate the comparison first
- // CHECK: fix-it:"{{.*}}":{124:10-124:10}:"("
- // CHECK: fix-it:"{{.*}}":{124:17-124:17}:")"
+ // CHECK: fix-it:"{{.*}}":{[[line]]:10-[[line]]:10}:"("
+ // CHECK: fix-it:"{{.*}}":{[[line]]:17-[[line]]:17}:")"
// CHECK: to silence this warning
- // CHECK: fix-it:"{{.*}}":{124:9-124:9}:"("
- // CHECK: fix-it:"{{.*}}":{124:11-124:11}:")"
+ // CHECK: fix-it:"{{.*}}":{[[line]]:9-[[line]]:9}:"("
+ // CHECK: fix-it:"{{.*}}":{[[line]]:11-[[line]]:11}:")"
ret = !e == getE();
// expected-warning@-1 {{logical not is only applied to the left hand side of this comparison}}
// expected-note@-2 {{add parentheses after the '!' to evaluate the comparison first}}
// expected-note@-3 {{add parentheses around left hand side expression to silence this warning}}
+ // CHECK: warn-logical-not-compare.cpp:[[line:[0-9]*]]:9: warning
// CHECK: to evaluate the comparison first
- // CHECK: fix-it:"{{.*}}":{135:10-135:10}:"("
- // CHECK: fix-it:"{{.*}}":{135:21-135:21}:")"
+ // CHECK: fix-it:"{{.*}}":{[[line]]:10-[[line]]:10}:"("
+ // CHECK: fix-it:"{{.*}}":{[[line]]:21-[[line]]:21}:")"
// CHECK: to silence this warning
- // CHECK: fix-it:"{{.*}}":{135:9-135:9}:"("
- // CHECK: fix-it:"{{.*}}":{135:11-135:11}:")"
+ // CHECK: fix-it:"{{.*}}":{[[line]]:9-[[line]]:9}:"("
+ // CHECK: fix-it:"{{.*}}":{[[line]]:11-[[line]]:11}:")"
ret = !getE() == e1;
// expected-warning@-1 {{logical not is only applied to the left hand side of this comparison}}
// expected-note@-2 {{add parentheses after the '!' to evaluate the comparison first}}
// expected-note@-3 {{add parentheses around left hand side expression to silence this warning}}
+ // CHECK: warn-logical-not-compare.cpp:[[line:[0-9]*]]:9: warning
// CHECK: to evaluate the comparison first
- // CHECK: fix-it:"{{.*}}":{146:10-146:10}:"("
- // CHECK: fix-it:"{{.*}}":{146:22-146:22}:")"
+ // CHECK: fix-it:"{{.*}}":{[[line]]:10-[[line]]:10}:"("
+ // CHECK: fix-it:"{{.*}}":{[[line]]:22-[[line]]:22}:")"
// CHECK: to silence this warning
- // CHECK: fix-it:"{{.*}}":{146:9-146:9}:"("
- // CHECK: fix-it:"{{.*}}":{146:16-146:16}:")"
+ // CHECK: fix-it:"{{.*}}":{[[line]]:9-[[line]]:9}:"("
+ // CHECK: fix-it:"{{.*}}":{[[line]]:16-[[line]]:16}:")"
ret = !getE() == getE();
// expected-warning@-1 {{logical not is only applied to the left hand side of this comparison}}
// expected-note@-2 {{add parentheses after the '!' to evaluate the comparison first}}
// expected-note@-3 {{add parentheses around left hand side expression to silence this warning}}
+ // CHECK: warn-logical-not-compare.cpp:[[line:[0-9]*]]:9: warning
// CHECK: to evaluate the comparison first
- // CHECK: fix-it:"{{.*}}":{157:10-157:10}:"("
- // CHECK: fix-it:"{{.*}}":{157:26-157:26}:")"
+ // CHECK: fix-it:"{{.*}}":{[[line]]:10-[[line]]:10}:"("
+ // CHECK: fix-it:"{{.*}}":{[[line]]:26-[[line]]:26}:")"
// CHECK: to silence this warning
- // CHECK: fix-it:"{{.*}}":{157:9-157:9}:"("
- // CHECK: fix-it:"{{.*}}":{157:16-157:16}:")"
+ // CHECK: fix-it:"{{.*}}":{[[line]]:9-[[line]]:9}:"("
+ // CHECK: fix-it:"{{.*}}":{[[line]]:16-[[line]]:16}:")"
ret = !(e == e1);
ret = !(e == getE());
@@ -186,6 +197,7 @@ bool PR16673(int x) {
// expected-warning@-1 {{logical not is only applied to the left hand side of this comparison}}
// expected-note@-2 {{add parentheses after the '!' to evaluate the comparison first}}
// expected-note@-3 {{add parentheses around left hand side expression to silence this warning}}
+ // CHECK: warn-logical-not-compare.cpp:[[line:[0-9]*]]:11: warning
// CHECK: to evaluate the comparison first
// CHECK-NOT: fix-it
// CHECK: to silence this warning
diff --git a/test/SemaCXX/warn-pure-virtual-call-from-ctor-dtor.cpp b/test/SemaCXX/warn-pure-virtual-call-from-ctor-dtor.cpp
index ade6198fbd0d..e69a81b77f70 100644
--- a/test/SemaCXX/warn-pure-virtual-call-from-ctor-dtor.cpp
+++ b/test/SemaCXX/warn-pure-virtual-call-from-ctor-dtor.cpp
@@ -1,7 +1,7 @@
// RUN: %clang_cc1 %s -fsyntax-only -verify
struct A {
- A() { f(); } // expected-warning {{call to pure virtual member function 'f'; overrides of 'f' in subclasses are not available in the constructor of 'A'}}
- ~A() { f(); } // expected-warning {{call to pure virtual member function 'f'; overrides of 'f' in subclasses are not available in the destructor of 'A'}}
+ A() { f(); } // expected-warning {{call to pure virtual member function 'f' has undefined behavior; overrides of 'f' in subclasses are not available in the constructor of 'A'}}
+ ~A() { f(); } // expected-warning {{call to pure virtual member function 'f' has undefined behavior; overrides of 'f' in subclasses are not available in the destructor of 'A'}}
virtual void f() = 0; // expected-note 2 {{'f' declared here}}
};
@@ -12,3 +12,11 @@ struct B {
B() { a->f(); };
~B() { a->f(); };
};
+
+// Don't warn if the call is fully qualified. (PR23215)
+struct C {
+ virtual void f() = 0;
+ C() {
+ C::f();
+ }
+};
diff --git a/test/SemaCXX/warn-pure-virtual-kext.cpp b/test/SemaCXX/warn-pure-virtual-kext.cpp
new file mode 100644
index 000000000000..e681a02cc916
--- /dev/null
+++ b/test/SemaCXX/warn-pure-virtual-kext.cpp
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 %s -fapple-kext -fsyntax-only -verify
+
+struct A {
+ virtual void f() = 0; // expected-note {{'f' declared here}}
+ A() {
+ A::f(); // expected-warning {{call to pure virtual member function 'f' has undefined behavior; overrides of 'f' in subclasses are not available in the constructor of 'A'}} // expected-note {{qualified call to 'A'::'f' is treated as a virtual call to 'f' due to -fapple-kext}}
+ }
+};
diff --git a/test/SemaCXX/warn-sign-conversion.cpp b/test/SemaCXX/warn-sign-conversion.cpp
index 746b1242fe1b..dcfb95b6b57d 100644
--- a/test/SemaCXX/warn-sign-conversion.cpp
+++ b/test/SemaCXX/warn-sign-conversion.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -verify -fsyntax-only -Wsign-conversion %s
+// RUN: %clang_cc1 -triple %itanium_abi_triple -verify -fsyntax-only -Wsign-conversion %s
// NOTE: When a 'enumeral mismatch' warning is implemented then expect several
// of the following cases to be impacted.
diff --git a/test/SemaCXX/warn-thread-safety-analysis.cpp b/test/SemaCXX/warn-thread-safety-analysis.cpp
index 4f31d406b5fb..b5d2f8e1de83 100644
--- a/test/SemaCXX/warn-thread-safety-analysis.cpp
+++ b/test/SemaCXX/warn-thread-safety-analysis.cpp
@@ -5091,3 +5091,101 @@ class Foo {
} // end namespace ScopedAdoptTest
+
+namespace TestReferenceNoThreadSafetyAnalysis {
+
+#define TS_UNCHECKED_READ(x) ts_unchecked_read(x)
+
+// Takes a reference to a guarded data member, and returns an unguarded
+// reference.
+template <class T>
+inline const T& ts_unchecked_read(const T& v) NO_THREAD_SAFETY_ANALYSIS {
+ return v;
+}
+
+template <class T>
+inline T& ts_unchecked_read(T& v) NO_THREAD_SAFETY_ANALYSIS {
+ return v;
+}
+
+
+class Foo {
+public:
+ Foo(): a(0) { }
+
+ int a;
+};
+
+
+class Bar {
+public:
+ Bar() : a(0) { }
+
+ Mutex mu;
+ int a GUARDED_BY(mu);
+ Foo foo GUARDED_BY(mu);
+};
+
+
+void test() {
+ Bar bar;
+ const Bar cbar;
+
+ int a = TS_UNCHECKED_READ(bar.a); // nowarn
+ TS_UNCHECKED_READ(bar.a) = 1; // nowarn
+
+ int b = TS_UNCHECKED_READ(bar.foo).a; // nowarn
+ TS_UNCHECKED_READ(bar.foo).a = 1; // nowarn
+
+ int c = TS_UNCHECKED_READ(cbar.a); // nowarn
+}
+
+#undef TS_UNCHECKED_READ
+
+} // end namespace TestReferenceNoThreadSafetyAnalysis
+
+
+namespace GlobalAcquiredBeforeAfterTest {
+
+Mutex mu1;
+Mutex mu2 ACQUIRED_AFTER(mu1);
+
+void test3() {
+ mu2.Lock();
+ mu1.Lock(); // expected-warning {{mutex 'mu1' must be acquired before 'mu2'}}
+ mu1.Unlock();
+ mu2.Unlock();
+}
+
+} // end namespace GlobalAcquiredBeforeAfterTest
+
+
+namespace LockableUnions {
+
+union LOCKABLE MutexUnion {
+ int a;
+ char* b;
+
+ void Lock() EXCLUSIVE_LOCK_FUNCTION();
+ void Unlock() UNLOCK_FUNCTION();
+};
+
+MutexUnion muun2;
+MutexUnion muun1 ACQUIRED_BEFORE(muun2);
+
+void test() {
+ muun2.Lock();
+ muun1.Lock(); // expected-warning {{mutex 'muun1' must be acquired before 'muun2'}}
+ muun1.Unlock();
+ muun2.Unlock();
+}
+
+} // end namespace LockableUnions
+
+// This used to crash.
+class acquired_before_empty_str {
+ void WaitUntilSpaceAvailable() {
+ lock_.ReaderLock(); // expected-note {{acquired here}}
+ } // expected-warning {{mutex 'lock_' is still held at the end of function}}
+ Mutex lock_ ACQUIRED_BEFORE("");
+};
diff --git a/test/SemaCXX/warn-unused-local-typedef-serialize.cpp b/test/SemaCXX/warn-unused-local-typedef-serialize.cpp
index ccb5a09164b4..aa2c48bb5719 100644
--- a/test/SemaCXX/warn-unused-local-typedef-serialize.cpp
+++ b/test/SemaCXX/warn-unused-local-typedef-serialize.cpp
@@ -1,4 +1,3 @@
-// XFAIL: hexagon
// RUN: %clang -x c++-header -c -Wunused-local-typedef %s -o %t.gch -Werror
// RUN: %clang -DBE_THE_SOURCE -c -Wunused-local-typedef -include %t %s -o /dev/null 2>&1 | FileCheck %s
// RUN: %clang -DBE_THE_SOURCE -c -Wunused-local-typedef -include %t %s -o /dev/null 2>&1 | FileCheck %s
diff --git a/test/SemaCXX/writable-strings-deprecated.cpp b/test/SemaCXX/writable-strings-deprecated.cpp
index f9258334980b..7de11b59dd11 100644
--- a/test/SemaCXX/writable-strings-deprecated.cpp
+++ b/test/SemaCXX/writable-strings-deprecated.cpp
@@ -1,25 +1,31 @@
-// RUN: %clang_cc1 -fsyntax-only -Wno-deprecated-writable-strings -verify %s
-// RUN: %clang_cc1 -fsyntax-only -Wno-deprecated -Wdeprecated-increment-bool -verify %s
-// RUN: %clang_cc1 -fsyntax-only -fwritable-strings -verify %s
-// RUN: %clang_cc1 -fsyntax-only -Wno-write-strings -verify %s
-// RUN: %clang_cc1 -fsyntax-only -Werror=c++11-compat -verify %s -DERROR
-// RUN: %clang_cc1 -fsyntax-only -Werror=deprecated -Wno-error=deprecated-increment-bool -verify %s -DERROR
-// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s
-// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s -Wno-deprecated -Wdeprecated-increment-bool
+// RUN: %clang_cc1 -fsyntax-only -verify %s -DWARNING
+// RUN: %clang_cc1 -fsyntax-only -std=c++98 -verify %s -DWARNING
+// RUN: %clang_cc1 -fsyntax-only -std=c++98 -Wno-deprecated-writable-strings -verify %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++98 -Wno-deprecated -Wdeprecated-increment-bool -verify %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++98 -fwritable-strings -verify %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++98 -Wno-write-strings -verify %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++98 -Werror=c++11-compat -verify %s -DERROR
+// RUN: %clang_cc1 -fsyntax-only -std=c++98 -Werror=deprecated -Wno-error=deprecated-increment-bool -verify %s -DERROR
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s -DWARNING
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s -Wno-deprecated -Wdeprecated-increment-bool -DWARNING
// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s -pedantic-errors -DERROR
// rdar://8827606
char *fun(void)
{
return "foo";
+#if defined(ERROR)
#if __cplusplus >= 201103L
-#ifdef ERROR
// expected-error@-3 {{ISO C++11 does not allow conversion from string literal to 'char *'}}
#else
- // expected-warning@-5 {{ISO C++11 does not allow conversion from string literal to 'char *'}}
+ // expected-error@-5 {{conversion from string literal to 'char *' is deprecated}}
+#endif
+#elif defined(WARNING)
+#if __cplusplus >= 201103L
+ // expected-warning@-9 {{ISO C++11 does not allow conversion from string literal to 'char *'}}
+#else
+ // expected-warning@-11 {{conversion from string literal to 'char *' is deprecated}}
#endif
-#elif defined(ERROR)
- // expected-error@-8 {{deprecated}}
#endif
}