]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
* gcc-interface/decl.c (is_cplusplus_method): Check that the type of
authorebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 24 Nov 2015 08:42:37 +0000 (08:42 +0000)
committerebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 24 Nov 2015 08:42:37 +0000 (08:42 +0000)
the first parameter (indirectly) has C++ convention too.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@230788 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ada/ChangeLog
gcc/ada/gcc-interface/decl.c

index 2b552a24a2087a2b4620c93f72c77511201e6ea2..65cc3da8e4b0a9c69552b38ceab5d88a4838b902 100644 (file)
@@ -1,3 +1,8 @@
+2015-11-24  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * gcc-interface/decl.c (is_cplusplus_method): Check that the type of
+       the first parameter (indirectly) has C++ convention too.
+
 2015-11-23  Olivier Hainque  <hainque@adacore.com>
 
        * system-aix.ads: Add Frontend_Exceptions flag.
index e3284378aaf51b4fee76d5262f675ba1d5d7bc70..9994c679a40a66ef9237b9a1c04de78c4bd8ebc8 100644 (file)
@@ -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;