From 06808f1b880f461c396450db4c6a9c6d6c6c2efc Mon Sep 17 00:00:00 2001 From: Eli Friedman Date: Wed, 8 Aug 2012 04:39:56 +0000 Subject: [PATCH] Get rid of an early return in Sema::ActOnFields which doesn't make sense anymore. Fixes a crash (), and generally seems to improve recovery in other cases. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@161474 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaDecl.cpp | 5 ----- test/Sema/invalid-decl.c | 9 +++++++++ test/SemaCXX/PR9460.cpp | 6 +++--- test/SemaCXX/constructor-initializer.cpp | 4 ++-- 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index ffe45fad03..869fedb00c 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -9751,11 +9751,6 @@ void Sema::ActOnFields(Scope* S, 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. diff --git a/test/Sema/invalid-decl.c b/test/Sema/invalid-decl.c index a5e7ad3b1e..2699b25492 100644 --- a/test/Sema/invalid-decl.c +++ b/test/Sema/invalid-decl.c @@ -20,3 +20,12 @@ zend_module_entry openssl_module_entry = { sizeof(zend_module_entry) }; +// +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; +} diff --git a/test/SemaCXX/PR9460.cpp b/test/SemaCXX/PR9460.cpp index 5b8b7b2cf6..0dd8446770 100644 --- a/test/SemaCXX/PR9460.cpp +++ b/test/SemaCXX/PR9460.cpp @@ -8,11 +8,11 @@ struct basic_string{ basic_string(aT*); }; -struct runtime_error{ // expected-note{{candidate constructor}} - runtime_error( // expected-note{{candidate constructor}} +struct runtime_error{ + runtime_error( basic_string 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); } } ); diff --git a/test/SemaCXX/constructor-initializer.cpp b/test/SemaCXX/constructor-initializer.cpp index 1a4e54444f..f503d01f36 100644 --- a/test/SemaCXX/constructor-initializer.cpp +++ b/test/SemaCXX/constructor-initializer.cpp @@ -232,13 +232,13 @@ namespace PR7402 { // : 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'}} } }; } -- 2.40.0