brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.3 KiB · 474da6e Raw
81 lines · plain
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++ %t/Inputs/first.h -cl-std=CL2.017// RUN: %clang_cc1 -fsyntax-only -x c++ %t/Inputs/second.h -cl-std=CL2.018 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 -cl-std=CL2.029 30#if !defined(FIRST) && !defined(SECOND)31#include "first.h"32#include "second.h"33#endif34 35 36#if defined(FIRST)37void invalid1() {38  typedef read_only pipe int x;39}40void invalid2() {41  typedef read_only pipe int x;42}43void valid() {44  typedef read_only pipe int x;45  typedef write_only pipe int y;46  typedef read_write pipe int z;47}48#elif defined(SECOND)49void invalid1() {50  typedef write_only pipe int x;51}52void invalid2() {53  typedef read_only pipe float x;54}55void valid() {56  typedef read_only pipe int x;57  typedef write_only pipe int y;58  typedef read_write pipe int z;59}60#else61void run() {62  invalid1();63// expected-error@second.h:* {{'invalid1' has different definitions in different modules; definition in module 'SecondModule' first difference is function body}}64// expected-note@first.h:* {{but in 'FirstModule' found a different body}}65  invalid2();66// expected-error@second.h:* {{'invalid2' has different definitions in different modules; definition in module 'SecondModule' first difference is function body}}67// expected-note@first.h:* {{but in 'FirstModule' found a different body}}68  valid();69}70#endif71 72 73// Keep macros contained to one file.74#ifdef FIRST75#undef FIRST76#endif77 78#ifdef SECOND79#undef SECOND80#endif81