This is an archive of the discontinued LLVM Phabricator instance.

[OpenMP] Avoid crash in preparation for diagnose of unsupported type
AbandonedPublic

Authored by jdoerfert on Apr 10 2020, 4:01 PM.

Details

Summary

This was reported as PR45231 but occurs even without cmath in C++17
mode if we have an expression involving unsupported types outside of a
function. For now we just avoid to create a diagnose builder in this
case as it might be valid anyway. A proper solution to handle
unsupported types has to be found. Discussion is ongoing in D74387.

Diff Detail

Event Timeline

jdoerfert created this revision.Apr 10 2020, 4:01 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 10 2020, 4:02 PM
This revision is now accepted and ready to land.Apr 13 2020, 11:26 AM
Fznamznon added inline comments.Apr 14 2020, 10:10 AM
clang/lib/Sema/SemaOpenMP.cpp
1831

Please ignore my comment if it says nonsense. It actually can since I don't know a lot about OpenMP but,
looking into targetDiag, I would say that underlying function (diagIfOpenMPDeviceCode in case of OpenMP device mode) should check that we actually have current function because it does getCurFunctionDecl() call.
Otherwise any attempt to emit diagnostic in OpenMP device mode using targetDiag or diagIfOpenMPDeviceCode will fail outside of functions.

jdoerfert marked an inline comment as done.Apr 14 2020, 12:12 PM
jdoerfert added inline comments.
clang/lib/Sema/SemaOpenMP.cpp
1831

It's not nonsense. I think the current system is not meant for non-function diagnostics. That said, I could probably bail later in the call chain, e.g. in diagIfOpenMPDeviceCode. Later we should rethink how this is done as we adopt to a more user-friendly model.

jdoerfert planned changes to this revision.May 28 2020, 9:21 AM

I think this will be fixed by D74387, we should include the tests somewhere though.

I think this will be fixed by D74387, we should include the tests somewhere though.

D74387 includes a test case with expression involving unsupported types outside of a function (at the end of in nvptx_unsupported_type_messages.cpp).

jdoerfert abandoned this revision.May 28 2020, 9:57 AM

Great. I'll ask in the other patch to add these three lines just to be sure ;)