From 1d73d1aaa16f9855bc1687e928d614dbb58742be Mon Sep 17 00:00:00 2001 From: Erich Keane Date: Wed, 13 Jun 2018 13:25:11 +0000 Subject: Correct behavior of __builtin_*_overflow and constexpr. Enable these builtins to be called across a lambda boundary with captureless const/constexpr, as brought up by Eli here: https://reviews.llvm.org/D48040 Differential Revision: https://reviews.llvm.org/D48053 llvm-svn: 334597 --- clang/test/SemaCXX/builtins-overflow.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 clang/test/SemaCXX/builtins-overflow.cpp (limited to 'clang/test/SemaCXX/builtins-overflow.cpp') diff --git a/clang/test/SemaCXX/builtins-overflow.cpp b/clang/test/SemaCXX/builtins-overflow.cpp new file mode 100644 index 00000000000..9054cce2573 --- /dev/null +++ b/clang/test/SemaCXX/builtins-overflow.cpp @@ -0,0 +1,15 @@ +// RUN: %clang_cc1 -fsyntax-only -std=c++17 -verify %s +// expected-no-diagnostics + +int a() { + const int x = 3; + static int z; + constexpr int *y = &z; + return []() { return __builtin_sub_overflow((int)x, (int)x, (int *)y); }(); +} +int a2() { + const int x = 3; + static int z; + constexpr int *y = &z; + return []() { return __builtin_sub_overflow(x, x, y); }(); +} -- cgit v1.2.3