-74ac873be1862090b7ec0e4a876fd1b758520359
+ab702e73e56aefb3b77b8f8f42da94bc22143eeb
The first line of this file holds the git revision number of the last
merge done from the dlang/dmd repository.
buf2.reserve(32);
Mangler v(&buf2);
v.paramsToDecoBuffer(t->arguments);
+ const char *s = buf2.peekString();
int len = (int)buf2.offset;
- buf->printf("%d%.*s", len, len, buf2.extractData());
+ buf->printf("%d%.*s", len, len, s);
}
void visit(TypeNull *t)
const char *Scope::search_correct_C(Identifier *ident)
{
TOK tok;
- if (ident == Id::_NULL)
+ if (ident == Id::C_NULL)
tok = TOKnull;
- else if (ident == Id::_TRUE)
+ else if (ident == Id::C_TRUE)
tok = TOKtrue;
- else if (ident == Id::_FALSE)
+ else if (ident == Id::C_FALSE)
tok = TOKfalse;
- else if (ident == Id::_unsigned)
+ else if (ident == Id::C_unsigned)
tok = TOKuns32;
+ else if (ident == Id::C_wchar_t)
+ tok = global.params.isWindows ? TOKwchar : TOKdchar;
else
return NULL;
return Token::toChars(tok);
{ "udaSelector", "selector" },
// C names, for undefined identifier error messages
- { "_NULL", "NULL" },
- { "_TRUE", "TRUE" },
- { "_FALSE", "FALSE" },
- { "_unsigned", "unsigned" },
+ { "C_NULL", "NULL" },
+ { "C_TRUE", "TRUE" },
+ { "C_FALSE", "FALSE" },
+ { "C_unsigned", "unsigned" },
+ { "C_wchar_t", "wchar_t" },
};
p++;
Token n;
scan(&n);
- if (n.value == TOKidentifier && n.ident == Id::line)
+ if (n.value == TOKidentifier)
{
- poundLine();
- continue;
+ if (n.ident == Id::line)
+ {
+ poundLine();
+ continue;
+ }
+ else
+ {
+ const Loc locx = loc();
+ warning(locx, "C preprocessor directive `#%s` is not supported", n.ident->toChars());
+ }
}
- else
+ else if (n.value == TOKif)
{
- t->value = TOKpound;
- return;
+ error("C preprocessor directive `#if` is not supported, use `version` or `static if`");
}
+ t->value = TOKpound;
+ return;
}
default:
case TOKuns16: t = Type::tuns16; goto LabelX;
case TOKint32: t = Type::tint32; goto LabelX;
case TOKuns32: t = Type::tuns32; goto LabelX;
- case TOKint64: t = Type::tint64; goto LabelX;
+ case TOKint64:
+ t = Type::tint64;
+ nextToken();
+ if (token.value == TOKint64) // if `long long`
+ {
+ error("use `long` for a 64 bit integer instead of `long long`");
+ nextToken();
+ }
+ else if (token.value == TOKfloat64) // if `long double`
+ {
+ error("use `real` instead of `long double`");
+ t = Type::tfloat80;
+ nextToken();
+
+ }
+ break;
+
case TOKuns64: t = Type::tuns64; goto LabelX;
case TOKint128: t = Type::tint128; goto LabelX;
case TOKuns128: t = Type::tuns128; goto LabelX;
--- /dev/null
+/* REQUIRED_ARGS: -wi
+TEST_OUTPUT:
+---
+fail_compilation/cerrors.d(11): Error: C preprocessor directive `#if` is not supported, use `version` or `static if`
+fail_compilation/cerrors.d(11): Error: declaration expected, not `#`
+fail_compilation/cerrors.d(15): Warning: C preprocessor directive `#endif` is not supported
+fail_compilation/cerrors.d(15): Error: declaration expected, not `#`
+---
+*/
+
+#if 1
+
+void test(wchar_t u);
+
+#endif
--- /dev/null
+/*
+TEST_OUTPUT:
+---
+fail_compilation/ctypes.d(11): Error: use `real` instead of `long double`
+fail_compilation/ctypes.d(12): Error: use `long` for a 64 bit integer instead of `long long`
+---
+*/
+
+void test()
+{
+ long double r;
+ long long ll;
+}
--- /dev/null
+
+/*
+DISABLED: win32 win64
+TEST_OUTPUT:
+---
+fail_compilation/widechars.d(10): Error: undefined identifier `wchar_t`, did you mean `dchar`?
+---
+*/
+
+wchar_t x;