[PATCH] [Mips] Generate warning for invalid combination of '-mnan' and '-march' options.

Petar Jovanovic petar.jovanovic at imgtec.com
Tue Apr 7 06:59:32 PDT 2015


================
Comment at: lib/Basic/Targets.cpp:5769
@@ +5768,3 @@
+        .Case("mips32r3", NanLegacy | Nan2008)
+        .Case("mips32r5", NanLegacy | Nan2008)
+        .Case("mips32r6", Nan2008)
----------------
vradosavljevic wrote:
> dsanders wrote:
> > petarj wrote:
> > > It might be me only, but seeing a function that returns enum but can actually return non-enumerated value seems wrong (I am not saying it is illegal though).
> > > I see this is already done for ArchDefineTypes within PPCTargetInfo, but it still looks wrong (to me).
> > > Would not this trigger a runtime error in clang if it was compiled with "-fsanitize=enum"?
> > I think this is the main remaining comment. I agree in principle that enum types should have the value of one of the enum values. Like Petar, I don't think it's technically wrong though. Have you tried the -fsanitize=enum option that was suggested?
> > 
> > Elsewhere, an integer type is used instead but given that there's only two values and I would be very surprised if we ever add more, we should probably just define NanBoth = 3 if it's a problem.
> I tried -fsanitize=enum there wasn't runtime error. Should i define NanBoth?
It seems -fsanitize=enum will allow all values up to a number that you get when you OR all possible valid enum values, so 3 in this case is OK, but not 4 for instance.
So, no need to modify this if none of the tools is complaining.

http://reviews.llvm.org/D8170

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the cfe-commits mailing list