diff options
| author | Nathan Sidwell <nathan@acm.org> | 2015-01-15 16:45:53 +0000 |
|---|---|---|
| committer | Nathan Sidwell <nathan@acm.org> | 2015-01-15 16:45:53 +0000 |
| commit | c116802ef387eeb024f8711a5a74ed38c7686d23 (patch) | |
| tree | e8b849c1594e7c35bbf4b1214cae5ff6104bcca2 /clang/lib/Sema | |
| parent | 8c9a0708a05bf84b593c11d0224afb088e5bb7db (diff) | |
| download | bcm5719-llvm-c116802ef387eeb024f8711a5a74ed38c7686d23.tar.gz bcm5719-llvm-c116802ef387eeb024f8711a5a74ed38c7686d23.zip | |
PR 20146
reject CV void return type on C definitions per 6.9.1/3
llvm-svn: 226178
Diffstat (limited to 'clang/lib/Sema')
| -rw-r--r-- | clang/lib/Sema/SemaType.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
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 |

