From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 60AC93895FC9; Fri, 21 Jun 2024 07:18:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 60AC93895FC9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1718954292; bh=dEC4F1EwtT7af6cWWdigYwCOv1fujYW2vcRGn3NN5mc=; h=From:To:Subject:Date:From; b=CLLEuSQjB9lBJuZPXwqc4z22ji+LVZZ14VRT9BPwXtk5KqeUAC3ZMhb2rNUbQboNr iyP1GgGItovOQdrbzbuqoOrjj6pw8XlO2Mf/W2SGPKYmwp1O8g9MHfZbgMBq37Km9/ DdfkUEnT+PMt98ZldS4ymQv+rwWkBdxU/LhEzrWk= From: "burnus at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: =?UTF-8?B?W0J1ZyBtaWRkbGUtZW5kLzExNTU3NF0gTmV3OiBbT3Blbk1QXSBO?= =?UTF-8?B?ZXN0ZWQgQyBmdW5jdGlvbiDigJMgJ2RlY2xhcmUgdGFyZ2V0IGxpbmsodmFy?= =?UTF-8?B?KScgbGVhZHMgdG8gInJlZmVyZW5jZWQgaW4gb2ZmbG9hZGVkIGNvZGUgYnV0?= =?UTF-8?B?IGhhc24ndCBiZWVuIG1hcmtlZCB0byBiZSBpbmNsdWRlZCBpbiB0aGUgb2Zm?= =?UTF-8?B?bG9hZGVkIGNvZGUi?= Date: Fri, 21 Jun 2024 07:18:11 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 15.0 X-Bugzilla-Keywords: openmp, rejects-valid X-Bugzilla-Severity: normal X-Bugzilla-Who: burnus at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status keywords bug_severity priority component assigned_to reporter cc target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D115574 Bug ID: 115574 Summary: [OpenMP] Nested C function =E2=80=93 'declare target link(var)' leads to "referenced in offloaded code but hasn't been marked to be included in the offloaded code" Product: gcc Version: 15.0 Status: UNCONFIRMED Keywords: openmp, rejects-valid Severity: normal Priority: P3 Component: middle-end Assignee: unassigned at gcc dot gnu.org Reporter: burnus at gcc dot gnu.org CC: jakub at gcc dot gnu.org Target Milestone: --- C variant for the issue PR 115559. [Nested functions are a GNU extension - thus, we may decide not to fix this= .] Nonetheless, the following compiles but fails during device LTO: foo.c:2:13: error: variable 'a' has been referenced in offloaded code but hasn't been marked to be included in the offloaded code 2 | static int a, b[5]; | ^ foo.c:2:16: error: variable 'b' has been referenced in offloaded code but hasn't been marked to be included in the offloaded code 2 | static int a, b[5]; void f() { static int a, b[5]; #pragma declare target link(a,b) void g() { a =3D 7; b[3] =3D 3; } // #pragma omp declare target enter(g) #pragma omp target map(tofrom: a, b) g(); } The problem is the global-var check in c/c-parser.cc (and cp/parser.cc): id =3D get_identifier ("omp declare target link"); std::swap (at1, at2); } ... if (!at1) { DECL_ATTRIBUTES (t) =3D tree_cons (id, NULL_TREE, DECL_ATTRIBUTES= (t)); if (TREE_CODE (t) !=3D FUNCTION_DECL && !is_global_var (t)) continue; symtab_node *node =3D symtab_node::get (t); if (node !=3D NULL) { node->offloadable =3D 1; ... vec_safe_push (offload_vars, t); As neither is a global var, it is not added.=