From f1bc6414556c6526a6560be45066ffe77c8815a7 Mon Sep 17 00:00:00 2001 From: Eric Botcazou Date: Sat, 10 Mar 2018 10:11:29 +0000 Subject: [PATCH] trans.c (node_has_volatile_full_access): Consider only entities for objects. * gcc-interface/trans.c (node_has_volatile_full_access) : Consider only entities for objects. From-SVN: r258412 --- gcc/ada/ChangeLog | 5 +++++ gcc/ada/gcc-interface/trans.c | 2 ++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gnat.dg/prot3.adb | 8 ++++++++ gcc/testsuite/gnat.dg/prot3_pkg.adb | 17 +++++++++++++++++ gcc/testsuite/gnat.dg/prot3_pkg.ads | 16 ++++++++++++++++ 6 files changed, 53 insertions(+) create mode 100644 gcc/testsuite/gnat.dg/prot3.adb create mode 100644 gcc/testsuite/gnat.dg/prot3_pkg.adb create mode 100644 gcc/testsuite/gnat.dg/prot3_pkg.ads diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 56afab01ff5..5dabc1537ea 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,8 @@ +2018-03-10 Eric Botcazou + + * gcc-interface/trans.c (node_has_volatile_full_access) : + Consider only entities for objects. + 2018-03-07 Sebastian Huber * gcc-interface/Makefile.in (OSCONS_CPP): Remove redundant diff --git a/gcc/ada/gcc-interface/trans.c b/gcc/ada/gcc-interface/trans.c index ac80a3e0e8e..fbdced57a0a 100644 --- a/gcc/ada/gcc-interface/trans.c +++ b/gcc/ada/gcc-interface/trans.c @@ -4082,6 +4082,8 @@ node_has_volatile_full_access (Node_Id gnat_node) case N_Identifier: case N_Expanded_Name: gnat_entity = Entity (gnat_node); + if (!Is_Object (gnat_entity)) + break; return Is_Volatile_Full_Access (gnat_entity) || Is_Volatile_Full_Access (Etype (gnat_entity)); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 2c07f6a11ca..bf028b86a22 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-03-10 Eric Botcazou + + * gnat.dg/prot3.adb: New test. + * gnat.dg/prot3_pkg.ad[sb]: New helper. + 2018-03-09 Jason Merrill Paolo Carlini diff --git a/gcc/testsuite/gnat.dg/prot3.adb b/gcc/testsuite/gnat.dg/prot3.adb new file mode 100644 index 00000000000..25390659238 --- /dev/null +++ b/gcc/testsuite/gnat.dg/prot3.adb @@ -0,0 +1,8 @@ +-- { dg-do run } + +with Prot3_Pkg; use Prot3_Pkg; + +procedure Prot3 is +begin + P.Foo (4); +end; diff --git a/gcc/testsuite/gnat.dg/prot3_pkg.adb b/gcc/testsuite/gnat.dg/prot3_pkg.adb new file mode 100644 index 00000000000..07ae1829f60 --- /dev/null +++ b/gcc/testsuite/gnat.dg/prot3_pkg.adb @@ -0,0 +1,17 @@ +package body Prot3_Pkg is + + protected body Prot is + function Fn (J : Short_Integer) return Rec + is + begin + return (V1 => J * J, + V2 => J); + end; + + procedure Foo (J : Short_Integer) is + begin + Val := Fn (J); + end; + end Prot; + +end Prot3_Pkg; diff --git a/gcc/testsuite/gnat.dg/prot3_pkg.ads b/gcc/testsuite/gnat.dg/prot3_pkg.ads new file mode 100644 index 00000000000..b4cce90a543 --- /dev/null +++ b/gcc/testsuite/gnat.dg/prot3_pkg.ads @@ -0,0 +1,16 @@ +package Prot3_Pkg is + + type Rec is record + V1 : Short_Integer; + V2 : Short_Integer; + end record with Volatile_Full_Access; + + protected type Prot is + procedure Foo (J : Short_Integer); + private + Val : Rec; + end Prot; + + P : Prot; + +end Prot3_Pkg; -- 2.30.2