[PATCH] Be yet more clever about -Wunused-value in macros

Richard Smith richard at metafoo.co.uk
Wed Feb 6 16:02:28 PST 2013



================
Comment at: lib/Sema/SemaStmt.cpp:169
@@ +168,3 @@
+  if (SourceMgr.isMacroBodyExpansion(ExprLoc) &&
+      !(isa<CallExpr>(E->IgnoreParens()) &&
+        E->getLocStart().isMacroID() &&
----------------
Matt Beaumont-Gay wrote:
> Richard Smith wrote:
> > The ad-hoc nature of this check gives me pause. I'd be more comfortable saying that __attribute__((warn_unused_result)) always gives a warning, even in a macro body.
> What about __attribute__((pure)) or methods declared const?
I think it's fine to continue to suppress the warning for those. The difference is that __attribute__((warn_unused_result)) means "it's always a bug if the result of this function is unused". That should apply even within macros, whereas the other cases may be fine, because the macro may be providing an optional (ignorable) result.


http://llvm-reviews.chandlerc.com/D380



More information about the cfe-commits mailing list