[cfe-commits] Microsoft extension (enum 'enum' used in qualified name)
Nikola Smiljanic
popizdeh at gmail.com
Thu Apr 19 13:22:57 PDT 2012
Microsoft allows code like this:
struct S {
enum E { a };
};
int i = S::E::a; // C4482
http://msdn.microsoft.com/en-us/library/ms173704.aspx
int j = S::a; // OK
This is my attempt to make this compile this when -fms-extensions is
used. I think that my comment could be better but I'm not very good at
explaining these things. I have no idea what to do with this test file
so I'm attaching it in addition to the patch. What do you think?
-------------- next part --------------
Index: lib/Sema/SemaCXXScopeSpec.cpp
===================================================================
--- lib/Sema/SemaCXXScopeSpec.cpp (revision 155007)
+++ lib/Sema/SemaCXXScopeSpec.cpp (working copy)
@@ -283,16 +283,20 @@
// Determine whether we have a class (or, in C++11, an enum) or
// a typedef thereof. If so, build the nested-name-specifier.
+ // In Microsoft mode scoped enumerators are allowed in C++98.
QualType T = Context.getTypeDeclType(cast<TypeDecl>(SD));
if (T->isDependentType())
return true;
else if (TypedefNameDecl *TD = dyn_cast<TypedefNameDecl>(SD)) {
if (TD->getUnderlyingType()->isRecordType() ||
(Context.getLangOpts().CPlusPlus0x &&
+ TD->getUnderlyingType()->isEnumeralType()) ||
+ (Context.getLangOpts().MicrosoftExt &&
TD->getUnderlyingType()->isEnumeralType()))
return true;
} else if (isa<RecordDecl>(SD) ||
- (Context.getLangOpts().CPlusPlus0x && isa<EnumDecl>(SD)))
+ (Context.getLangOpts().CPlusPlus0x && isa<EnumDecl>(SD)) ||
+ (Context.getLangOpts().MicrosoftExt && isa<EnumDecl>(SD)))
return true;
return false;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.cpp
Type: text/x-c++src
Size: 403 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120419/309f01a1/attachment.cpp>
More information about the cfe-commits
mailing list