From a6e155fd9a392285ab37e12777a8c140f913bbc5 Mon Sep 17 00:00:00 2001 From: Valentin Clement Date: Mon, 22 Aug 2022 11:12:20 +0200 Subject: [PATCH] [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 --- flang/module/__fortran_builtins.f90 | 2 +- flang/test/Semantics/bind-c07.f90 | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 flang/test/Semantics/bind-c07.f90 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 @@ module __Fortran_builtins 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