cpp_diagnostics.carbon 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450
  1. // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. // Exceptions. See /LICENSE for license information.
  3. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. //
  5. // INCLUDE-FILE: toolchain/testing/testdata/min_prelude/none.carbon
  6. //
  7. // AUTOUPDATE
  8. // TIP: To test this file alone, run:
  9. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/interop/cpp/cpp_diagnostics.carbon
  10. // TIP: To dump output, run:
  11. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/interop/cpp/cpp_diagnostics.carbon
  12. // ============================================================================
  13. // One error
  14. // ============================================================================
  15. // --- one_error.h
  16. #error "error1"
  17. // --- fail_import_cpp_file_with_one_error.carbon
  18. library "[[@TEST_NAME]]";
  19. // CHECK:STDERR: fail_import_cpp_file_with_one_error.carbon:[[@LINE+7]]:1: in import [InImport]
  20. // CHECK:STDERR: ./one_error.h:2: error: In file included from fail_import_cpp_file_with_one_error.carbon.generated.cpp_imports.h:1:
  21. // CHECK:STDERR: ./one_error.h:2:2: error: "error1"
  22. // CHECK:STDERR: 2 | #error "error1"
  23. // CHECK:STDERR: | ^
  24. // CHECK:STDERR: [CppInteropParseError]
  25. // CHECK:STDERR:
  26. import Cpp library "one_error.h";
  27. // ============================================================================
  28. // Multiple errors
  29. // ============================================================================
  30. // --- multiple_errors.h
  31. #error "error1"
  32. #error "error2"
  33. // --- fail_import_cpp_file_with_multiple_errors.carbon
  34. library "[[@TEST_NAME]]";
  35. // CHECK:STDERR: fail_import_cpp_file_with_multiple_errors.carbon:[[@LINE+14]]:1: in import [InImport]
  36. // CHECK:STDERR: ./multiple_errors.h:2: error: In file included from fail_import_cpp_file_with_multiple_errors.carbon.generated.cpp_imports.h:1:
  37. // CHECK:STDERR: ./multiple_errors.h:2:2: error: "error1"
  38. // CHECK:STDERR: 2 | #error "error1"
  39. // CHECK:STDERR: | ^
  40. // CHECK:STDERR: [CppInteropParseError]
  41. // CHECK:STDERR:
  42. // CHECK:STDERR: fail_import_cpp_file_with_multiple_errors.carbon:[[@LINE+7]]:1: in import [InImport]
  43. // CHECK:STDERR: ./multiple_errors.h:3: error: In file included from fail_import_cpp_file_with_multiple_errors.carbon.generated.cpp_imports.h:1:
  44. // CHECK:STDERR: ./multiple_errors.h:3:2: error: "error2"
  45. // CHECK:STDERR: 3 | #error "error2"
  46. // CHECK:STDERR: | ^
  47. // CHECK:STDERR: [CppInteropParseError]
  48. // CHECK:STDERR:
  49. import Cpp library "multiple_errors.h";
  50. // ============================================================================
  51. // One warning
  52. // ============================================================================
  53. // --- one_warning.h
  54. #warning "warning1"
  55. // --- import_cpp_file_with_one_warning.carbon
  56. library "[[@TEST_NAME]]";
  57. //@dump-sem-ir-begin
  58. // CHECK:STDERR: import_cpp_file_with_one_warning.carbon:[[@LINE+7]]:1: in import [InImport]
  59. // CHECK:STDERR: ./one_warning.h:2: warning: In file included from import_cpp_file_with_one_warning.carbon.generated.cpp_imports.h:1:
  60. // CHECK:STDERR: ./one_warning.h:2:2: warning: "warning1"
  61. // CHECK:STDERR: 2 | #warning "warning1"
  62. // CHECK:STDERR: | ^
  63. // CHECK:STDERR: [CppInteropParseWarning]
  64. // CHECK:STDERR:
  65. import Cpp library "one_warning.h";
  66. //@dump-sem-ir-end
  67. // ============================================================================
  68. // Multiple warnings
  69. // ============================================================================
  70. // --- multiple_warnings.h
  71. #warning "warning1"
  72. #warning "warning2"
  73. #warning "warning3"
  74. // --- import_cpp_file_with_multiple_warnings.carbon
  75. library "[[@TEST_NAME]]";
  76. //@dump-sem-ir-begin
  77. // CHECK:STDERR: import_cpp_file_with_multiple_warnings.carbon:[[@LINE+21]]:1: in import [InImport]
  78. // CHECK:STDERR: ./multiple_warnings.h:2: warning: In file included from import_cpp_file_with_multiple_warnings.carbon.generated.cpp_imports.h:1:
  79. // CHECK:STDERR: ./multiple_warnings.h:2:2: warning: "warning1"
  80. // CHECK:STDERR: 2 | #warning "warning1"
  81. // CHECK:STDERR: | ^
  82. // CHECK:STDERR: [CppInteropParseWarning]
  83. // CHECK:STDERR:
  84. // CHECK:STDERR: import_cpp_file_with_multiple_warnings.carbon:[[@LINE+14]]:1: in import [InImport]
  85. // CHECK:STDERR: ./multiple_warnings.h:3: warning: In file included from import_cpp_file_with_multiple_warnings.carbon.generated.cpp_imports.h:1:
  86. // CHECK:STDERR: ./multiple_warnings.h:3:2: warning: "warning2"
  87. // CHECK:STDERR: 3 | #warning "warning2"
  88. // CHECK:STDERR: | ^
  89. // CHECK:STDERR: [CppInteropParseWarning]
  90. // CHECK:STDERR:
  91. // CHECK:STDERR: import_cpp_file_with_multiple_warnings.carbon:[[@LINE+7]]:1: in import [InImport]
  92. // CHECK:STDERR: ./multiple_warnings.h:4: warning: In file included from import_cpp_file_with_multiple_warnings.carbon.generated.cpp_imports.h:1:
  93. // CHECK:STDERR: ./multiple_warnings.h:4:2: warning: "warning3"
  94. // CHECK:STDERR: 4 | #warning "warning3"
  95. // CHECK:STDERR: | ^
  96. // CHECK:STDERR: [CppInteropParseWarning]
  97. // CHECK:STDERR:
  98. import Cpp library "multiple_warnings.h";
  99. //@dump-sem-ir-end
  100. // ============================================================================
  101. // One error and one warning
  102. // ============================================================================
  103. // --- one_error_and_one_warning.h
  104. #error "error1"
  105. #warning "warning1"
  106. // --- fail_import_cpp_file_with_one_error_and_one_warning.carbon
  107. library "[[@TEST_NAME]]";
  108. // CHECK:STDERR: fail_import_cpp_file_with_one_error_and_one_warning.carbon:[[@LINE+14]]:1: in import [InImport]
  109. // CHECK:STDERR: ./one_error_and_one_warning.h:2: error: In file included from fail_import_cpp_file_with_one_error_and_one_warning.carbon.generated.cpp_imports.h:1:
  110. // CHECK:STDERR: ./one_error_and_one_warning.h:2:2: error: "error1"
  111. // CHECK:STDERR: 2 | #error "error1"
  112. // CHECK:STDERR: | ^
  113. // CHECK:STDERR: [CppInteropParseError]
  114. // CHECK:STDERR:
  115. // CHECK:STDERR: fail_import_cpp_file_with_one_error_and_one_warning.carbon:[[@LINE+7]]:1: in import [InImport]
  116. // CHECK:STDERR: ./one_error_and_one_warning.h:3: warning: In file included from fail_import_cpp_file_with_one_error_and_one_warning.carbon.generated.cpp_imports.h:1:
  117. // CHECK:STDERR: ./one_error_and_one_warning.h:3:2: warning: "warning1"
  118. // CHECK:STDERR: 3 | #warning "warning1"
  119. // CHECK:STDERR: | ^
  120. // CHECK:STDERR: [CppInteropParseWarning]
  121. // CHECK:STDERR:
  122. import Cpp library "one_error_and_one_warning.h";
  123. // ============================================================================
  124. // Multiple errors and multiple warnings
  125. // ============================================================================
  126. // --- multiple_errors_and_multiple_warnings.h
  127. #error "error1"
  128. #error "error2"
  129. #warning "warning1"
  130. #warning "warning2"
  131. #warning "warning3"
  132. // --- fail_import_cpp_file_with_multiple_errors_and_multiple_warnings.carbon
  133. library "[[@TEST_NAME]]";
  134. // CHECK:STDERR: fail_import_cpp_file_with_multiple_errors_and_multiple_warnings.carbon:[[@LINE+35]]:1: in import [InImport]
  135. // CHECK:STDERR: ./multiple_errors_and_multiple_warnings.h:2: error: In file included from fail_import_cpp_file_with_multiple_errors_and_multiple_warnings.carbon.generated.cpp_imports.h:1:
  136. // CHECK:STDERR: ./multiple_errors_and_multiple_warnings.h:2:2: error: "error1"
  137. // CHECK:STDERR: 2 | #error "error1"
  138. // CHECK:STDERR: | ^
  139. // CHECK:STDERR: [CppInteropParseError]
  140. // CHECK:STDERR:
  141. // CHECK:STDERR: fail_import_cpp_file_with_multiple_errors_and_multiple_warnings.carbon:[[@LINE+28]]:1: in import [InImport]
  142. // CHECK:STDERR: ./multiple_errors_and_multiple_warnings.h:3: error: In file included from fail_import_cpp_file_with_multiple_errors_and_multiple_warnings.carbon.generated.cpp_imports.h:1:
  143. // CHECK:STDERR: ./multiple_errors_and_multiple_warnings.h:3:2: error: "error2"
  144. // CHECK:STDERR: 3 | #error "error2"
  145. // CHECK:STDERR: | ^
  146. // CHECK:STDERR: [CppInteropParseError]
  147. // CHECK:STDERR:
  148. // CHECK:STDERR: fail_import_cpp_file_with_multiple_errors_and_multiple_warnings.carbon:[[@LINE+21]]:1: in import [InImport]
  149. // CHECK:STDERR: ./multiple_errors_and_multiple_warnings.h:4: warning: In file included from fail_import_cpp_file_with_multiple_errors_and_multiple_warnings.carbon.generated.cpp_imports.h:1:
  150. // CHECK:STDERR: ./multiple_errors_and_multiple_warnings.h:4:2: warning: "warning1"
  151. // CHECK:STDERR: 4 | #warning "warning1"
  152. // CHECK:STDERR: | ^
  153. // CHECK:STDERR: [CppInteropParseWarning]
  154. // CHECK:STDERR:
  155. // CHECK:STDERR: fail_import_cpp_file_with_multiple_errors_and_multiple_warnings.carbon:[[@LINE+14]]:1: in import [InImport]
  156. // CHECK:STDERR: ./multiple_errors_and_multiple_warnings.h:5: warning: In file included from fail_import_cpp_file_with_multiple_errors_and_multiple_warnings.carbon.generated.cpp_imports.h:1:
  157. // CHECK:STDERR: ./multiple_errors_and_multiple_warnings.h:5:2: warning: "warning2"
  158. // CHECK:STDERR: 5 | #warning "warning2"
  159. // CHECK:STDERR: | ^
  160. // CHECK:STDERR: [CppInteropParseWarning]
  161. // CHECK:STDERR:
  162. // CHECK:STDERR: fail_import_cpp_file_with_multiple_errors_and_multiple_warnings.carbon:[[@LINE+7]]:1: in import [InImport]
  163. // CHECK:STDERR: ./multiple_errors_and_multiple_warnings.h:6: warning: In file included from fail_import_cpp_file_with_multiple_errors_and_multiple_warnings.carbon.generated.cpp_imports.h:1:
  164. // CHECK:STDERR: ./multiple_errors_and_multiple_warnings.h:6:2: warning: "warning3"
  165. // CHECK:STDERR: 6 | #warning "warning3"
  166. // CHECK:STDERR: | ^
  167. // CHECK:STDERR: [CppInteropParseWarning]
  168. // CHECK:STDERR:
  169. import Cpp library "multiple_errors_and_multiple_warnings.h";
  170. // ============================================================================
  171. // Multiple files with warnings
  172. // ============================================================================
  173. // --- import_multiple_cpp_files_with_warnings.carbon
  174. library "[[@TEST_NAME]]";
  175. //@dump-sem-ir-begin
  176. // CHECK:STDERR: import_multiple_cpp_files_with_warnings.carbon:[[@LINE+28]]:1: in import [InImport]
  177. // CHECK:STDERR: ./one_warning.h:2: warning: In file included from import_multiple_cpp_files_with_warnings.carbon.generated.cpp_imports.h:1:
  178. // CHECK:STDERR: ./one_warning.h:2:2: warning: "warning1"
  179. // CHECK:STDERR: 2 | #warning "warning1"
  180. // CHECK:STDERR: | ^
  181. // CHECK:STDERR: [CppInteropParseWarning]
  182. // CHECK:STDERR:
  183. // CHECK:STDERR: import_multiple_cpp_files_with_warnings.carbon:[[@LINE+21]]:1: in import [InImport]
  184. // CHECK:STDERR: ./multiple_warnings.h:2: warning: In file included from import_multiple_cpp_files_with_warnings.carbon.generated.cpp_imports.h:2:
  185. // CHECK:STDERR: ./multiple_warnings.h:2:2: warning: "warning1"
  186. // CHECK:STDERR: 2 | #warning "warning1"
  187. // CHECK:STDERR: | ^
  188. // CHECK:STDERR: [CppInteropParseWarning]
  189. // CHECK:STDERR:
  190. // CHECK:STDERR: import_multiple_cpp_files_with_warnings.carbon:[[@LINE+14]]:1: in import [InImport]
  191. // CHECK:STDERR: ./multiple_warnings.h:3: warning: In file included from import_multiple_cpp_files_with_warnings.carbon.generated.cpp_imports.h:2:
  192. // CHECK:STDERR: ./multiple_warnings.h:3:2: warning: "warning2"
  193. // CHECK:STDERR: 3 | #warning "warning2"
  194. // CHECK:STDERR: | ^
  195. // CHECK:STDERR: [CppInteropParseWarning]
  196. // CHECK:STDERR:
  197. // CHECK:STDERR: import_multiple_cpp_files_with_warnings.carbon:[[@LINE+7]]:1: in import [InImport]
  198. // CHECK:STDERR: ./multiple_warnings.h:4: warning: In file included from import_multiple_cpp_files_with_warnings.carbon.generated.cpp_imports.h:2:
  199. // CHECK:STDERR: ./multiple_warnings.h:4:2: warning: "warning3"
  200. // CHECK:STDERR: 4 | #warning "warning3"
  201. // CHECK:STDERR: | ^
  202. // CHECK:STDERR: [CppInteropParseWarning]
  203. // CHECK:STDERR:
  204. import Cpp library "one_warning.h";
  205. import Cpp library "multiple_warnings.h";
  206. //@dump-sem-ir-end
  207. // ============================================================================
  208. // Multiple files with errors and warnings
  209. // ============================================================================
  210. // --- fail_import_multiple_cpp_files_with_errors_and_warnings.carbon
  211. library "[[@TEST_NAME]]";
  212. // CHECK:STDERR: fail_import_multiple_cpp_files_with_errors_and_warnings.carbon:[[@LINE+49]]:1: in import [InImport]
  213. // CHECK:STDERR: ./one_error_and_one_warning.h:2: error: In file included from fail_import_multiple_cpp_files_with_errors_and_warnings.carbon.generated.cpp_imports.h:1:
  214. // CHECK:STDERR: ./one_error_and_one_warning.h:2:2: error: "error1"
  215. // CHECK:STDERR: 2 | #error "error1"
  216. // CHECK:STDERR: | ^
  217. // CHECK:STDERR: [CppInteropParseError]
  218. // CHECK:STDERR:
  219. // CHECK:STDERR: fail_import_multiple_cpp_files_with_errors_and_warnings.carbon:[[@LINE+42]]:1: in import [InImport]
  220. // CHECK:STDERR: ./one_error_and_one_warning.h:3: warning: In file included from fail_import_multiple_cpp_files_with_errors_and_warnings.carbon.generated.cpp_imports.h:1:
  221. // CHECK:STDERR: ./one_error_and_one_warning.h:3:2: warning: "warning1"
  222. // CHECK:STDERR: 3 | #warning "warning1"
  223. // CHECK:STDERR: | ^
  224. // CHECK:STDERR: [CppInteropParseWarning]
  225. // CHECK:STDERR:
  226. // CHECK:STDERR: fail_import_multiple_cpp_files_with_errors_and_warnings.carbon:[[@LINE+35]]:1: in import [InImport]
  227. // CHECK:STDERR: ./multiple_errors_and_multiple_warnings.h:2: error: In file included from fail_import_multiple_cpp_files_with_errors_and_warnings.carbon.generated.cpp_imports.h:2:
  228. // CHECK:STDERR: ./multiple_errors_and_multiple_warnings.h:2:2: error: "error1"
  229. // CHECK:STDERR: 2 | #error "error1"
  230. // CHECK:STDERR: | ^
  231. // CHECK:STDERR: [CppInteropParseError]
  232. // CHECK:STDERR:
  233. // CHECK:STDERR: fail_import_multiple_cpp_files_with_errors_and_warnings.carbon:[[@LINE+28]]:1: in import [InImport]
  234. // CHECK:STDERR: ./multiple_errors_and_multiple_warnings.h:3: error: In file included from fail_import_multiple_cpp_files_with_errors_and_warnings.carbon.generated.cpp_imports.h:2:
  235. // CHECK:STDERR: ./multiple_errors_and_multiple_warnings.h:3:2: error: "error2"
  236. // CHECK:STDERR: 3 | #error "error2"
  237. // CHECK:STDERR: | ^
  238. // CHECK:STDERR: [CppInteropParseError]
  239. // CHECK:STDERR:
  240. // CHECK:STDERR: fail_import_multiple_cpp_files_with_errors_and_warnings.carbon:[[@LINE+21]]:1: in import [InImport]
  241. // CHECK:STDERR: ./multiple_errors_and_multiple_warnings.h:4: warning: In file included from fail_import_multiple_cpp_files_with_errors_and_warnings.carbon.generated.cpp_imports.h:2:
  242. // CHECK:STDERR: ./multiple_errors_and_multiple_warnings.h:4:2: warning: "warning1"
  243. // CHECK:STDERR: 4 | #warning "warning1"
  244. // CHECK:STDERR: | ^
  245. // CHECK:STDERR: [CppInteropParseWarning]
  246. // CHECK:STDERR:
  247. // CHECK:STDERR: fail_import_multiple_cpp_files_with_errors_and_warnings.carbon:[[@LINE+14]]:1: in import [InImport]
  248. // CHECK:STDERR: ./multiple_errors_and_multiple_warnings.h:5: warning: In file included from fail_import_multiple_cpp_files_with_errors_and_warnings.carbon.generated.cpp_imports.h:2:
  249. // CHECK:STDERR: ./multiple_errors_and_multiple_warnings.h:5:2: warning: "warning2"
  250. // CHECK:STDERR: 5 | #warning "warning2"
  251. // CHECK:STDERR: | ^
  252. // CHECK:STDERR: [CppInteropParseWarning]
  253. // CHECK:STDERR:
  254. // CHECK:STDERR: fail_import_multiple_cpp_files_with_errors_and_warnings.carbon:[[@LINE+7]]:1: in import [InImport]
  255. // CHECK:STDERR: ./multiple_errors_and_multiple_warnings.h:6: warning: In file included from fail_import_multiple_cpp_files_with_errors_and_warnings.carbon.generated.cpp_imports.h:2:
  256. // CHECK:STDERR: ./multiple_errors_and_multiple_warnings.h:6:2: warning: "warning3"
  257. // CHECK:STDERR: 6 | #warning "warning3"
  258. // CHECK:STDERR: | ^
  259. // CHECK:STDERR: [CppInteropParseWarning]
  260. // CHECK:STDERR:
  261. import Cpp library "one_error_and_one_warning.h";
  262. import Cpp library "multiple_errors_and_multiple_warnings.h";
  263. // ============================================================================
  264. // Indirect error
  265. // ============================================================================
  266. // --- indirect_error.h
  267. #include "one_error.h"
  268. // --- fail_todo_import_indirect_error.carbon
  269. library "[[@TEST_NAME]]";
  270. // TODO: The `In file included from` line should not be prefixed. See
  271. // https://github.com/carbon-language/carbon-lang/pull/5614#pullrequestreview-2900939411
  272. // CHECK:STDERR: fail_todo_import_indirect_error.carbon:[[@LINE+8]]:1: in import [InImport]
  273. // CHECK:STDERR: ./one_error.h:2: error: In file included from fail_todo_import_indirect_error.carbon.generated.cpp_imports.h:1:
  274. // CHECK:STDERR: In file included from ./indirect_error.h:2:
  275. // CHECK:STDERR: ./one_error.h:2:2: error: "error1"
  276. // CHECK:STDERR: 2 | #error "error1"
  277. // CHECK:STDERR: | ^
  278. // CHECK:STDERR: [CppInteropParseError]
  279. // CHECK:STDERR:
  280. import Cpp library "indirect_error.h";
  281. // ============================================================================
  282. // Indirect warning
  283. // ============================================================================
  284. // --- indirect_warning.h
  285. #include "one_warning.h"
  286. // --- todo_import_indirect_warning.carbon
  287. library "[[@TEST_NAME]]";
  288. // TODO: The `In file included from` line should not be prefixed. See
  289. // https://github.com/carbon-language/carbon-lang/pull/5614#pullrequestreview-2900939411
  290. //@dump-sem-ir-begin
  291. // CHECK:STDERR: todo_import_indirect_warning.carbon:[[@LINE+8]]:1: in import [InImport]
  292. // CHECK:STDERR: ./one_warning.h:2: warning: In file included from todo_import_indirect_warning.carbon.generated.cpp_imports.h:1:
  293. // CHECK:STDERR: In file included from ./indirect_warning.h:2:
  294. // CHECK:STDERR: ./one_warning.h:2:2: warning: "warning1"
  295. // CHECK:STDERR: 2 | #warning "warning1"
  296. // CHECK:STDERR: | ^
  297. // CHECK:STDERR: [CppInteropParseWarning]
  298. // CHECK:STDERR:
  299. import Cpp library "indirect_warning.h";
  300. //@dump-sem-ir-end
  301. // ============================================================================
  302. // Lexer error before import
  303. // ============================================================================
  304. // --- fail_import_cpp_library_lexer_error.carbon
  305. library "[[@TEST_NAME]]"; // Trailing comment
  306. // TODO: Move this warning to be after the lexer trailing comment error.
  307. // CHECK:STDERR: fail_import_cpp_library_lexer_error.carbon:[[@LINE+11]]:1: in import [InImport]
  308. // CHECK:STDERR: ./one_warning.h:2: warning: In file included from fail_import_cpp_library_lexer_error.carbon.generated.cpp_imports.h:1:
  309. // CHECK:STDERR: ./one_warning.h:2:2: warning: "warning1"
  310. // CHECK:STDERR: 2 | #warning "warning1"
  311. // CHECK:STDERR: | ^
  312. // CHECK:STDERR: [CppInteropParseWarning]
  313. // CHECK:STDERR:
  314. // CHECK:STDERR: fail_import_cpp_library_lexer_error.carbon:[[@LINE-10]]:44: error: trailing comments are not permitted [TrailingComment]
  315. // CHECK:STDERR: library "import_cpp_library_lexer_error"; // Trailing comment
  316. // CHECK:STDERR: ^
  317. // CHECK:STDERR:
  318. import Cpp library "one_warning.h";
  319. // ============================================================================
  320. // Diagnostic with fix-it hints
  321. // ============================================================================
  322. // --- fix_it_hints.h
  323. double score = 0.1
  324. // --- fail_import_fix_it_hints.carbon
  325. library "[[@TEST_NAME]]";
  326. // CHECK:STDERR: fail_import_fix_it_hints.carbon:[[@LINE+8]]:1: in import [InImport]
  327. // CHECK:STDERR: ./fix_it_hints.h:2: error: In file included from fail_import_fix_it_hints.carbon.generated.cpp_imports.h:1:
  328. // CHECK:STDERR: ./fix_it_hints.h:2:19: error: expected ';' after top level declarator
  329. // CHECK:STDERR: 2 | double score = 0.1
  330. // CHECK:STDERR: | ^
  331. // CHECK:STDERR: | ;
  332. // CHECK:STDERR: [CppInteropParseError]
  333. // CHECK:STDERR:
  334. import Cpp library "fix_it_hints.h";
  335. fn F() {
  336. Cpp.foo();
  337. }
  338. // CHECK:STDOUT: --- import_cpp_file_with_one_warning.carbon
  339. // CHECK:STDOUT:
  340. // CHECK:STDOUT: imports {
  341. // CHECK:STDOUT: }
  342. // CHECK:STDOUT:
  343. // CHECK:STDOUT: file {
  344. // CHECK:STDOUT: %Cpp.import_cpp = import_cpp {
  345. // CHECK:STDOUT: import Cpp "one_warning.h"
  346. // CHECK:STDOUT: }
  347. // CHECK:STDOUT: }
  348. // CHECK:STDOUT:
  349. // CHECK:STDOUT: --- import_cpp_file_with_multiple_warnings.carbon
  350. // CHECK:STDOUT:
  351. // CHECK:STDOUT: imports {
  352. // CHECK:STDOUT: }
  353. // CHECK:STDOUT:
  354. // CHECK:STDOUT: file {
  355. // CHECK:STDOUT: %Cpp.import_cpp = import_cpp {
  356. // CHECK:STDOUT: import Cpp "multiple_warnings.h"
  357. // CHECK:STDOUT: }
  358. // CHECK:STDOUT: }
  359. // CHECK:STDOUT:
  360. // CHECK:STDOUT: --- import_multiple_cpp_files_with_warnings.carbon
  361. // CHECK:STDOUT:
  362. // CHECK:STDOUT: imports {
  363. // CHECK:STDOUT: }
  364. // CHECK:STDOUT:
  365. // CHECK:STDOUT: file {
  366. // CHECK:STDOUT: %Cpp.import_cpp = import_cpp {
  367. // CHECK:STDOUT: import Cpp "one_warning.h"
  368. // CHECK:STDOUT: import Cpp "multiple_warnings.h"
  369. // CHECK:STDOUT: }
  370. // CHECK:STDOUT: }
  371. // CHECK:STDOUT:
  372. // CHECK:STDOUT: --- todo_import_indirect_warning.carbon
  373. // CHECK:STDOUT:
  374. // CHECK:STDOUT: imports {
  375. // CHECK:STDOUT: }
  376. // CHECK:STDOUT:
  377. // CHECK:STDOUT: file {
  378. // CHECK:STDOUT: %Cpp.import_cpp = import_cpp {
  379. // CHECK:STDOUT: import Cpp "indirect_warning.h"
  380. // CHECK:STDOUT: }
  381. // CHECK:STDOUT: }
  382. // CHECK:STDOUT: