]> granicus.if.org Git - clang/commitdiff
Don't try to write a macro offset for an identifier that names a non-exported macro
authorDouglas Gregor <dgregor@apple.com>
Wed, 14 Sep 2011 20:36:30 +0000 (20:36 +0000)
committerDouglas Gregor <dgregor@apple.com>
Wed, 14 Sep 2011 20:36:30 +0000 (20:36 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@139728 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Serialization/ASTWriter.cpp
test/Modules/macros.c

index 28a69d4bdbb9219b0e4cfb5b1e5f905433376dd5..e2e1d2b2b50c3e5db53c7acd5fd37d8de74a1d69 100644 (file)
@@ -2300,7 +2300,8 @@ public:
     uint32_t Bits = 0;
     bool hasMacroDefinition 
       = II->hasMacroDefinition() && 
-        (Macro || (Macro = PP.getMacroInfo(II))) && !Macro->isBuiltinMacro();
+        (Macro || (Macro = PP.getMacroInfo(II))) && !Macro->isBuiltinMacro() &&
+        (!IsModule || Macro->isExported());
     Bits = (uint32_t)II->getObjCOrBuiltinID();
     Bits = (Bits << 1) | unsigned(hasMacroDefinition);
     Bits = (Bits << 1) | unsigned(II->isExtensionToken());
index 578e09fbda4f287b7de8bedb0afc59283a8ffc2b..8fefe7a9cffc24e8db537552e9f9747caa2ffa11 100644 (file)
@@ -9,6 +9,8 @@
 #__export_macro__ INTEGER
 #__export_macro__ DOUBLE
 
+int (INTEGER);
+
 #else
 
 __import_module__ macros;
@@ -30,4 +32,7 @@ DOUBLE *dp = &d;
 
 #__export_macro__ WIBBLE // expected-error{{no macro named 'WIBBLE' to export}}
 
+void f() {
+  int i = INTEGER; // the value was exported, the macro was not.
+}
 #endif