[PATCH] D91659: Allow anonymous enum typedefs to be referenced with the 'enum' specifier under MSVC compat mode
Shivanshu Goyal via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Nov 17 21:52:58 PST 2020
shivanshu3 marked 3 inline comments as done.
shivanshu3 added a comment.
Thank you very much for the review @rsmith!
================
Comment at: clang/lib/Sema/SemaDecl.cpp:15752-15754
+ bool AnonymousEnumEligible = getLangOpts().MSVCCompat &&
+ (Kind == TTK_Enum) &&
+ Tag->getDeclName().isEmpty();
----------------
rsmith wrote:
> In the anonymous union case, we also need to check for qualifiers on the typedef type, and more broadly perhaps we should be using `getAnonDeclWithTypedefName` here too. Presumably the new case should also only apply for `TUK_Reference`.
I added a check for TUK_Reference. But I don't fully understand your other comment about checking the qualifiers on the typedef type. Could you please explain a little more?
================
Comment at: clang/test/Sema/enum-typedef-msvc.c:15
+ (void)foo;
+}
----------------
rsmith wrote:
> Please also add a testcase for the situation where the use of `enum Foo` occurs in the same scope as the typedef and anonymous `enum` declaration. (MSVC has weird behavior here that we don't necessarily need to follow, but we should make sure we at least do something defensible.)
Oh interesting! I didn't realize MSVC produces an error in that case. Clang does not produce an error with these changes in that case. Is that OK?
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D91659/new/
https://reviews.llvm.org/D91659
More information about the cfe-commits
mailing list