[PATCH] D61318: [Sema] Prevent binding references with mismatching address spaces to temporaries

Anastasia Stulova via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 30 09:14:07 PDT 2019


Anastasia created this revision.
Anastasia added reviewers: rjmccall, ebevhan.

This is a straw-man idea for solving binding references with address spaces to temporaries. If the logic below makes sense I will apply it elsewhere in similar checks.

Arbitrary address space references can't be bound to temporaries. The reference binding logic should check that the address space of temporary can be implicitly converted to address space in reference when temporary materialization is performed.

Example:

  _AS1 float gf;
  ...
  _AS1 const int& ref = gf; //this can only be accepted if implicit conversion from _AS1 to LangAS::Default is allowed

This review depends on: https://reviews.llvm.org/D58060


https://reviews.llvm.org/D61318

Files:
  include/clang/Basic/DiagnosticIDs.h
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/Initialization.h
  lib/Sema/SemaInit.cpp
  test/SemaOpenCLCXX/address-space-references.cl

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D61318.197349.patch
Type: text/x-patch
Size: 4121 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190430/93378382/attachment-0001.bin>


More information about the cfe-commits mailing list