diff options
author | dim <dim@FreeBSD.org> | 2012-12-02 13:20:44 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2012-12-02 13:20:44 +0000 |
commit | 056abd2059c65a3e908193aeae16fad98017437c (patch) | |
tree | 2732d02d7d51218d6eed98ac7fcfc5b8794896b5 /test/Modules/macros.c | |
parent | cc73504950eb7b5dff2dded9bedd67bc36d64641 (diff) | |
download | FreeBSD-src-056abd2059c65a3e908193aeae16fad98017437c.zip FreeBSD-src-056abd2059c65a3e908193aeae16fad98017437c.tar.gz |
Vendor import of clang release_32 branch r168974 (effectively, 3.2 RC2):
http://llvm.org/svn/llvm-project/cfe/branches/release_32@168974
Diffstat (limited to 'test/Modules/macros.c')
-rw-r--r-- | test/Modules/macros.c | 107 |
1 files changed, 107 insertions, 0 deletions
diff --git a/test/Modules/macros.c b/test/Modules/macros.c index 83e1c66..8db3915 100644 --- a/test/Modules/macros.c +++ b/test/Modules/macros.c @@ -1,8 +1,20 @@ // RUN: rm -rf %t +// RUN: %clang_cc1 -fmodules -x objective-c -emit-module -fmodule-cache-path %t -fmodule-name=macros_top %S/Inputs/module.map +// RUN: %clang_cc1 -fmodules -x objective-c -emit-module -fmodule-cache-path %t -fmodule-name=macros_left %S/Inputs/module.map +// RUN: %clang_cc1 -fmodules -x objective-c -emit-module -fmodule-cache-path %t -fmodule-name=macros_right %S/Inputs/module.map // RUN: %clang_cc1 -fmodules -x objective-c -emit-module -fmodule-cache-path %t -fmodule-name=macros %S/Inputs/module.map // RUN: %clang_cc1 -fmodules -x objective-c -verify -fmodule-cache-path %t %s // RUN: %clang_cc1 -E -fmodules -x objective-c -fmodule-cache-path %t %s | FileCheck -check-prefix CHECK-PREPROCESSED %s // FIXME: When we have a syntax for modules in C, use that. +// These notes come from headers in modules, and are bogus. + +// FIXME: expected-note{{previous definition is here}} +// expected-note{{other definition of 'LEFT_RIGHT_DIFFERENT'}} +// expected-note{{expanding this definition of 'TOP_RIGHT_REDEF'}} +// FIXME: expected-note{{previous definition is here}} \ +// expected-note{{expanding this definition of 'LEFT_RIGHT_DIFFERENT'}} + +// expected-note{{other definition of 'TOP_RIGHT_REDEF'}} @__experimental_modules_import macros; @@ -27,4 +39,99 @@ DOUBLE *dp = &d; void f() { // CHECK-PREPROCESSED: int i = INTEGER; int i = INTEGER; // the value was exported, the macro was not. + i += macros; // expanded from __MODULE__ within the 'macros' module. +} + +#ifdef __MODULE__ +# error Not building a module! +#endif + +#if __building_module(macros) +# error Not building a module +#endif + +// None of the modules we depend on have been imported, and therefore +// their macros should not be visible. +#ifdef LEFT +# error LEFT should not be visible +#endif + +#ifdef RIGHT +# error RIGHT should not be visible +#endif + +#ifdef TOP +# error TOP should not be visible +#endif + +// Import left module (which also imports top) +@__experimental_modules_import macros_left; + +#ifndef LEFT +# error LEFT should be visible +#endif + +#ifdef RIGHT +# error RIGHT should not be visible +#endif + +#ifndef TOP +# error TOP should be visible +#endif + +#ifdef TOP_LEFT_UNDEF +# error TOP_LEFT_UNDEF should not be visible +#endif + +void test1() { + int i; + TOP_RIGHT_REDEF *ip = &i; } + +#define LEFT_RIGHT_DIFFERENT2 double // FIXME: expected-warning{{'LEFT_RIGHT_DIFFERENT2' macro redefined}} + +// Import right module (which also imports top) +@__experimental_modules_import macros_right; + +#undef LEFT_RIGHT_DIFFERENT3 + +#ifndef LEFT +# error LEFT should be visible +#endif + +#ifndef RIGHT +# error RIGHT should be visible +#endif + +#ifndef TOP +# error TOP should be visible +#endif + +void test2() { + int i; + float f; + double d; + TOP_RIGHT_REDEF *ip = &i; // expected-warning{{ambiguous expansion of macro 'TOP_RIGHT_REDEF'}} + + LEFT_RIGHT_IDENTICAL *ip2 = &i; + LEFT_RIGHT_DIFFERENT *fp = &f; // expected-warning{{ambiguous expansion of macro 'LEFT_RIGHT_DIFFERENT'}} + LEFT_RIGHT_DIFFERENT2 *dp = &d; + int LEFT_RIGHT_DIFFERENT3; +} + +#define LEFT_RIGHT_DIFFERENT double // FIXME: expected-warning{{'LEFT_RIGHT_DIFFERENT' macro redefined}} + +void test3() { + double d; + LEFT_RIGHT_DIFFERENT *dp = &d; // okay +} + +#ifndef TOP_RIGHT_UNDEF +# error TOP_RIGHT_UNDEF should still be defined +#endif + +@__experimental_modules_import macros_right.undef; + +#ifdef TOP_RIGHT_UNDEF +# error TOP_RIGHT_UNDEF should not be defined +#endif |