[clang] [Frontend][Sema] Add CC1-only -fms-anonymous-structs to enable Microsoft anonymous struct/union feature (PR #176551)
Hubert Tong via cfe-commits
cfe-commits at lists.llvm.org
Wed Jan 21 07:59:57 PST 2026
================
@@ -190,6 +190,26 @@ TEST_F(CommandLineTest, BoolOptionDefaultTrueSingleFlagPresent) {
ASSERT_THAT(GeneratedArgs, Contains(StrEq("-fno-temp-file")));
}
+TEST_F(CommandLineTest, MSAnonymousStructsFlagPresent) {
+ const char *Args[] = {"-cc1", "-fms-anonymous-structs"};
+
+ ASSERT_TRUE(CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags));
+
+ EXPECT_TRUE(Invocation.getLangOpts().MSAnonymousStructs);
+
+ Invocation.generateCC1CommandLine(GeneratedArgs, *this);
+
+ ASSERT_THAT(GeneratedArgs, Contains(StrEq("-fms-anonymous-structs")));
+}
+
+TEST_F(CommandLineTest, MSAnonymousStructsEnabledByMSExtensions) {
+ const char *Args[] = {"clang", "-fms-extensions"};
+
+ ASSERT_TRUE(CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags));
+
+ EXPECT_TRUE(Invocation.getLangOpts().MSAnonymousStructs);
+}
+
----------------
hubert-reinterpretcast wrote:
Same comment as above re: not needing to update this test.
https://github.com/llvm/llvm-project/pull/176551
More information about the cfe-commits
mailing list