diff options
Diffstat (limited to 'clang/test')
-rw-r--r-- | clang/test/CodeGenCXX/const-init-cxx11.cpp | 9 | ||||
-rw-r--r-- | clang/test/SemaCXX/constexpr-printing.cpp | 7 |
2 files changed, 16 insertions, 0 deletions
diff --git a/clang/test/CodeGenCXX/const-init-cxx11.cpp b/clang/test/CodeGenCXX/const-init-cxx11.cpp new file mode 100644 index 00000000000..5ec9a690f98 --- /dev/null +++ b/clang/test/CodeGenCXX/const-init-cxx11.cpp @@ -0,0 +1,9 @@ +// RUN: %clang_cc1 -verify -triple x86_64-apple-darwin -emit-llvm -o - %s -std=c++11 | FileCheck %s + +namespace CrossFuncLabelDiff { + // Make sure we refuse to constant-fold the variable b. + constexpr long a() { return (long)&&lbl + (0 && ({lbl: 0;})); } + void test() { static long b = (long)&&lbl - a(); lbl: return; } + // CHECK: sub nsw i64 ptrtoint (i8* blockaddress(@_ZN18CrossFuncLabelDiff4testEv, {{.*}}) to i64), + // CHECK: store i64 {{.*}}, i64* @_ZZN18CrossFuncLabelDiff4testEvE1b, align 8 +} diff --git a/clang/test/SemaCXX/constexpr-printing.cpp b/clang/test/SemaCXX/constexpr-printing.cpp index 03768c09fb9..2e0eb9c23d1 100644 --- a/clang/test/SemaCXX/constexpr-printing.cpp +++ b/clang/test/SemaCXX/constexpr-printing.cpp @@ -89,3 +89,10 @@ constexpr wchar_t wc = get(L"test\0\\\"\t\a\b\234\u1234"); // \ expected-error {{}} expected-note {{L"test\000\\\"\t\a\b\234\u1234"}} constexpr char32_t c32_err = get(U"\U00110000"); // expected-error {{invalid universal character}} + +typedef decltype(sizeof(int)) LabelDiffTy; +constexpr LabelDiffTy mulBy3(LabelDiffTy x) { return x * 3; } // expected-note {{subexpression}} +void LabelDiffTest() { + static_assert(mulBy3((LabelDiffTy)&&a-(LabelDiffTy)&&b) == 3, ""); // expected-error {{constant expression}} expected-note {{call to 'mulBy3(&&a - &&b)'}} + a:b:return; +} |