diff options
author | Gary Funck <gary@intrepid.com> | 2017-10-17 03:19:54 +0000 |
---|---|---|
committer | Gary Funck <gary@intrepid.com> | 2017-10-17 03:19:54 +0000 |
commit | 94de5b24eede2f2ed005b253a2c584675cd682d8 (patch) | |
tree | ac7aa645d5d9139bd11f7410e3654026e3e2cd44 /gcc/testsuite/g++.dg/template/extern-c.C | |
parent | 7af4e6706d969f6d2402e0a50473a70a9c85e5be (diff) | |
parent | 8905b0de50e8b67dda7c2e787c840720b98a637d (diff) |
Merge trunk version 253779 into gupc branch.gupc
git-svn-id: https://gcc.gnu.org/svn/gcc/branches/gupc@253802 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/testsuite/g++.dg/template/extern-c.C')
-rw-r--r-- | gcc/testsuite/g++.dg/template/extern-c.C | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/template/extern-c.C b/gcc/testsuite/g++.dg/template/extern-c.C new file mode 100644 index 00000000000..c0dd7cb66d5 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/extern-c.C @@ -0,0 +1,66 @@ +template <typename T> void specializable (T); + +/* Invalid template: within "extern C". */ + +extern "C" { // { dg-message "1: 'extern .C.' linkage started here" } + +template <typename T> // { dg-error "template with C linkage" } +void within_extern_c_braces (void); + +} + +/* Valid template: not within "extern C". */ + +template <typename T> +void not_within_extern_c (void); + + +/* Invalid specialization: within "extern C". */ + +extern "C" { // { dg-message "1: 'extern .C.' linkage started here" } + +template <> // { dg-error "template specialization with C linkage" } +void specializable (int); + +} + + +/* Valid specialization: not within "extern C". */ +template <> +void specializable (char); + + +/* Example of extern C without braces. */ + +extern "C" template <typename T> // { dg-line open_extern_c_no_braces } +void within_extern_c_no_braces (void); +// { dg-error "12: template with C linkage" "" { target *-*-* } open_extern_c_no_braces } +// { dg-message "1: 'extern .C.' linkage started here" "" { target *-*-* } open_extern_c_no_braces } + + +/* Nested extern "C" specifications. + We should report within the innermost extern "C" that's still open. */ + +extern "C" { + extern "C" { // { dg-line middle_open_extern_c } + extern "C" { + } + + template <typename T> // { dg-error "template with C linkage" } + void within_nested_extern_c (void); + // { dg-message "3: 'extern .C.' linkage started here" "" { target *-*-* } middle_open_extern_c } + + extern "C++" { + /* Valid template: within extern "C++". */ + template <typename T> + void within_nested_extern_cpp (void); + + extern "C" { // { dg-line last_open_extern_c } + /* Invalid template: within "extern C". */ + template <typename T> // { dg-error "template with C linkage" } + void within_extern_c_within_extern_cpp (void); + // { dg-message "7: 'extern .C.' linkage started here" "" { target *-*-* } last_open_extern_c } + } + } + } +} |