diff options
Diffstat (limited to 'clang')
-rw-r--r-- | clang/lib/Sema/SemaExpr.cpp | 6 | ||||
-rw-r--r-- | clang/test/Sema/conditional.c | 13 |
2 files changed, 16 insertions, 3 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index ecc1f2b001f..4673ae498fd 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -917,12 +917,14 @@ inline QualType Sema::CheckConditionalOperands( // C99 6.5.15 // C99 6.5.15p5: "If both operands have void type, the result has void type." // The following || allows only one side to be void (a GCC-ism). if (lexT->isVoidType() || rexT->isVoidType()) { - if (!lexT->isVoidType()) + if (!lexT->isVoidType()) { Diag(rex->getLocStart(), diag::ext_typecheck_cond_one_void, rex->getSourceRange()); + return rexT.getUnqualifiedType(); + } if (!rexT->isVoidType()) Diag(lex->getLocStart(), diag::ext_typecheck_cond_one_void, - lex->getSourceRange()); + lex->getSourceRange()); return lexT.getUnqualifiedType(); } // C99 6.5.15p6 - "if one operand is a null pointer constant, the result has diff --git a/clang/test/Sema/conditional.c b/clang/test/Sema/conditional.c index 3af0fe57b43..e1ad1a51ba9 100644 --- a/clang/test/Sema/conditional.c +++ b/clang/test/Sema/conditional.c @@ -1,4 +1,15 @@ -// RUN: clang %s -fsyntax-only +// RUN: clang %s -fsyntax-only -verify const char* test1 = 1 ? "i" : 1 == 1 ? "v" : "r"; +void _efree(void *ptr); + +int _php_stream_free1() +{ + return (1 ? free(0) : _efree(0)); // expected-error {{incompatible type returning 'void', expected 'int'}} +} + +int _php_stream_free2() +{ + return (1 ? _efree(0) : free(0)); // expected-error {{incompatible type returning 'void', expected 'int'}} +} |