for (unsigned i = 0, e = StrLen; i != e; ++i) {
llvm::APInt CodeUnit(PromotedCharTyWidth, SL->getCodeUnit(i));
Expr *Init = new (Context) IntegerLiteral(
- Context, CodeUnit, PromotedCharTy, SourceLocation());
+ Context, CodeUnit, PromotedCharTy, SubExpr->getExprLoc());
if (CharTy != PromotedCharTy)
Init = ImplicitCastExpr::Create(Context, CharTy, CK_IntegralCast,
Init, 0, VK_RValue);
for (unsigned i = 0, e = StrLen; i != e; ++i) {
llvm::APInt CodeUnit(PromotedCharTyWidth, Str[i]);
Expr *Init = new (Context) IntegerLiteral(
- Context, CodeUnit, PromotedCharTy, SourceLocation());
+ Context, CodeUnit, PromotedCharTy, SubExpr->getExprLoc());
if (CharTy != PromotedCharTy)
Init = ImplicitCastExpr::Create(Context, CharTy, CK_IntegralCast,
Init, 0, VK_RValue);
.a = 0,
.b = 1 // expected-error{{field designator 'b' does not refer to any field}}
} } };
+
+// Check initializer override warnings overriding a character in a string
+struct overwrite_string_struct {
+ char L[6];
+ int M;
+} overwrite_string[] = {
+ { { "foo" }, 1 }, // expected-note {{previous initialization is here}}
+ [0].L[2] = 'x' // expected-warning{{initializer overrides prior initialization of this subobject}}
+};
+struct overwrite_string_struct2 {
+ char L[6];
+ int M;
+} overwrite_string2[] = {
+ { { "foo" }, 1 },
+ [0].L[4] = 'x' // no-warning
+ };