[cfe-commits] r160490 - in /cfe/trunk: lib/Sema/SemaDecl.cpp test/SemaCXX/enum-scoped.cpp
Richard Smith
richard at metafoo.co.uk
Wed Jul 18 21:13:17 PDT 2012
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.)
> if (CXXRecordDecl *Record
> = dyn_cast<CXXRecordDecl>(
>
> TheEnumDecl->getDeclContext()->getRedeclContext()))
> - if (Record->getIdentifier() && Record->getIdentifier() == Id)
> + if (!TheEnumDecl->isScoped() &&
> + Record->getIdentifier() && Record->getIdentifier() == Id)
> Diag(IdLoc, diag::err_member_name_of_class) << Id;
>
> EnumConstantDecl *New =
>
> Modified: cfe/trunk/test/SemaCXX/enum-scoped.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/enum-scoped.cpp?rev=160490&r1=160489&r2=160490&view=diff
>
> ==============================================================================
> --- cfe/trunk/test/SemaCXX/enum-scoped.cpp (original)
> +++ cfe/trunk/test/SemaCXX/enum-scoped.cpp Wed Jul 18 22:12:23 2012
> @@ -245,3 +245,10 @@
> int m = g<int>();
> int n = g<short>(); // expected-note {{here}}
> }
> +
> +namespace pr13128 {
> + // This should compile cleanly
> + class C {
> + enum class E { C };
> + };
> +}
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120718/c1d2cea7/attachment.html>
More information about the cfe-commits
mailing list