[PATCH] Fix PR15558
Matt Beaumont-Gay
matthewbg at google.com
Mon Apr 8 15:58:20 PDT 2013
================
Comment at: lib/Sema/Sema.cpp:755-756
@@ -755,1 +754,4 @@
+ } else if (getSourceManager().isFromMainFile(DiagD->getLocation())) {
+ // If the decl is in a header, it may be used in some other TU, so
+ // only warn if it's in the main file.
Diag(DiagD->getLocation(), diag::warn_unused_variable)
----------------
Richard Smith wrote:
> This comment is not quite right; maybe...
>
> If the declaration is in a header which is included into multiple TUs, it will declare one variable per TU, and one of the other variables may be used.
Done.
================
Comment at: test/SemaCXX/Inputs/warn-unused-variables.h:8-10
@@ +7,5 @@
+
+class B {
+ static A a;
+};
+}
----------------
Richard Smith wrote:
> This doesn't seem like a good testcase, since the variable is both unused here and cannot declare another variable which is usable from another TU without an ODR violation (ideally, we should still warn in this case).
>
> Maybe move 'class B' into the anonymous namespace too?
Done.
http://llvm-reviews.chandlerc.com/D597
More information about the cfe-commits
mailing list