From 3466cebe94ba461b296bb1314e76118cc2823dfb Mon Sep 17 00:00:00 2001 From: Bruno Cardoso Lopes Date: Thu, 14 Nov 2019 13:44:18 -0800 Subject: [PATCH] Add a test to cover structural match for recursive data types This didn't use to work prior to r370639, now that this is supported add a testcase to prevent regressions. rdar://problem/53602368 --- clang/test/Modules/Inputs/rec-types/a.h | 2 ++ clang/test/Modules/Inputs/rec-types/b.h | 2 ++ clang/test/Modules/Inputs/rec-types/c.h | 7 +++++++ clang/test/Modules/Inputs/rec-types/module.modulemap | 9 +++++++++ .../test/Modules/structural-equivalent-recursive-types.c | 7 +++++++ 5 files changed, 27 insertions(+) create mode 100644 clang/test/Modules/Inputs/rec-types/a.h create mode 100644 clang/test/Modules/Inputs/rec-types/b.h create mode 100644 clang/test/Modules/Inputs/rec-types/c.h create mode 100644 clang/test/Modules/Inputs/rec-types/module.modulemap create mode 100644 clang/test/Modules/structural-equivalent-recursive-types.c diff --git a/clang/test/Modules/Inputs/rec-types/a.h b/clang/test/Modules/Inputs/rec-types/a.h new file mode 100644 index 000000000000..8e88ea7c5042 --- /dev/null +++ b/clang/test/Modules/Inputs/rec-types/a.h @@ -0,0 +1,2 @@ +// rec-types/a.h +#include "b.h" diff --git a/clang/test/Modules/Inputs/rec-types/b.h b/clang/test/Modules/Inputs/rec-types/b.h new file mode 100644 index 000000000000..05bbd99dd580 --- /dev/null +++ b/clang/test/Modules/Inputs/rec-types/b.h @@ -0,0 +1,2 @@ +// rec-types/b.h +#include "c.h" diff --git a/clang/test/Modules/Inputs/rec-types/c.h b/clang/test/Modules/Inputs/rec-types/c.h new file mode 100644 index 000000000000..fd2eb5a259b0 --- /dev/null +++ b/clang/test/Modules/Inputs/rec-types/c.h @@ -0,0 +1,7 @@ +struct some_descriptor +{ + // commenting line above make this struct work + void *(*thunk)(struct some_descriptor *); + unsigned long key; +}; + diff --git a/clang/test/Modules/Inputs/rec-types/module.modulemap b/clang/test/Modules/Inputs/rec-types/module.modulemap new file mode 100644 index 000000000000..680ed71ac9f2 --- /dev/null +++ b/clang/test/Modules/Inputs/rec-types/module.modulemap @@ -0,0 +1,9 @@ +module a { + header "a.h" + // Hide content by not re-exporting module b. +} + +module b { + header "b.h" + export * +} diff --git a/clang/test/Modules/structural-equivalent-recursive-types.c b/clang/test/Modules/structural-equivalent-recursive-types.c new file mode 100644 index 000000000000..bb3ec7b499bb --- /dev/null +++ b/clang/test/Modules/structural-equivalent-recursive-types.c @@ -0,0 +1,7 @@ +// RUN: rm -rf %t +// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -I%S/Inputs/rec-types -fsyntax-only %s -verify +#include "a.h" +#include "c.h" +void foo(struct some_descriptor *st) { (void)st->thunk; } + +// expected-no-diagnostics