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

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


EricWF marked an inline comment as done.

================
Comment at: include/clang/Basic/DiagnosticSemaKinds.td:6807
@@ +6806,3 @@
+
+def err_has_constant_init_expression_trait_invalid_arg : Error<
+  "expression does not reference a named variable">;
----------------
Help improving this wording would be appreciated.

================
Comment at: lib/Sema/SemaExprCXX.cpp:4775
@@ +4774,3 @@
+      // a 'constant initializer'.
+      else if ((VD->hasGlobalStorage() ||
+          VD->getTLSKind() != VarDecl::TLS_None) && VD->hasInit()) {
----------------
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].



https://reviews.llvm.org/D23385





More information about the cfe-commits mailing list