[PATCH] D133586: [clang] initialize type qualifiers for FunctionNoProtoType

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Sep 22 11:53:29 PDT 2022


aaron.ballman added a comment.

In D133586#3787814 <https://reviews.llvm.org/D133586#3787814>, @rmaz wrote:

> I took a look at writing a test to cover this, but hit the following problem: function qualifiers are only valid on c++ members, and there we cannot create FunctionNoProtoTypes. I couldn't think of a way of testing this by comparing module output that would fail deterministically, as it relies on reusing uninitialized memory that is non-zero.

This is why I'm wondering how we're hitting this problem in the first place. C++ shouldn't be able to create a function without a prototype so why does the ODR hash matter (do we use that in C and I just wasn't aware of it)?



================
Comment at: clang/include/clang/AST/Type.h:3947
+                     Info) {
+    FunctionTypeBits.FastTypeQuals = 0;
+  }
----------------
It seems a bit odd to me that we only want to initialize one member of the bits and none of the rest.


================
Comment at: clang/unittests/AST/DeclTest.cpp:365
+      Code.code(),
+      /*Args=*/{"-target", "i386-apple-darwin", "-x", "objective-c"});
+  ASTContext &Ctx = AST->getASTContext();
----------------
You should also pass `-std=c89` explicitly so that the test continues to work when we switch the default language mode to C23 someday in the future.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133586



More information about the cfe-commits mailing list