]> granicus.if.org Git - clang/commit
Merging r355743:
authorHans Wennborg <hans@hanshq.net>
Tue, 12 Mar 2019 08:29:08 +0000 (08:29 +0000)
committerHans Wennborg <hans@hanshq.net>
Tue, 12 Mar 2019 08:29:08 +0000 (08:29 +0000)
commit0dc9b9fd99ef1b58dbd2c023b64f4dd74c0b9102
tree3593e87e00bb362faab987bebcc75ed922ee32e1
parent3dd7642ee4ba0dbb7e651b5ec66ed7039e97a313
Merging r355743:
------------------------------------------------------------------------
r355743 | ericwf | 2019-03-08 23:06:48 +0100 (Fri, 08 Mar 2019) | 26 lines

[8.0 Regression] Fix handling of `__builtin_constant_p` inside template arguments, enumerators, case statements, and the enable_if attribute.

Summary:
The following code is accepted by Clang 7 and prior but rejected by the upcoming 8 release and in trunk [1]

```
// error {{never produces a constant expression}}
void foo(const char* s) __attribute__((enable_if(__builtin_constant_p(*s) == false, "trap"))) {}
void test() { foo("abc"); }
```

Prior to Clang 8, the call to `__builtin_constant_p` was a constant expression returning false. Currently, it's not a valid constant expression.

The bug is caused because we failed to set `InConstantContext` when attempting to evaluate unevaluated constant expressions.

[1]  https://godbolt.org/z/ksAjmq

Reviewers: rsmith, hans, sbenza

Reviewed By: rsmith

Subscribers: kristina, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D59038
------------------------------------------------------------------------

git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_80@355898 91177308-0d34-0410-b5e6-96231b3b80d8
lib/AST/ExprConstant.cpp
test/SemaCXX/constant-expression-cxx1y.cpp
test/SemaCXX/enable_if.cpp