================
@@ -978,33 +978,42 @@ static QualType ConvertDeclSpecToType(TypeProcessingState
&state) {
// parser already though by it pretending to have seen an 'int' in this
// case.
if (S.getLangOpts().isImplicitIntRequired()) {
- S.Diag(DeclLoc, diag::warn_missing_type_specifier)
- << DS.getSourceRange()
- << FixItHint::CreateInsertion(DS.getBeginLoc(), "int");
+ // Only emit the diagnostic for the first declarator in a DeclGroup, as
+ // the warning is always implied for all subsequent declarators, and the
+ // fix must only be applied exactly once as well.
+ if (declarator.isFirstDeclarator()) {
+ S.Diag(DeclLoc, diag::warn_missing_type_specifier)
+ << DS.getSourceRange()
+ << FixItHint::CreateInsertion(DS.getBeginLoc(), "int ");
+ }
} else if (!DS.hasTypeSpecifier()) {
// C99 and C++ require a type specifier. For example, C99 6.7.2p2 says:
// "At least one type specifier shall be given in the declaration
- // specifiers in each declaration, and in the specifier-qualifier list in
- // each struct declaration and type name."
+ // specifiers in each declaration, and in the specifier-qualifier list
+ // in each struct declaration and type name."
if (!S.getLangOpts().isImplicitIntAllowed() && !DS.isTypeSpecPipe()) {
- S.Diag(DeclLoc, diag::err_missing_type_specifier)
- << DS.getSourceRange();
+ if (declarator.isFirstDeclarator()) {
+ S.Diag(DeclLoc, diag::err_missing_type_specifier)
+ << DS.getSourceRange();
----------------
Sirraide wrote:
I feel like this one should get a fix-it as well; can you come up w/ a test
case that triggers this error?
https://github.com/llvm/llvm-project/pull/179356
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits