Page MenuHomePhabricator

[CUDA] Do not allow non-empty destructors for global device-side variables.
ClosedPublic

Authored by tra on May 10 2016, 3:38 PM.

Details

Summary

According to Cuda Programming guide (v7.5, E2.3.1):

device, constant and shared variables defined in namespace
scope, that are of class type, cannot have a non-empty constructor or a
non-empty destructor.

A destructor for a class is considered empty at a point in the translation unit, if it is either a trivial destructor or it satisfies all of the following conditions:

  • The destructor function has been defined.
  • The destructor function body is an empty compound statement.
  • Its class has no virtual functions and no virtual base classes.
  • The destructors of all base classes of its class can be considered empty.
  • For all the nonstatic data members of its class that are of class type (or array thereof), the destructor can be considered empty.

Clang already deals with device-side constructors (see D15305).
This patch enforces similar rules for destructors.

Diff Detail

Repository
rL LLVM

Event Timeline

tra updated this revision to Diff 56829.May 10 2016, 3:38 PM
tra retitled this revision from to [CUDA] Do not allow non-empty destructors for global device-side variables..
tra updated this object.
tra added reviewers: jlebar, rsmith, jingyue.
tra updated this object.
tra added a subscriber: cfe-commits.
jlebar accepted this revision.May 10 2016, 3:41 PM
jlebar edited edge metadata.

lgtm, but I'd like Richard to sign off on this too.

lib/Sema/SemaDecl.cpp
10438 ↗(On Diff #56829)

if there

This revision is now accepted and ready to land.May 10 2016, 3:41 PM
This revision was automatically updated to reflect the committed changes.