[cfe-commits] r70371 - in /cfe/trunk: lib/Sema/SemaDecl.cpp test/Sema/struct-decl.c

Chris Lattner sabre at nondot.org
Tue Apr 28 22:12:23 PDT 2009


Author: lattner
Date: Wed Apr 29 00:12:23 2009
New Revision: 70371

URL: http://llvm.org/viewvc/llvm-project?rev=70371&view=rev
Log:
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 :)

Modified:
    cfe/trunk/lib/Sema/SemaDecl.cpp
    cfe/trunk/test/Sema/struct-decl.c

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=70371&r1=70370&r2=70371&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Wed Apr 29 00:12:23 2009
@@ -2895,6 +2895,7 @@
   // (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 @@
     Diag(Loc, diag::err_duplicate_member) << II;
     Diag(PrevDecl->getLocation(), diag::note_previous_declaration);
     NewFD->setInvalidDecl();
-    Record->setInvalidDecl();
   }
 
   if (getLangOptions().CPlusPlus && !T->isPODType())

Modified: cfe/trunk/test/Sema/struct-decl.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/struct-decl.c?rev=70371&r1=70370&r2=70371&view=diff

==============================================================================
--- cfe/trunk/test/Sema/struct-decl.c (original)
+++ cfe/trunk/test/Sema/struct-decl.c Wed Apr 29 00:12:23 2009
@@ -33,3 +33,11 @@
  char data;
 };
 
+
+// PR4092
+struct s0 {
+  char a;  // expected-note {{previous declaration is here}}
+  char a;  // expected-error {{duplicate member 'a'}}
+};
+
+struct s0 f0(void) {}





More information about the cfe-commits mailing list