Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion clang/lib/AST/ByteCode/Compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4872,7 +4872,7 @@ Compiler<Emitter>::visitVarDecl(const VarDecl *VD, const Expr *Init,

// The previous attempt at initialization might've been unsuccessful,
// so let's try this one.
return Init && checkDecl() && initGlobal(*GlobalIndex);
return !Init || (checkDecl() && initGlobal(*GlobalIndex));
}

UnsignedOrNone GlobalIndex = P.createGlobal(VD, Init);
Expand Down
13 changes: 13 additions & 0 deletions clang/test/AST/ByteCode/builtin-functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {}
Expand Down