Backports fix from upstream to allow __FUNCTION__ and
__PRETTY_FUNCTION__ to be used as C string literals.
Reviewed-on: https://github.com/dlang/dmd/pull/12923
PR d/101441
gcc/d/ChangeLog:
* dmd/expression.c (FuncInitExp::resolveLoc): Set type as `string'.
(PrettyFuncInitExp::resolveLoc): Likewise.
gcc/testsuite/ChangeLog:
* gdc.test/compilable/b19002.d: New test.
(cherry picked from commit
1a2306ffe79df89389cc850ce85c586d0f1c8264)
s = "";
Expression *e = new StringExp(loc, const_cast<char *>(s));
e = expressionSemantic(e, sc);
- e = e->castTo(sc, type);
+ e->type = Type::tstring;
return e;
}
Expression *e = new StringExp(loc, const_cast<char *>(s));
e = expressionSemantic(e, sc);
- e = e->castTo(sc, type);
+ e->type = Type::tstring;
return e;
}
--- /dev/null
+module b19002;
+
+void printf(scope const char* format){}
+
+void main()
+{
+ printf(__FILE__);
+ printf(__FILE_FULL_PATH__);
+ printf(__FUNCTION__);
+ printf(__PRETTY_FUNCTION__);
+ printf(__MODULE__);
+}