]> granicus.if.org Git - clang/commitdiff
[modules] Weaken an out-of-date assertion: an #undef can have no location if we
authorRichard Smith <richard-llvm@metafoo.co.uk>
Sat, 9 Aug 2014 01:24:07 +0000 (01:24 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Sat, 9 Aug 2014 01:24:07 +0000 (01:24 +0000)
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

include/clang/Lex/MacroInfo.h
test/Modules/Inputs/macros_bottom.h [new file with mode: 0644]
test/Modules/Inputs/macros_right_undef.h
test/Modules/Inputs/macros_top.h
test/Modules/Inputs/module.map
test/Modules/macros.c

index bce7f5f1b4ae726ee58f4fec31a1d5ecd7d4296a..174d0cc0dd101862fe3e7054db2657e11db471c5 100644 (file)
@@ -524,7 +524,7 @@ public:
                                unsigned ImportedFromModuleID = 0,
                                ArrayRef<unsigned> 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 (file)
index 0000000..fc0a78e
--- /dev/null
@@ -0,0 +1,3 @@
+@import macros_right;
+
+extern TOP_DEF_RIGHT_UNDEF *TDRUp;
index 15a83666a136909ceb0a5607483f7e101bb89233..5084561e108bc7e7a59f4b78881cf0697dc982e2 100644 (file)
@@ -2,3 +2,4 @@
 
 @import macros_top;
 #undef TOP_OTHER_DEF_RIGHT_UNDEF
+#undef TOP_DEF_RIGHT_UNDEF
index 10935043e2a166406c9dda4640aae4a5a6a94c5d..e063133a172d09e2afc9e3397a59b71349e1c18b 100644 (file)
@@ -22,3 +22,4 @@
 #define TOP_OTHER_DEF_RIGHT_UNDEF void
 
 #define TOP_REDEF_IN_SUBMODULES 0
+#define TOP_DEF_RIGHT_UNDEF void
index fea12015233b6fa26c9cc4321deb94454301bf6d..0081c1ca000c7f25289f771242abc67161c13deb 100644 (file)
@@ -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" }
index 7a7e570ca256b3359fa37584425439754c6d1d5e..92ea88a480203fca8ca092da6a43dfcb22a5db51 100644 (file)
@@ -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.