[PATCH] D123955: [C2x] Disallow functions without prototypes/functions with identifier lists

Erich Keane via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 18 12:25:47 PDT 2022


erichkeane added inline comments.


================
Comment at: clang/lib/AST/ASTContext.cpp:11243
 
   // We really shouldn't be making a no-proto type here.
+  if (ArgTypes.empty() && Variadic && !getLangOpts().StrictPrototypes)
----------------
How tough would it be to change this to represent always as a C++-esque `foo(...)` prototype, just always?


================
Comment at: clang/lib/Sema/SemaDecl.cpp:8821
         (!R->getAsAdjusted<FunctionType>() && R->isFunctionProtoType());
+    assert(SemaRef.getLangOpts().StrictPrototypes
+               ? HasPrototype
----------------
This assert is quite strange, particularly with the string part of it only in the 'else' of the conditional? It seems you're trying to ensure that:
"if strictProtoTypes, assert hasProtoType"?

In that case, I'd likely suggest:

`assert((HasProtoType || !SemeaRef.getLangOpts().StrictPrototypes) && "Strict prototypes are required");`




================
Comment at: clang/test/Parser/c2x-attributes.c:64
+                                      c2x-warning 2 {{type specifier missing, defaults to 'int'}} \
+                                      c2x-error {{expected ';' after top level declarator}} \
+                                      c2x-error {{expected identifier or '('}}
----------------
This is an unfortunate change in diagnostic quality.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123955



More information about the cfe-commits mailing list