diff options
Diffstat (limited to 'clang/test/AST/ByteCode')
-rw-r--r-- | clang/test/AST/ByteCode/builtin-functions.cpp | 13 | ||||
-rw-r--r-- | clang/test/AST/ByteCode/c.c | 9 | ||||
-rw-r--r-- | clang/test/AST/ByteCode/cxx14.cpp | 9 | ||||
-rw-r--r-- | clang/test/AST/ByteCode/extern.cpp | 6 |
4 files changed, 35 insertions, 2 deletions
diff --git a/clang/test/AST/ByteCode/builtin-functions.cpp b/clang/test/AST/ByteCode/builtin-functions.cpp index f47bc49..0b7d51b 100644 --- a/clang/test/AST/ByteCode/builtin-functions.cpp +++ b/clang/test/AST/ByteCode/builtin-functions.cpp @@ -63,6 +63,19 @@ constexpr int test_address_of_incomplete_array_type() { // both-error {{never pr static_assert(test_address_of_incomplete_array_type() == 1234, ""); // both-error {{constant}} \ // both-note {{in call}} +namespace LocalExternRedecl { + constexpr int externRedecl1() { + extern int arr[]; + return 0; + } + constexpr int externRedecl2() { // both-error {{never produces a constant expression}} + extern int arr[]; + __builtin_memmove(&arr, &arr, 4 * sizeof(arr[0])); // both-note 2{{incomplete type}} + return 1234; + } + static_assert(externRedecl2() == 1234); // both-error {{not an integral constant expression}} \ + // both-note {{in call to}} +} struct NonTrivial { constexpr NonTrivial() : n(0) {} diff --git a/clang/test/AST/ByteCode/c.c b/clang/test/AST/ByteCode/c.c index 657a920..cfdc9d0 100644 --- a/clang/test/AST/ByteCode/c.c +++ b/clang/test/AST/ByteCode/c.c @@ -372,3 +372,12 @@ void discardedCmp(void) /// ArraySubscriptExpr that's not an lvalue typedef unsigned char U __attribute__((vector_size(1))); void nonLValueASE(U f) { f[0] = f[((U)(U){0})[0]]; } + +static char foo_(a) // all-warning {{definition without a prototype}} + char a; +{ + return 'a'; +} +static void bar_(void) { + foo_(foo_(1)); +} diff --git a/clang/test/AST/ByteCode/cxx14.cpp b/clang/test/AST/ByteCode/cxx14.cpp new file mode 100644 index 0000000..9622311 --- /dev/null +++ b/clang/test/AST/ByteCode/cxx14.cpp @@ -0,0 +1,9 @@ +// RUN: %clang_cc1 -std=c++14 -verify=both,expected %s -fexperimental-new-constant-interpreter +// RUN: %clang_cc1 -std=c++14 -verify=both,ref %s + + + +constexpr int(*null_ptr)() = nullptr; +constexpr int test4 = (*null_ptr)(); // both-error {{must be initialized by a constant expression}} \ + // both-note {{evaluates to a null function pointer}} + diff --git a/clang/test/AST/ByteCode/extern.cpp b/clang/test/AST/ByteCode/extern.cpp index a616269..c321593 100644 --- a/clang/test/AST/ByteCode/extern.cpp +++ b/clang/test/AST/ByteCode/extern.cpp @@ -1,9 +1,11 @@ // RUN: %clang_cc1 -fexperimental-new-constant-interpreter -verify=both,expected %s -// RUN: %clang_cc1 -verify=both,ref %s - +// RUN: %clang_cc1 -verify=both,ref %s // both-no-diagnostics +extern const double Num; +extern const double Num = 12; + extern const int E; constexpr int getE() { return E; |