comparison gcc/testsuite/g++.dg/template/extern-c.C @ 111:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents
children
comparison
equal deleted inserted replaced
68:561a7518be6b 111:04ced10e8804
1 template <typename T> void specializable (T);
2
3 /* Invalid template: within "extern C". */
4
5 extern "C" { // { dg-message "1: 'extern .C.' linkage started here" }
6
7 template <typename T> // { dg-error "template with C linkage" }
8 void within_extern_c_braces (void);
9
10 }
11
12 /* Valid template: not within "extern C". */
13
14 template <typename T>
15 void not_within_extern_c (void);
16
17
18 /* Invalid specialization: within "extern C". */
19
20 extern "C" { // { dg-message "1: 'extern .C.' linkage started here" }
21
22 template <> // { dg-error "template specialization with C linkage" }
23 void specializable (int);
24
25 }
26
27
28 /* Valid specialization: not within "extern C". */
29 template <>
30 void specializable (char);
31
32
33 /* Example of extern C without braces. */
34
35 extern "C" template <typename T> // { dg-line open_extern_c_no_braces }
36 void within_extern_c_no_braces (void);
37 // { dg-error "12: template with C linkage" "" { target *-*-* } open_extern_c_no_braces }
38 // { dg-message "1: 'extern .C.' linkage started here" "" { target *-*-* } open_extern_c_no_braces }
39
40
41 /* Nested extern "C" specifications.
42 We should report within the innermost extern "C" that's still open. */
43
44 extern "C" {
45 extern "C" { // { dg-line middle_open_extern_c }
46 extern "C" {
47 }
48
49 template <typename T> // { dg-error "template with C linkage" }
50 void within_nested_extern_c (void);
51 // { dg-message "3: 'extern .C.' linkage started here" "" { target *-*-* } middle_open_extern_c }
52
53 extern "C++" {
54 /* Valid template: within extern "C++". */
55 template <typename T>
56 void within_nested_extern_cpp (void);
57
58 extern "C" { // { dg-line last_open_extern_c }
59 /* Invalid template: within "extern C". */
60 template <typename T> // { dg-error "template with C linkage" }
61 void within_extern_c_within_extern_cpp (void);
62 // { dg-message "7: 'extern .C.' linkage started here" "" { target *-*-* } last_open_extern_c }
63 }
64 }
65 }
66 }