<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <br>
    <div class="moz-cite-prefix">On 13/01/2014 13:23, Aaron Ballman
      wrote:<br>
    </div>
    <blockquote
cite="mid:CAAt6xTsQpCv-h7+xcRn5szDMX8O14Ax2nowRnjAqiTRGyDjgvw@mail.gmail.com"
      type="cite">
      <pre wrap="">On Sun, Jan 12, 2014 at 11:43 PM, Kal <a class="moz-txt-link-rfc2396E" href="mailto:b17c0de@gmail.com"><b17c0de@gmail.com></a> wrote:
</pre>
      <blockquote type="cite">
        <pre wrap="">Am 13.01.14 03:43, schrieb Aaron Ballman:

New patch attached with some suggestions implemented. Changes include:

1) Updated the cmake file because the name of the tablegen file was
updated (this should have been in the initial patch)
2) Lexing unknown syntax now attempts better recovery. This allows us
to be a bit more future-proof
3) Unknown syntax is now handled as a warning instead of an error.
However, malformed __has_attribute is still treated as an error (for
instance, __has_attribute[haha] will be an error, but
__has_attribute([haha]) will be a warning). The warning may warrant
its own diagnostic group instead of piggy-backing on UnknownAttribute.
4) C++11 language option checking was moved into tablegen instead of
the preprocessor
5) Updated test cases for the new warning, future-proofing and the
movement of C++11 language option checking

What this patch does not address is:

* It's still using __has_attribute while we discuss an improved name
* The default __has_attribute(ident) functionality still checks for
all attribute names (changing this would be a separate patch,
regardless)

One other thing to consider with regards to naming -- another approach
we could take would be to not encode the syntax directly in the
feature macro, but instead use separate macros (with its analogous
currently-proposed syntax in comments):

__has_gnu_attribute(ident)  // __has_attribute(__attribute__((ident)))
__has_declspec_attribute(ident)  // __has_attribute(__declspec(ident))
__has_generalized_attribute(ident) // __has_attribute([[ident]])
__has_keyword_attribute(ident)  // __has_attribute(ident)


What about the following instead (could also swap the order of these
arguments):

__has_attribute(gnu,         ident) //
__has_attribute(__attribute__((ident)))
__has_attribute(declspec,    ident) // __has_attribute(__declspec(ident))
__has_attribute(generalized, ident) // __has_attribute([[ident]])
__has_attribute(keyword,     ident) // __has_attribute(ident)

</pre>
      </blockquote>
      <pre wrap="">
Thank you for the input!

Unfortunately, it would cause backwards compatibility problems as the
current implementation has no fallback mode for syntaxes it doesn't
understand (so this would break existing code, and have no migration
path forward). At the very least, the name would have to change.
Personally, if we are using a single identifier for the feature test
macro, I would prefer to key off the distinct attribute syntax instead
of another contextualized identifier. Users already know how to write
the attribute, so the syntax is something already known. A new
contextual identifier is one more thing to learn and remember.</pre>
    </blockquote>
    <br>
    Yes, for the alternative proposal (3) it only makes sense to name
    the macros individually for each attribute type. There's no value in
    expecting a name in the first macro argument and the comma form
    would be incompatible.<br>
    <br>
    As a tweak to this latest alternative proposal, there's also no
    longer a need for the spelling to be written because each macro can
    test for the attribute name precisely.<br>
    <br>
    Also instead of 'ident', it's strictly speaking a 'name' in the case
    of C++11 generalized attributes given that they can be namespaced
    (gnu, omp?). These are the forms and names I'd suggest:<br>
    <br>
    <blockquote><code>__has_attribute(deprecated) // Test for GNU
        attributes only, macro always defined (minor tightening of
        semantics)</code><code></code><br>
      <code></code><code>__has_declspec(deprecated) // Macro only
        defined in MSVC extension mode</code><code></code><br>
      <code></code><code>__has_generalized_attribute(gnu::deprecated)</code><code>
        // Macro only defined in C++11 mode</code><code></code><br>
      <code></code><code>__has_simple_attribute(alignas) // Macro always
        defined, but mostly useful for C++11 keyword attributes like
        'alignas'</code><br>
    </blockquote>
    <br>
    Overall I think it'll be either this or Aaron's proposal to have a
    single unified feature macro that uses the spellings.<br>
    <br>
    This one has the benefit of simpler parse rules in the preprocessor
    where we don't have access to balanced token and recovery
    facilities, so is less "magical".<br>
    <br>
    On the other hand Aaron's original proposal has the benefit of being
    visually closer to the attribute as written.<br>
    <br>
    Both this one and Aaron's patch are now forward compatible and well
    specified. Overall I'm on the fence as to which is preferable,
    slightly favouring Aaron's original proposal.<br>
    <br>
    Alp.<br>
    <br>
    <br>
    <blockquote
cite="mid:CAAt6xTsQpCv-h7+xcRn5szDMX8O14Ax2nowRnjAqiTRGyDjgvw@mail.gmail.com"
      type="cite">
      <pre wrap="">

~Aaron
_______________________________________________
cfe-dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a>
<a class="moz-txt-link-freetext" href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a>
</pre>
    </blockquote>
    <br>
    <pre class="moz-signature" cols="72">-- 
<a class="moz-txt-link-freetext" href="http://www.nuanti.com">http://www.nuanti.com</a>
the browser experts
</pre>
  </body>
</html>