|
1 | 1 | // RUN: %clang_cc1 -fsyntax-only -pedantic -std=c++11 -verify=expected,cxx11-17 -triple x86_64-apple-darwin %s
|
2 | 2 | // RUN: %clang_cc1 -fsyntax-only -pedantic -std=c++17 -verify=expected,cxx11-17 -triple x86_64-apple-darwin %s
|
3 | 3 | // RUN: %clang_cc1 -fsyntax-only -pedantic -std=c++20 -verify -triple x86_64-apple-darwin %s
|
| 4 | +// RUN: not %clang_cc1 -fsyntax-only -fdiagnostics-parseable-fixits -std=c++20 -triple x86_64-apple-darwin %s 2>&1 | FileCheck %s |
4 | 5 |
|
5 | 6 | enum class E1 {
|
6 | 7 | Val1 = 1L
|
@@ -376,76 +377,140 @@ namespace GH24265 {
|
376 | 377 | void f() {
|
377 | 378 | E_int::e + E_long::e; // expected-error {{invalid operands to binary expression ('GH24265::E_int' and 'GH24265::E_long')}}
|
378 | 379 | // expected-note@-1 {{no implicit conversion for scoped enum; consider casting to underlying type}}
|
379 |
| - // expected-note@-2 {{no implicit conversion for scoped enum; consider casting to underlying type}} |
| 380 | + // CHECK: fix-it:{{.*}}:{[[@LINE-2]]:5-[[@LINE-2]]:5}:"static_cast<int>(" |
| 381 | + // CHECK: fix-it:{{.*}}:{[[@LINE-3]]:12-[[@LINE-3]]:12}:")" |
| 382 | + // expected-note@-4 {{no implicit conversion for scoped enum; consider casting to underlying type}} |
| 383 | + // CHECK: fix-it:{{.*}}:{[[@LINE-5]]:16-[[@LINE-5]]:16}:"static_cast<long>(" |
| 384 | + // CHECK: fix-it:{{.*}}:{[[@LINE-6]]:24-[[@LINE-6]]:24}:")" |
380 | 385 | E_int::e + 0; // expected-error {{invalid operands to binary expression ('GH24265::E_int' and 'int')}}
|
381 | 386 | // expected-note@-1 {{no implicit conversion for scoped enum; consider casting to underlying type}}
|
| 387 | + // CHECK: fix-it:{{.*}}:{[[@LINE-2]]:5-[[@LINE-2]]:5}:"static_cast<int>(" |
| 388 | + // CHECK: fix-it:{{.*}}:{[[@LINE-3]]:12-[[@LINE-3]]:12}:")" |
382 | 389 |
|
383 | 390 | 0 * E_int::e; // expected-error {{invalid operands to binary expression ('int' and 'GH24265::E_int')}}
|
384 | 391 | // expected-note@-1 {{no implicit conversion for scoped enum; consider casting to underlying type}}
|
| 392 | + // CHECK: fix-it:{{.*}}:{[[@LINE-2]]:9-[[@LINE-2]]:9}:"static_cast<int>(" |
| 393 | + // CHECK: fix-it:{{.*}}:{[[@LINE-3]]:16-[[@LINE-3]]:16}:")" |
385 | 394 | 0 / E_int::e; // expected-error {{invalid operands to binary expression ('int' and 'GH24265::E_int')}}
|
386 | 395 | // expected-note@-1 {{no implicit conversion for scoped enum; consider casting to underlying type}}
|
| 396 | + // CHECK: fix-it:{{.*}}:{[[@LINE-2]]:9-[[@LINE-2]]:9}:"static_cast<int>(" |
| 397 | + // CHECK: fix-it:{{.*}}:{[[@LINE-3]]:16-[[@LINE-3]]:16}:")" |
387 | 398 | 0 % E_int::e; // expected-error {{invalid operands to binary expression ('int' and 'GH24265::E_int')}}
|
388 | 399 | // expected-note@-1 {{no implicit conversion for scoped enum; consider casting to underlying type}}
|
| 400 | + // CHECK: fix-it:{{.*}}:{[[@LINE-2]]:9-[[@LINE-2]]:9}:"static_cast<int>(" |
| 401 | + // CHECK: fix-it:{{.*}}:{[[@LINE-3]]:16-[[@LINE-3]]:16}:")" |
389 | 402 | 0 + E_int::e; // expected-error {{invalid operands to binary expression ('int' and 'GH24265::E_int')}}
|
390 | 403 | // expected-note@-1 {{no implicit conversion for scoped enum; consider casting to underlying type}}
|
| 404 | + // CHECK: fix-it:{{.*}}:{[[@LINE-2]]:9-[[@LINE-2]]:9}:"static_cast<int>(" |
| 405 | + // CHECK: fix-it:{{.*}}:{[[@LINE-3]]:16-[[@LINE-3]]:16}:")" |
391 | 406 | 0 - E_int::e; // expected-error {{invalid operands to binary expression ('int' and 'GH24265::E_int')}}
|
392 | 407 | // expected-note@-1 {{no implicit conversion for scoped enum; consider casting to underlying type}}
|
| 408 | + // CHECK: fix-it:{{.*}}:{[[@LINE-2]]:9-[[@LINE-2]]:9}:"static_cast<int>(" |
| 409 | + // CHECK: fix-it:{{.*}}:{[[@LINE-3]]:16-[[@LINE-3]]:16}:")" |
393 | 410 | 0 << E_int::e; // expected-error {{invalid operands to binary expression ('int' and 'GH24265::E_int')}}
|
394 | 411 | // expected-note@-1 {{no implicit conversion for scoped enum; consider casting to underlying type}}
|
| 412 | + // CHECK: fix-it:{{.*}}:{[[@LINE-2]]:10-[[@LINE-2]]:10}:"static_cast<int>(" |
| 413 | + // CHECK: fix-it:{{.*}}:{[[@LINE-3]]:17-[[@LINE-3]]:17}:")" |
395 | 414 | 0 >> E_int::e; // expected-error {{invalid operands to binary expression ('int' and 'GH24265::E_int')}}
|
396 | 415 | // expected-note@-1 {{no implicit conversion for scoped enum; consider casting to underlying type}}
|
| 416 | + // CHECK: fix-it:{{.*}}:{[[@LINE-2]]:10-[[@LINE-2]]:10}:"static_cast<int>(" |
| 417 | + // CHECK: fix-it:{{.*}}:{[[@LINE-3]]:17-[[@LINE-3]]:17}:")" |
397 | 418 |
|
398 | 419 | #if __cplusplus >= 202002L
|
399 | 420 | 0 <=> E_int::e; // expected-error {{invalid operands to binary expression ('int' and 'GH24265::E_int')}}
|
400 | 421 | // expected-note@-1 {{no implicit conversion for scoped enum; consider casting to underlying type}}
|
| 422 | + // CHECK: fix-it:{{.*}}:{[[@LINE-2]]:11-[[@LINE-2]]:11}:"static_cast<int>(" |
| 423 | + // CHECK: fix-it:{{.*}}:{[[@LINE-3]]:18-[[@LINE-3]]:18}:")" |
401 | 424 | #endif
|
402 | 425 |
|
403 | 426 | 0 < E_int::e; // expected-error {{invalid operands to binary expression ('int' and 'GH24265::E_int')}}
|
404 | 427 | // expected-note@-1 {{no implicit conversion for scoped enum; consider casting to underlying type}}
|
| 428 | + // CHECK: fix-it:{{.*}}:{[[@LINE-2]]:9-[[@LINE-2]]:9}:"static_cast<int>(" |
| 429 | + // CHECK: fix-it:{{.*}}:{[[@LINE-3]]:16-[[@LINE-3]]:16}:")" |
405 | 430 | 0 > E_int::e; // expected-error {{invalid operands to binary expression ('int' and 'GH24265::E_int')}}
|
406 | 431 | // expected-note@-1 {{no implicit conversion for scoped enum; consider casting to underlying type}}
|
| 432 | + // CHECK: fix-it:{{.*}}:{[[@LINE-2]]:9-[[@LINE-2]]:9}:"static_cast<int>(" |
| 433 | + // CHECK: fix-it:{{.*}}:{[[@LINE-3]]:16-[[@LINE-3]]:16}:")" |
407 | 434 | 0 <= E_int::e; // expected-error {{invalid operands to binary expression ('int' and 'GH24265::E_int')}}
|
408 | 435 | // expected-note@-1 {{no implicit conversion for scoped enum; consider casting to underlying type}}
|
| 436 | + // CHECK: fix-it:{{.*}}:{[[@LINE-2]]:10-[[@LINE-2]]:10}:"static_cast<int>(" |
| 437 | + // CHECK: fix-it:{{.*}}:{[[@LINE-3]]:17-[[@LINE-3]]:17}:")" |
409 | 438 | 0 >= E_int::e; // expected-error {{invalid operands to binary expression ('int' and 'GH24265::E_int')}}
|
410 | 439 | // expected-note@-1 {{no implicit conversion for scoped enum; consider casting to underlying type}}
|
| 440 | + // CHECK: fix-it:{{.*}}:{[[@LINE-2]]:10-[[@LINE-2]]:10}:"static_cast<int>(" |
| 441 | + // CHECK: fix-it:{{.*}}:{[[@LINE-3]]:17-[[@LINE-3]]:17}:")" |
411 | 442 | 0 == E_int::e; // expected-error {{invalid operands to binary expression ('int' and 'GH24265::E_int')}}
|
412 | 443 | // expected-note@-1 {{no implicit conversion for scoped enum; consider casting to underlying type}}
|
| 444 | + // CHECK: fix-it:{{.*}}:{[[@LINE-2]]:10-[[@LINE-2]]:10}:"static_cast<int>(" |
| 445 | + // CHECK: fix-it:{{.*}}:{[[@LINE-3]]:17-[[@LINE-3]]:17}:")" |
413 | 446 | 0 != E_int::e; // expected-error {{invalid operands to binary expression ('int' and 'GH24265::E_int')}}
|
414 | 447 | // expected-note@-1 {{no implicit conversion for scoped enum; consider casting to underlying type}}
|
| 448 | + // CHECK: fix-it:{{.*}}:{[[@LINE-2]]:10-[[@LINE-2]]:10}:"static_cast<int>(" |
| 449 | + // CHECK: fix-it:{{.*}}:{[[@LINE-3]]:17-[[@LINE-3]]:17}:")" |
415 | 450 | 0 & E_int::e; // expected-error {{invalid operands to binary expression ('int' and 'GH24265::E_int')}}
|
416 | 451 | // expected-note@-1 {{no implicit conversion for scoped enum; consider casting to underlying type}}
|
| 452 | + // CHECK: fix-it:{{.*}}:{[[@LINE-2]]:9-[[@LINE-2]]:9}:"static_cast<int>(" |
| 453 | + // CHECK: fix-it:{{.*}}:{[[@LINE-3]]:16-[[@LINE-3]]:16}:")" |
417 | 454 | 0 ^ E_int::e; // expected-error {{invalid operands to binary expression ('int' and 'GH24265::E_int')}}
|
418 | 455 | // expected-note@-1 {{no implicit conversion for scoped enum; consider casting to underlying type}}
|
| 456 | + // CHECK: fix-it:{{.*}}:{[[@LINE-2]]:9-[[@LINE-2]]:9}:"static_cast<int>(" |
| 457 | + // CHECK: fix-it:{{.*}}:{[[@LINE-3]]:16-[[@LINE-3]]:16}:")" |
419 | 458 | 0 | E_int::e; // expected-error {{invalid operands to binary expression ('int' and 'GH24265::E_int')}}
|
420 | 459 | // expected-note@-1 {{no implicit conversion for scoped enum; consider casting to underlying type}}
|
| 460 | + // CHECK: fix-it:{{.*}}:{[[@LINE-2]]:9-[[@LINE-2]]:9}:"static_cast<int>(" |
| 461 | + // CHECK: fix-it:{{.*}}:{[[@LINE-3]]:16-[[@LINE-3]]:16}:")" |
421 | 462 | 0 && E_int::e; // expected-error {{value of type 'GH24265::E_int' is not contextually convertible to 'bool'}}
|
422 | 463 | // expected-error@-1 {{invalid operands to binary expression ('int' and 'GH24265::E_int')}}
|
423 | 464 | // expected-note@-2 {{no implicit conversion for scoped enum; consider casting to underlying type}}
|
| 465 | + // CHECK: fix-it:{{.*}}:{[[@LINE-3]]:10-[[@LINE-3]]:10}:"static_cast<int>(" |
| 466 | + // CHECK: fix-it:{{.*}}:{[[@LINE-4]]:17-[[@LINE-4]]:17}:")" |
424 | 467 | 0 || E_int::e; // expected-error {{value of type 'GH24265::E_int' is not contextually convertible to 'bool'}}
|
425 | 468 | // expected-error@-1 {{invalid operands to binary expression ('int' and 'GH24265::E_int')}}
|
426 | 469 | // expected-note@-2 {{no implicit conversion for scoped enum; consider casting to underlying type}}
|
| 470 | + // CHECK: fix-it:{{.*}}:{[[@LINE-3]]:10-[[@LINE-3]]:10}:"static_cast<int>(" |
| 471 | + // CHECK: fix-it:{{.*}}:{[[@LINE-4]]:17-[[@LINE-4]]:17}:")" |
427 | 472 |
|
428 | 473 | int a;
|
429 | 474 | a *= E_int::e; // expected-error {{invalid operands to binary expression ('int' and 'GH24265::E_int')}}
|
430 | 475 | // expected-note@-1 {{no implicit conversion for scoped enum; consider casting to underlying type}}
|
| 476 | + // CHECK: fix-it:{{.*}}:{[[@LINE-2]]:10-[[@LINE-2]]:10}:"static_cast<int>(" |
| 477 | + // CHECK: fix-it:{{.*}}:{[[@LINE-3]]:17-[[@LINE-3]]:17}:")" |
431 | 478 | a /= E_int::e; // expected-error {{invalid operands to binary expression ('int' and 'GH24265::E_int')}}
|
432 | 479 | // expected-note@-1 {{no implicit conversion for scoped enum; consider casting to underlying type}}
|
| 480 | + // CHECK: fix-it:{{.*}}:{[[@LINE-2]]:10-[[@LINE-2]]:10}:"static_cast<int>(" |
| 481 | + // CHECK: fix-it:{{.*}}:{[[@LINE-3]]:17-[[@LINE-3]]:17}:")" |
433 | 482 | a %= E_int::e; // expected-error {{invalid operands to binary expression ('int' and 'GH24265::E_int')}}
|
434 | 483 | // expected-note@-1 {{no implicit conversion for scoped enum; consider casting to underlying type}}
|
| 484 | + // CHECK: fix-it:{{.*}}:{[[@LINE-2]]:10-[[@LINE-2]]:10}:"static_cast<int>(" |
| 485 | + // CHECK: fix-it:{{.*}}:{[[@LINE-3]]:17-[[@LINE-3]]:17}:")" |
435 | 486 | a += E_int::e; // expected-error {{invalid operands to binary expression ('int' and 'GH24265::E_int')}}
|
436 | 487 | // expected-note@-1 {{no implicit conversion for scoped enum; consider casting to underlying type}}
|
| 488 | + // CHECK: fix-it:{{.*}}:{[[@LINE-2]]:10-[[@LINE-2]]:10}:"static_cast<int>(" |
| 489 | + // CHECK: fix-it:{{.*}}:{[[@LINE-3]]:17-[[@LINE-3]]:17}:")" |
437 | 490 | a -= E_int::e; // expected-error {{invalid operands to binary expression ('int' and 'GH24265::E_int')}}
|
438 | 491 | // expected-note@-1 {{no implicit conversion for scoped enum; consider casting to underlying type}}
|
| 492 | + // CHECK: fix-it:{{.*}}:{[[@LINE-2]]:10-[[@LINE-2]]:10}:"static_cast<int>(" |
| 493 | + // CHECK: fix-it:{{.*}}:{[[@LINE-3]]:17-[[@LINE-3]]:17}:")" |
439 | 494 | a <<= E_int::e; // expected-error {{invalid operands to binary expression ('int' and 'GH24265::E_int')}}
|
440 | 495 | // expected-note@-1 {{no implicit conversion for scoped enum; consider casting to underlying type}}
|
| 496 | + // CHECK: fix-it:{{.*}}:{[[@LINE-2]]:11-[[@LINE-2]]:11}:"static_cast<int>(" |
| 497 | + // CHECK: fix-it:{{.*}}:{[[@LINE-3]]:18-[[@LINE-3]]:18}:")" |
441 | 498 | a >>= E_int::e; // expected-error {{invalid operands to binary expression ('int' and 'GH24265::E_int')}}
|
442 | 499 | // expected-note@-1 {{no implicit conversion for scoped enum; consider casting to underlying type}}
|
| 500 | + // CHECK: fix-it:{{.*}}:{[[@LINE-2]]:11-[[@LINE-2]]:11}:"static_cast<int>(" |
| 501 | + // CHECK: fix-it:{{.*}}:{[[@LINE-3]]:18-[[@LINE-3]]:18}:")" |
443 | 502 | a &= E_int::e; // expected-error {{invalid operands to binary expression ('int' and 'GH24265::E_int')}}
|
444 | 503 | // expected-note@-1 {{no implicit conversion for scoped enum; consider casting to underlying type}}
|
| 504 | + // CHECK: fix-it:{{.*}}:{[[@LINE-2]]:10-[[@LINE-2]]:10}:"static_cast<int>(" |
| 505 | + // CHECK: fix-it:{{.*}}:{[[@LINE-3]]:17-[[@LINE-3]]:17}:")" |
445 | 506 | a ^= E_int::e; // expected-error {{invalid operands to binary expression ('int' and 'GH24265::E_int')}}
|
446 | 507 | // expected-note@-1 {{no implicit conversion for scoped enum; consider casting to underlying type}}
|
| 508 | + // CHECK: fix-it:{{.*}}:{[[@LINE-2]]:10-[[@LINE-2]]:10}:"static_cast<int>(" |
| 509 | + // CHECK: fix-it:{{.*}}:{[[@LINE-3]]:17-[[@LINE-3]]:17}:")" |
447 | 510 | a |= E_int::e; // expected-error {{invalid operands to binary expression ('int' and 'GH24265::E_int')}}
|
448 | 511 | // expected-note@-1 {{no implicit conversion for scoped enum; consider casting to underlying type}}
|
| 512 | + // CHECK: fix-it:{{.*}}:{[[@LINE-2]]:10-[[@LINE-2]]:10}:"static_cast<int>(" |
| 513 | + // CHECK: fix-it:{{.*}}:{[[@LINE-3]]:17-[[@LINE-3]]:17}:")" |
449 | 514 |
|
450 | 515 | // TODO: These do not have the diagnostic yet
|
451 | 516 | E_int b;
|
|
0 commit comments