From Jason Turner

[dcl.fct.def.general]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp8xdulqo9/{from.md → to.md} +19 -15
tmp/tmp8xdulqo9/{from.md → to.md} RENAMED
@@ -19,22 +19,18 @@ Any informal reference to the body of a function should be interpreted
19
  as a reference to the non-terminal *function-body*. The optional
20
  *attribute-specifier-seq* in a *function-definition* appertains to the
21
  function. A *virt-specifier-seq* can be part of a *function-definition*
22
  only if it is a *member-declaration* ([[class.mem]]).
23
 
24
- The *declarator* in a *function-definition* shall have the form
 
 
 
25
 
26
- ``` bnf
27
- 'D1 (' parameter-declaration-clause ')' cv-qualifier-seqₒₚₜ
28
 
29
- ref-qualifierₒₚₜ exception-specificationₒₚₜ attribute-specifier-seqₒₚₜ trailing-return-typeₒₚₜ
30
- ```
31
-
32
- as described in  [[dcl.fct]]. A function shall be defined only in
33
- namespace or class scope.
34
-
35
- a simple example of a complete function definition is
36
 
37
  ``` cpp
38
  int max(int a, int b, int c) {
39
  int m = (a > b) ? a : b;
40
  return (m > c) ? m : c;
@@ -42,26 +38,30 @@ int max(int a, int b, int c) {
42
  ```
43
 
44
  Here `int` is the *decl-specifier-seq*; `max(int` `a,` `int` `b,` `int`
45
  `c)` is the *declarator*; `{ /* ... */ }` is the *function-body*.
46
 
 
 
47
  A *ctor-initializer* is used only in a constructor; see  [[class.ctor]]
48
  and  [[class.init]].
49
 
50
- A *cv-qualifier-seq* or a *ref-qualifier* (or both) can be part of a
51
- non-static member function declaration, non-static member function
52
- definition, or pointer to member function only ([[dcl.fct]]); see 
53
- [[class.this]].
54
 
55
  Unused parameters need not be named. For example,
56
 
57
  ``` cpp
58
  void print(int a, int) {
59
  std::printf("a = %d\n",a);
60
  }
61
  ```
62
 
 
 
63
  In the *function-body*, a *function-local predefined variable* denotes a
64
  block-scope object of static storage duration that is implicitly defined
65
  (see  [[basic.scope.block]]).
66
 
67
  The function-local predefined variable `__func__` is defined as if a
@@ -71,15 +71,19 @@ definition of the form
71
  static const char __func__[] = "function-name";
72
  ```
73
 
74
  had been provided, where *function-name* is an *implementation-defined*
75
  string. It is unspecified whether such a variable has an address
76
- distinct from that of any other object in the program.[^13]
 
 
77
 
78
  ``` cpp
79
  struct S {
80
  S() : s(__func__) { } // OK
81
  const char* s;
82
  };
83
  void f(const char* s = __func__); // error: __func__ is undeclared
84
  ```
85
 
 
 
 
19
  as a reference to the non-terminal *function-body*. The optional
20
  *attribute-specifier-seq* in a *function-definition* appertains to the
21
  function. A *virt-specifier-seq* can be part of a *function-definition*
22
  only if it is a *member-declaration* ([[class.mem]]).
23
 
24
+ In a *function-definition*, either `void` *declarator* `;` or
25
+ *declarator* `;` shall be a well-formed function declaration as
26
+ described in  [[dcl.fct]]. A function shall be defined only in namespace
27
+ or class scope.
28
 
29
+ [*Example 1*:
 
30
 
31
+ A simple example of a complete function definition is
 
 
 
 
 
 
32
 
33
  ``` cpp
34
  int max(int a, int b, int c) {
35
  int m = (a > b) ? a : b;
36
  return (m > c) ? m : c;
 
38
  ```
39
 
40
  Here `int` is the *decl-specifier-seq*; `max(int` `a,` `int` `b,` `int`
41
  `c)` is the *declarator*; `{ /* ... */ }` is the *function-body*.
42
 
43
+ — *end example*]
44
+
45
  A *ctor-initializer* is used only in a constructor; see  [[class.ctor]]
46
  and  [[class.init]].
47
 
48
+ [*Note 1*: A *cv-qualifier-seq* affects the type of `this` in the body
49
+ of a member function; see  [[dcl.ref]]. *end note*]
50
+
51
+ [*Note 2*:
52
 
53
  Unused parameters need not be named. For example,
54
 
55
  ``` cpp
56
  void print(int a, int) {
57
  std::printf("a = %d\n",a);
58
  }
59
  ```
60
 
61
+ — *end note*]
62
+
63
  In the *function-body*, a *function-local predefined variable* denotes a
64
  block-scope object of static storage duration that is implicitly defined
65
  (see  [[basic.scope.block]]).
66
 
67
  The function-local predefined variable `__func__` is defined as if a
 
71
  static const char __func__[] = "function-name";
72
  ```
73
 
74
  had been provided, where *function-name* is an *implementation-defined*
75
  string. It is unspecified whether such a variable has an address
76
+ distinct from that of any other object in the program.[^11]
77
+
78
+ [*Example 2*:
79
 
80
  ``` cpp
81
  struct S {
82
  S() : s(__func__) { } // OK
83
  const char* s;
84
  };
85
  void f(const char* s = __func__); // error: __func__ is undeclared
86
  ```
87
 
88
+ — *end example*]
89
+