diff options
Diffstat (limited to 'gcc/testsuite/g++.old-deja/g++.jason/template27.C')
-rw-r--r-- | gcc/testsuite/g++.old-deja/g++.jason/template27.C | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.old-deja/g++.jason/template27.C b/gcc/testsuite/g++.old-deja/g++.jason/template27.C new file mode 100644 index 000000000..a440397d7 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.jason/template27.C @@ -0,0 +1,49 @@ +// { dg-do run } +// PRMS Id: 6826 +// Check that unnecessary templates are not instantiated. + +template <class T> +class Test +{ + public: + void doThiss(); + void doThat(); +}; + +template <class T> +void Test<T>::doThiss() +{ + T x; + + x.thiss(); +} + +template <class T> +void Test<T>::doThat() +{ + T x; + + x.that(); +} + +class A +{ + public: + void thiss() {} +}; + +class B +{ + public: + void that() {} +}; + +int main() +{ + Test<A> a; + a.doThiss(); // a.doThat() is not well formed, but then + // it's not used so needn't be instantiated. + + Test<B> b; + b.doThat(); // simillarly b.doThiss(); +} |