improve diagnostics for case when a field type is unknown by
not emitting a follow-on error about 'int', which the user
never wrote. PR5924.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92339 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp
index ab90a80..f1474cd 100644
--- a/lib/Sema/SemaDeclCXX.cpp
+++ b/lib/Sema/SemaDeclCXX.cpp
@@ -1155,7 +1155,8 @@
}
else
NewExp = (Expr*)Args[0];
- if (PerformCopyInitialization(NewExp, FieldType, AA_Passing))
+ if (!Member->isInvalidDecl() &&
+ PerformCopyInitialization(NewExp, FieldType, AA_Passing))
return true;
Args[0] = NewExp;
}
diff --git a/test/SemaCXX/illegal-member-initialization.cpp b/test/SemaCXX/illegal-member-initialization.cpp
index ceefa5d..1890dbc 100644
--- a/test/SemaCXX/illegal-member-initialization.cpp
+++ b/test/SemaCXX/illegal-member-initialization.cpp
@@ -20,3 +20,13 @@
B& b; // expected-note{{declared at}}
const B cb; // expected-note{{declared at}}
};
+
+
+// PR5924
+struct bar {};
+bar xxx();
+
+struct foo {
+ foo_t a; // expected-error {{unknown type name 'foo_t'}}
+ foo() : a(xxx()) {} // no error here.
+};