[PATCH] Recover from missing typenames on template args for MSVC compatibility

Richard Smith richard at metafoo.co.uk
Mon Jun 9 18:42:09 PDT 2014


================
Comment at: include/clang/Basic/DiagnosticSemaKinds.td:3115
@@ +3114,3 @@
+def ext_ms_template_type_arg_missing_typename : ExtWarn<
+  "template type parameter requires a type; assuming 'typename' was intended as a Microsoft extension">,
+  InGroup<Microsoft>;
----------------
This diagnostic text isn't going to work well with `-fms-extensions -pedantic-errors`. Maybe phrase this more similarly to the existing cases:

  "template argument for template type parameter must be a type; omitted 'typename' is a Microsoft extension"

(I'm also not convinced that we should call this a "Microsoft extension", but I can live with it.)

================
Comment at: lib/Sema/SemaExpr.cpp:2196
@@ +2195,3 @@
+        << SourceRange(SS.getBeginLoc(), NameInfo.getEndLoc())
+        << FixItHint::CreateInsertion(SS.getBeginLoc(), "typename ");
+    return ExprError();
----------------
Our policy for fixits is to only put them on errors/warnings if we recover as if the fixit were applied (this is important for -fixit behavior). Either remove the fixit for now or move it to a note.

================
Comment at: lib/Sema/SemaTemplate.cpp:5921-5923
@@ -5896,2 +5920,5 @@
 
+// FIXME: We probably come here when the user implicitly instantiates a
+// template.  We're dropping Converted here on the floor instead of using our
+// corrected AST to continue parsing.
 DeclResult
----------------
This comment doesn't look quite right: we don't get here for references to a template-id.  We might have an explicit instantiation or an explicit or partial specialization, but the one thing we *don't* have is an implicit instantiation.

This would also make more sense down next to `Converted`.

http://reviews.llvm.org/D4049






More information about the cfe-commits mailing list