[PATCH] D23385: Implement __has_constant_initializer(obj) expression traits.

Eric Fiselier via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 11 16:43:54 PDT 2016


EricWF added inline comments.

================
Comment at: lib/Sema/SemaExprCXX.cpp:4775
@@ +4774,3 @@
+      // a 'constant initializer'.
+      else if ((VD->hasGlobalStorage() ||
+          VD->getTLSKind() != VarDecl::TLS_None) && VD->hasInit()) {
----------------
EricWF wrote:
> jroelofs wrote:
> > no else after return.
> > 
> > Also, what do you want this to do for `ParmVarDecl`s that happen to have an initializer? i.e:
> > 
> > ```
> > void foo(int i = 45) {}
> > ```
> I believe that case should return false. `i` isn't static or thread local so it doesn't have a "constant initializer" according to [basic.start.static].
> 
Perhaps using `__has_constant_initializer` should emit a diagnostic when used on non-static, non-thread-local objects?


https://reviews.llvm.org/D23385





More information about the cfe-commits mailing list