Home | History | Annotate | Download | only in Modules
      1 // RUN: rm -rf %t
      2 // RUN: cd %S
      3 //
      4 // RUN: %clang_cc1 -fmodules -x c++ -fmodules-cache-path=%t \
      5 // RUN:   -v \
      6 // RUN:   -iquote Inputs/macro-ambiguity/a/quote \
      7 // RUN:   -isystem Inputs/macro-ambiguity/a/system \
      8 // RUN:   -fno-implicit-modules -fno-modules-implicit-maps \
      9 // RUN:   -fmodule-map-file-home-is-cwd \
     10 // RUN:   -emit-module -fmodule-name=a -o %t/a.pcm \
     11 // RUN:   Inputs/macro-ambiguity/module.modulemap
     12 //
     13 // RUN: %clang_cc1 -fmodules -x c++ -fmodules-cache-path=%t \
     14 // RUN:   -v \
     15 // RUN:   -iquote Inputs/macro-ambiguity/b/quote \
     16 // RUN:   -isystem Inputs/macro-ambiguity/b/system \
     17 // RUN:   -fno-implicit-modules -fno-modules-implicit-maps \
     18 // RUN:   -fmodule-map-file-home-is-cwd \
     19 // RUN:   -emit-module -fmodule-name=b -o %t/b.pcm \
     20 // RUN:   Inputs/macro-ambiguity/module.modulemap
     21 //
     22 // RUN: %clang_cc1 -fmodules -x c++ -fmodules-cache-path=%t \
     23 // RUN:   -v \
     24 // RUN:   -iquote Inputs/macro-ambiguity/c/quote \
     25 // RUN:   -isystem Inputs/macro-ambiguity/c/system \
     26 // RUN:   -fno-implicit-modules -fno-modules-implicit-maps \
     27 // RUN:   -fmodule-map-file-home-is-cwd \
     28 // RUN:   -emit-module -fmodule-name=c -o %t/c.pcm \
     29 // RUN:   Inputs/macro-ambiguity/module.modulemap
     30 //
     31 // RUN: %clang_cc1 -fmodules -x c++ -fmodules-cache-path=%t \
     32 // RUN:   -v \
     33 // RUN:   -iquote Inputs/macro-ambiguity/d/quote \
     34 // RUN:   -isystem Inputs/macro-ambiguity/d/system \
     35 // RUN:   -fno-implicit-modules -fno-modules-implicit-maps \
     36 // RUN:   -fmodule-map-file-home-is-cwd \
     37 // RUN:   -emit-module -fmodule-name=d -o %t/d.pcm \
     38 // RUN:   Inputs/macro-ambiguity/module.modulemap
     39 //
     40 // RUN: %clang_cc1 -fmodules -x c++ -fmodules-cache-path=%t \
     41 // RUN:   -v \
     42 // RUN:   -iquote Inputs/macro-ambiguity/a/quote \
     43 // RUN:   -isystem Inputs/macro-ambiguity/a/system \
     44 // RUN:   -iquote Inputs/macro-ambiguity/b/quote \
     45 // RUN:   -isystem Inputs/macro-ambiguity/b/system \
     46 // RUN:   -iquote Inputs/macro-ambiguity/c/quote \
     47 // RUN:   -isystem Inputs/macro-ambiguity/c/system \
     48 // RUN:   -iquote Inputs/macro-ambiguity/d/quote \
     49 // RUN:   -isystem Inputs/macro-ambiguity/d/system \
     50 // RUN:   -iquote Inputs/macro-ambiguity/e/quote \
     51 // RUN:   -isystem Inputs/macro-ambiguity/e/system \
     52 // RUN:   -fno-implicit-modules -fno-modules-implicit-maps \
     53 // RUN:   -fmodule-map-file-home-is-cwd \
     54 // RUN:   -fmodule-map-file=Inputs/macro-ambiguity/module.modulemap \
     55 // RUN:   -fmodule-file=%t/a.pcm \
     56 // RUN:   -fmodule-file=%t/b.pcm \
     57 // RUN:   -fmodule-file=%t/c.pcm \
     58 // RUN:   -fmodule-file=%t/d.pcm \
     59 // RUN:   -Wambiguous-macro -verify macro-ambiguity.cpp
     60 
     61 // Include the textual headers first to maximize the ways in which things can
     62 // become ambiguous.
     63 #include "e_quote.h"
     64 #include <e_system.h>
     65 
     66 #include "a_quote.h"
     67 #include <a_system.h>
     68 #include "b_quote.h"
     69 #include <b_system.h>
     70 #include "c_quote.h"
     71 #include <c_system.h>
     72 #include "d_quote.h"
     73 #include <d_system.h>
     74 
     75 int test(int x) {
     76   // We expect to get warnings for all of the quoted includes but none of the
     77   // system includes here because the first module is a non-system module and
     78   // the quote macros come from non-system-headers.
     79   x = FOO1_QUOTE(x); // expected-warning {{ambiguous expansion of macro}}
     80   // expected-note@Inputs/macro-ambiguity/c/quote/c_quote.h:4 {{expanding this definition}}
     81   // expected-note@Inputs/macro-ambiguity/a/quote/a_quote.h:4 {{other definition}}
     82 
     83   x = FOO1_SYSTEM(x);
     84 
     85   x = BAR1_QUOTE(x); // expected-warning {{ambiguous expansion of macro}}
     86   // expected-note@Inputs/macro-ambiguity/d/quote/d_quote.h:4 {{expanding this definition}}
     87   // expected-note@Inputs/macro-ambiguity/a/quote/a_quote.h:5 {{other definition}}
     88 
     89   x = BAR1_SYSTEM(x);
     90 
     91   x = BAZ1_QUOTE(x); // expected-warning {{ambiguous expansion of macro}}
     92   // expected-note@Inputs/macro-ambiguity/a/quote/a_quote.h:6 {{expanding this definition}}
     93   // expected-note@Inputs/macro-ambiguity/e/quote/e_quote.h:4 {{other definition}}
     94 
     95   x = BAZ1_SYSTEM(x);
     96 
     97   // Here, we don't even warn on bar because in that cas both b and d are
     98   // system modules and so the use of non-system headers is irrelevant.
     99   x = FOO2_QUOTE(x); // expected-warning {{ambiguous expansion of macro}}
    100   // expected-note@Inputs/macro-ambiguity/c/quote/c_quote.h:5 {{expanding this definition}}
    101   // expected-note@Inputs/macro-ambiguity/b/quote/b_quote.h:4 {{other definition}}
    102 
    103   x = FOO2_SYSTEM(x);
    104 
    105   x = BAR2_QUOTE(x);
    106 
    107   x = BAR2_SYSTEM(x);
    108 
    109   x = BAZ2_QUOTE(x); // expected-warning {{ambiguous expansion of macro}}
    110   // expected-note@Inputs/macro-ambiguity/b/quote/b_quote.h:6 {{expanding this definition}}
    111   // expected-note@Inputs/macro-ambiguity/e/quote/e_quote.h:5 {{other definition}}
    112 
    113   x = BAZ2_SYSTEM(x);
    114   return x;
    115 }
    116