[clang] [clang][FMV] Do not omit explicit default target_version attribute. (PR #96628)

Alexandros Lamprineas via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 27 06:37:28 PDT 2024


================
@@ -102,8 +102,9 @@ int __attribute__((target_version("sha2"))) combine(void) { return 1; }
 // expected-error at +1 {{multiversioned function declaration has a different calling convention}}
 int __attribute__((aarch64_vector_pcs, target_version("sha3"))) combine(void) { return 2; }
 
-int __attribute__((target_version("fp+aes+pmull+rcpc"))) unspec_args() { return -1; }
+int unspec_args();
 // expected-error at -1 {{multiversioned function must have a prototype}}
----------------
labrinea wrote:

The C99 standards says
"A function prototype is a declaration of a function that declares the types of its parameters".
"An identifier list in a function declarator that is not part of a definition of that function shall be empty."
"After adjustment, the parameters in a parameter type list in a function declarator that is part of a definition of that function shall not have incomplete type."
"A parameter type list specifies the types of, and may declare identifiers for, the parameters of the function."
"The special case of an unnamed parameter of type void as the only item in the list specifies that the function has no parameters."
"An identifier list declares only the identifiers of the parameters of the function. An empty list in a function declarator that is part of a definition of that function specifies that the function has no parameters. **The empty list in a function declarator that is not part of a definition of that function specifies that no information about the number or types of the parameters is supplied**".

In our case the declarator is part of a definition as far as I understand.

The latest C standard I found says
"For a function declarator without a parameter type list: the effect is as if it were declared with a parameter type list consisting of the keyword void. A function declarator provides a prototype for the function."

So perhaps we don't want to diagnose this case at all. Anyhow I don't think such a change should be part of this patch.

https://github.com/llvm/llvm-project/pull/96628


More information about the cfe-commits mailing list