hans added a comment.

In D128649#3612875 <https://reviews.llvm.org/D128649#3612875>, @steplong wrote:

>> Isn't the question whether `f` is considered "extern C" in the end or not? I 
>> thought `isExternC()` checks that? Are you saying it would return false for 
>> `f` in your example?
>
> Yup, `isExternC()` is returning false for that case because there's "static".

I see. It seems there's already some code that gives special treatment to 
"static extern c" functions in CodeGenModule::MaybeHandleStaticInExternC(): 
https://github.com/llvm/llvm-project/blob/llvmorg-14.0.6/clang/lib/CodeGen/CodeGenModule.cpp#L4420

Okay, I think this is almost ready. I just had one more comment about the 
if-statements above.



================
Comment at: clang/lib/Sema/SemaAttr.cpp:825
+      }
+    } else if (!isa<FunctionDecl>(ND)) {
+      Diag(Loc, diag::err_pragma_alloc_text_not_function);
----------------
Instead of checking this in two places, how about doing something like:

```
FunctionDecl *FD = dyn_cast<FunctionDecl>(ND->getCanonicalDecl());
if (!FD) {
  // error
}
```

above right after the `if (!ND)` check? Then the C++ specific code just becomes

```
if (!FD->isInExternCContext()) {
  // error
}
```


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D128649/new/

https://reviews.llvm.org/D128649

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to