[PATCH] D103611: Correct the behavior of va_arg checking in C++

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 8 04:23:25 PDT 2021


aaron.ballman added inline comments.


================
Comment at: clang/lib/Sema/SemaExpr.cpp:15789-15790
+                : Context.getCorrespondingUnsignedType(UnderlyingType);
+        if (Context.typesAreCompatible(PromoteType, UnderlyingType,
+                                       /*CompareUnqualified*/ true))
+          PromoteType = QualType();
----------------
I believe I could switch to using `hasSameType()` here though, if you preferred.


================
Comment at: clang/lib/Sema/SemaExpr.cpp:15775
+      if (Context.typesAreCompatible(PromoteType, UnderlyingType,
+                                     /*CompareUnqualified*/ true))
         PromoteType = QualType();
----------------
efriedma wrote:
> If we're not going to take advantage of the C notion of compatibility, might as well just check hasSameType().
We do still make use of that in C. For example, `mergeTypes()` (called by `typesAreCompatible()` in C mode) also does work for functions without a prototype (a distinctly C concept), special logic for merging enums and integers, qualifier handling, etc.


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

https://reviews.llvm.org/D103611



More information about the cfe-commits mailing list