brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.0 KiB · 1bd87bf Raw
101 lines · c
1// RUN: rm -rf %t2// RUN: split-file %s %t3// RUN: %clang_cc1 -fsyntax-only -I %t/include %t/test.c \4// RUN:            -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/modules.cache5 6// Test when a decl is present in multiple modules through an inclusion of7// a non-modular header. Make sure such decl is serialized correctly and can be8// used after deserialization.9 10//--- include/non-modular.h11#ifndef NON_MODULAR_H12#define NON_MODULAR_H13 14union TestUnion {15  int x;16  float y;17};18 19struct ReferenceUnion1 {20  union TestUnion name;21  unsigned versionMajor;22};23struct ReferenceUnion2 {24  union TestUnion name;25  unsigned versionMinor;26};27 28// Test another kind of RecordDecl.29struct TestStruct {30  int p;31  float q;32};33 34struct ReferenceStruct1 {35  unsigned fieldA;36  struct TestStruct fieldB;37};38 39struct ReferenceStruct2 {40  unsigned field1;41  struct TestStruct field2;42};43 44#endif45 46//--- include/piecewise1-empty.h47//--- include/piecewise1-initially-hidden.h48#include <non-modular.h>49 50//--- include/piecewise2-empty.h51//--- include/piecewise2-initially-hidden.h52#include <non-modular.h>53 54//--- include/with-multiple-decls.h55#include <piecewise1-empty.h>56// Include the non-modular header and resolve a name duplication between decl57// in non-modular.h and in piecewise1-initially-hidden.h, create a58// redeclaration chain.59#include <non-modular.h>60// Include a decl with a duplicate name again to add more to IdentifierResolver.61#include <piecewise2-empty.h>62 63//--- include/module.modulemap64module Piecewise1 {65  module Empty {66    header "piecewise1-empty.h"67  }68  module InitiallyHidden {69    header "piecewise1-initially-hidden.h"70    export *71  }72}73 74module Piecewise2 {75  module Empty {76    header "piecewise2-empty.h"77  }78  module InitiallyHidden {79    header "piecewise2-initially-hidden.h"80    export *81  }82}83 84module WithMultipleDecls {85  header "with-multiple-decls.h"86  export *87}88 89//--- test.c90#include <with-multiple-decls.h>91 92struct Test {93  int x;94  union TestUnion name;95};96 97struct Test2 {98  struct TestStruct name;99  float y;100};101