<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none"><!-- p { margin-top: 0px; margin-bottom: 0px; }--></style>
</head>
<body dir="ltr" style="font-size:12pt;color:#000000;background-color:#FFFFFF;font-family:Calibri,Arial,Helvetica,sans-serif;">
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px; margin-top: 0px; margin-bottom: 0px;">
(Also trying cfe-dev. Originally sent this to cfe-users.)<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px; margin-top: 0px; margin-bottom: 0px;">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px; margin-top: 0px; margin-bottom: 0px;">
Hi,<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px; margin-top: 0px; margin-bottom: 0px;">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px; margin-top: 0px; margin-bottom: 0px;">
I'm hoping a C++ language expert can help me with scoping rules for named function parameters.<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px; margin-top: 0px; margin-bottom: 0px;">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px; margin-top: 0px; margin-bottom: 0px;">
As background, I'd like to allow named function parameters in non-function declarations (such as function-pointer-typed variables) to be referenced in attribute expressions.  Currently, attempting to do so results in "use of undeclared identifier".  However,
 I'm not even sure the standard allows me to do this, let alone what assumptions any patch to clang might run afoul of.<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px; margin-top: 0px; margin-bottom: 0px;">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px; margin-top: 0px; margin-bottom: 0px;">
Consider the declaration:<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px; margin-top: 0px; margin-bottom: 0px;">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px; margin-top: 0px; margin-bottom: 0px;">
    void (*pFn)(int x);<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px; margin-top: 0px; margin-bottom: 0px;">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px; margin-top: 0px; margin-bottom: 0px;">
Reading the standard (specifically, I'm looking at C++11 draft N4527), I gather that:<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px; margin-top: 0px; margin-bottom: 0px;">
​1. pFn is not a "function declarator". I didn't see a clear definition of this, but I assume function and variable are mutually exclusive descriptions of a declarator, and that this would be a variable declarator.<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px; margin-top: 0px; margin-bottom: 0px;">
2. According to [basic.scope.proto] (3.3.4), named parameters inside function declarators which are not also definitions have function prototype scope, but this only applies to function declarators.  I do not find a scoping rule that would apply to x in my
 pFn example, assuming point 1 is correct.<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px; margin-top: 0px; margin-bottom: 0px;">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px; margin-top: 0px; margin-bottom: 0px;">
This seems like x has no applicable scoping rule and you shouldn't be able to reference it.  However, I note the following declaration is accepted as valid C++11:<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px; margin-top: 0px; margin-bottom: 0px;">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px; margin-top: 0px; margin-bottom: 0px;">
    auto (*pSum)(int x, double y) -> decltype(x + y);<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px; margin-top: 0px; margin-bottom: 0px;">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px; margin-top: 0px; margin-bottom: 0px;">
I'd appreciate any help understanding what portions of the standard apply to my examples and how to interpret them, and whether the standard in fact allows me to place an attribute on pFn which references x.</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px; margin-top: 0px; margin-bottom: 0px;">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px; margin-top: 0px; margin-bottom: 0px;">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px; margin-top: 0px; margin-bottom: 0px;">
Thanks,</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px; margin-top: 0px; margin-bottom: 0px;">
David Fontaine<br>
</div>
<p><br>
</p>

<DIV>
<HR>
</DIV>
<DIV>This email message is for the sole use of the intended recipient(s) and may 
contain confidential information.  Any unauthorized review, use, disclosure 
or distribution is prohibited.  If you are not the intended recipient, 
please contact the sender by reply email and destroy all copies of the original 
message. </DIV>
<DIV>
<HR>
</DIV>
</body>
</html>