From cfdd9a5446a71facdab4a04ea856d325b11e407a Mon Sep 17 00:00:00 2001 From: Eric Ludlam Date: Sun, 18 Oct 2015 10:15:30 -0400 Subject: [PATCH] Tests for polymorphism * test/manual/cedet/cedet/semantic/tests/testpoly.cpp Tests for polymorphism with a couple examples where we could try to disambiguate. --- .../cedet/cedet/semantic/tests/testpoly.cpp | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 test/manual/cedet/cedet/semantic/tests/testpoly.cpp diff --git a/test/manual/cedet/cedet/semantic/tests/testpoly.cpp b/test/manual/cedet/cedet/semantic/tests/testpoly.cpp new file mode 100644 index 00000000000..769a5bef0ac --- /dev/null +++ b/test/manual/cedet/cedet/semantic/tests/testpoly.cpp @@ -0,0 +1,59 @@ +// Test disambiguation of polymorphic methods. + +class xx { +public: + int int_field; + int char_field; + char foo(char x); + int foo (int x); +}; + +int whatever() { + xx x; + + char same_char; + int same_int; + int i; + char c; + + i = x.foo(same // -1- + // #1# ( "same_int" ) + ); + + c = x.foo(same // -2- + // #2# ( "same_char" ) + ); + +} + +// Example from Dmitry +struct foo { + int a; + int b; +}; + +struct bar { + int c; + int d; +}; + +foo tee(int i) { + foo f; + return f; +} + +bar tee(long i) { + bar b; + return b; +} + +int main() { + int i = 1; + long l = 2; + + tee(i).//-3- + ; // #3# ( "a" "b" ) + + tee(l).//-4- + ; // #4# ( "c" "d" ) +} -- 2.39.2