steplong added a comment. I tried the following:
FunctionDecl *FD = ND->getAsFunction(); DeclContext *DC = ND->getDeclContext(); DEBUG_WITH_TYPE("foo", llvm::dbgs() << "[FOO] DC->isExternCContext() : " << DC->isExternCContext() << "\n"); DEBUG_WITH_TYPE("foo", llvm::dbgs() << "[FOO] FD->isExternC() : " << FD->isExternC() << "\n"); DEBUG_WITH_TYPE("foo", llvm::dbgs() << "[FOO] FD->isInExternCContext() : " << FD->isInExternCContext() << "\n"); llvm::dbgs() << "[FOO] "; ND->dump(); if (getLangOpts().CPlusPlus && !DC->isExternCContext()) { Diag(Loc, diag::err_pragma_alloc_text_c_linkage); return; } and I'm getting the following output: [FOO] DC->isExternCContext() : 0 [FOO] FD->isExternC() : 0 [FOO] FD->isInExternCContext() : 0 [FOO] FunctionDecl 0x10ec0250 prev 0x10ec0148 <foo.cpp:4:1, col:17> col:13 foo 'void ()' static The C file is: 1 extern "C" { 2 static void foo(); 3 } 4 static void foo(); 5 #pragma alloc_text("s", foo) 6 static void foo() {} Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D126559/new/ https://reviews.llvm.org/D126559 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits