brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.6 KiB · e2da431 Raw
129 lines · cpp
1// Clear and create directories2// RUN: rm -rf %t3// RUN: mkdir %t4// RUN: mkdir %t/cache5// RUN: mkdir %t/Inputs6 7// Build first header file8// RUN: echo "#define FIRST" >> %t/Inputs/first.h9// RUN: cat %s               >> %t/Inputs/first.h10 11// Build second header file12// RUN: echo "#define SECOND" >> %t/Inputs/second.h13// RUN: cat %s                >> %t/Inputs/second.h14 15// Test that each header can compile16// RUN: %clang_cc1 -fsyntax-only -x c++ -std=c++11 %t/Inputs/first.h -fzvector17// RUN: %clang_cc1 -fsyntax-only -x c++ -std=c++11 %t/Inputs/second.h -fzvector18 19// Build module map file20// RUN: echo "module FirstModule {"     >> %t/Inputs/module.modulemap21// RUN: echo "    header \"first.h\""   >> %t/Inputs/module.modulemap22// RUN: echo "}"                        >> %t/Inputs/module.modulemap23// RUN: echo "module SecondModule {"    >> %t/Inputs/module.modulemap24// RUN: echo "    header \"second.h\""  >> %t/Inputs/module.modulemap25// RUN: echo "}"                        >> %t/Inputs/module.modulemap26 27// Run test28// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/cache -x c++ -I%t/Inputs -verify %s -std=c++11 -fzvector29 30#if !defined(FIRST) && !defined(SECOND)31#include "first.h"32#include "second.h"33#endif34 35namespace Types {36namespace Vector {37#if defined(FIRST)38struct Invalid1 {39  __attribute((vector_size(8))) int x;40};41struct Invalid2 {42  __attribute((vector_size(8))) int x;43};44struct Invalid3 {45  __attribute((vector_size(16))) int x;46};47struct Valid {48  __attribute((vector_size(8))) int x1;49  __attribute((vector_size(16))) int x2;50  __attribute((vector_size(8))) unsigned x3;51  __attribute((vector_size(16))) long x4;52  vector unsigned x5;53  vector int x6;54};55#elif defined(SECOND)56struct Invalid1 {57  __attribute((vector_size(16))) int x;58};59struct Invalid2 {60  __attribute((vector_size(8))) unsigned x;61};62struct Invalid3 {63  vector unsigned x;64};65struct Valid {66  __attribute((vector_size(8))) int x1;67  __attribute((vector_size(16))) int x2;68  __attribute((vector_size(8))) unsigned x3;69  __attribute((vector_size(16))) long x4;70  vector unsigned x5;71  vector int x6;72};73#else74Invalid1 i1;75// expected-error@second.h:* {{'Types::Vector::Invalid1::x' from module 'SecondModule' is not present in definition of 'Types::Vector::Invalid1' in module 'FirstModule'}}76// expected-note@first.h:* {{declaration of 'x' does not match}}77Invalid2 i2;78// expected-error@second.h:* {{'Types::Vector::Invalid2::x' from module 'SecondModule' is not present in definition of 'Types::Vector::Invalid2' in module 'FirstModule'}}79// expected-note@first.h:* {{declaration of 'x' does not match}}80Invalid3 i3;81// expected-error@second.h:* {{'Types::Vector::Invalid3::x' from module 'SecondModule' is not present in definition of 'Types::Vector::Invalid3' in module 'FirstModule'}}82// expected-note@first.h:* {{declaration of 'x' does not match}}83 84Valid v;85#endif86}  // namespace Vector87 88 89 90namespace ExtVector {91}  // namespace ExtVector92#if defined(FIRST)93struct Invalid {94  using f = __attribute__((ext_vector_type(4))) float;95};96struct Valid {97  using f = __attribute__((ext_vector_type(8))) float;98};99#elif defined(SECOND)100struct Invalid {101  using f = __attribute__((ext_vector_type(8))) float;102};103struct Valid {104  using f = __attribute__((ext_vector_type(8))) float;105};106#else107Invalid i;108// expected-error@first.h:* {{'Types::Invalid::f' from module 'FirstModule' is not present in definition of 'Types::Invalid' in module 'SecondModule'}}109// expected-note@second.h:* {{declaration of 'f' does not match}}110 111Valid v;112#endif113 114}  // namespace Types115 116 117// Keep macros contained to one file.118#ifdef FIRST119#undef FIRST120#endif121 122#ifdef SECOND123#undef SECOND124#endif125 126#ifdef ACCESS127#undef ACCESS128#endif129