Topic: C++11 generalized attributes for namespaces


Author: Boris Kolpackov<boris@codesynthesis.com>
Date: Sun, 8 Apr 2012 08:14:43 -0700 (PDT)
Raw View
Hi,

I am looking into C++11 generalized attributes and trying to understand
if they apply to namespaces, including the global namespace/translation
unit.

According to Clause 7 [dcl.dcl] paragraph 1 (the attribute-declaration
production), we can have something like this:

[[attr]];

namespace n
{
      [[attr]];
}

However, I can't seem to find any text that says what such an attribute
appertains to. Is it to the innermost namespace? Or, may be, always to
the translation unit?

Revision 4[1] of the Generalized Attributes paper had this paragraph:

"In an attribute-declaration, the attribute-specifier appertains to its
innermost enclosing namespace; if that namespace is the global namespace,
the attribute-specifier appertains to the entire translation unit. In an
attribute-specification, the attribute-specifier appertains to all entities
declared or named within the declaration-seq, if any. Multiple attribute-
specification nest. When they nest, for each attribute, the innermost one
determines the attribute effective for all entities in the declaration-seq.
An attribute-specification does not establish a scope."

However, in Revision 6[2] this paragraph has been removed.

I would appreciate it if someone can clarify this.

[1] http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2553.pdf
[2] http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2761.pdf

Thanks,
 Boris
--
Boris Kolpackov, Code Synthesis        http://codesynthesis.com/~boris/blog
Compiler-based ORM system for C++      http://codesynthesis.com/products/odb
Open-source XML data binding for C++   http://codesynthesis.com/products/xsd
XML data binding for embedded systems  http://codesynthesis.com/products/xsde


[ comp.std.c++ is moderated.  To submit articles, try posting with your ]
[ newsreader.  If that fails, use mailto:std-cpp-submit@vandevoorde.com ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]




Author: =?ISO-8859-1?Q?Daniel_Kr=FCgler?= <daniel.kruegler@googlemail.com>
Date: Wed, 11 Apr 2012 23:12:38 -0700 (PDT)
Raw View
On 2012-04-08 17:14, Boris Kolpackov wrote:
>
> I am looking into C++11 generalized attributes and trying to understand
> if they apply to namespaces, including the global namespace/translation
> unit.
>
> According to Clause 7 [dcl.dcl] paragraph 1 (the attribute-declaration
> production), we can have something like this:
>
> [[attr]];
>
> namespace n
> {
>       [[attr]];
> }
>
> However, I can't seem to find any text that says what such an attribute
> appertains to. Is it to the innermost namespace? Or, may be, always to
> the translation unit?


[..]

> I would appreciate it if someone can clarify this.


The semantics should be described by the general statement in 7 p1:

"Except where otherwise specified, the meaning of an
attribute-declaration is implementation-defined."

HTH & Greetings from Bremen,

Daniel Kr   gler


--
[ comp.std.c++ is moderated.  To submit articles, try posting with your ]
[ newsreader.  If that fails, use mailto:std-cpp-submit@vandevoorde.com ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]