[PATCH] D131892: [Sema] fix false -Wcomma being emitted from void returning functions
Aaron Ballman via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Aug 15 10:50:52 PDT 2022
aaron.ballman added a comment.
Thank you for working on this fix! I think it's quite close to finished, but it needs some additional test coverage. Also, please add a release note about the fix so users know what's going on.
================
Comment at: clang/lib/Sema/SemaExpr.cpp:13978-13980
+ if (const CallExpr *CE = dyn_cast<CallExpr>(E))
+ if (const Type *T = CE->getCallReturnType(Context).getTypePtrOrNull())
+ return T->isVoidType();
----------------
================
Comment at: clang/test/SemaCXX/warn-comma-operator.cpp:151
+ // Descriptions about -Wcomma: https://reviews.llvm.org/D3976
+}
+
----------------
Can you also add test cases like:
```
struct S {
void mem();
};
typedef void Void;
Void typedef_func();
void whatever() {
S s;
// Member function calls also work as expected.
s.mem(), int_func();
// As do lambda calls.
[]() { return; }(), int_func();
// And we don't get confused about type aliases.
typedef_func(), int_func();
// Even function pointers don't confuse us.
void (*fp)() = void_func;
fp(), int_func();
}
```
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D131892/new/
https://reviews.llvm.org/D131892
More information about the cfe-commits
mailing list