summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/RunClang.cxx40
-rw-r--r--test/CMakeLists.txt2
-rw-r--r--test/expect/gccxml.any.Class-implicit-member-bad-base.stdout.txt (renamed from test/expect/gccxml.broken.any.Class-implicit-member-bad-base.stdout.txt)0
-rw-r--r--test/expect/gccxml.any.Class-implicit-member-bad-base.xml.txt26
-rw-r--r--test/expect/gccxml.broken.any.Class-implicit-member-bad-base.result.txt1
-rw-r--r--test/expect/gccxml.broken.any.Class-implicit-member-bad-base.stderr.txt2
-rw-r--r--test/expect/gccxml.c++98.Class-template-bases.xml.txt6
7 files changed, 41 insertions, 36 deletions
diff --git a/src/RunClang.cxx b/src/RunClang.cxx
index b73d801..8346b09 100644
--- a/src/RunClang.cxx
+++ b/src/RunClang.cxx
@@ -61,40 +61,16 @@ public:
clang::Sema& sema = this->CI.getSema();
sema.ForceDeclarationOfImplicitMembers(rd);
-# define DEFINE_IMPLICIT(name, decl) do { \
- clang::Sema::SFINAETrap trap(sema, /*AccessChecking=*/ true); \
- sema.DefineImplicit##name(clang::SourceLocation(), (decl)); \
- if (trap.hasErrorOccurred()) { \
- (decl)->setInvalidDecl(); \
- } \
- } while(0)
-
for(clang::DeclContext::decl_iterator i = rd->decls_begin(),
e = rd->decls_end(); i != e; ++i) {
clang::CXXMethodDecl* m = clang::dyn_cast<clang::CXXMethodDecl>(*i);
- if(m && m->isImplicit() && !m->isDeleted() &&
- !m->doesThisDeclarationHaveABody()) {
- if (clang::CXXConstructorDecl* c =
- clang::dyn_cast<clang::CXXConstructorDecl>(m)) {
- if (c->isDefaultConstructor()) {
- DEFINE_IMPLICIT(DefaultConstructor, c);
- } else if (c->isCopyConstructor()) {
- DEFINE_IMPLICIT(CopyConstructor, c);
- } else if (c->isMoveConstructor()) {
- DEFINE_IMPLICIT(MoveConstructor, c);
- }
- } else if (clang::CXXDestructorDecl* d =
- clang::dyn_cast<clang::CXXDestructorDecl>(m)) {
- DEFINE_IMPLICIT(Destructor, d);
- } else if (m->isCopyAssignmentOperator()) {
- DEFINE_IMPLICIT(CopyAssignment, m);
- } else if (m->isMoveAssignmentOperator()) {
- DEFINE_IMPLICIT(MoveAssignment, m);
- }
+ if(m && !m->isDeleted() && !m->isInvalidDecl()) {
+ /* Ensure the member is defined. */
+ sema.MarkFunctionReferenced(clang::SourceLocation(), m);
+ /* Finish implicitly instantiated member. */
+ sema.PerformPendingInstantiations();
}
}
-
-# undef DEFINE_IMPLICIT
}
void HandleTagDeclDefinition(clang::TagDecl* d) {
@@ -108,6 +84,12 @@ public:
void HandleTranslationUnit(clang::ASTContext& ctx) {
clang::Sema& sema = this->CI.getSema();
+ // Perform instantiations needed by the original translation unit.
+ sema.PerformPendingInstantiations();
+
+ // Suppress diagnostics from below extensions to the translation unit.
+ sema.getDiagnostics().setSuppressAllDiagnostics(true);
+
// Add implicit members to classes.
for(clang::CXXRecordDecl* rd : this->Classes) {
this->AddImplicitMembers(rd);
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 4675d12..5978260 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -146,6 +146,7 @@ castxml_test_gccxml(Class-friends)
castxml_test_gccxml(Class-implicit-member-access)
castxml_test_gccxml(Class-implicit-member-access-mutable)
castxml_test_gccxml(Class-implicit-member-array)
+castxml_test_gccxml(Class-implicit-member-bad-base)
castxml_test_gccxml(Class-implicit-member-const)
castxml_test_gccxml(Class-implicit-member-reference)
castxml_test_gccxml(Class-implicit-members)
@@ -222,6 +223,5 @@ castxml_test_gccxml_c(Typedef-called-class)
castxml_test_gccxml_c(invalid)
-castxml_test_gccxml_broken(Class-implicit-member-bad-base)
castxml_test_gccxml_broken(Class-template-constructor-template)
castxml_test_gccxml_broken(ReferenceType-to-Class-template)
diff --git a/test/expect/gccxml.broken.any.Class-implicit-member-bad-base.stdout.txt b/test/expect/gccxml.any.Class-implicit-member-bad-base.stdout.txt
index 10f3293..10f3293 100644
--- a/test/expect/gccxml.broken.any.Class-implicit-member-bad-base.stdout.txt
+++ b/test/expect/gccxml.any.Class-implicit-member-bad-base.stdout.txt
diff --git a/test/expect/gccxml.any.Class-implicit-member-bad-base.xml.txt b/test/expect/gccxml.any.Class-implicit-member-bad-base.xml.txt
new file mode 100644
index 0000000..3f73cac
--- /dev/null
+++ b/test/expect/gccxml.any.Class-implicit-member-bad-base.xml.txt
@@ -0,0 +1,26 @@
+^<\?xml version="1.0"\?>
+<GCC_XML[^>]*>
+ <Class id="_1" name="start" context="_2" location="f1:9" file="f1" line="9" members="_3 _4 _5" bases="_6">
+ <Base type="_6" access="public" virtual="0"/>
+ </Class>
+ <Constructor id="_3" name="start" context="_1" access="public" location="f1:9" file="f1" line="9" inline="1" artificial="1"( throws="")?/>
+ <Constructor id="_4" name="start" context="_1" access="public" location="f1:9" file="f1" line="9" inline="1" artificial="1"( throws="")?>
+ <Argument type="_7" location="f1:9" file="f1" line="9"/>
+ </Constructor>
+ <Destructor id="_5" name="start" context="_1" access="public" location="f1:9" file="f1" line="9" inline="1" artificial="1"( throws="")?/>
+ <Class id="_6" name="base&lt;const int&gt;" context="_2" location="f1:1" file="f1" line="1" members="_8 _9 _10 _11"/>
+ <ReferenceType id="_7" type="_1c"/>
+ <Field id="_8" name="data" type="_13" context="_6" access="protected" location="f1:3" file="f1" line="3"/>
+ <Constructor id="_9" name="base" context="_6" access="protected" location="f1:4" file="f1" line="4"/>
+ <Constructor id="_10" name="base" context="_6" access="public" location="f1:1" file="f1" line="1" inline="1" artificial="1"( throws="")?>
+ <Argument type="_14" location="f1:1" file="f1" line="1"/>
+ </Constructor>
+ <Destructor id="_11" name="base" context="_6" access="public" location="f1:1" file="f1" line="1" inline="1" artificial="1"( throws="")?/>
+ <CvQualifiedType id="_15c" type="_15" const="1"/>
+ <ReferenceType id="_14" type="_6c"/>
+ <FundamentalType id="_15" name="int"/>
+ <Namespace id="_2" name="::"/>
+ <CvQualifiedType id="_1c" type="_1" const="1"/>
+ <CvQualifiedType id="_6c" type="_6" const="1"/>
+ <File id="f1" name=".*/test/input/Class-implicit-member-bad-base.cxx"/>
+</GCC_XML>$
diff --git a/test/expect/gccxml.broken.any.Class-implicit-member-bad-base.result.txt b/test/expect/gccxml.broken.any.Class-implicit-member-bad-base.result.txt
deleted file mode 100644
index d00491f..0000000
--- a/test/expect/gccxml.broken.any.Class-implicit-member-bad-base.result.txt
+++ /dev/null
@@ -1 +0,0 @@
-1
diff --git a/test/expect/gccxml.broken.any.Class-implicit-member-bad-base.stderr.txt b/test/expect/gccxml.broken.any.Class-implicit-member-bad-base.stderr.txt
deleted file mode 100644
index 7f45214..0000000
--- a/test/expect/gccxml.broken.any.Class-implicit-member-bad-base.stderr.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-.*/test/input/Class-implicit-member-bad-base.cxx:6:16: error: read-only variable is not assignable
-.*/test/input/Class-implicit-member-bad-base.cxx:9:7: note: in instantiation of member function 'base<const int>::operator=' requested here
diff --git a/test/expect/gccxml.c++98.Class-template-bases.xml.txt b/test/expect/gccxml.c++98.Class-template-bases.xml.txt
index 327ac3d..448de83 100644
--- a/test/expect/gccxml.c++98.Class-template-bases.xml.txt
+++ b/test/expect/gccxml.c++98.Class-template-bases.xml.txt
@@ -4,7 +4,7 @@
<Base type="_7" access="public" virtual="0"/>
<Base type="_8" access="public" virtual="0"/>
</Class>
- <Constructor id="_3" name="start" context="_1" access="public" location="f1:4" file="f1" line="4" inline="1" artificial="1" throws=""/>
+ <Constructor id="_3" name="start" context="_1" access="public" location="f1:4" file="f1" line="4" inline="1" artificial="1"( throws="")?/>
<Constructor id="_4" name="start" context="_1" access="public" location="f1:4" file="f1" line="4" inline="1" artificial="1" throws="">
<Argument type="_9" location="f1:4" file="f1" line="4"/>
</Constructor>
@@ -16,7 +16,7 @@
<Class id="_8" name="dependent_base&lt;int&gt;" context="_2" location="f1:2" file="f1" line="2" members="_15 _16 _17 _18"/>
<ReferenceType id="_9" type="_1c"/>
<ReferenceType id="_10" type="_1"/>
- <Constructor id="_11" name="non_dependent_base" context="_7" access="public" location="f1:1" file="f1" line="1" inline="1" artificial="1" throws=""/>
+ <Constructor id="_11" name="non_dependent_base" context="_7" access="public" location="f1:1" file="f1" line="1" inline="1" artificial="1"( throws="")?/>
<Constructor id="_12" name="non_dependent_base" context="_7" access="public" location="f1:1" file="f1" line="1" inline="1" artificial="1" throws="">
<Argument type="_20" location="f1:1" file="f1" line="1"/>
</Constructor>
@@ -24,7 +24,7 @@
<Argument type="_20" location="f1:1" file="f1" line="1"/>
</OperatorMethod>
<Destructor id="_14" name="non_dependent_base" context="_7" access="public" location="f1:1" file="f1" line="1" inline="1" artificial="1" throws=""/>
- <Constructor id="_15" name="dependent_base" context="_8" access="public" location="f1:2" file="f1" line="2" inline="1" artificial="1" throws=""/>
+ <Constructor id="_15" name="dependent_base" context="_8" access="public" location="f1:2" file="f1" line="2" inline="1" artificial="1"( throws="")?/>
<Constructor id="_16" name="dependent_base" context="_8" access="public" location="f1:2" file="f1" line="2" inline="1" artificial="1" throws="">
<Argument type="_22" location="f1:2" file="f1" line="2"/>
</Constructor>