diff options
author | Richard Trieu <rtrieu@google.com> | 2017-07-11 22:10:49 +0000 |
---|---|---|
committer | Richard Trieu <rtrieu@google.com> | 2017-07-11 22:10:49 +0000 |
commit | 81731280aca58aa40cd81ef3039c59aa4e386e92 (patch) | |
tree | 7c805a80e7cef45ea964b853db0829ba1e3be70d /test/Modules | |
parent | 76fbb101be021fa2b7fa11836be23e30f61a774a (diff) |
[ODRHash] Support more method types.
Hash CXXConstructorDecl and CXXDestructorDecl. Extend the diagnostics from
CXXMethodDecl to include constructors and destructors.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@307720 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Modules')
-rw-r--r-- | test/Modules/odr_hash.cpp | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/test/Modules/odr_hash.cpp b/test/Modules/odr_hash.cpp index ee45ae5299..4f16db964e 100644 --- a/test/Modules/odr_hash.cpp +++ b/test/Modules/odr_hash.cpp @@ -519,6 +519,75 @@ S14 s14; #endif } // namespace Method +namespace Constructor { +#if defined(FIRST) +struct S1 { + S1() {} + void foo() {} +}; +#elif defined(SECOND) +struct S1 { + void foo() {} + S1() {} +}; +#else +S1 s1; +// expected-error@second.h:* {{'Constructor::S1' has different definitions in different modules; first difference is definition in module 'SecondModule' found method 'foo'}} +// expected-note@first.h:* {{but in 'FirstModule' found constructor}} +#endif + +#if defined(FIRST) +struct S2 { + S2(int) {} + S2(int, int) {} +}; +#elif defined(SECOND) +struct S2 { + S2(int, int) {} + S2(int) {} +}; +#else +S2* s2; +// expected-error@second.h:* {{'Constructor::S2' has different definitions in different modules; first difference is definition in module 'SecondModule' found constructor that has 2 parameters}} +// expected-note@first.h:* {{but in 'FirstModule' found constructor that has 1 parameter}} +#endif +} // namespace Constructor + +namespace Destructor { +#if defined(FIRST) +struct S1 { + ~S1() {} + S1() {} +}; +#elif defined(SECOND) +struct S1 { + S1() {} + ~S1() {} +}; +#else +S1 s1; +// expected-error@second.h:* {{'Destructor::S1' has different definitions in different modules; first difference is definition in module 'SecondModule' found constructor}} +// expected-note@first.h:* {{but in 'FirstModule' found destructor}} +#endif + +#if defined(FIRST) +struct S2 { + virtual ~S2() {} + void foo() {} +}; +#elif defined(SECOND) +struct S2 { + ~S2() {} + virtual void foo() {} +}; +#else +S2 s2; +// expected-error@second.h:* {{'Destructor::S2' has different definitions in different modules; first difference is definition in module 'SecondModule' found destructor is not virtual}} +// expected-note@first.h:* {{but in 'FirstModule' found destructor is virtual}} +#endif + +} // namespace Destructor + // Naive parsing of AST can lead to cycles in processing. Ensure // self-references don't trigger an endless cycles of AST node processing. namespace SelfReference { |