public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r11-8808] d: __FUNCTION__ doesn't work in core.stdc.stdio functions without cast (PR101441)
@ 2021-07-28 11:36 Iain Buclaw
0 siblings, 0 replies; only message in thread
From: Iain Buclaw @ 2021-07-28 11:36 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:9075f62ddc3b9ffdb9e1b28d472adfd7fef4a0f1
commit r11-8808-g9075f62ddc3b9ffdb9e1b28d472adfd7fef4a0f1
Author: Iain Buclaw <ibuclaw@gdcproject.org>
Date: Mon Jul 26 15:24:12 2021 +0200
d: __FUNCTION__ doesn't work in core.stdc.stdio functions without cast (PR101441)
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)
Diff:
---
gcc/d/dmd/expression.c | 4 ++--
gcc/testsuite/gdc.test/compilable/b19002.d | 12 ++++++++++++
2 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/gcc/d/dmd/expression.c b/gcc/d/dmd/expression.c
index 7166f972424..18aa6aa9ab4 100644
--- a/gcc/d/dmd/expression.c
+++ b/gcc/d/dmd/expression.c
@@ -5620,7 +5620,7 @@ Expression *FuncInitExp::resolveLoc(Loc loc, Scope *sc)
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;
}
@@ -5654,7 +5654,7 @@ Expression *PrettyFuncInitExp::resolveLoc(Loc loc, Scope *sc)
Expression *e = new StringExp(loc, const_cast<char *>(s));
e = expressionSemantic(e, sc);
- e = e->castTo(sc, type);
+ e->type = Type::tstring;
return e;
}
diff --git a/gcc/testsuite/gdc.test/compilable/b19002.d b/gcc/testsuite/gdc.test/compilable/b19002.d
new file mode 100644
index 00000000000..fd8e6d18b37
--- /dev/null
+++ b/gcc/testsuite/gdc.test/compilable/b19002.d
@@ -0,0 +1,12 @@
+module b19002;
+
+void printf(scope const char* format){}
+
+void main()
+{
+ printf(__FILE__);
+ printf(__FILE_FULL_PATH__);
+ printf(__FUNCTION__);
+ printf(__PRETTY_FUNCTION__);
+ printf(__MODULE__);
+}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-07-28 11:36 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-28 11:36 [gcc r11-8808] d: __FUNCTION__ doesn't work in core.stdc.stdio functions without cast (PR101441) Iain Buclaw
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).