llvm-project/clang/lib
Duncan P. N. Exon Smith 8536392a83 Sema: Methods in unavailable classes are unavailable
Similar to the template cases in r262050, when a C++ method in an
unavailable struct/class calls unavailable API, don't diagnose an error.
I.e., this case was failing:

    void foo() __attribute__((unavailable));
    struct __attribute__((unavailable)) A {
      void bar() { foo(); }
    };

Since A is unavailable, A::bar is allowed to call foo.  However, we were
emitting a diagnostic here.  This commit checks up the context chain
from A::bar, in a manner inspired by SemaDeclAttr.cpp:isDeclUnavailable.

I expected to find other related issues but failed to trigger them:

- I wondered if DeclBase::getAvailability should check for
  `TemplateDecl` instead of `FunctionTemplateDecl`, but I couldn't find
  a way to trigger this.  I left behind a few extra tests to make sure
  we don't regress.

- I wondered if Sema::isFunctionConsideredUnavailable should be
  symmetric, checking up the context chain of the callee (this commit
  only checks up the context chain of the caller).  However, I couldn't
  think of a testcase that didn't require first referencing the
  unavailable type; this, we already diagnose.

rdar://problem/25030656

llvm-svn: 262921
2016-03-08 10:28:52 +00:00
..
ARCMigrate Fix some Clang-tidy readability-redundant-control-flow warnings; other minor fixes. 2016-02-10 19:11:58 +00:00
AST Sema: Treat 'strict' availability flag like unavailable 2016-03-08 06:12:54 +00:00
ASTMatchers Fix a -Wunused-variable diagnostic. 2016-02-23 10:29:04 +00:00
Analysis [analyzer] Find ObjC 'self' decl even when block captures local named 'self'. 2016-02-23 22:26:04 +00:00
Basic Implement __builtin_eh_return_data_regno for SPARC and SPARC64. 2016-03-07 17:19:15 +00:00
CodeGen Module Debugging: Fix a crash when emitting debug info for nested tag types 2016-03-07 20:58:52 +00:00
Driver clang-cl: Enable PCH flags by default. 2016-03-04 21:59:42 +00:00
Edit Remove autoconf support 2016-01-26 21:30:40 +00:00
Format clang-format: [JS] Support destructuring assignments in for loops. 2016-03-05 18:34:26 +00:00
Frontend Make TargetInfo store an actual DataLayout instead of a string. 2016-03-04 19:00:41 +00:00
FrontendTool Revert r260265, "clang-cl: Support loading plugins on Windows" 2016-02-11 16:33:20 +00:00
Headers Add doxygen comments to bmiintrin.h's intrinsics. 2016-03-08 01:36:59 +00:00
Index Make TargetInfo store an actual DataLayout instead of a string. 2016-03-04 19:00:41 +00:00
Lex [Modules] Don't swallow errors when parsing optional attributes. 2016-03-06 04:20:05 +00:00
Parse Implement support for [[nodiscard]] in C++1z that is based off existing support for warn_unused_result, and treat it as an extension pre-C++1z. This also means extending the existing warn_unused_result attribute so that it can be placed on an enum as well as a class. 2016-03-07 22:44:55 +00:00
Rewrite Remove use of builtin comma operator. 2016-02-18 22:34:54 +00:00
Sema Sema: Methods in unavailable classes are unavailable 2016-03-08 10:28:52 +00:00
Serialization Reapply r262741 [OPENMP] Codegen for distribute directive 2016-03-07 16:04:49 +00:00
StaticAnalyzer [analyzer] Fix missed leak from MSVC specific allocation functions 2016-03-08 01:21:51 +00:00
Tooling Add functions to apply replacements and reformat them. 2016-03-01 12:37:30 +00:00
CMakeLists.txt Fix build with various feature flag combinations 2014-07-14 22:17:22 +00:00