aboutsummaryrefslogtreecommitdiff
path: root/gcc/d/dmd/cppmangle.c
diff options
context:
space:
mode:
authorIain Buclaw <ibuclaw@gdcproject.org>2019-03-12 13:29:16 +0000
committerIain Buclaw <ibuclaw@gcc.gnu.org>2019-03-12 13:29:16 +0000
commitc9634470ba8b918c01a7680740cf9ea13ca06967 (patch)
tree279986d79aff26484061e545bce82c387b8edb0a /gcc/d/dmd/cppmangle.c
parentdf2a91dece0ac6e410e3cf48b39cba8c3744c5f3 (diff)
downloadgcc-c9634470ba8b918c01a7680740cf9ea13ca06967.zip
gcc-c9634470ba8b918c01a7680740cf9ea13ca06967.tar.gz
gcc-c9634470ba8b918c01a7680740cf9ea13ca06967.tar.bz2
d/dmd: Merge upstream dmd 7423993c9
Fixes C++ mangling for substituted basic types that are target-specific. Introduces a new method that currently does nothing, but could in future make use of flag_abi_version as extern(C++) integration improves in latter versions of the D front-end. Reviewed-on: https://github.com/dlang/dmd/pull/9439 gcc/d/ChangeLog: 2019-03-12 Iain Buclaw <ibuclaw@gdcproject.org> * d-lang.cc (d_init_options): Set global.params.cplusplus to C++14. * d-target.cc (Target::cppFundamentalType): New method. From-SVN: r269611
Diffstat (limited to 'gcc/d/dmd/cppmangle.c')
-rw-r--r--gcc/d/dmd/cppmangle.c64
1 files changed, 52 insertions, 12 deletions
diff --git a/gcc/d/dmd/cppmangle.c b/gcc/d/dmd/cppmangle.c
index b991417..9b24fd2 100644
--- a/gcc/d/dmd/cppmangle.c
+++ b/gcc/d/dmd/cppmangle.c
@@ -120,6 +120,40 @@ class CppMangleVisitor : public Visitor
!getQualifier(s)); // at global level
}
+ /************************
+ * Determine if type is a C++ fundamental type.
+ * Params:
+ * t = type to check
+ * Returns:
+ * true if it is a fundamental type
+ */
+ static bool isFundamentalType(Type *t)
+ {
+ // First check the target whether some specific ABI is being followed.
+ bool isFundamental;
+ if (Target::cppFundamentalType(t, isFundamental))
+ return isFundamental;
+ if (t->ty == Tenum)
+ {
+ // Peel off enum type from special types.
+ TypeEnum *te = (TypeEnum *)t;
+ if (te->sym->isSpecial())
+ t = te->sym->getMemtype(Loc());
+ }
+
+ // Fundamental arithmetic types:
+ // 1. integral types: bool, char, int, ...
+ // 2. floating point types: float, double, real
+ // 3. void
+ // 4. null pointer: std::nullptr_t (since C++11)
+ if (t->ty == Tvoid || t->ty == Tbool)
+ return true;
+ else if (t->ty == Tnull && global.params.cplusplus >= CppStdRevisionCpp11)
+ return true;
+ else
+ return t->isTypeBasic() && (t->isintegral() || t->isreal());
+ }
+
/******************************
* Write the mangled representation of the template arguments.
* Params:
@@ -741,7 +775,8 @@ public:
*/
void writeBasicType(Type *t, char p, char c)
{
- if (p || t->isConst())
+ // Only do substitutions for non-fundamental types.
+ if (!isFundamentalType(t) || t->isConst())
{
if (substitute(t))
return;
@@ -767,6 +802,22 @@ public:
if (t->isImmutable() || t->isShared())
return error(t);
+ // Handle any target-specific basic types.
+ if (const char *tm = Target::cppTypeMangle(t))
+ {
+ // Only do substitutions for non-fundamental types.
+ if (!isFundamentalType(t) || t->isConst())
+ {
+ if (substitute(t))
+ return;
+ else
+ append(t);
+ }
+ CV_qualifiers(t);
+ buf->writestring(tm);
+ return;
+ }
+
/* <builtin-type>:
* v void
* w wchar_t
@@ -832,17 +883,6 @@ public:
case Tcomplex80: p = 'C'; c = 'e'; break;
default:
- // Handle any target-specific basic types.
- if (const char *tm = Target::cppTypeMangle(t))
- {
- if (substitute(t))
- return;
- else
- append(t);
- CV_qualifiers(t);
- buf->writestring(tm);
- return;
- }
return error(t);
}
writeBasicType(t, p, c);