Skip to content

Commit

Permalink
Enums were treated as their underlying type while reading.
Browse files Browse the repository at this point in the history
  • Loading branch information
h0nzZik committed Apr 6, 2017
1 parent 91161bd commit ea0aeb2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
4 changes: 3 additions & 1 deletion semantics/cpp14/language/common/memory/reading.k
Expand Up @@ -52,6 +52,8 @@ module CPP-MEMORY-READING
rule interpret(prv(0, Tr::Trace, T:CPPNullPtrTType)) => prv(nullptrVal, Tr, T)
rule interpret(prv(0, Tr::Trace, T:CPPPointerType)) => prv(NullPointer, Tr, T)

rule interpret(prv(I:Int, Tr::Trace, T:CPPEnumType)) => #fun(prv(I::Int, Tr::Trace, (T => T)))(interpret(prv(I, Tr, underlyingType(T))))
syntax PRVal ::= interpretEnum(PRVal, CPPEnumType)
rule interpret(prv(I:Int, Tr::Trace, T:CPPEnumType)) => interpretEnum(interpret(prv(I, Tr, underlyingType(T))), T)
rule interpretEnum(prv(I:Int, Tr::Trace, T:CPPIntegerType), E:CPPEnumType) => prv(I, Tr, E)

endmodule
10 changes: 10 additions & 0 deletions tests/unit-pass/enum-copy-initialize.C
@@ -0,0 +1,10 @@
enum class E { Val = 7 };
enum F { F_Val = 8 };

int main() {
E e1 = E::Val;
E e2 = e1;

F f1 = F_Val;
F f2 = f1;
}

0 comments on commit ea0aeb2

Please sign in to comment.