r175868 - When a parameter list in a C function has an error, recover by forming a K&R function,
Argyrios Kyrtzidis
akyrtzi at gmail.com
Thu Feb 21 22:58:33 PST 2013
Author: akirtzidis
Date: Fri Feb 22 00:58:32 2013
New Revision: 175868
URL: http://llvm.org/viewvc/llvm-project?rev=175868&view=rev
Log:
When a parameter list in a C function has an error, recover by forming a K&R function,
instead of a non-function type.
Modified:
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/test/Sema/alloc_size.c
cfe/trunk/test/Sema/invalid-decl.c
Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=175868&r1=175867&r2=175868&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Fri Feb 22 00:58:32 2013
@@ -2580,6 +2580,8 @@ static TypeSourceInfo *GetFullTypeForDec
// definition.
S.Diag(FTI.ArgInfo[0].IdentLoc, diag::err_ident_list_in_fn_declaration);
D.setInvalidType(true);
+ // Recover by creating a K&R-style function type.
+ T = Context.getFunctionNoProtoType(T);
break;
}
Modified: cfe/trunk/test/Sema/alloc_size.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/alloc_size.c?rev=175868&r1=175867&r2=175868&view=diff
==============================================================================
--- cfe/trunk/test/Sema/alloc_size.c (original)
+++ cfe/trunk/test/Sema/alloc_size.c Fri Feb 22 00:58:32 2013
@@ -23,5 +23,5 @@ void* fn9(unsigned) __attribute__((alloc
void* fn10(size_t, size_t) __attribute__((alloc_size(1,2))); // expected-error{{redefinition of parameter}} \
// expected-error{{a parameter list without types is only allowed in a function definition}} \
- // expected-warning{{alloc_size attribute only applies to functions and methods}}
+ // expected-error{{attribute parameter 1 is out of bounds}}
void* fn11() __attribute__((alloc_size(1))); // expected-error{{attribute parameter 1 is out of bounds}}
Modified: cfe/trunk/test/Sema/invalid-decl.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/invalid-decl.c?rev=175868&r1=175867&r2=175868&view=diff
==============================================================================
--- cfe/trunk/test/Sema/invalid-decl.c (original)
+++ cfe/trunk/test/Sema/invalid-decl.c Fri Feb 22 00:58:32 2013
@@ -38,3 +38,7 @@ static void bar(hid_t p, char); // expec
void foo() {
(void)bar;
}
+
+void test2();
+void test2(undef); // expected-error {{a parameter list without types is only allowed in a function definition}}
+void test2() { }
More information about the cfe-commits
mailing list