dyn_cast<DeclRefExpr>(ae->getBase()->IgnoreParenImpCasts());
if (!dr)
return;
- const VarDecl *vd = cast<VarDecl>(dr->getDecl());
+ const VarDecl *vd = dyn_cast<VarDecl>(dr->getDecl());
+ if (!vd)
+ return;
const ConstantArrayType *cat = Context.getAsConstantArrayType(vd->getType());
if (!cat)
return;
x[sizeof(x[2])]; // expected-warning{{array index of '4' indexes past the end of an array (that contains 2 elements)}}
}
+// This code example tests that -Warray-bounds works with arrays that
+// are template parameters.
+template <char *sz> class Qux {
+ bool test() { return sz[0] == 'a'; }
+};
\ No newline at end of file