aboutsummaryrefslogtreecommitdiff
path: root/clang/test/AST/ByteCode
diff options
context:
space:
mode:
Diffstat (limited to 'clang/test/AST/ByteCode')
-rw-r--r--clang/test/AST/ByteCode/builtin-functions.cpp7
-rw-r--r--clang/test/AST/ByteCode/c.c6
-rw-r--r--clang/test/AST/ByteCode/codegen-cxx20.cpp15
-rw-r--r--clang/test/AST/ByteCode/cxx11.cpp9
-rw-r--r--clang/test/AST/ByteCode/records.cpp21
-rw-r--r--clang/test/AST/ByteCode/unions.cpp9
6 files changed, 67 insertions, 0 deletions
diff --git a/clang/test/AST/ByteCode/builtin-functions.cpp b/clang/test/AST/ByteCode/builtin-functions.cpp
index 0b7d51b..e9093b2 100644
--- a/clang/test/AST/ByteCode/builtin-functions.cpp
+++ b/clang/test/AST/ByteCode/builtin-functions.cpp
@@ -1510,6 +1510,8 @@ namespace Memcmp {
static_assert(f());
#endif
+ int unknown;
+ void foo(void) { unknown *= __builtin_memcmp(0, 0, 2); }
}
namespace Memchr {
@@ -1853,3 +1855,8 @@ namespace InitParam {
}
#endif
+
+namespace SAddOverflowInt {
+ int a;
+ void foo(void) { a *= __builtin_sadd_overflow(1, 2, 0); }
+}
diff --git a/clang/test/AST/ByteCode/c.c b/clang/test/AST/ByteCode/c.c
index cfdc9d0..3360d4f 100644
--- a/clang/test/AST/ByteCode/c.c
+++ b/clang/test/AST/ByteCode/c.c
@@ -381,3 +381,9 @@ static char foo_(a) // all-warning {{definition without a prototype}}
static void bar_(void) {
foo_(foo_(1));
}
+
+void foo2(void*);
+void bar2(void) {
+ int a[2][3][4][5]; // all-note {{array 'a' declared here}}
+ foo2(&a[0][4]); // all-warning {{array index 4 is past the end of the array}}
+}
diff --git a/clang/test/AST/ByteCode/codegen-cxx20.cpp b/clang/test/AST/ByteCode/codegen-cxx20.cpp
new file mode 100644
index 0000000..c1ef629
--- /dev/null
+++ b/clang/test/AST/ByteCode/codegen-cxx20.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -triple x86_64-linux -emit-llvm -o - %s -fcxx-exceptions | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-linux -emit-llvm -o - %s -fcxx-exceptions -fexperimental-new-constant-interpreter | FileCheck %s
+
+
+/// The read from a used to succeed, causing the entire if statement to vanish.
+extern void e();
+int somefunc() {
+ auto foo = [a = false]() mutable {
+ if (a)
+ e();
+ };
+ foo();
+}
+
+// CHECK: call void @_Z1ev()
diff --git a/clang/test/AST/ByteCode/cxx11.cpp b/clang/test/AST/ByteCode/cxx11.cpp
index 8efd320..427d3a1 100644
--- a/clang/test/AST/ByteCode/cxx11.cpp
+++ b/clang/test/AST/ByteCode/cxx11.cpp
@@ -370,3 +370,12 @@ namespace GH150709 {
static_assert((e2[0].*mp)() == 1, ""); // ref-error {{constant expression}}
static_assert((g.*mp)() == 1, ""); // ref-error {{constant expression}}
}
+
+namespace DiscardedAddrLabel {
+ void foo(void) {
+ L:
+ *&&L; // both-error {{indirection not permitted}} \
+ // both-warning {{expression result unused}}
+ }
+}
+
diff --git a/clang/test/AST/ByteCode/records.cpp b/clang/test/AST/ByteCode/records.cpp
index 00218ba..83f32c9 100644
--- a/clang/test/AST/ByteCode/records.cpp
+++ b/clang/test/AST/ByteCode/records.cpp
@@ -1861,3 +1861,24 @@ namespace PrimitiveInitializedByInitList {
} c{ 17 };
static_assert(c.b == 17, "");
}
+
+namespace MethodWillHaveBody {
+ class A {
+ public:
+ static constexpr int get_value2() { return 1 + get_value(); }
+ static constexpr int get_value() { return 1; }
+ };
+ static_assert(A::get_value2() == 2, "");
+
+ template<typename T> constexpr T f(T);
+ template<typename T> constexpr T g(T t) {
+ typedef int arr[f(T())]; // both-warning {{variable length array}} \
+ // both-note {{undefined function 'f<int>'}}
+ return t;
+ }
+ template<typename T> constexpr T f(T t) { // both-note {{declared here}}
+ typedef int arr[g(T())]; // both-note {{instantiation of}}
+ return t;
+ }
+ int n = f(0); // both-note {{instantiation of}}
+}
diff --git a/clang/test/AST/ByteCode/unions.cpp b/clang/test/AST/ByteCode/unions.cpp
index 6bccbda..4140704 100644
--- a/clang/test/AST/ByteCode/unions.cpp
+++ b/clang/test/AST/ByteCode/unions.cpp
@@ -977,4 +977,13 @@ namespace UnionMemberOnePastEnd {
}
static_assert(!b());
}
+
+namespace ActicvateInvalidPtr {
+ constexpr void bar() { // both-error {{never produces a constant expression}}
+ union {
+ int a[1];
+ } foo;
+ foo.a[1] = 0; // both-note {{assignment to dereferenced one-past-the-end pointer}}
+ }
+}
#endif