[cfe-commits] r161474 - in /cfe/trunk: lib/Sema/SemaDecl.cpp test/Sema/invalid-decl.c test/SemaCXX/PR9460.cpp test/SemaCXX/constructor-initializer.cpp

Eli Friedman eli.friedman at gmail.com
Tue Aug 7 21:39:56 PDT 2012


Author: efriedma
Date: Tue Aug  7 23:39:56 2012
New Revision: 161474

URL: http://llvm.org/viewvc/llvm-project?rev=161474&view=rev
Log:
Get rid of an early return in Sema::ActOnFields which doesn't make sense anymore.
Fixes a crash (<rdar://problem/11067144>), and generally seems to improve
recovery in other cases.


Modified:
    cfe/trunk/lib/Sema/SemaDecl.cpp
    cfe/trunk/test/Sema/invalid-decl.c
    cfe/trunk/test/SemaCXX/PR9460.cpp
    cfe/trunk/test/SemaCXX/constructor-initializer.cpp

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=161474&r1=161473&r2=161474&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Tue Aug  7 23:39:56 2012
@@ -9751,11 +9751,6 @@
                        AttributeList *Attr) {
   assert(EnclosingDecl && "missing record or interface decl");
 
-  // If the decl this is being inserted into is invalid, then it may be a
-  // redeclaration or some other bogus case.  Don't try to add fields to it.
-  if (EnclosingDecl->isInvalidDecl())
-    return;
-
   // If this is an Objective-C @implementation or category and we have
   // new fields here we should reset the layout of the interface since
   // it will now change.

Modified: cfe/trunk/test/Sema/invalid-decl.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/invalid-decl.c?rev=161474&r1=161473&r2=161474&view=diff
==============================================================================
--- cfe/trunk/test/Sema/invalid-decl.c (original)
+++ cfe/trunk/test/Sema/invalid-decl.c Tue Aug  7 23:39:56 2012
@@ -20,3 +20,12 @@
     sizeof(zend_module_entry)
 };
 
+// <rdar://problem/11067144>
+typedef int (FunctionType)(int *value);
+typedef struct {
+  UndefinedType undef; // expected-error {{unknown type name 'UndefinedType'}}
+  FunctionType fun; // expected-error {{field 'fun' declared as a function}}
+} StructType;
+void f(StructType *buf) {
+  buf->fun = 0;
+}

Modified: cfe/trunk/test/SemaCXX/PR9460.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/PR9460.cpp?rev=161474&r1=161473&r2=161474&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/PR9460.cpp (original)
+++ cfe/trunk/test/SemaCXX/PR9460.cpp Tue Aug  7 23:39:56 2012
@@ -8,11 +8,11 @@
   basic_string(aT*);
 };
 
-struct runtime_error{ // expected-note{{candidate constructor}}
-  runtime_error( // expected-note{{candidate constructor}}
+struct runtime_error{
+  runtime_error(
 basic_string<char> struct{ // expected-error {{cannot combine with previous 'type-name' declaration specifier}}
 a(){ // expected-error {{requires a type specifier}}
-  runtime_error(0); // expected-error{{no matching conversion for functional-style cast from 'int' to 'runtime_error'}}
+  runtime_error(0);
 }
 }
 );

Modified: cfe/trunk/test/SemaCXX/constructor-initializer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/constructor-initializer.cpp?rev=161474&r1=161473&r2=161474&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/constructor-initializer.cpp (original)
+++ cfe/trunk/test/SemaCXX/constructor-initializer.cpp Tue Aug  7 23:39:56 2012
@@ -232,13 +232,13 @@
 // <rdar://problem/8308215>: don't crash.
 // Lots of questionable recovery here;  errors can change.
 namespace test3 {
-  class A : public std::exception {}; // expected-error {{undeclared identifier}} expected-error {{expected class name}} expected-note 3 {{candidate}} expected-note {{passing argument}}
+  class A : public std::exception {}; // expected-error {{undeclared identifier}} expected-error {{expected class name}} expected-note 2 {{candidate}}
   class B : public A {
   public:
     B(const String& s, int e=0) // expected-error {{unknown type name}} 
       : A(e), m_String(s) , m_ErrorStr(__null) {} // expected-error {{no matching constructor}} expected-error {{does not name}}
     B(const B& e)
-      : A(e), m_String(e.m_String), m_ErrorStr(__null) { // expected-error {{no viable conversion}} expected-error {{does not name}}
+      : A(e), m_String(e.m_String), m_ErrorStr(__null) { // expected-error {{does not name}} expected-error {{no member named 'm_String' in 'test3::B'}}
     }
   };
 }





More information about the cfe-commits mailing list