aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSam Weinig <sam.weinig@gmail.com>2009-09-14 01:58:58 +0000
committerSam Weinig <sam.weinig@gmail.com>2009-09-14 01:58:58 +0000
commit76e2b710a92bceb9575a81db181109664946986e (patch)
treecc96fe8e937f23e65569265c66906ef2ad2d44cc /lib
parent283e4d59b8fe63e93f20b6ffb3a623a4f60a85ea (diff)
Add support for -Wchar-subscripts. Fixes PR4801.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81747 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Sema/SemaExpr.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index 11bd323011..32d3e06e3e 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -1809,6 +1809,9 @@ Sema::ActOnArraySubscriptExpr(Scope *S, ExprArg Base, SourceLocation LLoc,
return ExprError(Diag(LLoc, diag::err_typecheck_subscript_not_integer)
<< IndexExpr->getSourceRange());
+ if (IndexExpr->getType()->isCharType() && !IndexExpr->isTypeDependent())
+ Diag(LLoc, diag::warn_subscript_is_char) << IndexExpr->getSourceRange();
+
// C99 6.5.2.1p1: "shall have type "pointer to *object* type". Similarly,
// C++ [expr.sub]p1: The type "T" shall be a completely-defined object
// type. Note that Functions are not objects, and that (in C99 parlance)