public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Iain Buclaw <ibuclaw@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r9-9649] d: __FUNCTION__ doesn't work in core.stdc.stdio functions without cast (PR101441) Date: Wed, 28 Jul 2021 11:57:42 +0000 (GMT) [thread overview] Message-ID: <20210728115742.AE52D3861010@sourceware.org> (raw) https://gcc.gnu.org/g:d835fea487ad8c9526a8088cbe83bf425f5c3e6b commit r9-9649-gd835fea487ad8c9526a8088cbe83bf425f5c3e6b 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 4798409edb9..e59c5b114dd 100644 --- a/gcc/d/dmd/expression.c +++ b/gcc/d/dmd/expression.c @@ -6717,7 +6717,7 @@ Expression *FuncInitExp::resolveLoc(Loc loc, Scope *sc) s = ""; Expression *e = new StringExp(loc, const_cast<char *>(s)); e = semantic(e, sc); - e = e->castTo(sc, type); + e->type = Type::tstring; return e; } @@ -6751,7 +6751,7 @@ Expression *PrettyFuncInitExp::resolveLoc(Loc loc, Scope *sc) Expression *e = new StringExp(loc, const_cast<char *>(s)); e = semantic(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__); +}
reply other threads:[~2021-07-28 11:57 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20210728115742.AE52D3861010@sourceware.org \ --to=ibuclaw@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).