[cfe-dev] Determine whether the current clang version has a specific bug

Daniel Jasper djasper at google.com
Wed Jun 20 23:43:06 PDT 2012

I recently added the support to use __attribute__((unused)) on fields to
silence -Wunused-private-field. Now, for backwards compatibility of new
source files, we need a way to determine (e.g. in a header file) whether
this is supported in the used clang version.

Currently __has_feature, __has_extension and __has_attribute implement
something similar, but this change does not really fit any of those
categories as it should be considered a bug. Not allowing this attribute on
fields was an oversight that was fixed. Thus I (after discussion with
chandlerc) suggest introducing __has_bug.

This should default to 1 (all bugs that are not explicitly fixed in a clang
version are still bugs) and to provide compatibility with other compilers,
sources can used:
#ifndef __has_bug
# define __has_bug(x) __clang__

Any thoughts?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20120621/5bdb6dc6/attachment.html>

More information about the cfe-dev mailing list