Hi,
This patch backports a fix from upstream to allow __FUNCTION__ and
__PRETTY_FUNCTION__ to be used as C string literals.
Bootstrapped and regression tested on x86_64-linux-gnu/-m32/-mx32.
Committed to mainline, and backported to the gcc-9, gcc-10, and gcc-11
release branches.
Regards,
Iain.
---
gcc/d/ChangeLog:
PR d/101441
* dmd/MERGE: Merge upstream dmd f8c1ca928.
---
gcc/d/dmd/MERGE | 2 +-
gcc/d/dmd/expression.c | 4 ++--
gcc/testsuite/gdc.test/compilable/b19002.d | 12 ++++++++++++
3 files changed, 15 insertions(+), 3 deletions(-)
create mode 100644 gcc/testsuite/gdc.test/compilable/b19002.d
diff --git a/gcc/d/dmd/MERGE b/gcc/d/dmd/MERGE
index 127f9f8aa86..08bd50df212 100644
--- a/gcc/d/dmd/MERGE
+++ b/gcc/d/dmd/MERGE
@@ -1,4 +1,4 @@
-1d8386a63d412c9e77728b0b965025ac4dd40b75
+f8c1ca928360dd8c9f2fbb5771e2a5e398878ca0
The first line of this file holds the git revision number of the last
merge done from the dlang/dmd repository.
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__);
+}
--
2.30.2