This is an archive of the discontinued LLVM Phabricator instance.

[clang][OpenMP] Fix declare simd use on in-class member template function
ClosedPublic

Authored by mikerice on May 12 2022, 12:10 PM.

Details

Summary

Return the Decl when parsing the template member declaration so the
'omp declare simd' pragma can be applied to it. Previously a nullptr
was returned causing an error applying the pragma.

Fixes #52700.

The return of nullptr here seems to have been in the compiler for quite a long time.
I wasn't able to determine if that was intentional.

Diff Detail

Event Timeline

mikerice created this revision.May 12 2022, 12:10 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 12 2022, 12:10 PM
mikerice requested review of this revision.May 12 2022, 12:10 PM
ABataev added inline comments.May 12 2022, 12:19 PM
clang/lib/Parse/ParseTemplate.cpp
205

Can we have more than a single decl here?

mikerice added inline comments.May 12 2022, 3:54 PM
clang/lib/Parse/ParseTemplate.cpp
205

It is possible for ParseCXXClassMemberDeclaration to return multiple declarations in this context. For example:

struct A {                            
  #pragma omp declare simd linear(a:X)
  template<int X, typename T>         
  T infunc1(T a), infunc2(T a);       
};

But this code is only setup to return one Decl.

Since the 'declare simd' code expects only one Decl as well, it is probably best to just return the Decl when there is just one. Then an error will still occur trying to process the declare simd in case of code like above.

mikerice updated this revision to Diff 429092.May 12 2022, 3:56 PM

Return Decl only when a single Decl.
Test that error is still given if multiple Decls.

This revision is now accepted and ready to land.May 12 2022, 4:11 PM
This revision was landed with ongoing or failed builds.May 13 2022, 8:28 AM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptMay 13 2022, 8:28 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript