[Sema] Make `&function_with_enable_if_attrs` an error
This fixes a bug where one can take the address of a conditionally enabled function to drop its enable_if guards. For example: int foo(int a) __attribute__((enable_if(a > 0, ""))); int (*p)(int) = &foo; int result = p(-1); // compilation succeeds; calls foo(-1) Overloading logic has been updated to reflect this change, as well. Functions with enable_if attributes that are always true are still allowed to have their address taken. Differential Revision: http://reviews.llvm.org/D13607 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@250090 91177308-0d34-0410-b5e6-96231b3b80d8
Showing
- include/clang/Basic/DiagnosticSemaKinds.td 8 additions, 4 deletionsinclude/clang/Basic/DiagnosticSemaKinds.td
- include/clang/Sema/Sema.h 6 additions, 4 deletionsinclude/clang/Sema/Sema.h
- lib/Sema/SemaCast.cpp 10 additions, 0 deletionslib/Sema/SemaCast.cpp
- lib/Sema/SemaExpr.cpp 10 additions, 1 deletionlib/Sema/SemaExpr.cpp
- lib/Sema/SemaInit.cpp 3 additions, 1 deletionlib/Sema/SemaInit.cpp
- lib/Sema/SemaOverload.cpp 44 additions, 13 deletionslib/Sema/SemaOverload.cpp
- test/CodeGen/enable_if.c 51 additions, 0 deletionstest/CodeGen/enable_if.c
- test/Sema/enable_if.c 25 additions, 0 deletionstest/Sema/enable_if.c
- test/SemaCXX/enable_if.cpp 71 additions, 0 deletionstest/SemaCXX/enable_if.cpp
Loading
Please register or sign in to comment