From: Douglas Gregor Date: Wed, 14 Sep 2011 20:36:30 +0000 (+0000) Subject: Don't try to write a macro offset for an identifier that names a non-exported macro X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0c129afcfb7860b9e1ff29c34edeab17b770140b;p=clang Don't try to write a macro offset for an identifier that names a non-exported macro git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@139728 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Serialization/ASTWriter.cpp b/lib/Serialization/ASTWriter.cpp index 28a69d4bdb..e2e1d2b2b5 100644 --- a/lib/Serialization/ASTWriter.cpp +++ b/lib/Serialization/ASTWriter.cpp @@ -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()); diff --git a/test/Modules/macros.c b/test/Modules/macros.c index 578e09fbda..8fefe7a9cf 100644 --- a/test/Modules/macros.c +++ b/test/Modules/macros.c @@ -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