summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-04-29 05:12:23 +0000
committerChris Lattner <sabre@nondot.org>2009-04-29 05:12:23 +0000
commit0f94c5a741cf27e869905e98653e08f308d17043 (patch)
tree150789143d26cb85e10b434050cb54b80acf4c84
parent0b50fb1de13ca200a5beddc55c249b5e777112cc (diff)
downloadbcm5719-llvm-0f94c5a741cf27e869905e98653e08f308d17043.tar.gz
bcm5719-llvm-0f94c5a741cf27e869905e98653e08f308d17043.zip
Fix PR4092 by improving error recovery in two ways:
1. In a struct field redefinition, don't mark the struct erroneous. The field is erroneous, but the struct is otherwise well formed. 2. Don't emit diagnostics about functions that are known to be broken already. Either fix is sufficient to silence the second diagnostic in the example, but the combination is better :) llvm-svn: 70371
-rw-r--r--clang/lib/Sema/SemaDecl.cpp2
-rw-r--r--clang/test/Sema/struct-decl.c8
2 files changed, 9 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 4427f0de1f2..14136a30b69 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -2895,6 +2895,7 @@ Sema::DeclPtrTy Sema::ActOnStartOfFunctionDef(Scope *FnBodyScope, DeclPtrTy D) {
// (C99 6.9.1p3, C++ [dcl.fct]p6).
QualType ResultType = FD->getResultType();
if (!ResultType->isDependentType() && !ResultType->isVoidType() &&
+ !FD->isInvalidDecl() &&
RequireCompleteType(FD->getLocation(), ResultType,
diag::err_func_def_incomplete_result))
FD->setInvalidDecl();
@@ -3713,7 +3714,6 @@ FieldDecl *Sema::CheckFieldDecl(DeclarationName Name, QualType T,
Diag(Loc, diag::err_duplicate_member) << II;
Diag(PrevDecl->getLocation(), diag::note_previous_declaration);
NewFD->setInvalidDecl();
- Record->setInvalidDecl();
}
if (getLangOptions().CPlusPlus && !T->isPODType())
diff --git a/clang/test/Sema/struct-decl.c b/clang/test/Sema/struct-decl.c
index b288850a731..2c0945f9f86 100644
--- a/clang/test/Sema/struct-decl.c
+++ b/clang/test/Sema/struct-decl.c
@@ -33,3 +33,11 @@ struct datatag {
char data;
};
+
+// PR4092
+struct s0 {
+ char a; // expected-note {{previous declaration is here}}
+ char a; // expected-error {{duplicate member 'a'}}
+};
+
+struct s0 f0(void) {}
OpenPOWER on IntegriCloud