[PATCH] D137107: Allow MS extension: support of constexpr with __declspec(dllimport).

Zahira Ammarguellat via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Dec 5 14:39:52 PST 2022


zahiraam added inline comments.


================
Comment at: clang/lib/CodeGen/CGDeclCXX.cpp:572
     PrioritizedCXXGlobalInits.push_back(std::make_pair(Key, Fn));
+  } else if (D->hasConstantInitialization() && !(D->hasAttr<ConstInitAttr>())) {
+    OrderGlobalInitsOrStermFinalizers Key(201,
----------------
efriedma wrote:
> How is ConstInitAttr relevant here?
This change made (without the !(D->hasAttr<ConstInitAttr>()) made the LIT behavior of aix-static-init.cpp. The IR generated for 
namespace test3 {
  struct Test3 {
    constexpr Test3() {};
    ~Test3() {};
  };

  constinit Test3 t;
} // namespace test3

was different. I would have thought that the change we made for constexpr wouldn't affter constinit? 


================
Comment at: clang/test/Sema/dllimport.c:41
 // Address of variables can't be used for initialization in C language modes.
-int *VarForInit = &GlobalDecl; // expected-error{{initializer element is not a compile-time constant}}
+int *VarForInit = &GlobalDecl;
 
----------------
efriedma wrote:
> Like I mentioned before, we might want to restrict this feature to C++.
Sorry I forgot about that. I will change that so that the diag is generated only for C++.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137107/new/

https://reviews.llvm.org/D137107



More information about the cfe-commits mailing list