diff options
Diffstat (limited to 'test/Modules')
34 files changed, 219 insertions, 101 deletions
diff --git a/test/Modules/Inputs/ModuleDiags/has_errors.h b/test/Modules/Inputs/ModuleDiags/has_errors.h new file mode 100644 index 0000000..2c0929a --- /dev/null +++ b/test/Modules/Inputs/ModuleDiags/has_errors.h @@ -0,0 +1,2 @@ +static void foo(void) { } +static void foo(void) { } diff --git a/test/Modules/Inputs/ModuleDiags/has_warnings.h b/test/Modules/Inputs/ModuleDiags/has_warnings.h new file mode 100644 index 0000000..87112be --- /dev/null +++ b/test/Modules/Inputs/ModuleDiags/has_warnings.h @@ -0,0 +1,3 @@ + +int int_val; +float *float_ptr = &int_val; diff --git a/test/Modules/Inputs/ModuleDiags/module.map b/test/Modules/Inputs/ModuleDiags/module.map new file mode 100644 index 0000000..09b2508 --- /dev/null +++ b/test/Modules/Inputs/ModuleDiags/module.map @@ -0,0 +1,7 @@ +module HasWarnings { + header "has_warnings.h" +} + +module HasErrors { + header "has_errors.h" +} diff --git a/test/Modules/Inputs/System/usr/include/dbl_max.h b/test/Modules/Inputs/System/usr/include/dbl_max.h new file mode 100644 index 0000000..9a020d1 --- /dev/null +++ b/test/Modules/Inputs/System/usr/include/dbl_max.h @@ -0,0 +1 @@ +#define DBL_MAX __DBL_MAX__ diff --git a/test/Modules/Inputs/System/usr/include/module.map b/test/Modules/Inputs/System/usr/include/module.map index 884b59c..9b2f3af 100644 --- a/test/Modules/Inputs/System/usr/include/module.map +++ b/test/Modules/Inputs/System/usr/include/module.map @@ -19,3 +19,14 @@ module cstd [system] { header "stdint.h" } } + +module other_constants { + explicit module dbl_max { + header "dbl_max.h" + } +} + +module uses_other_constants { + header "uses_other_constants.h" + export * +} diff --git a/test/Modules/Inputs/System/usr/include/uses_other_constants.h b/test/Modules/Inputs/System/usr/include/uses_other_constants.h new file mode 100644 index 0000000..f6d4cca --- /dev/null +++ b/test/Modules/Inputs/System/usr/include/uses_other_constants.h @@ -0,0 +1,3 @@ +@import other_constants; +#include <float.h> + diff --git a/test/Modules/auto-module-import.m b/test/Modules/auto-module-import.m index 4bd3c52..7351828 100644 --- a/test/Modules/auto-module-import.m +++ b/test/Modules/auto-module-import.m @@ -1,10 +1,10 @@ -// other file: expected-note{{'no_umbrella_A_private' declared here}} - // RUN: rm -rf %t // RUN: %clang_cc1 -Wauto-import -fmodules-cache-path=%t -fmodules -F %S/Inputs %s -verify #include <DependsOnModule/DependsOnModule.h> // expected-warning{{treating #include as an import of module 'DependsOnModule'}} +// expected-note@Inputs/NoUmbrella.framework/PrivateHeaders/A_Private.h:1{{'no_umbrella_A_private' declared here}} + #ifdef MODULE_H_MACRO # error MODULE_H_MACRO should have been hidden #endif diff --git a/test/Modules/autolink.m b/test/Modules/autolink.m index 7f75473..4bf9d59 100644 --- a/test/Modules/autolink.m +++ b/test/Modules/autolink.m @@ -1,5 +1,6 @@ // RUN: rm -rf %t -// RUN: %clang_cc1 -emit-llvm -o - -fmodules-cache-path=%t -fmodules -fmodules-autolink -F %S/Inputs -I %S/Inputs %s | FileCheck %s +// RUN: %clang_cc1 -emit-llvm -o - -fmodules-cache-path=%t -fmodules -F %S/Inputs -I %S/Inputs %s | FileCheck %s +// RUN: %clang_cc1 -emit-llvm -fno-autolink -o - -fmodules-cache-path=%t -fmodules -F %S/Inputs -I %S/Inputs %s | FileCheck --check-prefix=CHECK-AUTOLINK-DISABLED %s @import autolink.sub2; @@ -38,3 +39,6 @@ int use_no_umbrella() { // CHECK: ![[DEPENDSONMODULE]] = metadata !{metadata !"-framework", metadata !"DependsOnModule"} // CHECK: ![[MODULE]] = metadata !{metadata !"-framework", metadata !"Module"} // CHECK: ![[NOUMBRELLA]] = metadata !{metadata !"-framework", metadata !"NoUmbrella"} + +// CHECK-AUTOLINK-DISABLED: !llvm.module.flags +// CHECK-AUTOLINK-DISABLED-NOT: "Linker Options" diff --git a/test/Modules/compiler_builtins.m b/test/Modules/compiler_builtins.m index 5ea7d79..4b8cb5b 100644 --- a/test/Modules/compiler_builtins.m +++ b/test/Modules/compiler_builtins.m @@ -2,7 +2,6 @@ // RUN: %clang -fsyntax-only -fmodules -fmodules-cache-path=%t -D__need_wint_t %s -Xclang -verify // RUN: %clang -fsyntax-only -std=c99 -fmodules -fmodules-cache-path=%t -D__need_wint_t %s -Xclang -verify // expected-no-diagnostics -// XFAIL: win32 #ifdef __SSE__ @import _Builtin_intrinsics.intel.sse; diff --git a/test/Modules/cstd.m b/test/Modules/cstd.m index 6d896a9..3d1dcf3 100644 --- a/test/Modules/cstd.m +++ b/test/Modules/cstd.m @@ -1,6 +1,9 @@ // RUN: rm -rf %t // RUN: %clang -fsyntax-only -isystem %S/Inputs/System/usr/include -fmodules -fmodules-cache-path=%t -D__need_wint_t -Werror=implicit-function-declaration %s +@import uses_other_constants; +const double other_value = DBL_MAX; + // Supplied by compiler, but referenced from the "/usr/include" module map. @import cstd.float_constants; @@ -16,7 +19,7 @@ void test_fprintf(FILE *file) { // Supplied by compiler, which forwards to the "/usr/include" version. @import cstd.stdint; -my_awesome_nonstandard_integer_type value; +my_awesome_nonstandard_integer_type value2; // Supplied by the compiler; that version wins. @import cstd.stdbool; @@ -25,5 +28,3 @@ my_awesome_nonstandard_integer_type value; # error "bool was not defined!" #endif - - diff --git a/test/Modules/cycles.c b/test/Modules/cycles.c index 4326e76..5f83092 100644 --- a/test/Modules/cycles.c +++ b/test/Modules/cycles.c @@ -6,8 +6,8 @@ // CHECK: While building module 'MutuallyRecursive1' imported from // CHECK: While building module 'MutuallyRecursive2' imported from // CHECK: MutuallyRecursive2.h:3:9: fatal error: cyclic dependency in module 'MutuallyRecursive1': MutuallyRecursive1 -> MutuallyRecursive2 -> MutuallyRecursive1 -// CHECK: While building module 'MutuallyRecursive1' imported from // CHECK: MutuallyRecursive1.h:2:9: fatal error: could not build module 'MutuallyRecursive2' // CHECK: cycles.c:4:9: fatal error: could not build module 'MutuallyRecursive1' -// CHECK-NOT: error: +// CHECK: 3 errors generated + diff --git a/test/Modules/decldef.m b/test/Modules/decldef.m index 7fb8a61..7ed82b5 100644 --- a/test/Modules/decldef.m +++ b/test/Modules/decldef.m @@ -1,8 +1,7 @@ // RUN: rm -rf %t // RUN: %clang_cc1 -fmodules -fobjc-arc -I %S/Inputs -fmodules-cache-path=%t %s -verify - -// In other file: expected-note {{previous definition is here}} +// expected-note@Inputs/def.h:5 {{previous definition is here}} @class Def; Def *def; diff --git a/test/Modules/decldef.mm b/test/Modules/decldef.mm index 732c2a2..593f53b 100644 --- a/test/Modules/decldef.mm +++ b/test/Modules/decldef.mm @@ -1,8 +1,7 @@ // RUN: rm -rf %t // RUN: %clang_cc1 -fmodules -fobjc-arc -I %S/Inputs -fmodules-cache-path=%t %s -verify - -// In other file: expected-note {{previous definition is here}} +// expected-note@Inputs/def.h:5 {{previous definition is here}} @class Def; Def *def; diff --git a/test/Modules/diamond-pch.c b/test/Modules/diamond-pch.c index 079f6af..e7ad02d 100644 --- a/test/Modules/diamond-pch.c +++ b/test/Modules/diamond-pch.c @@ -1,14 +1,20 @@ - - - -// in diamond-bottom.h: expected-note{{passing argument to parameter 'x' here}} +// RUN: rm -rf %t +// RUN: %clang_cc1 -fmodules -x objective-c -emit-module -fmodules-cache-path=%t -fmodule-name=diamond_top %S/Inputs/module.map +// RUN: %clang_cc1 -fmodules -x objective-c -emit-module -fmodules-cache-path=%t -fmodule-name=diamond_left %S/Inputs/module.map +// RUN: %clang_cc1 -fmodules -x objective-c -emit-module -fmodules-cache-path=%t -fmodule-name=diamond_right %S/Inputs/module.map +// RUN: %clang_cc1 -fmodules -x objective-c -emit-module -fmodules-cache-path=%t -fmodule-name=diamond_bottom %S/Inputs/module.map +// RUN: %clang_cc1 -fmodules -x objective-c -emit-pch -fmodules-cache-path=%t -o %t.pch %S/Inputs/diamond.h +// RUN: %clang_cc1 -fmodules -x objective-c -fmodules-cache-path=%t -include-pch %t.pch %s -verify +// FIXME: When we have a syntax for modules in C, use that. void test_diamond(int i, float f, double d, char c) { top(&i); left(&f); right(&d); bottom(&c); - bottom(&d); // expected-warning{{incompatible pointer types passing 'double *' to parameter of type 'char *'}} + bottom(&d); + // expected-warning@-1{{incompatible pointer types passing 'double *' to parameter of type 'char *'}} + // expected-note@Inputs/diamond_bottom.h:4{{passing argument to parameter 'x' here}} // Names in multiple places in the diamond. top_left(&c); @@ -17,12 +23,3 @@ void test_diamond(int i, float f, double d, char c) { struct left_and_right lr; lr.left = 17; } - -// RUN: rm -rf %t -// RUN: %clang_cc1 -fmodules -x objective-c -emit-module -fmodules-cache-path=%t -fmodule-name=diamond_top %S/Inputs/module.map -// RUN: %clang_cc1 -fmodules -x objective-c -emit-module -fmodules-cache-path=%t -fmodule-name=diamond_left %S/Inputs/module.map -// RUN: %clang_cc1 -fmodules -x objective-c -emit-module -fmodules-cache-path=%t -fmodule-name=diamond_right %S/Inputs/module.map -// RUN: %clang_cc1 -fmodules -x objective-c -emit-module -fmodules-cache-path=%t -fmodule-name=diamond_bottom %S/Inputs/module.map -// RUN: %clang_cc1 -fmodules -x objective-c -emit-pch -fmodules-cache-path=%t -o %t.pch %S/Inputs/diamond.h -// RUN: %clang_cc1 -fmodules -x objective-c -fmodules-cache-path=%t -include-pch %t.pch %s -verify -// FIXME: When we have a syntax for modules in C, use that. diff --git a/test/Modules/diamond.c b/test/Modules/diamond.c index 0bac1b7..89d5bc0 100644 --- a/test/Modules/diamond.c +++ b/test/Modules/diamond.c @@ -1,7 +1,10 @@ - - - -// in diamond-bottom.h: expected-note{{passing argument to parameter 'x' here}} +// RUN: rm -rf %t +// RUN: %clang_cc1 -fmodules -x objective-c -emit-module -fmodules-cache-path=%t -fmodule-name=diamond_top %S/Inputs/module.map +// RUN: %clang_cc1 -fmodules -x objective-c -emit-module -fmodules-cache-path=%t -fmodule-name=diamond_left %S/Inputs/module.map +// RUN: %clang_cc1 -fmodules -x objective-c -emit-module -fmodules-cache-path=%t -fmodule-name=diamond_right %S/Inputs/module.map +// RUN: %clang_cc1 -fmodules -x objective-c -emit-module -fmodules-cache-path=%t -fmodule-name=diamond_bottom %S/Inputs/module.map +// RUN: %clang_cc1 -fmodules -x objective-c -fmodules-cache-path=%t %s -verify +// FIXME: When we have a syntax for modules in C, use that. @import diamond_bottom; @@ -10,7 +13,9 @@ void test_diamond(int i, float f, double d, char c) { left(&f); right(&d); bottom(&c); - bottom(&d); // expected-warning{{incompatible pointer types passing 'double *' to parameter of type 'char *'}} + bottom(&d); + // expected-warning@-1{{incompatible pointer types passing 'double *' to parameter of type 'char *'}} + // expected-note@Inputs/diamond_bottom.h:4{{passing argument to parameter 'x' here}} // Names in multiple places in the diamond. top_left(&c); @@ -20,10 +25,3 @@ void test_diamond(int i, float f, double d, char c) { lr.left = 17; } -// RUN: rm -rf %t -// RUN: %clang_cc1 -fmodules -x objective-c -emit-module -fmodules-cache-path=%t -fmodule-name=diamond_top %S/Inputs/module.map -// RUN: %clang_cc1 -fmodules -x objective-c -emit-module -fmodules-cache-path=%t -fmodule-name=diamond_left %S/Inputs/module.map -// RUN: %clang_cc1 -fmodules -x objective-c -emit-module -fmodules-cache-path=%t -fmodule-name=diamond_right %S/Inputs/module.map -// RUN: %clang_cc1 -fmodules -x objective-c -emit-module -fmodules-cache-path=%t -fmodule-name=diamond_bottom %S/Inputs/module.map -// RUN: %clang_cc1 -fmodules -x objective-c -fmodules-cache-path=%t %s -verify -// FIXME: When we have a syntax for modules in C, use that. diff --git a/test/Modules/linkage-merge.cpp b/test/Modules/linkage-merge.cpp index 4e2ecef..9cc9ae6 100644 --- a/test/Modules/linkage-merge.cpp +++ b/test/Modules/linkage-merge.cpp @@ -1,13 +1,12 @@ -// FIXME: we should be able to put these in the .h file :-( -// expected-note {{target of using declaration}} -// expected-note {{using declaration}} +// RUN: rm -rf %t +// RUN: %clang_cc1 -verify -fmodules -fmodules-cache-path=%t -I %S/Inputs %s #include "linkage-merge-bar.h" static int f(int); int f(int); -static void g(int); // expected-error {{declaration conflicts with target of using declaration already in scope}} - -// RUN: rm -rf %t -// RUN: %clang_cc1 -verify -fmodules -fmodules-cache-path=%t -I %S/Inputs %s +static void g(int); +// expected-error@-1 {{declaration conflicts with target of using declaration already in scope}} +// expected-note@Inputs/linkage-merge-foo.h:2 {{target of using declaration}} +// expected-note@Inputs/linkage-merge-bar.h:3 {{using declaration}} diff --git a/test/Modules/linkage-merge.m b/test/Modules/linkage-merge.m index 16e2205..e838ca1 100644 --- a/test/Modules/linkage-merge.m +++ b/test/Modules/linkage-merge.m @@ -1,27 +1,26 @@ -// In module: expected-note{{previous declaration}} - - - - -// In module: expected-note{{previous definition is here}} +// RUN: rm -rf %t +// RUN: %clang_cc1 -fmodules -x objective-c -fmodules-cache-path=%t -emit-module -fmodule-name=linkage_merge_left %S/Inputs/module.map +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -w %s -verify // Test redeclarations of functions where the original declaration is // still hidden. @import linkage_merge_left; // excludes "sub" -extern int f0(float); // expected-error{{conflicting types for 'f0'}} +extern int f0(float); +// expected-error@-1{{conflicting types for 'f0'}} +// expected-note@Inputs/linkage-merge-sub.h:1{{previous declaration}} + static int f1(float); // okay: considered distinct static int f2(float); // okay: considered distinct extern int f3(float); // okay: considered distinct -extern float v0; // expected-error{{redefinition of 'v0' with a different type: 'float' vs 'int'}} +extern float v0; +// expected-error@-1{{redefinition of 'v0' with a different type: 'float' vs 'int'}} +// expected-note@Inputs/linkage-merge-sub.h:6{{previous definition is here}} + static float v1; static float v2; extern float v3; typedef float T0; - -// RUN: rm -rf %t -// RUN: %clang_cc1 -fmodules -x objective-c -fmodules-cache-path=%t -emit-module -fmodule-name=linkage_merge_left %S/Inputs/module.map -// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -w %s -verify diff --git a/test/Modules/lookup.cpp b/test/Modules/lookup.cpp index 002b6d1..efd88f4 100644 --- a/test/Modules/lookup.cpp +++ b/test/Modules/lookup.cpp @@ -5,7 +5,7 @@ import lookup_left_cxx; #define IMPORT(X) @import X IMPORT(lookup_right_cxx); -// in lookup_left.hpp: expected-warning@3 {{weak identifier 'weak_identifier' never declared}} +// expected-warning@Inputs/lookup_left.hpp:3 {{weak identifier 'weak_identifier' never declared}} void test(int i, float f) { // unqualified lookup diff --git a/test/Modules/lookup.m b/test/Modules/lookup.m index abe9542..54c7491 100644 --- a/test/Modules/lookup.m +++ b/test/Modules/lookup.m @@ -1,19 +1,19 @@ +// RUN: rm -rf %t +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -emit-module -x objective-c -fmodule-name=lookup_left_objc %S/Inputs/module.map +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -emit-module -x objective-c -fmodule-name=lookup_right_objc %S/Inputs/module.map +// RUN: %clang_cc1 -fmodules -x objective-c -fmodules-cache-path=%t -verify %s +// RUN: %clang_cc1 -fmodules -ast-print -x objective-c -fmodules-cache-path=%t %s | FileCheck -check-prefix=CHECK-PRINT %s -// lookup_left.h: expected-note{{using}} -// lookup_right.h: expected-note{{also found}} @import lookup_left_objc; @import lookup_right_objc; void test(id x) { - [x method]; // expected-warning{{multiple methods named 'method' found}} + [x method]; +// expected-warning@-1{{multiple methods named 'method' found}} +// expected-note@Inputs/lookup_left.h:2{{using}} +// expected-note@Inputs/lookup_right.h:3{{also found}} } -// RUN: rm -rf %t -// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -emit-module -x objective-c -fmodule-name=lookup_left_objc %S/Inputs/module.map -// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -emit-module -x objective-c -fmodule-name=lookup_right_objc %S/Inputs/module.map -// RUN: %clang_cc1 -fmodules -x objective-c -fmodules-cache-path=%t -verify %s -// RUN: %clang_cc1 -fmodules -ast-print -x objective-c -fmodules-cache-path=%t %s | FileCheck -check-prefix=CHECK-PRINT %s - // CHECK-PRINT: - (int) method; // CHECK-PRINT: - (double) method // CHECK-PRINT: void test(id x) diff --git a/test/Modules/macros.c b/test/Modules/macros.c index fc448d9..433e033 100644 --- a/test/Modules/macros.c +++ b/test/Modules/macros.c @@ -8,13 +8,13 @@ // 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}} -// FIXME: expected-note{{previous definition is here}} expected-note{{expanding this definition of 'LEFT_RIGHT_DIFFERENT'}} -// expected-note{{other definition of 'TOP_RIGHT_REDEF'}} expected-note{{expanding this definition of 'LEFT_RIGHT_DIFFERENT2'}} -// expected-note{{other definition of 'LEFT_RIGHT_DIFFERENT'}} - - -// expected-note{{expanding this definition of 'TOP_RIGHT_REDEF'}} +// FIXME: expected-note@Inputs/macros_left.h:11{{previous definition is here}} +// FIXME: expected-note@Inputs/macros_right.h:12{{previous definition is here}} +// expected-note@Inputs/macros_right.h:12{{expanding this definition of 'LEFT_RIGHT_DIFFERENT'}} +// expected-note@Inputs/macros_top.h:13{{other definition of 'TOP_RIGHT_REDEF'}} +// expected-note@Inputs/macros_right.h:13{{expanding this definition of 'LEFT_RIGHT_DIFFERENT2'}} +// expected-note@Inputs/macros_left.h:14{{other definition of 'LEFT_RIGHT_DIFFERENT'}} +// expected-note@Inputs/macros_right.h:17{{expanding this definition of 'TOP_RIGHT_REDEF'}} @import macros; diff --git a/test/Modules/method_pool.m b/test/Modules/method_pool.m index 9a8897b..6fd74b0 100644 --- a/test/Modules/method_pool.m +++ b/test/Modules/method_pool.m @@ -8,8 +8,8 @@ - (void)method5:(D*)obj; @end -// in other file: // expected-note@7{{using}} -// in other file: expected-note@12{{also found}} +// expected-note@Inputs/MethodPoolA.h:7{{using}} +// expected-note@Inputs/MethodPoolB.h:12{{also found}} void testMethod1(id object) { [object method1]; @@ -51,8 +51,8 @@ void testMethod3Again(id object) { void testMethod3AgainAgain(id object) { [object method3]; // expected-warning{{multiple methods named 'method3' found}} - // expected-note@2{{using}} - // expected-note@2{{also found}} + // expected-note@Inputs/MethodPoolBSub.h:2{{using}} + // expected-note@Inputs/MethodPoolASub.h:2{{also found}} } void testMethod4Again(id object) { diff --git a/test/Modules/module-private.cpp b/test/Modules/module-private.cpp index d4e73b5..438dcab 100644 --- a/test/Modules/module-private.cpp +++ b/test/Modules/module-private.cpp @@ -15,7 +15,7 @@ int test_broken() { HiddenStruct hidden; // \ // expected-error{{must use 'struct' tag to refer to type 'HiddenStruct' in this scope}} \ // expected-error{{definition of 'struct HiddenStruct' must be imported}} - // expected-note@3 {{previous definition is here}} + // expected-note@Inputs/module_private_left.h:3 {{previous definition is here}} Integer i; // expected-error{{unknown type name 'Integer'}} diff --git a/test/Modules/namespaces.cpp b/test/Modules/namespaces.cpp index 0e9dbff..426e002 100644 --- a/test/Modules/namespaces.cpp +++ b/test/Modules/namespaces.cpp @@ -73,5 +73,5 @@ void testAnonymousNotMerged() { N12::consumeFoo(N12::getFoo()); // expected-error{{cannot initialize a parameter of type 'N12::<anonymous>::Foo *' with an rvalue of type 'N12::<anonymous>::Foo *'}} } -// namespaces-right.h: expected-note@60 {{passing argument to parameter here}} -// namespaces-right.h: expected-note@67 {{passing argument to parameter here}} +// expected-note@Inputs/namespaces-right.h:60 {{passing argument to parameter here}} +// expected-note@Inputs/namespaces-right.h:67 {{passing argument to parameter here}} diff --git a/test/Modules/normal-module-map.cpp b/test/Modules/normal-module-map.cpp index 423e808..8155318 100644 --- a/test/Modules/normal-module-map.cpp +++ b/test/Modules/normal-module-map.cpp @@ -1,5 +1,3 @@ -// Note: inside the module. expected-note{{'nested_umbrella_a' declared here}} - // RUN: rm -rf %t // RUN: %clang_cc1 -x objective-c -fmodules-cache-path=%t -fmodules -I %S/Inputs/normal-module-map %s -verify #include "Umbrella/umbrella_sub.h" @@ -25,7 +23,9 @@ int testNestedUmbrellaA() { } int testNestedUmbrellaBFail() { - return nested_umbrella_b; // expected-error{{use of undeclared identifier 'nested_umbrella_b'; did you mean 'nested_umbrella_a'?}} + return nested_umbrella_b; + // expected-error@-1{{use of undeclared identifier 'nested_umbrella_b'; did you mean 'nested_umbrella_a'?}} + // expected-note@Inputs/normal-module-map/nested_umbrella/a.h:1{{'nested_umbrella_a' declared here}} } @import nested_umbrella.b; diff --git a/test/Modules/objc-categories.m b/test/Modules/objc-categories.m index d3ebcb7..81fb28b 100644 --- a/test/Modules/objc-categories.m +++ b/test/Modules/objc-categories.m @@ -8,11 +8,8 @@ @import category_bottom; - - - -// in category_left.h: expected-note {{previous definition}} -// in category_right.h: expected-warning@11 {{duplicate definition of category}} +// expected-note@Inputs/category_left.h:14 {{previous definition}} +// expected-warning@Inputs/category_right.h:11 {{duplicate definition of category}} @interface Foo(Source) -(void)source; @@ -75,7 +72,7 @@ void test_hidden_right_errors(Foo *foo) { [p4 p4_method]; // expected-warning{{instance method '-p4_method' not found (return type defaults to 'id')}} id p4p = p4.p4_prop; // expected-error{{property 'p4_prop' not found on object of type 'id<P4>'}} p4p = foo.p4_prop; // expected-error{{property 'p4_prop' not found on object of type 'Foo *'; did you mean 'p3_prop'?}} - // expected-note@7{{'p3_prop' declared here}} + // expected-note@Inputs/category_left_sub.h:7{{'p3_prop' declared here}} } @import category_right.sub; diff --git a/test/Modules/on-demand-build.m b/test/Modules/on-demand-build.m index 31742f7..e958759 100644 --- a/test/Modules/on-demand-build.m +++ b/test/Modules/on-demand-build.m @@ -7,7 +7,7 @@ @interface OtherClass @end -// in module: expected-note@17{{class method 'alloc' is assumed to return an instance of its receiver type ('Module *')}} +// expected-note@Inputs/Module.framework/Headers/Module.h:17{{class method 'alloc' is assumed to return an instance of its receiver type ('Module *')}} void test_getModuleVersion() { const char *version = getModuleVersion(); const char *version2 = [Module version]; diff --git a/test/Modules/redecl-merge.m b/test/Modules/redecl-merge.m index e373667..37e5967 100644 --- a/test/Modules/redecl-merge.m +++ b/test/Modules/redecl-merge.m @@ -27,8 +27,8 @@ int *call_eventually_noreturn_again(void) { int *call_eventually_noreturn2_again(void) { // noreturn and non-noreturn functions have different types eventually_noreturn2(); // expected-error{{call to 'eventually_noreturn2' is ambiguous}} - // expected-note@93{{candidate function}} - // expected-note@90{{candidate function}} + // expected-note@Inputs/redecl-merge-left.h:93{{candidate function}} + // expected-note@Inputs/redecl-merge-right.h:90{{candidate function}} } @implementation A @@ -79,24 +79,26 @@ void testTypedefMerge(int i, double d) { T1 *ip = &i; // FIXME: Typedefs aren't actually merged in the sense of other merges, because // we should only merge them when the types are identical. - // in other file: expected-note@60{{candidate found by name lookup is 'T2'}} - // in other file: expected-note@63{{candidate found by name lookup is 'T2'}} + // expected-note@Inputs/redecl-merge-left.h:60{{candidate found by name lookup is 'T2'}} + // expected-note@Inputs/redecl-merge-right.h:63{{candidate found by name lookup is 'T2'}} T2 *dp = &d; // expected-error{{reference to 'T2' is ambiguous}} } void testFuncMerge(int i) { func0(i); func1(i); - // in other file: expected-note@64{{candidate function}} - // in other file: expected-note@70{{candidate function}} + // expected-note@Inputs/redecl-merge-left.h:64{{candidate function}} + // expected-note@Inputs/redecl-merge-right.h:70{{candidate function}} func2(i); // expected-error{{call to 'func2' is ambiguous}} } void testVarMerge(int i) { var1 = i; - // in other files: expected-note@77 2{{candidate found by name lookup is 'var2'}} + // expected-note@Inputs/redecl-merge-left.h:77{{candidate found by name lookup is 'var2'}} + // expected-note@Inputs/redecl-merge-right.h:77{{candidate found by name lookup is 'var2'}} var2 = i; // expected-error{{reference to 'var2' is ambiguous}} - // in other files: expected-note@79 2{{candidate found by name lookup is 'var3'}} + // expected-note@Inputs/redecl-merge-left.h:79{{candidate found by name lookup is 'var3'}} + // expected-note@Inputs/redecl-merge-right.h:79{{candidate found by name lookup is 'var3'}} var3 = i; // expected-error{{reference to 'var3' is ambiguous}} } diff --git a/test/Modules/redecls/a.h b/test/Modules/redecls/a.h new file mode 100644 index 0000000..1647f86 --- /dev/null +++ b/test/Modules/redecls/a.h @@ -0,0 +1,3 @@ +@interface AA +@end +@class AA; diff --git a/test/Modules/redecls/b.h b/test/Modules/redecls/b.h new file mode 100644 index 0000000..d41573d --- /dev/null +++ b/test/Modules/redecls/b.h @@ -0,0 +1 @@ +@class AA; diff --git a/test/Modules/redecls/main.m b/test/Modules/redecls/main.m new file mode 100644 index 0000000..9ec02b0 --- /dev/null +++ b/test/Modules/redecls/main.m @@ -0,0 +1,27 @@ +// RUN: rm -rf %t.mcp +// RUN: %clang_cc1 -fmodules -x objective-c -emit-module -fmodule-name=a %S/module.map -fmodules-cache-path=%t.mcp +// RUN: %clang_cc1 -fmodules -x objective-c -emit-module -fmodule-name=b %S/module.map -fmodules-cache-path=%t.mcp +// RUN: %clang_cc1 -fmodules %s -emit-pch -o %t1.pch -fmodules-cache-path=%t.mcp +// RUN: %clang_cc1 -fmodules %s -emit-pch -o %t2.pch -include-pch %t1.pch -fmodules-cache-path=%t.mcp +// RUN: %clang_cc1 -fmodules %s -fsyntax-only -include-pch %t2.pch -fmodules-cache-path=%t.mcp -verify + +#ifndef HEADER1 +#define HEADER1 + +@import a; + +#elif !defined(HEADER2) +#define HEADER2 + +@class AA; +@import b; + +#else + +// rdar://13712705 +@interface SS : AA +@end + +#warning parsed this +#endif +// expected-warning@-2{{parsed this}} diff --git a/test/Modules/redecls/module.map b/test/Modules/redecls/module.map new file mode 100644 index 0000000..a365682 --- /dev/null +++ b/test/Modules/redecls/module.map @@ -0,0 +1,2 @@ +module a { header "a.h" } +module b { header "b.h" } diff --git a/test/Modules/serialized-diags.m b/test/Modules/serialized-diags.m new file mode 100644 index 0000000..18bce06 --- /dev/null +++ b/test/Modules/serialized-diags.m @@ -0,0 +1,32 @@ +@import HasWarnings; + +#ifdef WITH_ERRORS +@import HasErrors; +#endif + +float float_val; +double *double_ptr = &float_val; + +// RUN: rm -rf %t %t.diag %t.out +// RUN: %clang -fmodules -fmodules-cache-path=%t/ModuleCache -I %S/Inputs/ModuleDiags -fsyntax-only %s --serialize-diagnostics %t.diag > /dev/null 2>&1 +// RUN: c-index-test -read-diagnostics %t.diag > %t.out 2>&1 +// RUN: FileCheck --input-file=%t.out %s + +// CHECK: has_warnings.h:3:8: warning: incompatible pointer types initializing 'float *' +// CHECK: serialized-diags.m:1:9: note: while building module 'HasWarnings' imported from +// CHECK: serialized-diags.m:8:9: warning: incompatible pointer types initializing 'double *' +// CHECK: Number of diagnostics: 2 + +// RUN: rm -rf %t %t.diag_errors %t.out_errors +// RUN: not %clang -fmodules -fmodules-cache-path=%t/ModuleCache -I %S/Inputs/ModuleDiags -fsyntax-only -DWITH_ERRORS %s --serialize-diagnostics %t.diag_errors > /dev/null 2>&1 +// RUN: c-index-test -read-diagnostics %t.diag_errors > %t.out_errors 2>&1 +// RUN: FileCheck -check-prefix=CHECK-WITH-ERRORS --input-file=%t.out_errors %s + +// CHECK-WITH-ERRORS: has_warnings.h:3:8: warning: incompatible pointer types initializing 'float *' +// CHECK-WITH-ERRORS: serialized-diags.m:1:9: note: while building module 'HasWarnings' +// CHECK-WITH-ERRORS: has_errors.h:2:13: error: redefinition of 'foo' +// CHECK-WITH-ERRORS: serialized-diags.m:4:9: note: while building module 'HasErrors' +// CHECK-WITH-ERRORS: has_errors.h:1:13: note: previous definition is here +// CHECK-WITH-ERRORS: serialized-diags.m:4:9: fatal: could not build module 'HasErrors' +// CHECK-WITH-ERRORS: Number of diagnostics: 3 + diff --git a/test/Modules/subframeworks.m b/test/Modules/subframeworks.m index 22dfcca..ad70cc2 100644 --- a/test/Modules/subframeworks.m +++ b/test/Modules/subframeworks.m @@ -23,7 +23,7 @@ CXXOnly cxxonly; @import HasSubModules; -// expected-warning@1{{treating #include as an import of module 'HasSubModules.Sub.Types'}} +// expected-warning@Inputs/HasSubModules.framework/Frameworks/Sub.framework/PrivateHeaders/SubPriv.h:1{{treating #include as an import of module 'HasSubModules.Sub.Types'}} #import <HasSubModules/HasSubModulesPriv.h> struct FrameworkSubStruct ss; diff --git a/test/Modules/system_version.m b/test/Modules/system_version.m new file mode 100644 index 0000000..85b3263 --- /dev/null +++ b/test/Modules/system_version.m @@ -0,0 +1,32 @@ +// Test checking that we're hashing a system version file in the +// module hash. +// REQUIRES: shell + +// First, build a system root. +// RUN: rm -rf %t +// RUN: mkdir -p %t/usr/include +// RUN: cp %S/Inputs/Modified/A.h %t/usr/include +// RUN: cp %S/Inputs/Modified/B.h %t/usr/include +// RUN: cp %S/Inputs/Modified/module.map %t/usr/include + +// Run once with no system version file. We should end up with one module. +// RUN: %clang_cc1 -fmodules-cache-path=%t/cache -fmodules -isysroot %t -I %t/usr/include %s -verify +// RUN: ls -R %t | grep -c ModA.pcm| grep 1 + +// Add a system version file and run again. We should now have two +// module variants. +// RUN: mkdir -p %t/System/Library/CoreServices +// RUN: echo "hello" > %t/System/Library/CoreServices/SystemVersion.plist +// RUN: %clang_cc1 -fmodules-cache-path=%t/cache -fmodules -isysroot %t -I %t/usr/include %s -verify +// RUN: ls -R %t | grep -c ModA.pcm| grep 2 + +// Change the system version file and run again. We should now have three +// module variants. +// RUN: mkdir -p %t/System/Library/CoreServices +// RUN: echo "modules" > %t/System/Library/CoreServices/SystemVersion.plist +// RUN: %clang_cc1 -fmodules-cache-path=%t/cache -fmodules -isysroot %t -I %t/usr/include %s -verify +// RUN: ls -R %t | grep -c ModA.pcm| grep 3 + +// expected-no-diagnostics +@import ModA; + |