[flang-commits] [flang] a6e155f - [flang] Add bind(C) to buitlin C_PTR

Valentin Clement via flang-commits flang-commits at lists.llvm.org
Mon Aug 22 02:13:05 PDT 2022


Author: Valentin Clement
Date: 2022-08-22T11:12:37+02:00
New Revision: a6e155fd9a392285ab37e12777a8c140f913bbc5

URL: https://github.com/llvm/llvm-project/commit/a6e155fd9a392285ab37e12777a8c140f913bbc5
DIFF: https://github.com/llvm/llvm-project/commit/a6e155fd9a392285ab37e12777a8c140f913bbc5.diff

LOG: [flang] Add bind(C) to buitlin C_PTR

D131585 Adds couple of semantics check for the components of BIND(C)
derived-type. This would raise an error when a component is of C_PTR
type. Add `bind(c)` to the `__builtin_c_ptr` type so the wrong error
is not triggered.

Reviewed By: peixin, jeanPerier

Differential Revision: https://reviews.llvm.org/D132350

Added: 
    flang/test/Semantics/bind-c07.f90

Modified: 
    flang/module/__fortran_builtins.f90

Removed: 
    


################################################################################
diff  --git a/flang/module/__fortran_builtins.f90 b/flang/module/__fortran_builtins.f90
index 19184c824488..487041ae2bc6 100644
--- a/flang/module/__fortran_builtins.f90
+++ b/flang/module/__fortran_builtins.f90
@@ -19,7 +19,7 @@
   private :: selected_int_kind
   integer, parameter, private :: int64 = selected_int_kind(18)
 
-  type :: __builtin_c_ptr
+  type, bind(c) :: __builtin_c_ptr
     integer(kind=int64) :: __address
   end type
 

diff  --git a/flang/test/Semantics/bind-c07.f90 b/flang/test/Semantics/bind-c07.f90
new file mode 100644
index 000000000000..ee39f5e3fd00
--- /dev/null
+++ b/flang/test/Semantics/bind-c07.f90
@@ -0,0 +1,11 @@
+! RUN: bbc -emit-fir -o - %s | FileCheck %s
+
+module bind_c_type
+  use, intrinsic :: iso_c_binding
+
+  type, bind(C) :: t
+    type(c_ptr) :: tcptr = C_NULL_PTR
+  end type
+end module
+
+! CHECK-LABEL: _QMbind_c_typeE.di.t.tcptr


        


More information about the flang-commits mailing list