From 38cea6dc71c7a62e8e612b648f857bcb37a1aaa3 Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Fri, 25 May 2012 11:09:08 -0700 Subject: [PATCH] Issue error if "typedef" is inadvertently included in function definition. Issue #267. --- parse.yy | 2 ++ tests_errors/func-def-with-typedef.ispc | 4 ++++ 2 files changed, 6 insertions(+) create mode 100644 tests_errors/func-def-with-typedef.ispc diff --git a/parse.yy b/parse.yy index 3eb4b2be..33e19dbc 100644 --- a/parse.yy +++ b/parse.yy @@ -1862,6 +1862,8 @@ function_definition const FunctionType *funcType = CastType($2->type); if (funcType == NULL) AssertPos(@1, m->errorCount > 0); + else if ($1->storageClass == SC_TYPEDEF) + Error(@1, "Illegal \"typedef\" provided with function definition."); else { Stmt *code = $4; if (code == NULL) code = new StmtList(@4); diff --git a/tests_errors/func-def-with-typedef.ispc b/tests_errors/func-def-with-typedef.ispc new file mode 100644 index 00000000..a750a9be --- /dev/null +++ b/tests_errors/func-def-with-typedef.ispc @@ -0,0 +1,4 @@ +// Illegal "typedef" provided with function definition + +typedef float foo(float a, float b) { } +