steplong created this revision.
Herald added a project: All.
steplong requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
`isExternCContext()` is returning false for functions in C files
Change-Id: I51cccb476aa19dc0a0a78e951d7f482befdb78ca
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D126559
Files:
clang/lib/Sema/SemaAttr.cpp
clang/test/Sema/pragma-ms-alloc-text.c
Index: clang/test/Sema/pragma-ms-alloc-text.c
===================================================================
--- /dev/null
+++ clang/test/Sema/pragma-ms-alloc-text.c
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -fms-extensions -fsyntax-only -verify %s
+
+void foo();
+#pragma alloc_text("hello", foo) // expected-no-diagnostics
+void foo() {}
Index: clang/lib/Sema/SemaAttr.cpp
===================================================================
--- clang/lib/Sema/SemaAttr.cpp
+++ clang/lib/Sema/SemaAttr.cpp
@@ -762,8 +762,8 @@
return;
}
- DeclContext *DC = ND->getDeclContext();
- if (!DC->isExternCContext()) {
+ FunctionDecl *FD = ND->getAsFunction();
+ if (!FD->isExternC()) {
Diag(Loc, diag::err_pragma_alloc_text_c_linkage);
return;
}
Index: clang/test/Sema/pragma-ms-alloc-text.c
===================================================================
--- /dev/null
+++ clang/test/Sema/pragma-ms-alloc-text.c
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -fms-extensions -fsyntax-only -verify %s
+
+void foo();
+#pragma alloc_text("hello", foo) // expected-no-diagnostics
+void foo() {}
Index: clang/lib/Sema/SemaAttr.cpp
===================================================================
--- clang/lib/Sema/SemaAttr.cpp
+++ clang/lib/Sema/SemaAttr.cpp
@@ -762,8 +762,8 @@
return;
}
- DeclContext *DC = ND->getDeclContext();
- if (!DC->isExternCContext()) {
+ FunctionDecl *FD = ND->getAsFunction();
+ if (!FD->isExternC()) {
Diag(Loc, diag::err_pragma_alloc_text_c_linkage);
return;
}
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits