[cfe-commits] [PATCH] PR12008: out-of-line definitions of static constexpr member functions

Richard Smith richard at metafoo.co.uk
Mon Feb 20 13:57:03 PST 2012


Hi,

The constexpr specifier implicitly marks non-static member function
declarations as const. We currently look at the storage class of the
function to determine whether this marking applies, but as PR12008 points
out, this is inadequate: for out-of-line definitions of constexpr member
functions, we don't know whether the function is static until we have
looked up the previous declaration (and performed some other semantic
checks).

The attached patch fixes this by delaying the addition of the const
qualifier to a constexpr non-static member function until the point where
we know it's not static. For efficiency, the patch modifies the type of the
TypeSourceInfo object in-place; this is safe because the reference to the
TypeSourceInfo object is unique, and the addition of a 'const' qualifier
does not change the TypeLoc representation.

Thanks!
Richard
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120220/7b13e593/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 12008.diff
Type: text/x-patch
Size: 6861 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120220/7b13e593/attachment.bin>


More information about the cfe-commits mailing list