blob: 899c19bb29c971dabff9c9456a9069f4f7c86f5c [file] [log] [blame]
Douglas Gregor7143aab2011-09-01 17:04:32 +00001// RUN: %clang_cc1 -emit-module -o %t/macros.pcm -DMODULE %s
Douglas Gregor6e975c42011-09-13 23:15:45 +00002// RUN: %clang_cc1 -verify -fmodule-cache-path %t -fdisable-module-hash %s
Douglas Gregorde8a9052011-09-14 23:13:09 +00003// RUN: %clang_cc1 -E -fmodule-cache-path %t -fdisable-module-hash %s | FileCheck -check-prefix CHECK-PREPROCESSED %s
Douglas Gregor7143aab2011-09-01 17:04:32 +00004
5#if defined(MODULE)
6#define INTEGER(X) int
7#define FLOAT float
8#define DOUBLE double
9
10#__export_macro__ INTEGER
11#__export_macro__ DOUBLE
12
Douglas Gregorce835df2011-09-14 22:14:14 +000013int (INTEGER);
14
Douglas Gregor7143aab2011-09-01 17:04:32 +000015#else
16
17__import_module__ macros;
18
19#ifndef INTEGER
20# error INTEGER macro should be visible
21#endif
22
23#ifdef FLOAT
24# error FLOAT macro should not be visible
25#endif
26
27#ifdef MODULE
28# error MODULE macro should not be visible
29#endif
30
Douglas Gregorde8a9052011-09-14 23:13:09 +000031// CHECK-PREPROCESSED: double d
Douglas Gregor7143aab2011-09-01 17:04:32 +000032double d;
33DOUBLE *dp = &d;
34
35#__export_macro__ WIBBLE // expected-error{{no macro named 'WIBBLE' to export}}
36
Douglas Gregorce835df2011-09-14 22:14:14 +000037void f() {
Douglas Gregorde8a9052011-09-14 23:13:09 +000038 // CHECK-PREPROCESSED: int i = INTEGER;
Douglas Gregorce835df2011-09-14 22:14:14 +000039 int i = INTEGER; // the value was exported, the macro was not.
40}
Douglas Gregor7143aab2011-09-01 17:04:32 +000041#endif