[PATCH] Fix Parser crash for invalid trailing return type in delayed template parsing mode
Stephan Tolksdorf
st at quanttec.com
Wed Mar 12 11:17:38 PDT 2014
Hi majnemer,
Fix Parser crash for invalid trailing return type in delayed template parsing mode
http://llvm-reviews.chandlerc.com/D3062
Files:
lib/Parse/Parser.cpp
test/Parser/DelayedTemplateParsing.cpp
Index: lib/Parse/Parser.cpp
===================================================================
--- lib/Parse/Parser.cpp
+++ lib/Parse/Parser.cpp
@@ -914,8 +914,10 @@
if (!FTI.hasTrailingReturnType())
return true;
QualType TrailingRetType = FTI.getTrailingReturnType().get();
- return TrailingRetType->getCanonicalTypeInternal()
- ->getContainedAutoType();
+ // If an error occurred during parsing, TrailingRetType may be null.
+ return !TrailingRetType.isNull() &&
+ TrailingRetType->getCanonicalTypeInternal()
+ ->getContainedAutoType();
}
}
return false;
Index: test/Parser/DelayedTemplateParsing.cpp
===================================================================
--- test/Parser/DelayedTemplateParsing.cpp
+++ test/Parser/DelayedTemplateParsing.cpp
@@ -121,3 +121,5 @@
constexpr int Var = Fun(20);
}
+template <typename T>
+auto invalidTrailingRetType() -> Bogus {} // expected-error {{unknown type name 'Bogus'}}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D3062.1.patch
Type: text/x-patch
Size: 1014 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140312/f17e1e96/attachment.bin>
More information about the cfe-commits
mailing list