Skip to content

Commit

Permalink
[clang-cpp-14] Support variable template specialization
Browse files Browse the repository at this point in the history
  • Loading branch information
intrigus authored and lucasccordeiro committed Mar 18, 2024
1 parent 68a0dc9 commit 9a5f374
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 0 deletions.
4 changes: 4 additions & 0 deletions regression/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ set(REGRESSIONS_CPP11 esbmc-cpp11/cpp
esbmc-cpp11/template
)

# list of C++14 test suites
set(REGRESSIONS_CPP14 esbmc-cpp14/template)

# NOTE: In order to make the best of the concurrency set sort the tests from the slowest to fastest.
if(APPLE)
set(REGRESSIONS esbmc-unix
Expand Down Expand Up @@ -180,6 +183,7 @@ else()
${REGRESSIONS_SMTLIB}
${REGRESSIONS_Z3}
incremental-smt
${REGRESSIONS_CPP14}
${REGRESSIONS_CPP11}
${REGRESSIONS_CPP03}
${REGRESSIONS_GOTO_CONTRACTOR}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#include <assert.h>

template <typename>
int a;

int main()
{
a<int> = 2;
a<double> = 3;
assert(a<int> == 3);
assert(a<double> == 4);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
CORE
main.cpp
--cppstd 14

^VERIFICATION FAILED$
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include <assert.h>

template <typename>
int a;

int main()
{
a<int> = 2;
a<double> = 42;
assert(a<int> == 2);
assert(a<int> != 42);
assert(a<double> == 42);
assert(a<double> != 2);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
CORE
main.cpp
--cppstd 14

^VERIFICATION SUCCESSFUL$
1 change: 1 addition & 0 deletions src/clang-c-frontend/clang_c_convert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ bool clang_c_convertert::get_decl(const clang::Decl &decl, exprt &new_expr)

// Declaration of variables
case clang::Decl::Var:
case clang::Decl::VarTemplateSpecialization:
{
const clang::VarDecl &vd = static_cast<const clang::VarDecl &>(decl);
return get_var(vd, new_expr);
Expand Down

0 comments on commit 9a5f374

Please sign in to comment.