[PATCH] D63889: Check possible warnings on global initializers for reachability

Nathan Huckleberry via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 5 16:38:47 PDT 2019


Nathan-Huckleberry marked an inline comment as done.
Nathan-Huckleberry added inline comments.


================
Comment at: clang/lib/Sema/SemaDeclCXX.cpp:352
   SetParamDefaultArgument(Param, DefaultArg, EqualLoc);
+  CurContext->removeDecl(Param);
+  CurContext = Cur;
----------------
rsmith wrote:
> We may need to delay the diagnostics here until the default argument is *used*: if a default argument references a template instantiation, the instantiation is not performed until that point, which may mean that our semantic checking can't complete correctly until use.
Currently this patch really only works with globals. There are many places where the following check is made instead of calling `ParseInitializer`. These should probably be rewritten into a single function and do something similar with pushing/popping declarations. Not sure if that change should be made in this patch or not.

```
if (getLangOpts().CPlusPlus11 && Tok.is(tok::l_brace)) {
            Diag(Tok, diag::warn_cxx98_compat_generalized_initializer_lists);
            DefArgResult = ParseBraceInitializer();
          } else
            DefArgResult = ParseAssignmentExpression();
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63889





More information about the cfe-commits mailing list