[PATCH] D101043: [OpenCL] Drop extension pragma handling for extension types/declaration

Anastasia Stulova via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 22 03:40:17 PDT 2021


Anastasia created this revision.
Anastasia added reviewers: svenvh, yaxunl, mantognini.
Herald added subscribers: ebevhan, mgrang.
Anastasia requested review of this revision.

The current implementation of extension pragma is not conformant to the spec as it does not disable anything and therefore enabling non-disabled logic has no meaning.

The implementation doesn't respect the following requirement from OpenCL Extension spec s1.2:

https://www.khronos.org/registry/OpenCL/specs/3.0-unified/html/OpenCL_Ext.html#extensions-overview

> **disable** Behave (including issuing errors and warnings) as if the extension extension_name is not part of the language definition.

This means that extension functionality should not be exposed by default and if extension identifiers are not reserved they should not be recognized by the compiler.

Fixing the behavior doesn't seem easy in C/C++-based parsing as it requires dynamic loading and unloading functionality. In C/C++-based languages, this has never been considered and they provide dedicated language features for loading i.e. include files, namespaces, etc. I don't know languages that actually support such a feature. In GLSL from where the initial idea came from the loading and unloading of extension functionality is constrained to be only available before parsing of the shading sourcing is done.

Considering the severe limitations I would like to drop maintaining this code now especially because of its interference with OpenCL 3.0. If we decide to implement this behavior (although it doesn't seem likely) we should provide the complete fully functional implementation.

The desired logic for exposing extension functionality conditionally can be easily achieved by using the extension macros definition/guards and header files.


https://reviews.llvm.org/D101043

Files:
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Overload.h
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Serialization/ASTWriter.h
  clang/lib/Parse/ParsePragma.cpp
  clang/lib/Parse/Parser.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaType.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/CodeGenOpenCL/extension-begin.cl
  clang/test/SemaOpenCL/extension-begin.cl
  clang/test/SemaOpenCL/extension-begin.h

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D101043.339547.patch
Type: text/x-patch
Size: 24285 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210422/e576c3aa/attachment-0001.bin>


More information about the cfe-commits mailing list