diff options
author | Chandler Carruth <chandlerc@gmail.com> | 2010-02-03 11:02:14 +0000 |
---|---|---|
committer | Chandler Carruth <chandlerc@gmail.com> | 2010-02-03 11:02:14 +0000 |
commit | 4a73ea9c4e87aa111901f3c27b08f0571b58a4cf (patch) | |
tree | c1f5ee2f18138128e72a146316bdd6e4062906d5 /test/SemaCXX/new-delete-predefined-decl.cpp | |
parent | 5147fa6d580e4c123d0a90fa737f40824f50aa50 (diff) |
Teach the allocation function overload handling to deal with templates, and
prevent a crash on templates when looking for an existing declaration of the
predefined global operators. This fixes PR5918.
Added an easy test case for the overload handling, but testing the crash is
a bit trickier. Created a new test that can use multiple runs with a define to
trigger which test case is used so we can test this type of issue.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95220 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/SemaCXX/new-delete-predefined-decl.cpp')
-rw-r--r-- | test/SemaCXX/new-delete-predefined-decl.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/test/SemaCXX/new-delete-predefined-decl.cpp b/test/SemaCXX/new-delete-predefined-decl.cpp new file mode 100644 index 0000000000..6234b740a4 --- /dev/null +++ b/test/SemaCXX/new-delete-predefined-decl.cpp @@ -0,0 +1,18 @@ +// RUN: %clang_cc1 -DTEMPLATE_OVERLOAD -fsyntax-only -verify %s + +#include <stddef.h> + +// Note that each test must be run separately so it can be the first operator +// new declaration in the file. + +#if defined(TEMPLATE_OVERLOAD) +// Don't crash on global template operator new overloads. +template<typename T> void* operator new(size_t, T); +void test_template_overload() { + (void)new(0) double; +} +#endif + +void test_predefined() { + (void)new double; +} |