Skip to content

Commit

Permalink
Fix Issue 19658 - MSVC++ enum mangling
Browse files Browse the repository at this point in the history
  • Loading branch information
kinke committed Apr 12, 2019
1 parent 077d345 commit 6bb9f3b
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 32 deletions.
33 changes: 1 addition & 32 deletions src/dmd/cppmanglewin.d
Expand Up @@ -439,38 +439,7 @@ public:
if (checkTypeSaved(type))
return;
mangleModifier(type);
buf.writeByte('W');
switch (type.sym.memtype.ty)
{
case Tchar:
case Tint8:
buf.writeByte('0');
break;
case Tuns8:
buf.writeByte('1');
break;
case Tint16:
buf.writeByte('2');
break;
case Tuns16:
buf.writeByte('3');
break;
case Tint32:
buf.writeByte('4');
break;
case Tuns32:
buf.writeByte('5');
break;
case Tint64:
buf.writeByte('6');
break;
case Tuns64:
buf.writeByte('7');
break;
default:
visit(cast(Type)type);
break;
}
buf.writestring("W4");
mangleIdent(type.sym);
}
flags &= ~IS_NOT_TOP_TYPE;
Expand Down
38 changes: 38 additions & 0 deletions test/runnable/cpp11.d
Expand Up @@ -5,6 +5,8 @@

// Disabled on win32 because the compiler is too old

import core.stdc.stdint;

/****************************************/
alias nullptr_t = typeof(null);

Expand All @@ -28,7 +30,43 @@ else
}
}

/****************************************/
// https://issues.dlang.org/show_bug.cgi?id=19658

enum i8_19658 : int8_t { a };
enum u8_19658 : uint8_t { a };
enum i16_19658 : int16_t { a };
enum u16_19658 : uint16_t { a };
enum i32_19658 : int32_t { a };
enum u32_19658 : uint32_t { a };
enum i64_19658 : int64_t { a };
enum u64_19658 : uint64_t { a };

extern(C++) void test19658_i8(i8_19658);
extern(C++) void test19658_u8(u8_19658);
extern(C++) void test19658_i16(i16_19658);
extern(C++) void test19658_u16(u16_19658);
extern(C++) void test19658_i32(i32_19658);
extern(C++) void test19658_u32(u32_19658);
extern(C++) void test19658_i64(i64_19658);
extern(C++) void test19658_u64(u64_19658);

void test19658()
{
test19658_i8(i8_19658.a);
test19658_u8(u8_19658.a);
test19658_i16(i16_19658.a);
test19658_u16(u16_19658.a);
test19658_i32(i32_19658.a);
test19658_u32(u32_19658.a);
test19658_i64(i64_19658.a);
test19658_u64(u64_19658.a);
}

/****************************************/

void main()
{
test17();
test19658();
}
22 changes: 22 additions & 0 deletions test/runnable/extra-files/cpp11.cpp
@@ -1,5 +1,6 @@
#include <assert.h>
#include <cstddef>
#include <cstdint>

void testnull(std::nullptr_t n)
{
Expand All @@ -11,3 +12,24 @@ void testnullnull(std::nullptr_t n1, std::nullptr_t n2)
assert(n1 == nullptr);
assert(n2 == nullptr);
}

/****************************************/
// https://issues.dlang.org/show_bug.cgi?id=19658

enum class i8_19658 : std::int8_t;
enum class u8_19658 : std::uint8_t;
enum class i16_19658 : std::int16_t;
enum class u16_19658 : std::uint16_t;
enum class i32_19658 : std::int32_t;
enum class u32_19658 : std::uint32_t;
enum class i64_19658 : std::int64_t;
enum class u64_19658 : std::uint64_t;

void test19658_i8(i8_19658) {}
void test19658_u8(u8_19658) {}
void test19658_i16(i16_19658) {}
void test19658_u16(u16_19658) {}
void test19658_i32(i32_19658) {}
void test19658_u32(u32_19658) {}
void test19658_i64(i64_19658) {}
void test19658_u64(u64_19658) {}

0 comments on commit 6bb9f3b

Please sign in to comment.