From c116802ef387eeb024f8711a5a74ed38c7686d23 Mon Sep 17 00:00:00 2001 From: Nathan Sidwell Date: Thu, 15 Jan 2015 16:45:53 +0000 Subject: PR 20146 reject CV void return type on C definitions per 6.9.1/3 llvm-svn: 226178 --- clang/lib/Sema/SemaType.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'clang/lib') diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp index 0f96a1cbce3..7116973cf8d 100644 --- a/clang/lib/Sema/SemaType.cpp +++ b/clang/lib/Sema/SemaType.cpp @@ -2792,8 +2792,16 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state, // 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 -- cgit v1.2.3