[Diagnostics] Skip var decl of structs for -Wstring-concatenation

This commit is contained in:
Dávid Bolvanský 2020-08-13 20:19:21 +02:00
parent e137b55058
commit 2f7adf5ee3
2 changed files with 9 additions and 2 deletions

View File

@ -12886,7 +12886,8 @@ void Sema::CheckCompleteVariableDeclaration(VarDecl *var) {
AttributeCommonInfo::AS_Pragma));
}
if (var->hasInit() && isa<InitListExpr>(var->getInit())) {
if (!var->getType()->isStructureType() && var->hasInit() &&
isa<InitListExpr>(var->getInit())) {
const auto *ILE = cast<InitListExpr>(var->getInit());
unsigned NumInits = ILE->getNumInits();
if (NumInits > 2)
@ -12927,7 +12928,7 @@ void Sema::CheckCompleteVariableDeclaration(VarDecl *var) {
Diag(SL->getBeginLoc(),
diag::note_concatenated_string_literal_silence);
}
// Warn just once.
// In any case, stop now.
break;
}
}

View File

@ -148,6 +148,12 @@ const A not_warn6 = A{"",
""};
#endif
static A not_warn7 = {"",
""
"",
""};
// Do not warn when all the elements in the initializer are concatenated together.
const char *all_elems_in_init_concatenated[] = {"a" "b" "c"};