Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 3fa7f98

Browse filesBrowse files
Abseil Teamcopybara-github
Abseil Team
authored andcommitted
Shut up a Clang warning.
Clang warns on this pattern because it looks like the author might have meant to use the value of the first part of the comma operator, so it warns that it isn't being used. The cast here signals to Clang that this behavior is intentional. This was discovered while updating gmock in Android. Clang's -Wcomma warning is on by default with either -Wall or -Werror, so users of gmock with those on in combination with -Werror are unable to build without this fix. PiperOrigin-RevId: 495655990 Change-Id: Iaf27e2199669f5b6185a877738234e551b6b6556
1 parent 41fe6be commit 3fa7f98
Copy full SHA for 3fa7f98

File tree

1 file changed

+6
-1
lines changed
Filter options

1 file changed

+6
-1
lines changed

‎googlemock/include/gmock/gmock-matchers.h

Copy file name to clipboardExpand all lines: googlemock/include/gmock/gmock-matchers.h
+6-1Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4098,7 +4098,12 @@ class ArgsMatcherImpl : public MatcherInterface<ArgsTuple> {
40984098
const char* sep = "";
40994099
// Workaround spurious C4189 on MSVC<=15.7 when k is empty.
41004100
(void)sep;
4101-
const char* dummy[] = {"", (*os << sep << "#" << k, sep = ", ")...};
4101+
// The static_cast to void is needed to silence Clang's -Wcomma warning.
4102+
// This pattern looks suspiciously like we may have mismatched parentheses
4103+
// and may have been trying to use the first operation of the comma operator
4104+
// as a member of the array, so Clang warns that we may have made a mistake.
4105+
const char* dummy[] = {
4106+
"", (static_cast<void>(*os << sep << "#" << k), sep = ", ")...};
41024107
(void)dummy;
41034108
*os << ") ";
41044109
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.