From 7f62b3ae7ba4ada760b1f519e2c70569b02b84d0 Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 8 Apr 2014 11:12:23 -0400 Subject: test: Show failure when implicit member needs bad template instantiation When a function template (or member of a class template) is instantiated by an implicit class member definition, Clang delays the instantiation for later handling by clang::Sema::PerformPendingInstantiations during clang::Sema::ActOnEndOfTranslationUnit. If the instantiation causes errors they are not suppressed because our clang::Sema::SFINAETrap has gone out of scope. Even if we could keep a clang::Sema::SFINAETrap in scope, the clang::Sema::InstantiatingTemplate::Initialize method sets sema.InNonInstantiationSFINAEContext to false and adds an entry to sema.ActiveTemplateInstantiations. This prevents the clang::Sema::EmitCurrentDiagnostic call to isSFINAEContext from returning a valid SFINAE context, so errors are still not suppressed. Add a test case demonstrating this known failure, and mark it as "broken". This will require changes to Clang to fix. --- test/CMakeLists.txt | 1 + .../gccxml.broken.Class-implicit-member-bad-base-result.txt | 1 + .../gccxml.broken.Class-implicit-member-bad-base-stderr.txt | 2 ++ .../gccxml.broken.Class-implicit-member-bad-base-stdout.txt | 1 + test/input/Class-implicit-member-bad-base.cxx | 9 +++++++++ 5 files changed, 14 insertions(+) create mode 100644 test/expect/gccxml.broken.Class-implicit-member-bad-base-result.txt create mode 100644 test/expect/gccxml.broken.Class-implicit-member-bad-base-stderr.txt create mode 100644 test/expect/gccxml.broken.Class-implicit-member-bad-base-stdout.txt create mode 100644 test/input/Class-implicit-member-bad-base.cxx diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index f386e41..11110ee 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -163,5 +163,6 @@ 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.Class-implicit-member-bad-base-result.txt b/test/expect/gccxml.broken.Class-implicit-member-bad-base-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/test/expect/gccxml.broken.Class-implicit-member-bad-base-result.txt @@ -0,0 +1 @@ +1 diff --git a/test/expect/gccxml.broken.Class-implicit-member-bad-base-stderr.txt b/test/expect/gccxml.broken.Class-implicit-member-bad-base-stderr.txt new file mode 100644 index 0000000..7f45214 --- /dev/null +++ b/test/expect/gccxml.broken.Class-implicit-member-bad-base-stderr.txt @@ -0,0 +1,2 @@ +.*/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::operator=' requested here diff --git a/test/expect/gccxml.broken.Class-implicit-member-bad-base-stdout.txt b/test/expect/gccxml.broken.Class-implicit-member-bad-base-stdout.txt new file mode 100644 index 0000000..10f3293 --- /dev/null +++ b/test/expect/gccxml.broken.Class-implicit-member-bad-base-stdout.txt @@ -0,0 +1 @@ +^$ diff --git a/test/input/Class-implicit-member-bad-base.cxx b/test/input/Class-implicit-member-bad-base.cxx new file mode 100644 index 0000000..0a69e73 --- /dev/null +++ b/test/input/Class-implicit-member-bad-base.cxx @@ -0,0 +1,9 @@ +template class base { +protected: + T data; + base(); + void operator=(base const& a) { + this->data = a.data; + } +}; +class start: public base {}; -- cgit v0.12