def note_exits_block_captures_weak : Note<
"jump exits lifetime of block which weakly captures a variable">;
+def err_func_returning_qualified_void : Error<
+ "function cannot return qualified void type %0">;
def err_func_returning_array_function : Error<
"function cannot return %select{array|function}0 type %1">;
def err_field_declared_as_function : Error<"field %0 declared as a function">;
// class type in C++.
if ((T.getCVRQualifiers() || T->isAtomicType()) &&
!(S.getLangOpts().CPlusPlus &&
- (T->isDependentType() || T->isRecordType())))
- diagnoseRedundantReturnTypeQualifiers(S, T, D, chunkIndex);
+ (T->isDependentType() || T->isRecordType()))) {
+ if (T->isVoidType() && !S.getLangOpts().CPlusPlus &&
+ D.getFunctionDefinitionKind() == FDK_Definition) {
+ // [6.9.1/3] qualified void return is invalid on a C
+ // function definition. Apparently ok on declarations and
+ // in C++ though (!)
+ S.Diag(DeclType.Loc, diag::err_func_returning_qualified_void) << T;
+ } else
+ diagnoseRedundantReturnTypeQualifiers(S, T, D, chunkIndex);
+ }
// Objective-C ARC ownership qualifiers are ignored on the function
// return type (by type canonicalization). Complain if this attribute