This is an archive of the discontinued LLVM Phabricator instance.

[C11] PR24451: Allow restrict _Atomic pointers
AbandonedPublic

Authored by d.zobnin.bugzilla on Apr 1 2016, 9:40 AM.

Details

Reviewers
rsmith
Summary

Treat _Atomic pointers as pointer types (check value type of AtomicType) in case of handling the "restrict" qualifier. Accept such code (so does GCC):

int * restrict _Atomic p;

Diff Detail

Event Timeline

d.zobnin.bugzilla retitled this revision from to [C11] PR24451: Allow restrict _Atomic pointers.
d.zobnin.bugzilla updated this object.
d.zobnin.bugzilla added a reviewer: rsmith.
d.zobnin.bugzilla added a subscriber: cfe-commits.
rsmith edited edge metadata.Apr 1 2016, 11:29 AM

I'm not convinced this change is correct. There are two possibilities for what int *_Atomic restrict could mean:

  1. _Atomic(int *restrict): this seems to be ill-formed by 6.7.2.4/3, because the type name in an atomic type specifier cannot be a qualified type
  2. _Atomic(int *) restrict: this seems to be ill-formed by 6.7.3/2, because (by 6.2.5) an atomic type is not a pointer type

If you're trying to simulate a GCC extension, this should at least have a corresponding ExtWarn, but you'll also need to make the case that the extension is useful.

Richard, thank you for the review and explanation!
I don't have any examples of useful code using this extension, I was trying to fix the PR... So, do you think we should add this GCC extension to Clang (with a proper warning, of course) for compatibility reasons, or it will be better to close PR24451 and abandon this review?

Thank you,
Denis Zobnin

Richard, please let me know what in your opinion we should do with this revision.

Thank you,
Denis Zobnin

I mailed WG14 asking for clarification on how these rules are supposed to work (10 days ago) and am yet to hear anything in response. Is this apparent GCC extension/bug seeing much use in the wild? If not, I think our path forward is to file this as a bug against GCC and see if they want to fix it or accept it as an extension.