summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDecl.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-01-19 19:26:10 +0000
committerDouglas Gregor <dgregor@apple.com>2009-01-19 19:26:10 +0000
commitdd430f7ec9511f440a55d090c1a8d4df118e0e68 (patch)
tree7b670938f8911ad43483817101a0f90454211517 /clang/lib/Sema/SemaDecl.cpp
parentababe7d47df60f0a68b3a3712de4032e1a12d3fb (diff)
downloadbcm5719-llvm-dd430f7ec9511f440a55d090c1a8d4df118e0e68.tar.gz
bcm5719-llvm-dd430f7ec9511f440a55d090c1a8d4df118e0e68.zip
Centralize error reporting of improper uses of incomplete types in the
new DiagnoseIncompleteType. It provides additional information about struct/class/union/enum types when possible, either by pointing to the forward declaration of that type or by pointing to the definition (if we're in the process of defining that type). Fixes <rdar://problem/6500531>. llvm-svn: 62521
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
-rw-r--r--clang/lib/Sema/SemaDecl.cpp25
1 files changed, 13 insertions, 12 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index cff01c65301..fe604960f72 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -705,10 +705,9 @@ bool Sema::CheckParmsForFunctionDef(FunctionDecl *FD) {
// C99 6.7.5.3p4: the parameters in a parameter type list in a
// function declarator that is part of a function definition of
// that function shall not have incomplete type.
- if (Param->getType()->isIncompleteType() &&
- !Param->isInvalidDecl()) {
- Diag(Param->getLocation(), diag::err_typecheck_decl_incomplete_type)
- << Param->getType();
+ if (!Param->isInvalidDecl() &&
+ DiagnoseIncompleteType(Param->getLocation(), Param->getType(),
+ diag::err_typecheck_decl_incomplete_type)) {
Param->setInvalidDecl();
HasInvalidParm = true;
}
@@ -2503,10 +2502,10 @@ Sema::DeclTy *Sema::FinalizeDeclaratorGroup(Scope *S, DeclTy *group) {
// no linkage (C99 6.2.2p6), the type for the object shall be complete...
if (IDecl->isBlockVarDecl() &&
IDecl->getStorageClass() != VarDecl::Extern) {
- if (T->isIncompleteType() && !IDecl->isInvalidDecl()) {
- Diag(IDecl->getLocation(), diag::err_typecheck_decl_incomplete_type)<<T;
+ if (!IDecl->isInvalidDecl() &&
+ DiagnoseIncompleteType(IDecl->getLocation(), T,
+ diag::err_typecheck_decl_incomplete_type))
IDecl->setInvalidDecl();
- }
}
// File scope. C99 6.9.2p2: A declaration of an identifier for and
// object that has file scope without an initializer, and without a
@@ -2517,13 +2516,13 @@ Sema::DeclTy *Sema::FinalizeDeclaratorGroup(Scope *S, DeclTy *group) {
if (T->isIncompleteArrayType()) {
// C99 6.9.2 (p2, p5): Implicit initialization causes an incomplete
// array to be completed. Don't issue a diagnostic.
- } else if (T->isIncompleteType() && !IDecl->isInvalidDecl()) {
+ } else if (!IDecl->isInvalidDecl() &&
+ DiagnoseIncompleteType(IDecl->getLocation(), T,
+ diag::err_typecheck_decl_incomplete_type))
// 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;
IDecl->setInvalidDecl();
- }
}
if (IDecl->isFileVarDecl())
CheckForFileScopedRedefinitions(S, IDecl);
@@ -3382,7 +3381,8 @@ void Sema::ActOnFields(Scope* S,
// 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->getDeclName();
+ DiagnoseIncompleteType(FD->getLocation(), FD->getType(),
+ diag::err_field_incomplete);
FD->setInvalidDecl();
EnclosingDecl->setInvalidDecl();
continue;
@@ -3390,7 +3390,8 @@ void Sema::ActOnFields(Scope* S,
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->getDeclName();
+ DiagnoseIncompleteType(FD->getLocation(), FD->getType(),
+ diag::err_field_incomplete);
FD->setInvalidDecl();
EnclosingDecl->setInvalidDecl();
continue;
OpenPOWER on IntegriCloud