aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaChecking.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Sema/SemaChecking.cpp')
-rw-r--r--lib/Sema/SemaChecking.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/Sema/SemaChecking.cpp b/lib/Sema/SemaChecking.cpp
index 28085ef6ea..81ae7b3afb 100644
--- a/lib/Sema/SemaChecking.cpp
+++ b/lib/Sema/SemaChecking.cpp
@@ -3491,7 +3491,9 @@ static void CheckArrayAccess_Check(Sema &S,
else if (size.getBitWidth() < index.getBitWidth())
size = size.sext(index.getBitWidth());
- if (index.slt(size))
+ // Don't warn for valid indexes, or arrays of size 1 (which are often
+ // tail-allocated arrays that are emulating flexible arrays in C89 code).
+ if (index.slt(size) || size == 1)
return;
S.DiagRuntimeBehavior(E->getBase()->getLocStart(), BaseExpr,