summaryrefslogtreecommitdiffstats
path: root/clang/test/Parser/cxx-template-decl.cpp
diff options
context:
space:
mode:
authorReid Kleckner <reid@kleckner.net>2014-12-15 23:16:32 +0000
committerReid Kleckner <reid@kleckner.net>2014-12-15 23:16:32 +0000
commitd61a3110106abaa9073d255472a1331473612fcd (patch)
treedd89f41124872f21656f875204bf6790a8c1852b /clang/test/Parser/cxx-template-decl.cpp
parent42102b110eafdd73d70613d6f960452c5f82cea4 (diff)
downloadbcm5719-llvm-d61a3110106abaa9073d255472a1331473612fcd.tar.gz
bcm5719-llvm-d61a3110106abaa9073d255472a1331473612fcd.zip
Diagnose function template definitions inside functions
The parser can only be tricked into parsing a function template definition by inserting a typename keyword before the function template declaration. This used to make us crash, and now it's fixed. While here, remove an unneeded boolean parameter from ParseDeclGroup. This boolean always corresponded to non-typedef declarators at file scope. ParseDeclGroup already has precise diagnostics for the function definition typedef case, so we can let that through. Fixes PR21839. llvm-svn: 224287
Diffstat (limited to 'clang/test/Parser/cxx-template-decl.cpp')
-rw-r--r--clang/test/Parser/cxx-template-decl.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/clang/test/Parser/cxx-template-decl.cpp b/clang/test/Parser/cxx-template-decl.cpp
index bce1b7cbdeb..efa42ad30d0 100644
--- a/clang/test/Parser/cxx-template-decl.cpp
+++ b/clang/test/Parser/cxx-template-decl.cpp
@@ -211,6 +211,19 @@ void Instantiate() {
}
+namespace func_tmpl_spec_def_in_func {
+// We failed to diagnose function template specialization definitions inside
+// functions during recovery previously.
+template <class> void FuncTemplate() {}
+void TopLevelFunc() {
+ // expected-error@+2 {{expected a qualified name after 'typename'}}
+ // expected-error@+1 {{function definition is not allowed here}}
+ typename template <> void FuncTemplate<void>() { }
+ // expected-error@+1 {{function definition is not allowed here}}
+ void NonTemplateInner() { }
+}
+}
+
namespace broken_baseclause {
template<typename T>
struct base { };
OpenPOWER on IntegriCloud