[clang] [Driver][Frontend] Add -f[no-]ms-anonymous-structs flag to control Microsoft anonymous struct/union extension (PR #176551)

via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 29 06:00:26 PST 2026


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff origin/main HEAD --extensions c,cpp -- clang/test/Driver/ms-anonymous-structs.c clang/test/Frontend/ms-anon-structs-args.c clang/test/Sema/MicrosoftAnonymousStructs.c clang/lib/Driver/ToolChains/Clang.cpp clang/lib/Sema/SemaDecl.cpp --diff_from_common_commit
``````````

:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
index ab0286fd5..37965f7da 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -7180,9 +7180,9 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
   // - Implicitly enabled via -fms-extensions or -fms-compatibility
   // - Implicitly disabled via -fno-ms-extensions or -fno-ms-compatibility
   //
-  // When multiple relevent options are present, the last option on the command line
-  // takes precedence. This allows users to selectively override implicit enablement.
-  // Examples:
+  // When multiple relevent options are present, the last option on the command
+  // line takes precedence. This allows users to selectively override implicit
+  // enablement. Examples:
   //   -fms-extensions -fno-ms-anonymous-structs -> disabled (explicit override)
   //   -fno-ms-anonymous-structs -fms-extensions -> enabled (last flag wins)
   auto ShouldEnableMSAnonymousStructs =

``````````

</details>


https://github.com/llvm/llvm-project/pull/176551


More information about the cfe-commits mailing list