aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/gcc-interface/decl.c
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2015-11-24 08:42:37 +0000
committerEric Botcazou <ebotcazou@gcc.gnu.org>2015-11-24 08:42:37 +0000
commiteae6758d2b3d30b4f431b063ba98183fdac344a6 (patch)
treeb4dbfa6c163d20f36f8325484ea23a7c647eda62 /gcc/ada/gcc-interface/decl.c
parent7d906d07ed736abc854db2e770d5e5e07730581c (diff)
downloadgcc-eae6758d2b3d30b4f431b063ba98183fdac344a6.zip
gcc-eae6758d2b3d30b4f431b063ba98183fdac344a6.tar.gz
gcc-eae6758d2b3d30b4f431b063ba98183fdac344a6.tar.bz2
decl.c (is_cplusplus_method): Check that the type of the first parameter (indirectly) has C++ convention too.
* gcc-interface/decl.c (is_cplusplus_method): Check that the type of the first parameter (indirectly) has C++ convention too. From-SVN: r230788
Diffstat (limited to 'gcc/ada/gcc-interface/decl.c')
-rw-r--r--gcc/ada/gcc-interface/decl.c23
1 files changed, 19 insertions, 4 deletions
diff --git a/gcc/ada/gcc-interface/decl.c b/gcc/ada/gcc-interface/decl.c
index e328437..9994c67 100644
--- a/gcc/ada/gcc-interface/decl.c
+++ b/gcc/ada/gcc-interface/decl.c
@@ -5403,9 +5403,28 @@ get_minimal_subprog_decl (Entity_Id gnat_entity)
bool
is_cplusplus_method (Entity_Id gnat_entity)
{
+ /* Check that the subprogram has C++ convention. */
if (Convention (gnat_entity) != Convention_CPP)
return false;
+ /* A constructor is a method on the C++ side. We deal with it now because
+ it is declared without the 'this' parameter in the sources and, although
+ the front-end will create a version with the 'this' parameter for code
+ generation purposes, we want to return true for both versions. */
+ if (Is_Constructor (gnat_entity))
+ return true;
+
+ /* And that the type of the first parameter (indirectly) has it too. */
+ Entity_Id gnat_first = First_Formal (gnat_entity);
+ if (No (gnat_first))
+ return false;
+
+ Entity_Id gnat_type = Etype (gnat_first);
+ if (Is_Access_Type (gnat_type))
+ gnat_type = Directly_Designated_Type (gnat_type);
+ if (Convention (gnat_type) != Convention_CPP)
+ return false;
+
/* This is the main case: C++ method imported as a primitive operation.
Note that a C++ class with no virtual functions can be imported as a
limited record type so the operation is not necessarily dispatching. */
@@ -5416,10 +5435,6 @@ is_cplusplus_method (Entity_Id gnat_entity)
if (Is_Subprogram (gnat_entity) && Is_Thunk (gnat_entity))
return true;
- /* A constructor is a method on the C++ side. */
- if (Is_Constructor (gnat_entity))
- return true;
-
/* This is set on the E_Subprogram_Type built for a dispatching call. */
if (Is_Dispatch_Table_Entity (gnat_entity))
return true;