[PATCH] Do not parse members of incomplete class.
Serge Pavlov
sepavloff at gmail.com
Wed Jun 10 12:11:17 PDT 2015
REPOSITORY
rL LLVM
http://reviews.llvm.org/D8010
Files:
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/SemaCXX/incomplete-call.cpp
Index: cfe/trunk/lib/Sema/SemaDecl.cpp
===================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp
+++ cfe/trunk/lib/Sema/SemaDecl.cpp
@@ -4663,12 +4663,14 @@
RequireCompleteDeclContext(D.getCXXScopeSpec(), DC))
return nullptr;
+ // If a class is incomplete, do not parse entities inside it.
if (isa<CXXRecordDecl>(DC) && !cast<CXXRecordDecl>(DC)->hasDefinition()) {
Diag(D.getIdentifierLoc(),
diag::err_member_def_undefined_record)
<< Name << DC << D.getCXXScopeSpec().getRange();
- D.setInvalidType();
- } else if (!D.getDeclSpec().isFriendSpecified()) {
+ return nullptr;
+ }
+ if (!D.getDeclSpec().isFriendSpecified()) {
if (diagnoseQualifiedDeclaration(D.getCXXScopeSpec(), DC,
Name, D.getIdentifierLoc())) {
if (DC->isRecord())
Index: cfe/trunk/test/SemaCXX/incomplete-call.cpp
===================================================================
--- cfe/trunk/test/SemaCXX/incomplete-call.cpp
+++ cfe/trunk/test/SemaCXX/incomplete-call.cpp
@@ -47,3 +47,15 @@
void test_incomplete_object_call(C& c) {
c(); // expected-error{{incomplete type in call to object of type}}
}
+
+namespace pr18542 {
+ struct X {
+ int count;
+ template<typename CharT> class basic_istream;
+ template<typename CharT>
+ void basic_istream<CharT>::read() { // expected-error{{out-of-line definition of 'read' from class 'basic_istream<CharT>' without definition}}
+ count = 0;
+ }
+ };
+}
+
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D8010.27461.patch
Type: text/x-patch
Size: 1577 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150610/1ad35b11/attachment.bin>
More information about the cfe-commits
mailing list