[PATCH] D16770: [MS] PR26234: Allow typedef redefinition of equally qualified, sized and aligned types in C

Denis Zobnin via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 3 07:03:50 PST 2016


d.zobnin.bugzilla marked 5 inline comments as done.

================
Comment at: include/clang/AST/ASTContext.h:1772-1783
@@ -1771,1 +1771,14 @@
 
+  /// Return true is the given typedef types are compatible in C from MSVC's
+  /// point of view.
+  //
+  // Conditions:
+  //   1. Both typedef types are either integer, enumeral or pointers;
+  //   2. Both typedef types have the same qualifiers and signedness;
+  //   3. Both typedef types have the same size and alignment;
+  //   4. If pointers:
+  //     4.1. Levels of pointers are equal;
+  //     4.2. Pointee types are MSVC-compatible OR
+  //     4.3. One type points to void and another points to char.
+  bool areMSCompatibleTypedefTypesInC(QualType OldType, QualType NewType);
+
----------------
By the way, MSVC allows to redefine not anly typedefs, but variables as well (under the same conditions as typedefs):

```
int x;
long x;
```
Typedef redefinition seems to be just an example of MSVC's permissive behavior. The same for return types, etc.

So, do you think we need to compatible with MSVC, for example, also considering only integer types?

================
Comment at: include/clang/Basic/DiagnosticSemaKinds.td:4267-4269
@@ -4266,1 +4266,5 @@
   InGroup<DiagGroup<"objc-forward-class-redefinition">>;
+def warn_int_typedef_redefinition_ignored : ExtWarn<
+  "ignoring conflicting integer typedef redefinition%diff{ ($ vs $)|}0,1 "
+  "as a Microsoft extension; types have the same width and signedness">,
+  InGroup<Microsoft>;
----------------
Done. I also tried to move the phrase "types have the same ..." to a note, but I thought the only warning was better.


http://reviews.llvm.org/D16770





More information about the cfe-commits mailing list