From: Richard Smith Date: Sat, 9 Aug 2014 01:24:07 +0000 (+0000) Subject: [modules] Weaken an out-of-date assertion: an #undef can have no location if we X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f8e5e7e7103a1bb2e71affd6742d682cab904e1a;p=clang [modules] Weaken an out-of-date assertion: an #undef can have no location if we imported it from a module when performing finalization before writing out an AST file. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@215272 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Lex/MacroInfo.h b/include/clang/Lex/MacroInfo.h index bce7f5f1b4..174d0cc0dd 100644 --- a/include/clang/Lex/MacroInfo.h +++ b/include/clang/Lex/MacroInfo.h @@ -524,7 +524,7 @@ public: unsigned ImportedFromModuleID = 0, ArrayRef Overrides = None) : MacroDirective(MD_Undefine, UndefLoc, ImportedFromModuleID, Overrides) { - assert(UndefLoc.isValid() && "Invalid UndefLoc!"); + assert((UndefLoc.isValid() || ImportedFromModuleID) && "Invalid UndefLoc!"); } static bool classof(const MacroDirective *MD) { diff --git a/test/Modules/Inputs/macros_bottom.h b/test/Modules/Inputs/macros_bottom.h new file mode 100644 index 0000000000..fc0a78e462 --- /dev/null +++ b/test/Modules/Inputs/macros_bottom.h @@ -0,0 +1,3 @@ +@import macros_right; + +extern TOP_DEF_RIGHT_UNDEF *TDRUp; diff --git a/test/Modules/Inputs/macros_right_undef.h b/test/Modules/Inputs/macros_right_undef.h index 15a83666a1..5084561e10 100644 --- a/test/Modules/Inputs/macros_right_undef.h +++ b/test/Modules/Inputs/macros_right_undef.h @@ -2,3 +2,4 @@ @import macros_top; #undef TOP_OTHER_DEF_RIGHT_UNDEF +#undef TOP_DEF_RIGHT_UNDEF diff --git a/test/Modules/Inputs/macros_top.h b/test/Modules/Inputs/macros_top.h index 10935043e2..e063133a17 100644 --- a/test/Modules/Inputs/macros_top.h +++ b/test/Modules/Inputs/macros_top.h @@ -22,3 +22,4 @@ #define TOP_OTHER_DEF_RIGHT_UNDEF void #define TOP_REDEF_IN_SUBMODULES 0 +#define TOP_DEF_RIGHT_UNDEF void diff --git a/test/Modules/Inputs/module.map b/test/Modules/Inputs/module.map index fea1201523..0081c1ca00 100644 --- a/test/Modules/Inputs/module.map +++ b/test/Modules/Inputs/module.map @@ -40,6 +40,10 @@ module macros_right { header "macros_right_undef.h" } } +module macros_bottom { + header "macros_bottom.h" + export * +} module macros { header "macros.h" } module macros_other { header "macros_other.h" } module category_top { header "category_top.h" } diff --git a/test/Modules/macros.c b/test/Modules/macros.c index 7a7e570ca2..92ea88a480 100644 --- a/test/Modules/macros.c +++ b/test/Modules/macros.c @@ -130,8 +130,14 @@ void test3() { # error TOP_RIGHT_UNDEF should still be defined #endif +@import macros_bottom; + +TOP_DEF_RIGHT_UNDEF *TDRUf() { return TDRUp; } + @import macros_right.undef; +int TOP_DEF_RIGHT_UNDEF; // ok, no longer defined + // FIXME: When macros_right.undef is built, macros_top is visible because // the state from building macros_right leaks through, so macros_right.undef // undefines macros_top's macro.