This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rG78e774e0c827: [clang][Interp] Handle __extension__ unary operators (authored by tbaeder).
Changed prior to commit: https://reviews.llvm.org/D148690?vs=514844&id=544207#toc Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D148690/new/ https://reviews.llvm.org/D148690 Files: clang/lib/AST/Interp/ByteCodeExprGen.cpp clang/test/AST/Interp/literals.cpp Index: clang/test/AST/Interp/literals.cpp =================================================================== --- clang/test/AST/Interp/literals.cpp +++ clang/test/AST/Interp/literals.cpp @@ -880,5 +880,16 @@ static_assert(strings_match(__func__, "foo"), ""); static_assert(strings_match(__PRETTY_FUNCTION__, "void PredefinedExprs::foo()"), ""); } + + constexpr char heh(unsigned index) { + __FUNCTION__; // ref-warning {{result unused}} \ + // expected-warning {{result unused}} + __extension__ __FUNCTION__; // ref-warning {{result unused}} \ + // expected-warning {{result unused}} + return __FUNCTION__[index]; + } + static_assert(heh(0) == 'h', ""); + static_assert(heh(1) == 'e', ""); + static_assert(heh(2) == 'h', ""); #endif } Index: clang/lib/AST/Interp/ByteCodeExprGen.cpp =================================================================== --- clang/lib/AST/Interp/ByteCodeExprGen.cpp +++ clang/lib/AST/Interp/ByteCodeExprGen.cpp @@ -2004,6 +2004,9 @@ case UO_Real: // __real x case UO_Imag: // __imag x case UO_Extension: + if (DiscardResult) + return this->discard(SubExpr); + return this->visit(SubExpr); case UO_Coawait: assert(false && "Unhandled opcode"); }
Index: clang/test/AST/Interp/literals.cpp =================================================================== --- clang/test/AST/Interp/literals.cpp +++ clang/test/AST/Interp/literals.cpp @@ -880,5 +880,16 @@ static_assert(strings_match(__func__, "foo"), ""); static_assert(strings_match(__PRETTY_FUNCTION__, "void PredefinedExprs::foo()"), ""); } + + constexpr char heh(unsigned index) { + __FUNCTION__; // ref-warning {{result unused}} \ + // expected-warning {{result unused}} + __extension__ __FUNCTION__; // ref-warning {{result unused}} \ + // expected-warning {{result unused}} + return __FUNCTION__[index]; + } + static_assert(heh(0) == 'h', ""); + static_assert(heh(1) == 'e', ""); + static_assert(heh(2) == 'h', ""); #endif } Index: clang/lib/AST/Interp/ByteCodeExprGen.cpp =================================================================== --- clang/lib/AST/Interp/ByteCodeExprGen.cpp +++ clang/lib/AST/Interp/ByteCodeExprGen.cpp @@ -2004,6 +2004,9 @@ case UO_Real: // __real x case UO_Imag: // __imag x case UO_Extension: + if (DiscardResult) + return this->discard(SubExpr); + return this->visit(SubExpr); case UO_Coawait: assert(false && "Unhandled opcode"); }
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits