diff options
| author | Aaron Ballman <aaron@aaronballman.com> | 2012-07-19 03:12:23 +0000 |
|---|---|---|
| committer | Aaron Ballman <aaron@aaronballman.com> | 2012-07-19 03:12:23 +0000 |
| commit | 24a1047c8cda684c12cf473fa8adb21aca567f4e (patch) | |
| tree | a0668665e23e24e72fd17b2bfe62e6acba3621e3 /clang/lib | |
| parent | 18eff57031b337b175c7506f74e9787da6b5b728 (diff) | |
| download | bcm5719-llvm-24a1047c8cda684c12cf473fa8adb21aca567f4e.tar.gz bcm5719-llvm-24a1047c8cda684c12cf473fa8adb21aca567f4e.zip | |
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.
llvm-svn: 160490
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 4041ccf9d39..6c6aeb1ab14 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -10406,15 +10406,21 @@ Decl *Sema::ActOnEnumConstant(Scope *S, Decl *theEnumDecl, Decl *lastEnumConst, } } - // 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. 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 = |

