[PATCH] D128649: [clang-cl] Handle some pragma alloc_text corner cases handled by MSVC

Hans Wennborg via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jun 27 09:48:38 PDT 2022

hans added a comment.

In D128649#3612626 <https://reviews.llvm.org/D128649#3612626>, @steplong wrote:

> I think we have to use `isInExternCContext()` to accept the following (MSVC accepts this):
>   extern "C" { static void f(); }
>   static void f() {}

I'm probably missing something. Is the "static" important in this example? Since `f` has internal linkage, I don't see why a user would care if it's "extern C" or not, and also not in which section it would go (in this case it will not be emitted at all, because it's not used).

Isn't the question whether `f` is considered "extern C" in the end or not? I thought `isExternC()` checks that? Are you saying it would return false for `f` in your example?

Comment at: clang/lib/Sema/SemaAttr.cpp:822
+      } else {
+        Diag(Loc, diag::err_pragma_alloc_text_not_function);
+        return;
Since it's inside `if (getLangOpts().CPlusPlus) {` it will only error in C++ mode, but it should probably also error in C mode.

  rG LLVM Github Monorepo



More information about the cfe-commits mailing list