[PATCH] D50805: [Sema] Don't warn on returning the address of a label
Reid Kleckner via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Aug 16 13:14:45 PDT 2018
rnk updated this revision to Diff 161096.
rnk added a comment.
- keep the warning, suppress stmt expr case
https://reviews.llvm.org/D50805
Files:
clang/lib/Sema/SemaInit.cpp
clang/test/Sema/statements.c
Index: clang/test/Sema/statements.c
===================================================================
--- clang/test/Sema/statements.c
+++ clang/test/Sema/statements.c
@@ -34,6 +34,15 @@
return &&bar; // expected-warning {{returning address of label, which is local}}
}
+// PR38569: Don't warn when returning a label from a statement expression.
+void test10_logpc(void*);
+void test10a() {
+ test10_logpc(({
+ my_pc:
+ &&my_pc;
+ }));
+}
+
// PR6034
void test11(int bit) {
switch (bit)
Index: clang/lib/Sema/SemaInit.cpp
===================================================================
--- clang/lib/Sema/SemaInit.cpp
+++ clang/lib/Sema/SemaInit.cpp
@@ -6923,7 +6923,7 @@
<< isa<ParmVarDecl>(DRE->getDecl()) << DiagRange;
} else if (isa<BlockExpr>(L)) {
Diag(DiagLoc, diag::err_ret_local_block) << DiagRange;
- } else if (isa<AddrLabelExpr>(L)) {
+ } else if (isa<AddrLabelExpr>(L) && LK == LK_Return) {
Diag(DiagLoc, diag::warn_ret_addr_label) << DiagRange;
} else {
Diag(DiagLoc, diag::warn_ret_local_temp_addr_ref)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D50805.161096.patch
Type: text/x-patch
Size: 1110 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180816/9f827aba/attachment.bin>
More information about the cfe-commits
mailing list