File tree Expand file tree Collapse file tree
tests/tests/regressions/gh-252 Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -25,6 +25,10 @@ with --c++17:
2525 #include "a.h"
2626 int g2() { return A<int>().f(); } // Linking with a.cpp previously failed.
2727
28+ // c.cpp
29+ #include "a.h"
30+ template struct A<int>;
31+
2832The same problem affected GNU C89 "extern inline" functions, functions with
2933the gnu_inline attribute in C99 and later C modes (which lost the "extern"
3034keyword), and such definitions of functions with an ellipsis (which were not
Original file line number Diff line number Diff line change 1- eccp -DTEST_NUMBER=1 --c++17 Test_name.c use.C inst.C
1+ ./check_defs -DTEST_NUMBER=1 --c++17 Test_name.c use.C inst.C
22Test_name.c:
33use.C:
44inst.C:
5+ Test_name.o:
6+ use.o:
7+ inst.o: _ZN1AIiE1fEv _ZN1AIiE1gEiz
Original file line number Diff line number Diff line change 1- eccp -DTEST_NUMBER=2 --c++17 --g++ Test_name.c use.C inst.C
1+ ./check_defs -DTEST_NUMBER=2 --c++17 --g++ Test_name.c use.C inst.C
22Test_name.c:
33use.C:
44inst.C:
5+ Test_name.o:
6+ use.o:
7+ inst.o: _ZN1AIiE1fEv _ZN1AIiE1gEiz
Original file line number Diff line number Diff line change 1- eccp -DTEST_NUMBER=3 --c++17 --g++ -tused Test_name.c use.C inst.C
1+ ./check_defs -DTEST_NUMBER=3 --c++17 --g++ -tused Test_name.c use.C inst.C
22Test_name.c:
33use.C:
44inst.C:
5+ Test_name.o:
6+ use.o:
7+ inst.o: _ZN1AIiE1fEv _ZN1AIiE1gEiz
Original file line number Diff line number Diff line change 1- eccp -DTEST_NUMBER=4 --c++17 --clang Test_name.c use.C inst.C
1+ ./check_defs -DTEST_NUMBER=4 --c++17 --clang Test_name.c use.C inst.C
22Test_name.c:
33use.C:
44inst.C:
5+ Test_name.o:
6+ use.o:
7+ inst.o: _ZN1AIiE1fEv _ZN1AIiE1gEiz
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+ # Compile each source file to an object file, check that only inst.o (the
3+ # explicit instantiation) defines A<int>::f and A<int>::g, and then link the
4+ # object files.
5+ opts=
6+ objs=
7+ for arg in " $@ " ; do
8+ case $arg in
9+ * .c | * .C) objs=" $objs ${arg% .* } .o" ;;
10+ * ) opts=" $opts $arg " ;;
11+ esac
12+ done
13+ eccp -c " $@ " || exit $?
14+ status=0
15+ for obj in $objs ; do
16+ defs=` nm -g --defined-only $obj | grep -o ' _ZN1AIiE1[fg]E[a-z]*' | sort`
17+ defs=` echo $defs `
18+ echo $obj : $defs
19+ expected=
20+ if [ $obj = inst.o ]; then
21+ expected=" _ZN1AIiE1fEv _ZN1AIiE1gEiz"
22+ fi
23+ if [ " $defs " != " $expected " ]; then
24+ echo " FAIL: Expected '$expected '."
25+ status=1
26+ fi
27+ done
28+ if [ $status -ne 0 ]; then
29+ exit $status
30+ fi
31+ exec eccp $opts $objs
Original file line number Diff line number Diff line change 11// type:rp
22// options:--c++17:--c++17 --g++:--c++17 --g++ -tused:--c++17 --clang
33// source_files:a.h use.C inst.C
4+ // script:./check_defs
45// The members of A<int> are used here and in use.C, but only inst.C may
56// define them; each object used to contain an external definition.
67#include " a.h"
You can’t perform that action at this time.
0 commit comments