================
@@ -5341,6 +5341,15 @@ void CodeGenModule::EmitGlobalVarDefinition(const 
VarDecl *D,
       !IsDefinitionAvailableExternally &&
       D->needsDestruction(getContext()) == QualType::DK_cxx_destructor;
 
+  // It is helpless to emit the definition for an available_externally variable
+  // which can't be marked as const.
+  // We don't need to check if it needs global ctor or dtor. See the above
+  // comment for ideas.
+  if (IsDefinitionAvailableExternally &&
+      (!D->hasConstantInitialization() ||
+       !D->getType().isConstantStorage(getContext(), true, true)))
----------------
efriedma-quic wrote:

Should we check for needsDestruction()?  (For example, consider a struct with a 
constexpr constructor, but a non-trivial destructor.)

https://github.com/llvm/llvm-project/pull/93530
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to