[PATCH] Allow return type deduction for templates in delayed parsing mode.

Richard Smith richard at metafoo.co.uk
Tue Oct 29 16:58:40 PDT 2013



================
Comment at: lib/Parse/Parser.cpp:926-929
@@ +925,6 @@
+    return false;
+  for (unsigned I = 0, E = D.getNumTypeObjects(); I != E; ++I) {
+    unsigned chunkIndex = E - I - 1;
+    const DeclaratorChunk &DeclType = D.getTypeObject(chunkIndex);
+    if (DeclType.Kind == DeclaratorChunk::Function) {
+      const DeclaratorChunk::FunctionTypeInfo &FTI = DeclType.Fun;
----------------
Can you add some more difficult test cases for this (where the order in which we visit the objects matter), like:

  auto F() -> auto * { return (int*)0; }
  auto (*G())() -> int * { return F; }

================
Comment at: lib/Parse/Parser.cpp:1014-1015
@@ -994,3 +1013,4 @@
       TemplateInfo.Kind == ParsedTemplateInfo::Template &&
-      !D.getDeclSpec().isConstexprSpecified()) {
+      !D.getDeclSpec().isConstexprSpecified() && 
+      !isFunctionDeclaratorRequiringReturnTypeDeduction(D)) {
     MultiTemplateParamsArg TemplateParameterLists(*TemplateInfo.TemplateParams);
----------------
Can you make this use something like `Sema::canSkipFunctionBody` instead?


http://llvm-reviews.chandlerc.com/D2053



More information about the cfe-commits mailing list