gcc-4.0 non-local variable uses anonymous type warning

James E Wilson wilson@specifixinc.com
Tue Apr 26 02:38:00 GMT 2005


William S Fulton wrote:
> test.cxx:15: warning: non-local variable ‘<unnamed>::<anonymous enum> 
> <unnamed>::InstanceÂ’ uses anonymous type

Just grepping the sources for the warning, I find this comment
       /* [basic.link]: A name with no linkage (notably, the name of a class
          or enumeration declared in a local scope) shall not be used to
          declare an entity with linkage.
          Only check this for public decls for now.  */
Also this:
                   /* DRs 132, 319 and 389 seem to indicate types with
                      no linkage can only be used to declare extern "C"
                      entities.  Since it's not always an error in the
                      ISO C++ 90 Standard, we only issue a warning.  */

>   static enum { foo, bar = 10 } Instance;

The "public decls" comment above means that we deliberately don't emit 
the warning for static variables, but it is possible this may change in 
the future.  It may depend on how the defect reports get resolved.

I'm not a C++ expert, and don't have a copy of the C++ standard, so I 
can't comment further.
-- 
Jim Wilson, GNU Tools Support, http://www.SpecifixInc.com



More information about the Gcc mailing list