[PATCH] D34992: Emit static constexpr member as available_externally definition

Richard Smith - zygoloid via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 5 16:42:11 PDT 2017


rsmith added inline comments.


================
Comment at: clang/test/CodeGenCXX/cxx11-extern-constexpr.cpp:15
+// CHECK: @_ZL4BAR3 = available_externally constant i32 44,
+static constexpr int BAR3 = 44;
+
----------------
mehdi_amini wrote:
> rsmith wrote:
> > mehdi_amini wrote:
> > > Looks like I have a bug here, this should be an internal.
> > I would imagine that we skip promotion of declaration to definition in this case if we already have a definition.
> > 
> > To that end, please add a testcase like this:
> > 
> > ```
> > struct Bar {
> >   static constexpr int BAZ = 42;
> > };
> > auto *use = &Bar::BAZ;
> > const int Bar::BAZ;
> > ```
> > 
> > ... to make sure that we convert the definition of `Bar::BAZ` from `available_externally` to a strong definition (I think we should end up with `weak_odr` here).
> `weak_odr` in C++17 because it is an inline variable, but I expect a strong definition in c++11.
> I'll add this, this is a good test-case!
Well, `weak_odr` is a kind of strong definition :)

Ah, I'd intended to change from emitting this as a strong definition to emitting it as `weak_odr` even in C++11 (for better forward-compatibility with C++17), but it looks like I never did so. So yes, we'd expect an ExternalLinkage global here (for now) in C++11.


https://reviews.llvm.org/D34992





More information about the cfe-commits mailing list