Skip to content

Commit 3c67c22

Browse files
committed
[clang][Interp] Test non-active union access
1 parent 5b20595 commit 3c67c22

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

clang/lib/AST/Interp/Interp.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -457,10 +457,10 @@ bool CheckLoad(InterpState &S, CodePtr OpPC, const Pointer &Ptr) {
457457
return false;
458458
if (!CheckRange(S, OpPC, Ptr, AK_Read))
459459
return false;
460-
if (!CheckInitialized(S, OpPC, Ptr, AK_Read))
461-
return false;
462460
if (!CheckActive(S, OpPC, Ptr, AK_Read))
463461
return false;
462+
if (!CheckInitialized(S, OpPC, Ptr, AK_Read))
463+
return false;
464464
if (!CheckTemporary(S, OpPC, Ptr, AK_Read))
465465
return false;
466466
if (!CheckMutable(S, OpPC, Ptr))

clang/test/AST/Interp/unions.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
// RUN: %clang_cc1 -fexperimental-new-constant-interpreter -verify=expected,both %s
22
// RUN: %clang_cc1 -verify=ref,both %s
33

4-
// both-no-diagnostics
5-
64
union U {
75
int a;
86
int b;
97
};
108

119
constexpr U a = {12};
1210
static_assert(a.a == 12, "");
13-
14-
11+
static_assert(a.b == 0, ""); // both-error {{not an integral constant expression}} \
12+
// both-note {{read of member 'b' of union with active member 'a'}}

0 commit comments

Comments
 (0)