[cfe-commits] r160490 - in /cfe/trunk: lib/Sema/SemaDecl.cpp test/SemaCXX/enum-scoped.cpp

Richard Smith richard at metafoo.co.uk
Thu Jul 19 13:51:47 PDT 2012


On Thu, Jul 19, 2012 at 4:23 AM, Aaron Ballman <aaron at aaronballman.com>wrote:

> On Wed, Jul 18, 2012 at 11:13 PM, Richard Smith <richard at metafoo.co.uk>
> wrote:
> > On Wed, Jul 18, 2012 at 8:12 PM, Aaron Ballman <aaron at aaronballman.com>
> > wrote:
> >>
> >> Author: aaronballman
> >> Date: Wed Jul 18 22:12:23 2012
> >> New Revision: 160490
> >>
> >> URL: http://llvm.org/viewvc/llvm-project?rev=160490&view=rev
> >> Log:
> >> Relaxed enumeration constant naming rules for scoped enumerators so they
> >> no longer emit a diagnostic when the enumeration's name matches that of
> the
> >> class.  Fixes PR13128.
> >>
> >> Modified:
> >>     cfe/trunk/lib/Sema/SemaDecl.cpp
> >>     cfe/trunk/test/SemaCXX/enum-scoped.cpp
> >>
> >> Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
> >> URL:
> >>
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=160490&r1=160489&r2=160490&view=diff
> >>
> >>
> ==============================================================================
> >> --- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
> >> +++ cfe/trunk/lib/Sema/SemaDecl.cpp Wed Jul 18 22:12:23 2012
> >> @@ -10406,15 +10406,21 @@
> >>      }
> >>    }
> >>
> >> -  // C++ [class.mem]p13:
> >> -  //   If T is the name of a class, then each of the following shall
> have
> >> a
> >> -  //   name different from T:
> >> -  //     - every enumerator of every member of class T that is an
> >> enumerated
> >> -  //       type
> >> +  // C++ [class.mem]p15:
> >> +  // If T is the name of a class, then each of the following shall
> have a
> >> name
> >> +  // different from T:
> >> +  // - every enumerator of every member of class T that is an unscoped
> >> +  // enumerated type
> >> +  //
> >> +  // C++ [dcl.enum]p10:
> >> +  // Each enum-name and each unscoped enumerator is declared in the
> scope
> >> that
> >> +  // immediately contains the enum-specifier. Each scoped enumerator is
> >> declared
> >> +  // in the scope of the enumeration.
> >
> >
> > Is this quotation relevant here? (Sorry for not calling this out before.)
>
> I thought it was due to the scoping rules that the name is declared
> within the scope of the enumeration.  But I can also see it being
> superfluous.  I'm happy to remove it if you'd prefer.


I'd prefer it removed. This quotation would be relevant if the rule were
'no name declared directly within a class can have the same name as the
class', but that's not the rule; the rule is what's in p15. (In particular,
note the special case in p16.)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120719/cd43aae1/attachment.html>


More information about the cfe-commits mailing list