Hi,
Implemented review comments from Eli.
Richard does this fix look good to commit?
Thanks
Karthik Bhat
Hi jordan_rose, rsmith, eli.friedman,
http://llvm-reviews.chandlerc.com/D1580
CHANGE SINCE LAST DIFF
http://llvm-reviews.chandlerc.com/D1580?vs=3982&id=4314#toc
Files:
lib/Sema/SemaChecking.cpp
test/SemaCXX/array-bounds.cpp
Index: lib/Sema/SemaChecking.cpp
===================================================================
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -6374,6 +6374,12 @@
CheckArrayAccess(rhs);
return;
}
+ case Stmt::MemberExprClass: {
+ const MemberExpr *memExpr = cast<MemberExpr>(expr);
+ const Expr *base = memExpr->getBase();
+ CheckArrayAccess(base);
+ return;
+ }
default:
return;
}
Index: test/SemaCXX/array-bounds.cpp
===================================================================
--- test/SemaCXX/array-bounds.cpp
+++ test/SemaCXX/array-bounds.cpp
@@ -253,3 +253,16 @@
int a[128]; // expected-note {{array 'a' declared here}}
a[(unsigned char)'\xA1'] = 1; // expected-warning {{array index 161 is
past the end of the array}}
}
+
+typedef struct {
+ int a;
+} structTest;
+
+void
+test_arraystructOverflow() {
+ structTest data[2]; // expected-note 2 {{array 'data' declared here}}
+ if (!data[1].a && !data[2].a) { // expected-warning {{array index 2 is past
the end of the array (which contains 2 elements)}}
+ data[2].a = 1; // expected-warning {{array index 2 is past the end of the
array (which contains 2 elements)}}
+ }
+ return;
+}
Index: lib/Sema/SemaChecking.cpp
===================================================================
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -6374,6 +6374,12 @@
CheckArrayAccess(rhs);
return;
}
+ case Stmt::MemberExprClass: {
+ const MemberExpr *memExpr = cast<MemberExpr>(expr);
+ const Expr *base = memExpr->getBase();
+ CheckArrayAccess(base);
+ return;
+ }
default:
return;
}
Index: test/SemaCXX/array-bounds.cpp
===================================================================
--- test/SemaCXX/array-bounds.cpp
+++ test/SemaCXX/array-bounds.cpp
@@ -253,3 +253,16 @@
int a[128]; // expected-note {{array 'a' declared here}}
a[(unsigned char)'\xA1'] = 1; // expected-warning {{array index 161 is past the end of the array}}
}
+
+typedef struct {
+ int a;
+} structTest;
+
+void
+test_arraystructOverflow() {
+ structTest data[2]; // expected-note 2 {{array 'data' declared here}}
+ if (!data[1].a && !data[2].a) { // expected-warning {{array index 2 is past the end of the array (which contains 2 elements)}}
+ data[2].a = 1; // expected-warning {{array index 2 is past the end of the array (which contains 2 elements)}}
+ }
+ return;
+}
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits