[PATCH] D15373: Fix for bug 25786 - Assertion "Chunk.Kind == DeclaratorChunk::Function" failed with regparm attribute.

Reid Kleckner via cfe-commits cfe-commits at lists.llvm.org
Wed Dec 9 13:46:41 PST 2015


rnk added a subscriber: rnk.

================
Comment at: include/clang/Sema/Sema.h:2938
@@ -2937,2 +2937,3 @@
   bool CheckRegparmAttr(const AttributeList &attr, unsigned &value);
+  bool getCCFromAttr(const AttributeList &attr, CallingConv &CC);
   bool CheckCallingConvAttr(const AttributeList &attr, CallingConv &CC, 
----------------
Rather than adding this extra entry point, I think it would be simpler to extend CheckCallingConvAttr to return whatever extra info we need.

Besides, this new entry point also emits diagnostics, and it has a name that suggests it will not emit diagnostics.

================
Comment at: lib/Sema/SemaType.cpp:5866
@@ -5865,3 +5865,3 @@
   CallingConv CC;
   if (S.CheckCallingConvAttr(attr, CC))
     return true;
----------------
Right, we've already done the work that you are doing down below. We should just get what we needed to know out of here and pass it on.

================
Comment at: lib/Sema/SemaType.cpp:5925-5926
@@ +5924,4 @@
+      S.Context.getTargetInfo().checkCallingConvention(RawCC);
+  // If calling convention is available (CCCR_OK) or default (CCCR_Ignored), add
+  // it to type.
+  if (CCResult != TargetInfo::CCCR_Warning)
----------------
At a high level, why would you want to not create an AttributedType here? That seems desirable, the user wrote the type attribute in the source, and that should be reflected in the AST sugar.

If adding this sugar causes assertions later, then the bug must be somewhere else.

================
Comment at: test/CodeGen/adding_defaulted_attr_to_type.c:5
@@ +4,2 @@
+
+// CHECK: @f = common global void (i32)*
----------------
You can add more tests. I noticed this crashes for me:
  void (__attribute__((regparm(2), stdcall)) foo)(int);
That seems like a good one to add.

You can also rerun the test with i686-unknown-linux-gnu and #ifdefs to see that we accept the convention as desired on 32-bit.




http://reviews.llvm.org/D15373





More information about the cfe-commits mailing list