blob: e371237bb0119e6c0ecfb5d149c5f7281543e63f [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
Douglas Gregoraa93a872011-10-17 15:32:29 +000011#__private_macro__ FLOAT
12#__private_macro__ MODULE
Douglas Gregor7143aab2011-09-01 17:04:32 +000013
Douglas Gregorce835df2011-09-14 22:14:14 +000014int (INTEGER);
15
Douglas Gregor7143aab2011-09-01 17:04:32 +000016#else
17
18__import_module__ macros;
19
20#ifndef INTEGER
21# error INTEGER macro should be visible
22#endif
23
24#ifdef FLOAT
25# error FLOAT macro should not be visible
26#endif
27
28#ifdef MODULE
29# error MODULE macro should not be visible
30#endif
31
Douglas Gregorde8a9052011-09-14 23:13:09 +000032// CHECK-PREPROCESSED: double d
Douglas Gregor7143aab2011-09-01 17:04:32 +000033double d;
34DOUBLE *dp = &d;
35
36#__export_macro__ WIBBLE // expected-error{{no macro named 'WIBBLE' to export}}
37
Douglas Gregorce835df2011-09-14 22:14:14 +000038void f() {
Douglas Gregorde8a9052011-09-14 23:13:09 +000039 // CHECK-PREPROCESSED: int i = INTEGER;
Douglas Gregorce835df2011-09-14 22:14:14 +000040 int i = INTEGER; // the value was exported, the macro was not.
41}
Douglas Gregor7143aab2011-09-01 17:04:32 +000042#endif