OldDecl->getStorageClass() != VarDecl::PrivateExtern &&
VD->getStorageClass() != VarDecl::Extern &&
VD->getStorageClass() != VarDecl::PrivateExtern) {
- Diag(VD->getLocation(), diag::err_redefinition, VD->getName());
+ Diag(VD->getLocation(), diag::err_redefinition) << VD->getName();
Diag(OldDecl->getLocation(), diag::err_previous_definition);
}
}
// Verify the old decl was also a variable.
VarDecl *Old = dyn_cast<VarDecl>(OldD);
if (!Old) {
- Diag(New->getLocation(), diag::err_redefinition_different_kind,
- New->getName());
+ Diag(New->getLocation(), diag::err_redefinition_different_kind)
+ << New->getName();
Diag(OldD->getLocation(), diag::err_previous_definition);
return New;
}
QualType OldCType = Context.getCanonicalType(Old->getType());
QualType NewCType = Context.getCanonicalType(New->getType());
if (OldCType != NewCType && !Context.typesAreCompatible(OldCType, NewCType)) {
- Diag(New->getLocation(), diag::err_redefinition, New->getName());
+ Diag(New->getLocation(), diag::err_redefinition) << New->getName();
Diag(Old->getLocation(), diag::err_previous_definition);
return New;
}
if (New->getStorageClass() == VarDecl::Static &&
(Old->getStorageClass() == VarDecl::None ||
Old->getStorageClass() == VarDecl::Extern)) {
- Diag(New->getLocation(), diag::err_static_non_static, New->getName());
+ Diag(New->getLocation(), diag::err_static_non_static) << New->getName();
Diag(Old->getLocation(), diag::err_previous_definition);
return New;
}
// C99 6.2.2p4: Check if we have a non-static decl followed by a static.
if (New->getStorageClass() != VarDecl::Static &&
Old->getStorageClass() == VarDecl::Static) {
- Diag(New->getLocation(), diag::err_non_static_static, New->getName());
+ Diag(New->getLocation(), diag::err_non_static_static) << New->getName();
Diag(Old->getLocation(), diag::err_previous_definition);
return New;
}
// Variables with external linkage are analyzed in FinalizeDeclaratorGroup.
if (New->getStorageClass() != VarDecl::Extern && !New->isFileVarDecl()) {
- Diag(New->getLocation(), diag::err_redefinition, New->getName());
+ Diag(New->getLocation(), diag::err_redefinition) << New->getName();
Diag(Old->getLocation(), diag::err_previous_definition);
}
return New;
// that function shall not have incomplete type.
if (Param->getType()->isIncompleteType() &&
!Param->isInvalidDecl()) {
- Diag(Param->getLocation(), diag::err_typecheck_decl_incomplete_type,
- Param->getType().getAsString());
+ Diag(Param->getLocation(), diag::err_typecheck_decl_incomplete_type)
+ << Param->getType().getAsString();
Param->setInvalidDecl();
HasInvalidParm = true;
}
case DeclSpec::SCS_auto:
case DeclSpec::SCS_register:
case DeclSpec::SCS_mutable:
- Diag(D.getIdentifierLoc(), diag::err_typecheck_sclass_func,
- R.getAsString());
+ Diag(D.getIdentifierLoc(), diag::err_typecheck_sclass_func)
+ << R.getAsString();
InvalidDecl = true;
break;
case DeclSpec::SCS_unspecified: SC = FunctionDecl::None; break;
IdentifierInfo *II = Name.getAsIdentifierInfo();
if (!II) {
- Diag(D.getIdentifierLoc(), diag::err_bad_variable_name,
- Name.getAsString());
+ Diag(D.getIdentifierLoc(), diag::err_bad_variable_name)
+ << Name.getAsString();
return 0;
}
// C99 6.9p2: The storage-class specifiers auto and register shall not
// appear in the declaration specifiers in an external declaration.
if (SC == VarDecl::Auto || SC == VarDecl::Register) {
- Diag(D.getIdentifierLoc(), diag::err_typecheck_sclass_fscope,
- R.getAsString());
+ Diag(D.getIdentifierLoc(), diag::err_typecheck_sclass_fscope)
+ << R.getAsString();
InvalidDecl = true;
}
}
if (getLangOptions().CPlusPlus &&
Context.getCanonicalType(Type).isConstQualified() &&
Var->getStorageClass() != VarDecl::Extern)
- Diag(Var->getLocation(),
- diag::err_const_var_requires_init,
- Var->getName(),
- SourceRange(Var->getLocation(), Var->getLocation()));
+ Diag(Var->getLocation(), diag::err_const_var_requires_init)
+ << Var->getName()
+ << SourceRange(Var->getLocation(), Var->getLocation());
#endif
}
}
if (IDecl->isBlockVarDecl() &&
IDecl->getStorageClass() != VarDecl::Extern) {
if (T->isIncompleteType() && !IDecl->isInvalidDecl()) {
- Diag(IDecl->getLocation(), diag::err_typecheck_decl_incomplete_type,
- T.getAsString());
+ Diag(IDecl->getLocation(), diag::err_typecheck_decl_incomplete_type)
+ << T.getAsString();
IDecl->setInvalidDecl();
}
}
// C99 6.9.2p3: If the declaration of an identifier for an object is
// a tentative definition and has internal linkage (C99 6.2.2p3), the
// declared type shall not be an incomplete type.
- Diag(IDecl->getLocation(), diag::err_typecheck_decl_incomplete_type,
- T.getAsString());
+ Diag(IDecl->getLocation(), diag::err_typecheck_decl_incomplete_type)
+ << T.getAsString();
IDecl->setInvalidDecl();
}
}
IdentifierInfo *II = D.getIdentifier();
if (Decl *PrevDecl = LookupDecl(II, Decl::IDNS_Ordinary, S)) {
if (S->isDeclScope(PrevDecl)) {
- Diag(D.getIdentifierLoc(), diag::err_param_redefinition,
- dyn_cast<NamedDecl>(PrevDecl)->getName());
+ Diag(D.getIdentifierLoc(), diag::err_param_redefinition)
+ << cast<NamedDecl>(PrevDecl)->getName();
// Recover by removing the name
II = 0;
// See if this is a redefinition.
const FunctionDecl *Definition;
if (FD->getBody(Definition)) {
- Diag(FD->getLocation(), diag::err_redefinition,
- FD->getName());
+ Diag(FD->getLocation(), diag::err_redefinition) << FD->getName();
Diag(Definition->getLocation(), diag::err_previous_definition);
}
if (I->second->getSubStmt() == 0) {
LabelStmt *L = I->second;
// Emit error.
- Diag(L->getIdentLoc(), diag::err_undeclared_label_use, L->getName());
+ Diag(L->getIdentLoc(), diag::err_undeclared_label_use) << L->getName();
// At this point, we have gotos that use the bogus label. Stitch it into
// the function body so that they aren't leaked and that the AST is well
// struct S { struct S {} X; };
// We discover this when we complete the outer S. Reject and ignore the
// outer S.
- Diag(DefRecord->getLocation(), diag::err_nested_redefinition,
- DefRecord->getKindName());
+ Diag(DefRecord->getLocation(), diag::err_nested_redefinition)
+ << DefRecord->getKindName();
Diag(RecLoc, diag::err_previous_definition);
Record->setInvalidDecl();
return;
// C99 6.7.2.1p2 - A field may not be a function type.
if (FDTy->isFunctionType()) {
- Diag(FD->getLocation(), diag::err_field_declared_as_function,
- FD->getName());
+ Diag(FD->getLocation(), diag::err_field_declared_as_function)
+ << FD->getName();
FD->setInvalidDecl();
EnclosingDecl->setInvalidDecl();
continue;
// C99 6.7.2.1p2 - A field may not be an incomplete type except...
if (FDTy->isIncompleteType()) {
if (!Record) { // Incomplete ivar type is always an error.
- Diag(FD->getLocation(), diag::err_field_incomplete, FD->getName());
+ Diag(FD->getLocation(), diag::err_field_incomplete) << FD->getName();
FD->setInvalidDecl();
EnclosingDecl->setInvalidDecl();
continue;
if (i != NumFields-1 || // ... that the last member ...
!Record->isStruct() || // ... of a structure ...
!FDTy->isArrayType()) { //... may have incomplete array type.
- Diag(FD->getLocation(), diag::err_field_incomplete, FD->getName());
+ Diag(FD->getLocation(), diag::err_field_incomplete) << FD->getName();
FD->setInvalidDecl();
EnclosingDecl->setInvalidDecl();
continue;
}
if (NumNamedMembers < 1) { //... must have more than named member ...
- Diag(FD->getLocation(), diag::err_flexible_array_empty_struct,
- FD->getName());
+ Diag(FD->getLocation(), diag::err_flexible_array_empty_struct)
+ << FD->getName();
FD->setInvalidDecl();
EnclosingDecl->setInvalidDecl();
continue;
// it. Note that GCC supports variable sized arrays in the middle of
// structures.
if (i != NumFields-1) {
- Diag(FD->getLocation(), diag::err_variable_sized_type_in_struct,
- FD->getName());
+ Diag(FD->getLocation(), diag::err_variable_sized_type_in_struct)
+ << FD->getName();
FD->setInvalidDecl();
EnclosingDecl->setInvalidDecl();
continue;
}
// We support flexible arrays at the end of structs in other structs
// as an extension.
- Diag(FD->getLocation(), diag::ext_flexible_array_in_struct,
- FD->getName());
+ Diag(FD->getLocation(), diag::ext_flexible_array_in_struct)
+ << FD->getName();
if (Record)
Record->setHasFlexibleArrayMember(true);
}
}
/// A field cannot be an Objective-c object
if (FDTy->isObjCInterfaceType()) {
- Diag(FD->getLocation(), diag::err_statically_allocated_object,
- FD->getName());
+ Diag(FD->getLocation(), diag::err_statically_allocated_object)
+ << FD->getName();
FD->setInvalidDecl();
EnclosingDecl->setInvalidDecl();
continue;
// enum e0 {
// E0 = sizeof(enum e0 { E1 })
// };
- Diag(Enum->getLocation(), diag::err_nested_redefinition,
- Enum->getName());
+ Diag(Enum->getLocation(), diag::err_nested_redefinition) << Enum->getName();
Diag(EnumLoc, diag::err_previous_definition);
Enum->setInvalidDecl();
return;
V.trunc(IntWidth);
V.extend(InitVal.getBitWidth());
if (V != InitVal)
- Diag(ECD->getLocation(), diag::ext_enum_value_not_int,
- InitVal.toString(10));
+ Diag(ECD->getLocation(), diag::ext_enum_value_not_int)
+ << InitVal.toString(10);
}
// Keep track of the size of positive and negative values.
// If a name was specified then failure indicates the name
// wasn't found. Otherwise failure indicates the stack was
// empty.
- Diag(PragmaLoc, diag::warn_pragma_pack_pop_failed,
- Name ? "no record matching name" : "stack empty");
+ Diag(PragmaLoc, diag::warn_pragma_pack_pop_failed)
+ << (Name ? "no record matching name" : "stack empty");
// FIXME: Warn about popping named records as MSVC does.
} else {
// Otherwise, this label was either forward reference or multiply defined. If
// multiply defined, reject it now.
if (LabelDecl->getSubStmt()) {
- Diag(IdentLoc, diag::err_redefinition_of_label, LabelDecl->getName());
+ Diag(IdentLoc, diag::err_redefinition_of_label) << LabelDecl->getName();
Diag(LabelDecl->getIdentLoc(), diag::err_previous_definition);
return SubStmt;
}
if (!getLangOptions().CPlusPlus) {
if (DeclStmt *DS = dyn_cast_or_null<DeclStmt>(First)) {
- // C99 6.8.5p3: The declaration part of a 'for' statement shall only declare
- // identifiers for objects having storage class 'auto' or 'register'.
+ // C99 6.8.5p3: The declaration part of a 'for' statement shall only
+ // declare identifiers for objects having storage class 'auto' or
+ // 'register'.
for (DeclStmt::decl_iterator DI=DS->decl_begin(), DE=DS->decl_end();
DI!=DE; ++DI) {
VarDecl *VD = dyn_cast<VarDecl>(*DI);
ScopedDecl *D = DS->getSolitaryDecl();
FirstType = cast<ValueDecl>(D)->getType();
- // C99 6.8.5p3: The declaration part of a 'for' statement shall only declare
- // identifiers for objects having storage class 'auto' or 'register'.
+ // C99 6.8.5p3: The declaration part of a 'for' statement shall only
+ // declare identifiers for objects having storage class 'auto' or
+ // 'register'.
VarDecl *VD = cast<VarDecl>(D);
if (VD->isBlockVarDecl() && !VD->hasLocalStorage())
return Diag(VD->getLocation(), diag::err_non_variable_decl_in_for);
if (!Context.Target.validateOutputConstraint(OutputConstraint.c_str(),info))
// FIXME: We currently leak memory here.
return Diag(Literal->getLocStart(),
- diag::err_asm_invalid_output_constraint, OutputConstraint);
+ diag::err_asm_invalid_output_constraint) << OutputConstraint;
// Check that the output exprs are valid lvalues.
ParenExpr *OutputExpr = cast<ParenExpr>(Exprs[i]);
if (!Context.Target.isValidGCCRegisterName(Clobber.c_str()))
// FIXME: We currently leak memory here.
return Diag(Literal->getLocStart(),
- diag::err_asm_unknown_register_name, Clobber.c_str());
+ diag::err_asm_unknown_register_name) << Clobber.c_str();
}
return new AsmStmt(AsmLoc, IsSimple, IsVolatile, NumOutputs, NumInputs,