1 ########################################################################### 2 # Module for ABI Compliance Checker with regression test suite 3 # 4 # Copyright (C) 2009-2011 Institute for System Programming, RAS 5 # Copyright (C) 2011-2012 Nokia Corporation and/or its subsidiary(-ies) 6 # Copyright (C) 2011-2012 ROSA Laboratory 7 # Copyright (C) 2012-2016 Andrey Ponomarenko's ABI Laboratory 8 # 9 # Written by Andrey Ponomarenko 10 # 11 # This program is free software: you can redistribute it and/or modify 12 # it under the terms of the GNU General Public License or the GNU Lesser 13 # General Public License as published by the Free Software Foundation. 14 # 15 # This program is distributed in the hope that it will be useful, 16 # but WITHOUT ANY WARRANTY; without even the implied warranty of 17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 # GNU General Public License for more details. 19 # 20 # You should have received a copy of the GNU General Public License 21 # and the GNU Lesser General Public License along with this program. 22 # If not, see <http://www.gnu.org/licenses/>. 23 ########################################################################### 24 use strict; 25 26 my ($TestDump, $Debug, $Quiet, $ExtendedCheck, $LogMode, $ReportFormat, 27 $DumpFormat, $LIB_EXT, $GCC_PATH, $SortDump, $CheckHeadersOnly, 28 $OldStyle, $TestABIDumper); 29 my $OSgroup = get_OSgroup(); 30 31 sub testTool($$$$$$$$$$$) 32 { 33 ($TestDump, $Debug, $Quiet, $ExtendedCheck, $LogMode, $ReportFormat, 34 $DumpFormat, $LIB_EXT, $GCC_PATH, $SortDump, $CheckHeadersOnly, 35 $OldStyle, $TestABIDumper) = @_; 36 37 testC(); 38 testCpp(); 39 } 40 41 sub testCpp() 42 { 43 printMsg("INFO", "verifying detectable C++ library changes"); 44 my ($HEADER1, $SOURCE1, $HEADER2, $SOURCE2) = (); 45 my $DECL_SPEC = ($OSgroup eq "windows")?"__declspec( dllexport )":""; 46 my $EXTERN = ($OSgroup eq "windows")?"extern ":""; # add "extern" for CL compiler 47 48 # Class outside namespace 49 $HEADER1 .= " 50 class $DECL_SPEC OutsideNS { 51 public: 52 int someMethod(); 53 int field; 54 };"; 55 $SOURCE1 .= " 56 int OutsideNS::someMethod() { return 0; }"; 57 58 $HEADER2 .= " 59 class $DECL_SPEC OutsideNS { 60 public: 61 int someMethod(); 62 int field; 63 int field2; 64 };"; 65 $SOURCE2 .= " 66 int OutsideNS::someMethod() { return 0; }"; 67 68 # Begin namespace 69 $HEADER1 .= "namespace TestNS {\n"; 70 $HEADER2 .= "namespace TestNS {\n"; 71 $SOURCE1 .= "namespace TestNS {\n"; 72 $SOURCE2 .= "namespace TestNS {\n"; 73 74 # Changed template internals 75 # $HEADER1 .= " 76 # template <typename T, int _P> 77 # class $DECL_SPEC ChangedTemplate { 78 # public: 79 # T value; 80 # T*const field; 81 # T array[_P]; 82 # typedef int My; 83 # My var; 84 # }; 85 # ChangedTemplate<int, 1>* changedTemplate();"; 86 # $SOURCE1 .= " 87 # ChangedTemplate<int, 1>* changedTemplate() { return new ChangedTemplate<int, 1>(); }"; 88 # 89 # $HEADER2 .= " 90 # template <typename T, int _P> 91 # class $DECL_SPEC ChangedTemplate { 92 # public: 93 # double value; 94 # T* field; 95 # double array[_P]; 96 # typedef int My; 97 # My var; 98 # }; 99 # ChangedTemplate<int, 1>* changedTemplate();"; 100 # $SOURCE2 .= " 101 # ChangedTemplate<int, 1>* changedTemplate() { return new ChangedTemplate<int, 1>(); }"; 102 103 # Removed inline method 104 $HEADER1 .= " 105 class $DECL_SPEC RemovedInlineMethod { 106 public: 107 int someMethod(); 108 inline int removedMethod() { return 0; }; 109 int field; 110 };"; 111 $SOURCE1 .= " 112 int RemovedInlineMethod::someMethod() { return removedMethod(); }"; 113 114 $HEADER2 .= " 115 class $DECL_SPEC RemovedInlineMethod { 116 public: 117 int someMethod(); 118 int field; 119 };"; 120 $SOURCE2 .= " 121 int RemovedInlineMethod::someMethod() { return 0; }"; 122 123 # Pure_Virtual_Replacement 124 $HEADER1 .= " 125 class $DECL_SPEC PureVirtualReplacement { 126 public: 127 virtual int methodOld(int param) = 0; 128 int otherMethod(); 129 }; 130 131 class $DECL_SPEC PureVirtualReplacement_Derived: public PureVirtualReplacement { 132 public: 133 int methodOld(int param); 134 };"; 135 $SOURCE1 .= " 136 int PureVirtualReplacement::otherMethod() { return 0; } 137 int PureVirtualReplacement_Derived::methodOld(int param) { return 0; }"; 138 139 $HEADER2 .= " 140 class $DECL_SPEC PureVirtualReplacement { 141 public: 142 virtual int methodNew(int param) = 0; 143 int otherMethod(); 144 }; 145 146 class $DECL_SPEC PureVirtualReplacement_Derived: public PureVirtualReplacement { 147 public: 148 int methodNew(int param); 149 };"; 150 $SOURCE2 .= " 151 int PureVirtualReplacement::otherMethod() { return 0; } 152 int PureVirtualReplacement_Derived::methodNew(int param) { return 0; }"; 153 154 # Virtual_Replacement 155 $HEADER1 .= " 156 class $DECL_SPEC VirtualReplacement { 157 public: 158 virtual int methodOld(int param); 159 };"; 160 $SOURCE1 .= " 161 int VirtualReplacement::methodOld(int param) { return 0; }"; 162 163 $HEADER2 .= " 164 class $DECL_SPEC VirtualReplacement { 165 public: 166 virtual int methodNew(int param); 167 };"; 168 $SOURCE2 .= " 169 int VirtualReplacement::methodNew(int param) { return 0; }"; 170 171 # Removed_Symbol (renamed, source-compatible) 172 $HEADER1 .= " 173 int $DECL_SPEC renamedFunc(int param);"; 174 $SOURCE1 .= " 175 int renamedFunc(int param) { return 0; }"; 176 177 $HEADER2 .= " 178 int $DECL_SPEC renamedFunc_NewName(int param); 179 #define renamedFunc renamedFunc_NewName"; 180 $SOURCE2 .= " 181 int renamedFunc_NewName(int param) { return 0; }"; 182 183 # Removed_Symbol 184 $HEADER1 .= " 185 int $DECL_SPEC functionBecameInline(int param);"; 186 $SOURCE1 .= " 187 int functionBecameInline(int param) { return 0; }"; 188 189 $HEADER2 .= " 190 inline int functionBecameInline(int param) { return 0; }"; 191 192 # Removed_Symbol (safe) 193 $HEADER1 .= " 194 inline int removedInlineFunction(int param) { return 0; }"; 195 196 # Became Non-Opaque 197 $HEADER1 .= " 198 struct OpaqueStruct; 199 int paramBecameNonOpaque(OpaqueStruct* p);"; 200 $SOURCE1 .= " 201 int paramBecameNonOpaque(OpaqueStruct* p) { return 0; }"; 202 203 $HEADER2 .= " 204 struct OpaqueStruct 205 { 206 int i; 207 short j; 208 OpaqueStruct(); 209 }; 210 int paramBecameNonOpaque(OpaqueStruct* p);"; 211 $SOURCE2 .= " 212 int paramBecameNonOpaque(OpaqueStruct* p) { return 0; }"; 213 214 # Field_Became_Const 215 # Typedef 216 $HEADER1 .= " 217 typedef int*const CONST_INT_PTR; 218 class $DECL_SPEC FieldBecameConstTypedef { 219 public: 220 int* f; 221 int*const f2; 222 int method(CONST_INT_PTR p); 223 };"; 224 $SOURCE1 .= " 225 int FieldBecameConstTypedef::method(CONST_INT_PTR p) { return 0; }"; 226 227 $HEADER2 .= " 228 typedef int*const CONST_INT_PTR; 229 class $DECL_SPEC FieldBecameConstTypedef { 230 public: 231 CONST_INT_PTR f; 232 int*const f2; 233 int method(CONST_INT_PTR p); 234 };"; 235 $SOURCE2 .= " 236 int FieldBecameConstTypedef::method(CONST_INT_PTR p) { return 0; }"; 237 238 # Field_Removed_Const 239 $HEADER1 .= " 240 class $DECL_SPEC FieldRemovedConst { 241 public: 242 int*const*const f; 243 int method(); 244 };"; 245 $SOURCE1 .= " 246 int FieldRemovedConst::method() { return 0; }"; 247 248 $HEADER2 .= " 249 class $DECL_SPEC FieldRemovedConst { 250 public: 251 int**const f; 252 int method(); 253 };"; 254 $SOURCE2 .= " 255 int FieldRemovedConst::method() { return 0; }"; 256 257 # Field_Became_Const 258 $HEADER1 .= " 259 class $DECL_SPEC FieldBecameConst { 260 public: 261 int* f; 262 int method(); 263 };"; 264 $SOURCE1 .= " 265 int FieldBecameConst::method() { return 0; }"; 266 267 $HEADER2 .= " 268 class $DECL_SPEC FieldBecameConst { 269 public: 270 int*const f; 271 int method(); 272 };"; 273 $SOURCE2 .= " 274 int FieldBecameConst::method() { return 0; }"; 275 276 # Field_Became_Private 277 $HEADER1 .= " 278 class $DECL_SPEC FieldBecamePrivate { 279 public: 280 int* f; 281 int method(); 282 };"; 283 $SOURCE1 .= " 284 int FieldBecamePrivate::method() { return 0; }"; 285 286 $HEADER2 .= " 287 class $DECL_SPEC FieldBecamePrivate { 288 private: 289 int* f; 290 public: 291 int method(); 292 };"; 293 $SOURCE2 .= " 294 int FieldBecamePrivate::method() { return 0; }"; 295 296 # Field_Became_Protected 297 $HEADER1 .= " 298 class $DECL_SPEC FieldBecameProtected { 299 public: 300 int* f; 301 int method(); 302 };"; 303 $SOURCE1 .= " 304 int FieldBecameProtected::method() { return 0; }"; 305 306 $HEADER2 .= " 307 class $DECL_SPEC FieldBecameProtected { 308 protected: 309 int* f; 310 public: 311 int method(); 312 };"; 313 $SOURCE2 .= " 314 int FieldBecameProtected::method() { return 0; }"; 315 316 # Global_Data_Became_Private 317 $HEADER1 .= " 318 class $DECL_SPEC GlobalDataBecamePrivate { 319 public: 320 static int data; 321 322 };"; 323 $SOURCE1 .= " 324 int GlobalDataBecamePrivate::data = 10;"; 325 326 $HEADER2 .= " 327 class $DECL_SPEC GlobalDataBecamePrivate { 328 private: 329 static int data; 330 331 };"; 332 $SOURCE2 .= " 333 int GlobalDataBecamePrivate::data = 10;"; 334 335 # Method_Became_Private 336 $HEADER1 .= " 337 class $DECL_SPEC MethodBecamePrivate { 338 public: 339 int method(); 340 };"; 341 $SOURCE1 .= " 342 int MethodBecamePrivate::method() { return 0; }"; 343 344 $HEADER2 .= " 345 class $DECL_SPEC MethodBecamePrivate { 346 private: 347 int method(); 348 };"; 349 $SOURCE2 .= " 350 int MethodBecamePrivate::method() { return 0; }"; 351 352 # Method_Became_Protected 353 $HEADER1 .= " 354 class $DECL_SPEC MethodBecameProtected { 355 public: 356 int method(); 357 };"; 358 $SOURCE1 .= " 359 int MethodBecameProtected::method() { return 0; }"; 360 361 $HEADER2 .= " 362 class $DECL_SPEC MethodBecameProtected { 363 protected: 364 int method(); 365 };"; 366 $SOURCE2 .= " 367 int MethodBecameProtected::method() { return 0; }"; 368 369 # Method_Became_Public 370 $HEADER1 .= " 371 class $DECL_SPEC MethodBecamePublic { 372 protected: 373 int method(); 374 };"; 375 $SOURCE1 .= " 376 int MethodBecamePublic::method() { return 0; }"; 377 378 $HEADER2 .= " 379 class $DECL_SPEC MethodBecamePublic { 380 public: 381 int method(); 382 };"; 383 $SOURCE2 .= " 384 int MethodBecamePublic::method() { return 0; }"; 385 386 # Removed_Const_Overload 387 $HEADER1 .= " 388 class $DECL_SPEC RemovedConstOverload { 389 public: 390 int removed(); 391 int removed() const; 392 };"; 393 $SOURCE1 .= " 394 int RemovedConstOverload::removed() { return 0; } 395 int RemovedConstOverload::removed() const { return 0; }"; 396 397 $HEADER2 .= " 398 class $DECL_SPEC RemovedConstOverload { 399 public: 400 int removed(); 401 };"; 402 $SOURCE2 .= " 403 int RemovedConstOverload::removed() { return 0; }"; 404 405 # Inline method 406 $HEADER1 .= " 407 class $DECL_SPEC InlineMethod { 408 public: 409 inline int foo() { return 0; } 410 };"; 411 412 $HEADER2 .= " 413 class $DECL_SPEC InlineMethod { 414 public: 415 inline long foo() { return 0; } 416 };"; 417 418 # Global_Data_Became_Non_Const 419 $HEADER1 .= " 420 $EXTERN $DECL_SPEC const int globalDataBecameNonConst = 10;"; 421 422 $HEADER2 .= " 423 extern $DECL_SPEC int globalDataBecameNonConst;"; 424 $SOURCE2 .= " 425 int globalDataBecameNonConst = 15;"; 426 427 # Global_Data_Became_Non_Const 428 # Class Member 429 $HEADER1 .= " 430 class $DECL_SPEC GlobalDataBecameNonConst { 431 public: 432 static const int data; 433 };"; 434 $SOURCE1 .= " 435 const int GlobalDataBecameNonConst::data = 10;"; 436 437 $HEADER2 .= " 438 class $DECL_SPEC GlobalDataBecameNonConst { 439 public: 440 static int data; 441 };"; 442 $SOURCE2 .= " 443 int GlobalDataBecameNonConst::data = 10;"; 444 445 # Global_Data_Became_Const 446 $HEADER1 .= " 447 extern $DECL_SPEC int globalDataBecameConst;"; 448 $SOURCE1 .= " 449 int globalDataBecameConst = 10;"; 450 451 $HEADER2 .= " 452 $EXTERN $DECL_SPEC const int globalDataBecameConst = 15;"; 453 454 # Global_Data_Became_Const 455 # Class Member 456 $HEADER1 .= " 457 class $DECL_SPEC GlobalDataBecameConst { 458 public: 459 static int Data; 460 };"; 461 $SOURCE1 .= " 462 int GlobalDataBecameConst::Data = 10;"; 463 464 $HEADER2 .= " 465 class $DECL_SPEC GlobalDataBecameConst { 466 public: 467 static const int Data = 15; 468 };"; 469 470 # Global_Data_Value_Changed 471 $HEADER1 .= " 472 class $DECL_SPEC GlobalDataValue { 473 public: 474 static const int Integer = 10; 475 static const char Char = \'o\'; 476 };"; 477 478 $HEADER2 .= " 479 class $DECL_SPEC GlobalDataValue { 480 public: 481 static const int Integer = 15; 482 static const char Char = \'N\'; 483 };"; 484 485 # Global_Data_Value_Changed 486 # Integer 487 $HEADER1 .= " 488 $EXTERN $DECL_SPEC const int globalDataValue_Integer = 10;"; 489 490 $HEADER2 .= " 491 $EXTERN $DECL_SPEC const int globalDataValue_Integer = 15;"; 492 493 # Global_Data_Value_Changed 494 # Character 495 $HEADER1 .= " 496 $EXTERN $DECL_SPEC const char globalDataValue_Char = \'o\';"; 497 498 $HEADER2 .= " 499 $EXTERN $DECL_SPEC const char globalDataValue_Char = \'N\';"; 500 501 # Parameter_Became_Restrict 502 $HEADER1 .= " 503 class $DECL_SPEC ParameterBecameRestrict { 504 public: 505 int method(int* param); 506 };"; 507 $SOURCE1 .= " 508 int ParameterBecameRestrict::method(int* param) { return 0; }"; 509 510 $HEADER2 .= " 511 class $DECL_SPEC ParameterBecameRestrict { 512 public: 513 int method(int* __restrict param); 514 };"; 515 $SOURCE2 .= " 516 int ParameterBecameRestrict::method(int* __restrict param) { return 0; }"; 517 518 # Parameter_Became_Non_Restrict 519 $HEADER1 .= " 520 class $DECL_SPEC ParameterBecameNonRestrict { 521 public: 522 int method(int* __restrict param); 523 };"; 524 $SOURCE1 .= " 525 int ParameterBecameNonRestrict::method(int* __restrict param) { return 0; }"; 526 527 $HEADER2 .= " 528 class $DECL_SPEC ParameterBecameNonRestrict { 529 public: 530 int method(int* param); 531 };"; 532 $SOURCE2 .= " 533 int ParameterBecameNonRestrict::method(int* param) { return 0; }"; 534 535 # Field_Became_Volatile 536 $HEADER1 .= " 537 class $DECL_SPEC FieldBecameVolatile { 538 public: 539 int method(int param); 540 int f; 541 };"; 542 $SOURCE1 .= " 543 int FieldBecameVolatile::method(int param) { return param; }"; 544 545 $HEADER2 .= " 546 class $DECL_SPEC FieldBecameVolatile { 547 public: 548 int method(int param); 549 volatile int f; 550 };"; 551 $SOURCE2 .= " 552 int FieldBecameVolatile::method(int param) { return param; }"; 553 554 # Field_Became_Non_Volatile 555 $HEADER1 .= " 556 class $DECL_SPEC FieldBecameNonVolatile { 557 public: 558 int method(int param); 559 volatile int f; 560 };"; 561 $SOURCE1 .= " 562 int FieldBecameNonVolatile::method(int param) { return param; }"; 563 564 $HEADER2 .= " 565 class $DECL_SPEC FieldBecameNonVolatile { 566 public: 567 int method(int param); 568 int f; 569 };"; 570 $SOURCE2 .= " 571 int FieldBecameNonVolatile::method(int param) { return param; }"; 572 573 # Field_Became_Mutable 574 $HEADER1 .= " 575 class $DECL_SPEC FieldBecameMutable { 576 public: 577 int method(int param); 578 int f; 579 };"; 580 $SOURCE1 .= " 581 int FieldBecameMutable::method(int param) { return param; }"; 582 583 $HEADER2 .= " 584 class $DECL_SPEC FieldBecameMutable { 585 public: 586 int method(int param); 587 mutable int f; 588 };"; 589 $SOURCE2 .= " 590 int FieldBecameMutable::method(int param) { return param; }"; 591 592 # Field_Became_Non_Mutable 593 $HEADER1 .= " 594 class $DECL_SPEC FieldBecameNonMutable { 595 public: 596 int method(int param); 597 mutable int f; 598 };"; 599 $SOURCE1 .= " 600 int FieldBecameNonMutable::method(int param) { return param; }"; 601 602 $HEADER2 .= " 603 class $DECL_SPEC FieldBecameNonMutable { 604 public: 605 int method(int param); 606 int f; 607 };"; 608 $SOURCE2 .= " 609 int FieldBecameNonMutable::method(int param) { return param; }"; 610 611 # Method_Became_Const 612 # Method_Became_Volatile 613 $HEADER1 .= " 614 class $DECL_SPEC MethodBecameConstVolatile { 615 public: 616 int method(int param); 617 };"; 618 $SOURCE1 .= " 619 int MethodBecameConstVolatile::method(int param) { return param; }"; 620 621 $HEADER2 .= " 622 class $DECL_SPEC MethodBecameConstVolatile { 623 public: 624 int method(int param) volatile const; 625 };"; 626 $SOURCE2 .= " 627 int MethodBecameConstVolatile::method(int param) volatile const { return param; }"; 628 629 # Method_Became_Const 630 $HEADER1 .= " 631 class $DECL_SPEC MethodBecameConst { 632 public: 633 int method(int param); 634 };"; 635 $SOURCE1 .= " 636 int MethodBecameConst::method(int param) { return param; }"; 637 638 $HEADER2 .= " 639 class $DECL_SPEC MethodBecameConst { 640 public: 641 int method(int param) const; 642 };"; 643 $SOURCE2 .= " 644 int MethodBecameConst::method(int param) const { return param; }"; 645 646 # Method_Became_Non_Const 647 $HEADER1 .= " 648 class $DECL_SPEC MethodBecameNonConst { 649 public: 650 int method(int param) const; 651 };"; 652 $SOURCE1 .= " 653 int MethodBecameNonConst::method(int param) const { return param; }"; 654 655 $HEADER2 .= " 656 class $DECL_SPEC MethodBecameNonConst { 657 public: 658 int method(int param); 659 };"; 660 $SOURCE2 .= " 661 int MethodBecameNonConst::method(int param) { return param; }"; 662 663 # Method_Became_Volatile 664 $HEADER1 .= " 665 class $DECL_SPEC MethodBecameVolatile { 666 public: 667 int method(int param); 668 };"; 669 $SOURCE1 .= " 670 int MethodBecameVolatile::method(int param) { return param; }"; 671 672 $HEADER2 .= " 673 class $DECL_SPEC MethodBecameVolatile { 674 public: 675 int method(int param) volatile; 676 };"; 677 $SOURCE2 .= " 678 int MethodBecameVolatile::method(int param) volatile { return param; }"; 679 680 # Virtual_Method_Position 681 # Multiple bases 682 $HEADER1 .= " 683 class $DECL_SPEC PrimaryBase 684 { 685 public: 686 virtual ~PrimaryBase(); 687 virtual void foo(); 688 }; 689 class $DECL_SPEC SecondaryBase 690 { 691 public: 692 virtual ~SecondaryBase(); 693 virtual void bar(); 694 }; 695 class UnsafeVirtualOverride: public PrimaryBase, public SecondaryBase 696 { 697 public: 698 UnsafeVirtualOverride(); 699 ~UnsafeVirtualOverride(); 700 void foo(); 701 };"; 702 $SOURCE1 .= " 703 PrimaryBase::~PrimaryBase() { } 704 void PrimaryBase::foo() { } 705 706 SecondaryBase::~SecondaryBase() { } 707 void SecondaryBase::bar() { } 708 709 UnsafeVirtualOverride::UnsafeVirtualOverride() { } 710 UnsafeVirtualOverride::~UnsafeVirtualOverride() { } 711 void UnsafeVirtualOverride::foo() { }"; 712 713 $HEADER2 .= " 714 class $DECL_SPEC PrimaryBase 715 { 716 public: 717 virtual ~PrimaryBase(); 718 virtual void foo(); 719 }; 720 class $DECL_SPEC SecondaryBase 721 { 722 public: 723 virtual ~SecondaryBase(); 724 virtual void bar(); 725 }; 726 class UnsafeVirtualOverride: public PrimaryBase, public SecondaryBase 727 { 728 public: 729 UnsafeVirtualOverride(); 730 ~UnsafeVirtualOverride(); 731 void foo(); 732 void bar(); 733 };"; 734 $SOURCE2 .= " 735 PrimaryBase::~PrimaryBase() { } 736 void PrimaryBase::foo() { } 737 738 SecondaryBase::~SecondaryBase() { } 739 void SecondaryBase::bar() { } 740 741 UnsafeVirtualOverride::UnsafeVirtualOverride() { } 742 UnsafeVirtualOverride::~UnsafeVirtualOverride() { } 743 void UnsafeVirtualOverride::foo() { } 744 void UnsafeVirtualOverride::bar() { }"; 745 746 # Removed_Interface (inline virtual d-tor) 747 $HEADER1 .= " 748 template <typename T> 749 class $DECL_SPEC BaseTemplate { 750 public: 751 BaseTemplate() { } 752 virtual int method(int param) { return param; }; 753 virtual ~BaseTemplate() { }; 754 }; 755 class $DECL_SPEC RemovedVirtualDestructor: public BaseTemplate<int> { 756 public: 757 RemovedVirtualDestructor() { }; 758 virtual int method2(int param); 759 };"; 760 $SOURCE1 .= " 761 int RemovedVirtualDestructor::method2(int param) { return param; }"; 762 763 $HEADER2 .= " 764 template <typename T> 765 class $DECL_SPEC BaseTemplate { 766 public: 767 BaseTemplate() { } 768 virtual int method(int param) { return param; }; 769 //virtual ~BaseTemplate() { }; 770 }; 771 class $DECL_SPEC RemovedVirtualDestructor: public BaseTemplate<int> { 772 public: 773 RemovedVirtualDestructor() { }; 774 virtual int method2(int param); 775 };"; 776 $SOURCE2 .= " 777 int RemovedVirtualDestructor::method2(int param) { return param; }"; 778 779 # Added_Virtual_Method_At_End 780 $HEADER1 .= " 781 class $DECL_SPEC DefaultConstructor { 782 public: 783 DefaultConstructor() { } 784 virtual int method(int param); 785 };"; 786 $SOURCE1 .= " 787 int DefaultConstructor::method(int param) { return param; }"; 788 789 $HEADER2 .= " 790 class $DECL_SPEC DefaultConstructor { 791 public: 792 DefaultConstructor() { } 793 virtual int method(int param); 794 virtual int addedMethod(int param); 795 };"; 796 $SOURCE2 .= " 797 int DefaultConstructor::method(int param) { return addedMethod(param); } 798 int DefaultConstructor::addedMethod(int param) { return param; }"; 799 800 # Added_Enum_Member 801 $HEADER1 .= " 802 enum AddedEnumMember { 803 OldMember 804 }; 805 $DECL_SPEC int addedEnumMember(enum AddedEnumMember param);"; 806 $SOURCE1 .= " 807 int addedEnumMember(enum AddedEnumMember param) { return 0; }"; 808 809 $HEADER2 .= " 810 enum AddedEnumMember { 811 OldMember, 812 NewMember 813 }; 814 $DECL_SPEC int addedEnumMember(enum AddedEnumMember param);"; 815 $SOURCE2 .= " 816 int addedEnumMember(enum AddedEnumMember param) { return 0; }"; 817 818 # Parameter_Type_Format (Safe) 819 $HEADER1 .= " 820 struct DType 821 { 822 int i; 823 double j; 824 }; 825 $DECL_SPEC int parameterTypeFormat_Safe(struct DType param);"; 826 $SOURCE1 .= " 827 int parameterTypeFormat_Safe(struct DType param) { return 0; }"; 828 829 $HEADER2 .= " 830 class DType 831 { 832 int i; 833 double j; 834 }; 835 $DECL_SPEC int parameterTypeFormat_Safe(class DType param);"; 836 $SOURCE2 .= " 837 int parameterTypeFormat_Safe(class DType param) { return 0; }"; 838 839 # Type_Became_Opaque (Struct) 840 $HEADER1 .= " 841 struct StructBecameOpaque 842 { 843 int i, j; 844 }; 845 $DECL_SPEC int structBecameOpaque(struct StructBecameOpaque* param);"; 846 $SOURCE1 .= " 847 int structBecameOpaque(struct StructBecameOpaque* param) { return 0; }"; 848 849 $HEADER2 .= " 850 struct StructBecameOpaque; 851 $DECL_SPEC int structBecameOpaque(struct StructBecameOpaque* param);"; 852 $SOURCE2 .= " 853 int structBecameOpaque(struct StructBecameOpaque* param) { return 0; }"; 854 855 # Type_Became_Opaque (Union) 856 $HEADER1 .= " 857 union UnionBecameOpaque 858 { 859 int i, j; 860 }; 861 $DECL_SPEC int unionBecameOpaque(union UnionBecameOpaque* param);"; 862 $SOURCE1 .= " 863 int unionBecameOpaque(union UnionBecameOpaque* param) { return 0; }"; 864 865 $HEADER2 .= " 866 union UnionBecameOpaque; 867 $DECL_SPEC int unionBecameOpaque(union UnionBecameOpaque* param);"; 868 $SOURCE2 .= " 869 int unionBecameOpaque(union UnionBecameOpaque* param) { return 0; }"; 870 871 # Field_Type_Format 872 $HEADER1 .= " 873 struct DType1 874 { 875 int i; 876 double j[7]; 877 }; 878 struct FieldTypeFormat 879 { 880 int i; 881 struct DType1 j; 882 }; 883 $DECL_SPEC int fieldTypeFormat(struct FieldTypeFormat param);"; 884 $SOURCE1 .= " 885 int fieldTypeFormat(struct FieldTypeFormat param) { return 0; }"; 886 887 $HEADER2 .= " 888 struct DType2 889 { 890 double i[7]; 891 int j; 892 }; 893 struct FieldTypeFormat 894 { 895 int i; 896 struct DType2 j; 897 }; 898 $DECL_SPEC int fieldTypeFormat(struct FieldTypeFormat param);"; 899 $SOURCE2 .= " 900 int fieldTypeFormat(struct FieldTypeFormat param) { return 0; }"; 901 902 # Field_Type_Format (func ptr) 903 $HEADER1 .= " 904 typedef void (*FuncPtr_Old) (int a); 905 struct FieldTypeFormat_FuncPtr 906 { 907 int i; 908 FuncPtr_Old j; 909 }; 910 $DECL_SPEC int fieldTypeFormat_FuncPtr(struct FieldTypeFormat_FuncPtr param);"; 911 $SOURCE1 .= " 912 int fieldTypeFormat_FuncPtr(struct FieldTypeFormat_FuncPtr param) { return 0; }"; 913 914 $HEADER2 .= " 915 typedef void (*FuncPtr_New) (int a, int b); 916 struct FieldTypeFormat_FuncPtr 917 { 918 int i; 919 FuncPtr_New j; 920 }; 921 $DECL_SPEC int fieldTypeFormat_FuncPtr(struct FieldTypeFormat_FuncPtr param);"; 922 $SOURCE2 .= " 923 int fieldTypeFormat_FuncPtr(struct FieldTypeFormat_FuncPtr param) { return 0; }"; 924 925 # Removed_Virtual_Method (inline) 926 $HEADER1 .= " 927 class $DECL_SPEC RemovedInlineVirtualFunction { 928 public: 929 RemovedInlineVirtualFunction(); 930 virtual int removedMethod(int param) { return 0; } 931 virtual int method(int param); 932 };"; 933 $SOURCE1 .= " 934 int RemovedInlineVirtualFunction::method(int param) { return param; } 935 RemovedInlineVirtualFunction::RemovedInlineVirtualFunction() { }"; 936 937 $HEADER2 .= " 938 class $DECL_SPEC RemovedInlineVirtualFunction { 939 public: 940 RemovedInlineVirtualFunction(); 941 virtual int method(int param); 942 };"; 943 $SOURCE2 .= " 944 int RemovedInlineVirtualFunction::method(int param) { return param; } 945 RemovedInlineVirtualFunction::RemovedInlineVirtualFunction() { }"; 946 947 # MethodPtr 948 $HEADER1 .= " 949 class TestMethodPtr { 950 public: 951 typedef void (TestMethodPtr::*Method)(int*); 952 Method _method; 953 TestMethodPtr(); 954 void method(); 955 };"; 956 $SOURCE1 .= " 957 TestMethodPtr::TestMethodPtr() { } 958 void TestMethodPtr::method() { }"; 959 960 $HEADER2 .= " 961 class TestMethodPtr { 962 public: 963 typedef void (TestMethodPtr::*Method)(int*, void*); 964 Method _method; 965 TestMethodPtr(); 966 void method(); 967 };"; 968 $SOURCE2 .= " 969 TestMethodPtr::TestMethodPtr() { } 970 void TestMethodPtr::method() { }"; 971 972 # FieldPtr 973 $HEADER1 .= " 974 class TestFieldPtr { 975 public: 976 typedef void* (TestFieldPtr::*Field); 977 Field _field; 978 TestFieldPtr(); 979 void method(void*); 980 };"; 981 $SOURCE1 .= " 982 TestFieldPtr::TestFieldPtr(){ } 983 void TestFieldPtr::method(void*) { }"; 984 985 $HEADER2 .= " 986 class TestFieldPtr { 987 public: 988 typedef int (TestFieldPtr::*Field); 989 Field _field; 990 TestFieldPtr(); 991 void method(void*); 992 };"; 993 $SOURCE2 .= " 994 TestFieldPtr::TestFieldPtr(){ } 995 void TestFieldPtr::method(void*) { }"; 996 997 # Removed_Symbol (Template Specializations) 998 $HEADER1 .= " 999 template <unsigned int _TP, typename AAA> 1000 class Template { 1001 public: 1002 char const *field; 1003 }; 1004 template <unsigned int _TP, typename AAA> 1005 class TestRemovedTemplate { 1006 public: 1007 char const *field; 1008 void method(int); 1009 }; 1010 template <> 1011 class TestRemovedTemplate<7, char> { 1012 public: 1013 char const *field; 1014 void method(int); 1015 };"; 1016 $SOURCE1 .= " 1017 void TestRemovedTemplate<7, char>::method(int){ }"; 1018 1019 # Removed_Symbol (Template Specializations) 1020 $HEADER1 .= " 1021 template <typename TName> 1022 int removedTemplateSpec(TName); 1023 1024 template <> int removedTemplateSpec<char>(char);"; 1025 $SOURCE1 .= " 1026 template <> int removedTemplateSpec<char>(char){return 0;}"; 1027 1028 # Removed_Field (Ref) 1029 $HEADER1 .= " 1030 struct TestRefChange { 1031 int a, b, c; 1032 }; 1033 $DECL_SPEC int paramRefChange(const TestRefChange & p1, int p2);"; 1034 $SOURCE1 .= " 1035 int paramRefChange(const TestRefChange & p1, int p2) { return p2; }"; 1036 1037 $HEADER2 .= " 1038 struct TestRefChange { 1039 int a, b; 1040 }; 1041 $DECL_SPEC int paramRefChange(const TestRefChange & p1, int p2);"; 1042 $SOURCE2 .= " 1043 int paramRefChange(const TestRefChange & p1, int p2) { return p2; }"; 1044 1045 # Removed_Parameter 1046 $HEADER1 .= " 1047 $DECL_SPEC int removedParameter(int param, int removed_param);"; 1048 $SOURCE1 .= " 1049 int removedParameter(int param, int removed_param) { return 0; }"; 1050 1051 $HEADER2 .= " 1052 $DECL_SPEC int removedParameter(int param);"; 1053 $SOURCE2 .= " 1054 int removedParameter(int param) { return 0; }"; 1055 1056 # Added_Parameter 1057 $HEADER1 .= " 1058 $DECL_SPEC int addedParameter(int param);"; 1059 $SOURCE1 .= " 1060 int addedParameter(int param) { return 0; }"; 1061 1062 $HEADER2 .= " 1063 $DECL_SPEC int addedParameter(int param, int added_param);"; 1064 $SOURCE2 .= " 1065 int addedParameter(int param, int added_param) { return 0; }"; 1066 1067 # Added 1068 $HEADER2 .= " 1069 typedef int (*FUNCPTR_TYPE)(int a, int b); 1070 $DECL_SPEC int addedFunc(FUNCPTR_TYPE*const** f);"; 1071 $SOURCE2 .= " 1072 int addedFunc(FUNCPTR_TYPE*const** f) { return 0; }"; 1073 1074 # Added (3) 1075 $HEADER2 .= " 1076 struct DStruct 1077 { 1078 int i, j, k; 1079 }; 1080 int addedFunc3(struct DStruct* p);"; 1081 $SOURCE2 .= " 1082 int addedFunc3(struct DStruct* p) { return 0; }"; 1083 1084 # Added_Virtual_Method 1085 $HEADER1 .= " 1086 class $DECL_SPEC AddedVirtualMethod { 1087 public: 1088 virtual int method(int param); 1089 };"; 1090 $SOURCE1 .= " 1091 int AddedVirtualMethod::method(int param) { return param; }"; 1092 1093 $HEADER2 .= " 1094 class $DECL_SPEC AddedVirtualMethod { 1095 public: 1096 virtual int addedMethod(int param); 1097 virtual int method(int param); 1098 };"; 1099 $SOURCE2 .= " 1100 int AddedVirtualMethod::addedMethod(int param) { 1101 return param; 1102 } 1103 int AddedVirtualMethod::method(int param) { return param; }"; 1104 1105 # Added_Virtual_Method (added "virtual" attribute) 1106 $HEADER1 .= " 1107 class $DECL_SPEC BecameVirtualMethod { 1108 public: 1109 int becameVirtual(int param); 1110 virtual int method(int param); 1111 };"; 1112 $SOURCE1 .= " 1113 int BecameVirtualMethod::becameVirtual(int param) { return param; } 1114 int BecameVirtualMethod::method(int param) { return param; }"; 1115 1116 $HEADER2 .= " 1117 class $DECL_SPEC BecameVirtualMethod { 1118 public: 1119 virtual int becameVirtual(int param); 1120 virtual int method(int param); 1121 };"; 1122 $SOURCE2 .= " 1123 int BecameVirtualMethod::becameVirtual(int param) { return param; } 1124 int BecameVirtualMethod::method(int param) { return param; }"; 1125 1126 # Added_Pure_Virtual_Method 1127 $HEADER1 .= " 1128 class $DECL_SPEC AddedPureVirtualMethod { 1129 public: 1130 virtual int method(int param); 1131 int otherMethod(int param); 1132 };"; 1133 $SOURCE1 .= " 1134 int AddedPureVirtualMethod::method(int param) { return param; } 1135 int AddedPureVirtualMethod::otherMethod(int param) { return param; }"; 1136 1137 $HEADER2 .= " 1138 class $DECL_SPEC AddedPureVirtualMethod { 1139 public: 1140 virtual int addedMethod(int param)=0; 1141 virtual int method(int param); 1142 int otherMethod(int param); 1143 };"; 1144 $SOURCE2 .= " 1145 int AddedPureVirtualMethod::method(int param) { return param; } 1146 int AddedPureVirtualMethod::otherMethod(int param) { return param; }"; 1147 1148 # Added_Virtual_Method_At_End (Safe) 1149 $HEADER1 .= " 1150 class $DECL_SPEC AddedVirtualMethodAtEnd { 1151 public: 1152 AddedVirtualMethodAtEnd(); 1153 int method1(int param); 1154 virtual int method2(int param); 1155 };"; 1156 $SOURCE1 .= " 1157 AddedVirtualMethodAtEnd::AddedVirtualMethodAtEnd() { } 1158 int AddedVirtualMethodAtEnd::method1(int param) { return param; } 1159 int AddedVirtualMethodAtEnd::method2(int param) { return param; }"; 1160 1161 $HEADER2 .= " 1162 class $DECL_SPEC AddedVirtualMethodAtEnd { 1163 public: 1164 AddedVirtualMethodAtEnd(); 1165 int method1(int param); 1166 virtual int method2(int param); 1167 virtual int addedMethod(int param); 1168 };"; 1169 $SOURCE2 .= " 1170 AddedVirtualMethodAtEnd::AddedVirtualMethodAtEnd() { } 1171 int AddedVirtualMethodAtEnd::method1(int param) { return param; } 1172 int AddedVirtualMethodAtEnd::method2(int param) { return param; } 1173 int AddedVirtualMethodAtEnd::addedMethod(int param) { return param; }"; 1174 1175 # Added_Virtual_Method_At_End (With Default Constructor) 1176 $HEADER1 .= " 1177 class $DECL_SPEC AddedVirtualMethodAtEnd_DefaultConstructor { 1178 public: 1179 int method1(int param); 1180 virtual int method2(int param); 1181 };"; 1182 $SOURCE1 .= " 1183 int AddedVirtualMethodAtEnd_DefaultConstructor::method1(int param) { return param; } 1184 int AddedVirtualMethodAtEnd_DefaultConstructor::method2(int param) { return param; }"; 1185 1186 $HEADER2 .= " 1187 class $DECL_SPEC AddedVirtualMethodAtEnd_DefaultConstructor { 1188 public: 1189 int method1(int param); 1190 virtual int method2(int param); 1191 virtual int addedMethod(int param); 1192 };"; 1193 $SOURCE2 .= " 1194 int AddedVirtualMethodAtEnd_DefaultConstructor::method1(int param) { return param; } 1195 int AddedVirtualMethodAtEnd_DefaultConstructor::method2(int param) { return param; } 1196 int AddedVirtualMethodAtEnd_DefaultConstructor::addedMethod(int param) { return param; }"; 1197 1198 # Added_First_Virtual_Method 1199 $HEADER1 .= " 1200 class $DECL_SPEC AddedFirstVirtualMethod { 1201 public: 1202 int method(int param); 1203 };"; 1204 $SOURCE1 .= " 1205 int AddedFirstVirtualMethod::method(int param) { return param; }"; 1206 1207 $HEADER2 .= " 1208 class $DECL_SPEC AddedFirstVirtualMethod { 1209 public: 1210 int method(int param); 1211 virtual int addedMethod(int param); 1212 };"; 1213 $SOURCE2 .= " 1214 int AddedFirstVirtualMethod::method(int param) { return param; } 1215 int AddedFirstVirtualMethod::addedMethod(int param) { return param; }"; 1216 1217 # Removed_Virtual_Method 1218 $HEADER1 .= " 1219 class $DECL_SPEC RemovedVirtualFunction { 1220 public: 1221 int a, b, c; 1222 virtual int removedMethod(int param); 1223 virtual int vMethod(int param); 1224 };"; 1225 $SOURCE1 .= " 1226 int RemovedVirtualFunction::removedMethod(int param) { return param; } 1227 int RemovedVirtualFunction::vMethod(int param) { return param; }"; 1228 1229 $HEADER2 .= " 1230 class $DECL_SPEC RemovedVirtualFunction { 1231 public: 1232 int a, b, c; 1233 int removedMethod(int param); 1234 virtual int vMethod(int param); 1235 };"; 1236 $SOURCE2 .= " 1237 int RemovedVirtualFunction::removedMethod(int param) { return param; } 1238 int RemovedVirtualFunction::vMethod(int param) { return param; }"; 1239 1240 # Removed_Virtual_Method (Pure, From the End) 1241 $HEADER1 .= " 1242 class $DECL_SPEC RemovedPureVirtualMethodFromEnd { 1243 public: 1244 virtual int method(int param); 1245 virtual int removedMethod(int param)=0; 1246 };"; 1247 $SOURCE1 .= " 1248 int RemovedPureVirtualMethodFromEnd::method(int param) { return param; } 1249 int RemovedPureVirtualMethodFromEnd::removedMethod(int param) { return param; }"; 1250 1251 $HEADER2 .= " 1252 class $DECL_SPEC RemovedPureVirtualMethodFromEnd 1253 { 1254 public: 1255 virtual int method(int param); 1256 int removedMethod(int param); 1257 };"; 1258 $SOURCE2 .= " 1259 int RemovedPureVirtualMethodFromEnd::method(int param) { return param; } 1260 int RemovedPureVirtualMethodFromEnd::removedMethod(int param) { return param; }"; 1261 1262 # Removed_Symbol (Pure with Implementation) 1263 $HEADER1 .= " 1264 class $DECL_SPEC RemovedPureSymbol { 1265 public: 1266 virtual int method(int param); 1267 virtual int removedMethod(int param)=0; 1268 };"; 1269 $SOURCE1 .= " 1270 int RemovedPureSymbol::method(int param) { return param; } 1271 int RemovedPureSymbol::removedMethod(int param) { return param; }"; 1272 1273 $HEADER2 .= " 1274 class $DECL_SPEC RemovedPureSymbol 1275 { 1276 public: 1277 virtual int method(int param); 1278 };"; 1279 $SOURCE2 .= " 1280 int RemovedPureSymbol::method(int param) { return param; }"; 1281 1282 # Removed_Virtual_Method (From the End) 1283 $HEADER1 .= " 1284 class $DECL_SPEC RemovedVirtualMethodFromEnd { 1285 public: 1286 virtual int method(int param); 1287 virtual int removedMethod(int param); 1288 };"; 1289 $SOURCE1 .= " 1290 int RemovedVirtualMethodFromEnd::method(int param) { return param; } 1291 int RemovedVirtualMethodFromEnd::removedMethod(int param) { return param; }"; 1292 1293 $HEADER2 .= " 1294 class $DECL_SPEC RemovedVirtualMethodFromEnd 1295 { 1296 public: 1297 virtual int method(int param); 1298 int removedMethod(int param); 1299 };"; 1300 $SOURCE2 .= " 1301 int RemovedVirtualMethodFromEnd::method(int param) { return param; } 1302 int RemovedVirtualMethodFromEnd::removedMethod(int param) { return param; }"; 1303 1304 # Removed_Last_Virtual_Method 1305 $HEADER1 .= " 1306 class $DECL_SPEC RemovedLastVirtualMethod 1307 { 1308 public: 1309 int method(int param); 1310 virtual int removedMethod(int param); 1311 };"; 1312 $SOURCE1 .= " 1313 int RemovedLastVirtualMethod::method(int param) { return param; }"; 1314 $SOURCE1 .= " 1315 int RemovedLastVirtualMethod::removedMethod(int param) { return param; }"; 1316 1317 $HEADER2 .= " 1318 class $DECL_SPEC RemovedLastVirtualMethod 1319 { 1320 public: 1321 int method(int param); 1322 int removedMethod(int param); 1323 };"; 1324 $SOURCE2 .= " 1325 int RemovedLastVirtualMethod::method(int param) { return param; }"; 1326 $SOURCE2 .= " 1327 int RemovedLastVirtualMethod::removedMethod(int param) { return param; }"; 1328 1329 # Virtual_Table_Size 1330 $HEADER1 .= " 1331 class $DECL_SPEC VirtualTableSize 1332 { 1333 public: 1334 virtual int method1(int param); 1335 virtual int method2(int param); 1336 }; 1337 class $DECL_SPEC VirtualTableSize_SubClass: public VirtualTableSize 1338 { 1339 public: 1340 virtual int method3(int param); 1341 virtual int method4(int param); 1342 };"; 1343 $SOURCE1 .= " 1344 int VirtualTableSize::method1(int param) { return param; } 1345 int VirtualTableSize::method2(int param) { return param; } 1346 int VirtualTableSize_SubClass::method3(int param) { return param; } 1347 int VirtualTableSize_SubClass::method4(int param) { return param; }"; 1348 1349 $HEADER2 .= " 1350 class $DECL_SPEC VirtualTableSize 1351 { 1352 public: 1353 virtual int method1(int param); 1354 virtual int method2(int param); 1355 virtual int addedMethod(int param); 1356 }; 1357 class $DECL_SPEC VirtualTableSize_SubClass: public VirtualTableSize 1358 { 1359 public: 1360 virtual int method3(int param); 1361 virtual int method4(int param); 1362 };"; 1363 $SOURCE2 .= " 1364 int VirtualTableSize::method1(int param) { return param; } 1365 int VirtualTableSize::method2(int param) { return param; } 1366 int VirtualTableSize::addedMethod(int param) { return param; } 1367 int VirtualTableSize_SubClass::method3(int param) { return param; } 1368 int VirtualTableSize_SubClass::method4(int param) { return param; }"; 1369 1370 # Virtual_Method_Position 1371 $HEADER1 .= " 1372 class $DECL_SPEC VirtualMethodPosition 1373 { 1374 public: 1375 virtual int method1(int param); 1376 virtual int method2(int param); 1377 };"; 1378 $SOURCE1 .= " 1379 int VirtualMethodPosition::method1(int param) { return param; }"; 1380 $SOURCE1 .= " 1381 int VirtualMethodPosition::method2(int param) { return param; }"; 1382 1383 $HEADER2 .= " 1384 class $DECL_SPEC VirtualMethodPosition 1385 { 1386 public: 1387 virtual int method2(int param); 1388 virtual int method1(int param); 1389 };"; 1390 $SOURCE2 .= " 1391 int VirtualMethodPosition::method1(int param) { return param; }"; 1392 $SOURCE2 .= " 1393 int VirtualMethodPosition::method2(int param) { return param; }"; 1394 1395 # Pure_Virtual_Method_Position 1396 $HEADER1 .= " 1397 class $DECL_SPEC PureVirtualFunctionPosition { 1398 public: 1399 virtual int method1(int param)=0; 1400 virtual int method2(int param)=0; 1401 int method3(int param); 1402 };"; 1403 $SOURCE1 .= " 1404 int PureVirtualFunctionPosition::method3(int param) { return method1(7)+method2(7); }"; 1405 1406 $HEADER2 .= " 1407 class $DECL_SPEC PureVirtualFunctionPosition { 1408 public: 1409 virtual int method2(int param)=0; 1410 virtual int method1(int param)=0; 1411 int method3(int param); 1412 };"; 1413 $SOURCE2 .= " 1414 int PureVirtualFunctionPosition::method3(int param) { return method1(7)+method2(7); }"; 1415 1416 # Virtual_Method_Position 1417 $HEADER1 .= " 1418 class $DECL_SPEC VirtualFunctionPosition { 1419 public: 1420 virtual int method1(int param); 1421 virtual int method2(int param); 1422 };"; 1423 $SOURCE1 .= " 1424 int VirtualFunctionPosition::method1(int param) { return 1; } 1425 int VirtualFunctionPosition::method2(int param) { return 2; }"; 1426 1427 $HEADER2 .= " 1428 class $DECL_SPEC VirtualFunctionPosition { 1429 public: 1430 virtual int method2(int param); 1431 virtual int method1(int param); 1432 };"; 1433 $SOURCE2 .= " 1434 int VirtualFunctionPosition::method1(int param) { return 1; } 1435 int VirtualFunctionPosition::method2(int param) { return 2; }"; 1436 1437 # Virtual_Method_Position (safe) 1438 $HEADER1 .= " 1439 class $DECL_SPEC VirtualFunctionPositionSafe_Base { 1440 public: 1441 virtual int method1(int param); 1442 virtual int method2(int param); 1443 }; 1444 class $DECL_SPEC VirtualFunctionPositionSafe: public VirtualFunctionPositionSafe_Base { 1445 public: 1446 virtual int method1(int param); 1447 virtual int method2(int param); 1448 };"; 1449 $SOURCE1 .= " 1450 int VirtualFunctionPositionSafe_Base::method1(int param) { return param; } 1451 int VirtualFunctionPositionSafe_Base::method2(int param) { return param; } 1452 int VirtualFunctionPositionSafe::method1(int param) { return param; } 1453 int VirtualFunctionPositionSafe::method2(int param) { return param; }"; 1454 1455 $HEADER2 .= " 1456 class $DECL_SPEC VirtualFunctionPositionSafe_Base { 1457 public: 1458 virtual int method1(int param); 1459 virtual int method2(int param); 1460 }; 1461 class $DECL_SPEC VirtualFunctionPositionSafe: public VirtualFunctionPositionSafe_Base { 1462 public: 1463 virtual int method2(int param); 1464 virtual int method1(int param); 1465 };"; 1466 $SOURCE2 .= " 1467 int VirtualFunctionPositionSafe_Base::method1(int param) { return param; } 1468 int VirtualFunctionPositionSafe_Base::method2(int param) { return param; } 1469 int VirtualFunctionPositionSafe::method1(int param) { return param; } 1470 int VirtualFunctionPositionSafe::method2(int param) { return param; }"; 1471 1472 # Overridden_Virtual_Method 1473 $HEADER1 .= " 1474 class $DECL_SPEC OverriddenVirtualMethod_Base { 1475 public: 1476 virtual int method1(int param); 1477 virtual int method2(int param); 1478 }; 1479 class $DECL_SPEC OverriddenVirtualMethod: public OverriddenVirtualMethod_Base { 1480 public: 1481 OverriddenVirtualMethod(); 1482 virtual int method3(int param); 1483 };"; 1484 $SOURCE1 .= " 1485 int OverriddenVirtualMethod_Base::method1(int param) { return param; } 1486 int OverriddenVirtualMethod_Base::method2(int param) { return param; } 1487 OverriddenVirtualMethod::OverriddenVirtualMethod() {} 1488 int OverriddenVirtualMethod::method3(int param) { return param; }"; 1489 1490 $HEADER2 .= " 1491 class $DECL_SPEC OverriddenVirtualMethod_Base { 1492 public: 1493 virtual int method1(int param); 1494 virtual int method2(int param); 1495 }; 1496 class $DECL_SPEC OverriddenVirtualMethod:public OverriddenVirtualMethod_Base { 1497 OverriddenVirtualMethod(); 1498 virtual int method2(int param); 1499 virtual int method3(int param); 1500 };"; 1501 $SOURCE2 .= " 1502 int OverriddenVirtualMethod_Base::method1(int param) { return param; } 1503 int OverriddenVirtualMethod_Base::method2(int param) { return param; } 1504 OverriddenVirtualMethod::OverriddenVirtualMethod() {} 1505 int OverriddenVirtualMethod::method2(int param) { return param; } 1506 int OverriddenVirtualMethod::method3(int param) { return param; }"; 1507 1508 # Overridden_Virtual_Method_B (+ removed) 1509 $HEADER1 .= " 1510 1511 class $DECL_SPEC OverriddenVirtualMethodB: public OverriddenVirtualMethod_Base { 1512 public: 1513 OverriddenVirtualMethodB(); 1514 virtual int method2(int param); 1515 virtual int method3(int param); 1516 };"; 1517 $SOURCE1 .= " 1518 OverriddenVirtualMethodB::OverriddenVirtualMethodB() {} 1519 int OverriddenVirtualMethodB::method2(int param) { return param; } 1520 int OverriddenVirtualMethodB::method3(int param) { return param; }"; 1521 1522 $HEADER2 .= " 1523 1524 class $DECL_SPEC OverriddenVirtualMethodB:public OverriddenVirtualMethod_Base { 1525 public: 1526 OverriddenVirtualMethodB(); 1527 virtual int method3(int param); 1528 };"; 1529 $SOURCE2 .= " 1530 OverriddenVirtualMethodB::OverriddenVirtualMethodB() {} 1531 int OverriddenVirtualMethodB::method3(int param) { return param; }"; 1532 1533 # Size 1534 $HEADER1 .= " 1535 struct $DECL_SPEC TypeSize 1536 { 1537 public: 1538 TypeSize method(TypeSize param); 1539 int i[5]; 1540 long j; 1541 double k; 1542 TypeSize* p; 1543 };"; 1544 $SOURCE1 .= " 1545 TypeSize TypeSize::method(TypeSize param) { return param; }"; 1546 1547 $HEADER2 .= " 1548 struct $DECL_SPEC TypeSize 1549 { 1550 public: 1551 TypeSize method(TypeSize param); 1552 int i[15]; 1553 long j; 1554 double k; 1555 TypeSize* p; 1556 int added_member; 1557 };"; 1558 $SOURCE2 .= " 1559 TypeSize TypeSize::method(TypeSize param) { return param; }"; 1560 1561 # Size_Of_Allocable_Class_Increased 1562 $HEADER1 .= " 1563 class $DECL_SPEC AllocableClassSize 1564 { 1565 public: 1566 AllocableClassSize(); 1567 int method(); 1568 double p[5]; 1569 };"; 1570 $SOURCE1 .= " 1571 AllocableClassSize::AllocableClassSize() { }"; 1572 $SOURCE1 .= " 1573 int AllocableClassSize::method() { return 0; }"; 1574 1575 $HEADER2 .= " 1576 struct $DECL_SPEC AllocableClassSize 1577 { 1578 public: 1579 AllocableClassSize(); 1580 int method(); 1581 double p[15]; 1582 };"; 1583 $SOURCE2 .= " 1584 AllocableClassSize::AllocableClassSize() { }"; 1585 $SOURCE2 .= " 1586 int AllocableClassSize::method() { return 0; }"; 1587 1588 # Size_Of_Allocable_Class_Decreased (decreased size, has derived class, has public members) 1589 $HEADER1 .= " 1590 class $DECL_SPEC DecreasedClassSize 1591 { 1592 public: 1593 DecreasedClassSize(); 1594 int method(); 1595 double p[15]; 1596 };"; 1597 $SOURCE1 .= " 1598 DecreasedClassSize::DecreasedClassSize() { }"; 1599 $SOURCE1 .= " 1600 int DecreasedClassSize::method() { return 0; }"; 1601 $HEADER1 .= " 1602 class $DECL_SPEC DecreasedClassSize_SubClass: public DecreasedClassSize 1603 { 1604 public: 1605 DecreasedClassSize_SubClass(); 1606 int method(); 1607 int f; 1608 };"; 1609 $SOURCE1 .= " 1610 DecreasedClassSize_SubClass::DecreasedClassSize_SubClass() { f=7; }"; 1611 $SOURCE1 .= " 1612 int DecreasedClassSize_SubClass::method() { return f; }"; 1613 1614 $HEADER2 .= " 1615 struct $DECL_SPEC DecreasedClassSize 1616 { 1617 public: 1618 DecreasedClassSize(); 1619 int method(); 1620 double p[5]; 1621 };"; 1622 $SOURCE2 .= " 1623 DecreasedClassSize::DecreasedClassSize() { }"; 1624 $SOURCE2 .= " 1625 int DecreasedClassSize::method() { return 0; }"; 1626 $HEADER2 .= " 1627 class $DECL_SPEC DecreasedClassSize_SubClass: public DecreasedClassSize 1628 { 1629 public: 1630 DecreasedClassSize_SubClass(); 1631 int method(); 1632 int f; 1633 };"; 1634 $SOURCE2 .= " 1635 DecreasedClassSize_SubClass::DecreasedClassSize_SubClass() { f=7; }"; 1636 $SOURCE2 .= " 1637 int DecreasedClassSize_SubClass::method() { return f; }"; 1638 1639 # Size_Of_Copying_Class 1640 $HEADER1 .= " 1641 class $DECL_SPEC CopyingClassSize 1642 { 1643 public: 1644 int method(); 1645 int p[5]; 1646 };"; 1647 $SOURCE1 .= " 1648 int CopyingClassSize::method() { return p[4]; }"; 1649 1650 $HEADER2 .= " 1651 struct $DECL_SPEC CopyingClassSize 1652 { 1653 public: 1654 int method(); 1655 int p[15]; 1656 };"; 1657 $SOURCE2 .= " 1658 int CopyingClassSize::method() { return p[10]; }"; 1659 1660 # Base_Class_Became_Virtually_Inherited 1661 $HEADER1 .= " 1662 class $DECL_SPEC BecameVirtualBase 1663 { 1664 public: 1665 BecameVirtualBase(); 1666 int method(); 1667 double p[5]; 1668 };"; 1669 $SOURCE1 .= " 1670 BecameVirtualBase::BecameVirtualBase() { }"; 1671 $SOURCE1 .= " 1672 int BecameVirtualBase::method() { return 0; }"; 1673 $HEADER1 .= " 1674 class $DECL_SPEC AddedVirtualBase1:public BecameVirtualBase 1675 { 1676 public: 1677 AddedVirtualBase1(); 1678 int method(); 1679 };"; 1680 $SOURCE1 .= " 1681 AddedVirtualBase1::AddedVirtualBase1() { }"; 1682 $SOURCE1 .= " 1683 int AddedVirtualBase1::method() { return 0; }"; 1684 $HEADER1 .= " 1685 class $DECL_SPEC AddedVirtualBase2: public BecameVirtualBase 1686 { 1687 public: 1688 AddedVirtualBase2(); 1689 int method(); 1690 };"; 1691 $SOURCE1 .= " 1692 AddedVirtualBase2::AddedVirtualBase2() { }"; 1693 $SOURCE1 .= " 1694 int AddedVirtualBase2::method() { return 0; }"; 1695 $HEADER1 .= " 1696 class $DECL_SPEC BaseClassBecameVirtuallyInherited:public AddedVirtualBase1, public AddedVirtualBase2 1697 { 1698 public: 1699 BaseClassBecameVirtuallyInherited(); 1700 };"; 1701 $SOURCE1 .= " 1702 BaseClassBecameVirtuallyInherited::BaseClassBecameVirtuallyInherited() { }"; 1703 1704 $HEADER2 .= " 1705 class $DECL_SPEC BecameVirtualBase 1706 { 1707 public: 1708 BecameVirtualBase(); 1709 int method(); 1710 double p[5]; 1711 };"; 1712 $SOURCE2 .= " 1713 BecameVirtualBase::BecameVirtualBase() { }"; 1714 $SOURCE2 .= " 1715 int BecameVirtualBase::method() { return 0; }"; 1716 $HEADER2 .= " 1717 class $DECL_SPEC AddedVirtualBase1:public virtual BecameVirtualBase 1718 { 1719 public: 1720 AddedVirtualBase1(); 1721 int method(); 1722 };"; 1723 $SOURCE2 .= " 1724 AddedVirtualBase1::AddedVirtualBase1() { }"; 1725 $SOURCE2 .= " 1726 int AddedVirtualBase1::method() { return 0; }"; 1727 $HEADER2 .= " 1728 class $DECL_SPEC AddedVirtualBase2: public virtual BecameVirtualBase 1729 { 1730 public: 1731 AddedVirtualBase2(); 1732 int method(); 1733 };"; 1734 $SOURCE2 .= " 1735 AddedVirtualBase2::AddedVirtualBase2() { }"; 1736 $SOURCE2 .= " 1737 int AddedVirtualBase2::method() { return 0; }"; 1738 $HEADER2 .= " 1739 class $DECL_SPEC BaseClassBecameVirtuallyInherited:public AddedVirtualBase1, public AddedVirtualBase2 1740 { 1741 public: 1742 BaseClassBecameVirtuallyInherited(); 1743 };"; 1744 $SOURCE2 .= " 1745 BaseClassBecameVirtuallyInherited::BaseClassBecameVirtuallyInherited() { }"; 1746 1747 # Added_Base_Class, Removed_Base_Class 1748 $HEADER1 .= " 1749 class $DECL_SPEC BaseClass 1750 { 1751 public: 1752 BaseClass(); 1753 int method(); 1754 double p[5]; 1755 }; 1756 class $DECL_SPEC RemovedBaseClass 1757 { 1758 public: 1759 RemovedBaseClass(); 1760 int method(); 1761 }; 1762 class $DECL_SPEC ChangedBaseClass:public BaseClass, public RemovedBaseClass 1763 { 1764 public: 1765 ChangedBaseClass(); 1766 };"; 1767 $SOURCE1 .= " 1768 BaseClass::BaseClass() { } 1769 int BaseClass::method() { return 0; } 1770 RemovedBaseClass::RemovedBaseClass() { } 1771 int RemovedBaseClass::method() { return 0; } 1772 ChangedBaseClass::ChangedBaseClass() { }"; 1773 1774 $HEADER2 .= " 1775 class $DECL_SPEC BaseClass 1776 { 1777 public: 1778 BaseClass(); 1779 int method(); 1780 double p[5]; 1781 }; 1782 class $DECL_SPEC AddedBaseClass 1783 { 1784 public: 1785 AddedBaseClass(); 1786 int method(); 1787 }; 1788 class $DECL_SPEC ChangedBaseClass:public BaseClass, public AddedBaseClass 1789 { 1790 public: 1791 ChangedBaseClass(); 1792 };"; 1793 $SOURCE2 .= " 1794 BaseClass::BaseClass() { } 1795 int BaseClass::method() { return 0; } 1796 AddedBaseClass::AddedBaseClass() { } 1797 int AddedBaseClass::method() { return 0; } 1798 ChangedBaseClass::ChangedBaseClass() { }"; 1799 1800 # Added_Base_Class_And_Shift, Removed_Base_Class_And_Shift 1801 $HEADER1 .= " 1802 struct $DECL_SPEC BaseClass2 1803 { 1804 BaseClass2(); 1805 int method(); 1806 double p[15]; 1807 }; 1808 class $DECL_SPEC ChangedBaseClassAndSize:public BaseClass 1809 { 1810 public: 1811 ChangedBaseClassAndSize(); 1812 };"; 1813 $SOURCE1 .= " 1814 BaseClass2::BaseClass2() { } 1815 int BaseClass2::method() { return 0; } 1816 ChangedBaseClassAndSize::ChangedBaseClassAndSize() { }"; 1817 1818 $HEADER2 .= " 1819 struct $DECL_SPEC BaseClass2 1820 { 1821 BaseClass2(); 1822 int method(); 1823 double p[15]; 1824 }; 1825 class $DECL_SPEC ChangedBaseClassAndSize:public BaseClass2 1826 { 1827 public: 1828 ChangedBaseClassAndSize(); 1829 };"; 1830 $SOURCE2 .= " 1831 BaseClass2::BaseClass2() { } 1832 int BaseClass2::method() { return 0; } 1833 ChangedBaseClassAndSize::ChangedBaseClassAndSize() { }"; 1834 1835 # Added_Field_And_Size 1836 $HEADER1 .= " 1837 struct $DECL_SPEC AddedFieldAndSize 1838 { 1839 int method(AddedFieldAndSize param); 1840 double i, j, k; 1841 AddedFieldAndSize* p; 1842 };"; 1843 $SOURCE1 .= " 1844 int AddedFieldAndSize::method(AddedFieldAndSize param) { return 0; }"; 1845 1846 $HEADER2 .= " 1847 struct $DECL_SPEC AddedFieldAndSize 1848 { 1849 int method(AddedFieldAndSize param); 1850 double i, j, k; 1851 AddedFieldAndSize* p; 1852 int added_member1; 1853 long long added_member2; 1854 };"; 1855 $SOURCE2 .= " 1856 int AddedFieldAndSize::method(AddedFieldAndSize param) { return 0; }"; 1857 1858 # Added_Field 1859 $HEADER1 .= " 1860 class $DECL_SPEC ObjectAddedMember 1861 { 1862 public: 1863 int method(int param); 1864 double i, j, k; 1865 AddedFieldAndSize* p; 1866 };"; 1867 $SOURCE1 .= " 1868 int ObjectAddedMember::method(int param) { return param; }"; 1869 1870 $HEADER2 .= " 1871 class $DECL_SPEC ObjectAddedMember 1872 { 1873 public: 1874 int method(int param); 1875 double i, j, k; 1876 AddedFieldAndSize* p; 1877 int added_member1; 1878 long long added_member2; 1879 };"; 1880 $SOURCE2 .= " 1881 int ObjectAddedMember::method(int param) { return param; }"; 1882 1883 # Added_Field (safe) 1884 $HEADER1 .= " 1885 struct $DECL_SPEC AddedBitfield 1886 { 1887 int method(AddedBitfield param); 1888 double i, j, k; 1889 int b1 : 32; 1890 int b2 : 31; 1891 AddedBitfield* p; 1892 };"; 1893 $SOURCE1 .= " 1894 int AddedBitfield::method(AddedBitfield param) { return 0; }"; 1895 1896 $HEADER2 .= " 1897 struct $DECL_SPEC AddedBitfield 1898 { 1899 int method(AddedBitfield param); 1900 double i, j, k; 1901 int b1 : 32; 1902 int b2 : 31; 1903 int added_bitfield : 1; 1904 int added_bitfield2 : 1; 1905 AddedBitfield* p; 1906 };"; 1907 $SOURCE2 .= " 1908 int AddedBitfield::method(AddedBitfield param) { return 0; }"; 1909 1910 # Bit_Field_Size 1911 $HEADER1 .= " 1912 struct $DECL_SPEC BitfieldSize 1913 { 1914 int method(BitfieldSize param); 1915 short changed_bitfield : 1; 1916 };"; 1917 $SOURCE1 .= " 1918 int BitfieldSize::method(BitfieldSize param) { return 0; }"; 1919 1920 $HEADER2 .= " 1921 struct $DECL_SPEC BitfieldSize 1922 { 1923 int method(BitfieldSize param); 1924 short changed_bitfield : 7; 1925 };"; 1926 $SOURCE2 .= " 1927 int BitfieldSize::method(BitfieldSize param) { return 0; }"; 1928 1929 # Removed_Field 1930 $HEADER1 .= " 1931 struct $DECL_SPEC RemovedBitfield 1932 { 1933 int method(RemovedBitfield param); 1934 double i, j, k; 1935 int b1 : 32; 1936 int b2 : 31; 1937 int removed_bitfield : 1; 1938 RemovedBitfield* p; 1939 };"; 1940 $SOURCE1 .= " 1941 int RemovedBitfield::method(RemovedBitfield param) { return 0; }"; 1942 1943 $HEADER2 .= " 1944 struct $DECL_SPEC RemovedBitfield 1945 { 1946 int method(RemovedBitfield param); 1947 double i, j, k; 1948 int b1 : 32; 1949 int b2 : 31; 1950 RemovedBitfield* p; 1951 };"; 1952 $SOURCE2 .= " 1953 int RemovedBitfield::method(RemovedBitfield param) { return 0; }"; 1954 1955 # Removed_Middle_Field 1956 $HEADER1 .= " 1957 struct $DECL_SPEC RemovedMiddleBitfield 1958 { 1959 int method(RemovedMiddleBitfield param); 1960 double i, j, k; 1961 int b1 : 32; 1962 int removed_middle_bitfield : 1; 1963 int b2 : 31; 1964 RemovedMiddleBitfield* p; 1965 };"; 1966 $SOURCE1 .= " 1967 int RemovedMiddleBitfield::method(RemovedMiddleBitfield param) { return 0; }"; 1968 1969 $HEADER2 .= " 1970 struct $DECL_SPEC RemovedMiddleBitfield 1971 { 1972 int method(RemovedMiddleBitfield param); 1973 double i, j, k; 1974 int b1 : 32; 1975 int b2 : 31; 1976 RemovedMiddleBitfield* p; 1977 };"; 1978 $SOURCE2 .= " 1979 int RemovedMiddleBitfield::method(RemovedMiddleBitfield param) { return 0; }"; 1980 1981 # Added_Middle_Field_And_Size 1982 $HEADER1 .= " 1983 struct $DECL_SPEC AddedMiddleFieldAndSize 1984 { 1985 int method(AddedMiddleFieldAndSize param); 1986 int i; 1987 long j; 1988 double k; 1989 AddedMiddleFieldAndSize* p; 1990 };"; 1991 $SOURCE1 .= " 1992 int AddedMiddleFieldAndSize::method(AddedMiddleFieldAndSize param) { return 0; }"; 1993 1994 $HEADER2 .= " 1995 struct $DECL_SPEC AddedMiddleFieldAndSize 1996 { 1997 int method(AddedMiddleFieldAndSize param); 1998 int i; 1999 int added_middle_member; 2000 long j; 2001 double k; 2002 AddedMiddleFieldAndSize* p; 2003 };"; 2004 $SOURCE2 .= " 2005 int AddedMiddleFieldAndSize::method(AddedMiddleFieldAndSize param) { return 0; }"; 2006 2007 # Added_Field (padding) 2008 $HEADER1 .= " 2009 struct $DECL_SPEC AddedMiddlePaddedField 2010 { 2011 int method(int param); 2012 short i; 2013 long j; 2014 double k; 2015 };"; 2016 $SOURCE1 .= " 2017 int AddedMiddlePaddedField::method(int param) { return 0; }"; 2018 2019 $HEADER2 .= " 2020 struct $DECL_SPEC AddedMiddlePaddedField 2021 { 2022 int method(int param); 2023 short i; 2024 short added_padded_field; 2025 long j; 2026 double k; 2027 };"; 2028 $SOURCE2 .= " 2029 int AddedMiddlePaddedField::method(int param) { return 0; }"; 2030 2031 # Added_Field (tail padding) 2032 $HEADER1 .= " 2033 struct $DECL_SPEC AddedTailField 2034 { 2035 int method(int param); 2036 int i1, i2, i3, i4, i5, i6, i7; 2037 short s; 2038 };"; 2039 $SOURCE1 .= " 2040 int AddedTailField::method(int param) { return 0; }"; 2041 2042 $HEADER2 .= " 2043 struct $DECL_SPEC AddedTailField 2044 { 2045 int method(int param); 2046 int i1, i2, i3, i4, i5, i6, i7; 2047 short s; 2048 short added_tail_field; 2049 };"; 2050 $SOURCE2 .= " 2051 int AddedTailField::method(int param) { return 0; }"; 2052 2053 # Test Alignment 2054 $HEADER1 .= " 2055 struct $DECL_SPEC TestAlignment 2056 { 2057 int method(int param); 2058 short s:9; 2059 short j:9; 2060 char c; 2061 short t:9; 2062 short u:9; 2063 char d; 2064 };"; 2065 $SOURCE1 .= " 2066 int TestAlignment::method(int param) { return 0; }"; 2067 2068 $HEADER2 .= " 2069 struct $DECL_SPEC TestAlignment 2070 { 2071 int method(int param); 2072 short s:9; 2073 short j:9; 2074 char c; 2075 short t:9; 2076 short u:9; 2077 char d; 2078 };"; 2079 $SOURCE2 .= " 2080 int TestAlignment::method(int param) { return 0; }"; 2081 2082 # Renamed_Field 2083 $HEADER1 .= " 2084 struct $DECL_SPEC RenamedField 2085 { 2086 int method(RenamedField param); 2087 long i; 2088 long j; 2089 double k; 2090 RenamedField* p; 2091 };"; 2092 $SOURCE1 .= " 2093 int RenamedField::method(RenamedField param) { return 0; }"; 2094 2095 $HEADER2 .= " 2096 struct $DECL_SPEC RenamedField 2097 { 2098 int method(RenamedField param); 2099 long renamed_member; 2100 long j; 2101 double k; 2102 RenamedField* p; 2103 };"; 2104 $SOURCE2 .= " 2105 int RenamedField::method(RenamedField param) { return 0; }"; 2106 2107 # Removed_Field_And_Size 2108 $HEADER1 .= " 2109 struct $DECL_SPEC RemovedFieldAndSize 2110 { 2111 int method(RemovedFieldAndSize param); 2112 double i, j, k; 2113 RemovedFieldAndSize* p; 2114 int removed_member1; 2115 long removed_member2; 2116 };"; 2117 $SOURCE1 .= " 2118 int RemovedFieldAndSize::method(RemovedFieldAndSize param) { return 0; }"; 2119 2120 $HEADER2 .= " 2121 struct $DECL_SPEC RemovedFieldAndSize 2122 { 2123 int method(RemovedFieldAndSize param); 2124 double i, j, k; 2125 RemovedFieldAndSize* p; 2126 };"; 2127 $SOURCE2 .= " 2128 int RemovedFieldAndSize::method(RemovedFieldAndSize param) { return 0; }"; 2129 2130 # Field Position 2131 $HEADER1 .= " 2132 struct $DECL_SPEC MovedField 2133 { 2134 int method(int param); 2135 double i; 2136 int j; 2137 };"; 2138 $SOURCE1 .= " 2139 int MovedField::method(int param) { return 0; }"; 2140 2141 $HEADER2 .= " 2142 struct $DECL_SPEC MovedField 2143 { 2144 int method(int param); 2145 int j; 2146 double i; 2147 };"; 2148 $SOURCE2 .= " 2149 int MovedField::method(int param) { return 0; }"; 2150 2151 # Removed_Middle_Field_And_Size 2152 $HEADER1 .= " 2153 struct $DECL_SPEC RemovedMiddleFieldAndSize 2154 { 2155 int method(RemovedMiddleFieldAndSize param); 2156 int i; 2157 int removed_middle_member; 2158 long j; 2159 double k; 2160 RemovedMiddleFieldAndSize* p; 2161 };"; 2162 $SOURCE1 .= " 2163 int RemovedMiddleFieldAndSize::method(RemovedMiddleFieldAndSize param) { return 0; }"; 2164 2165 $HEADER2 .= " 2166 struct $DECL_SPEC RemovedMiddleFieldAndSize 2167 { 2168 int method(RemovedMiddleFieldAndSize param); 2169 int i; 2170 long j; 2171 double k; 2172 RemovedMiddleFieldAndSize* p; 2173 };"; 2174 $SOURCE2 .= " 2175 int RemovedMiddleFieldAndSize::method(RemovedMiddleFieldAndSize param) { return 0; }"; 2176 2177 # Enum_Member_Value 2178 $HEADER1 .= " 2179 enum EnumMemberValue 2180 { 2181 MEMBER_1=1, 2182 MEMBER_2=2 2183 };"; 2184 $HEADER1 .= " 2185 $DECL_SPEC int enumMemberValueChange(enum EnumMemberValue param);"; 2186 $SOURCE1 .= " 2187 int enumMemberValueChange(enum EnumMemberValue param) { return 0; }"; 2188 2189 $HEADER2 .= " 2190 enum EnumMemberValue 2191 { 2192 MEMBER_1=2, 2193 MEMBER_2=1 2194 };"; 2195 $HEADER2 .= " 2196 $DECL_SPEC int enumMemberValueChange(enum EnumMemberValue param);"; 2197 $SOURCE2 .= " 2198 int enumMemberValueChange(enum EnumMemberValue param) { return 0; }"; 2199 2200 # Enum_Member_Name 2201 $HEADER1 .= " 2202 enum EnumMemberRename 2203 { 2204 BRANCH_1=1, 2205 BRANCH_2=2 2206 };"; 2207 $HEADER1 .= " 2208 $DECL_SPEC int enumMemberRename(enum EnumMemberRename param);"; 2209 $SOURCE1 .= " 2210 int enumMemberRename(enum EnumMemberRename param) { return 0; }"; 2211 2212 $HEADER2 .= " 2213 enum EnumMemberRename 2214 { 2215 BRANCH_FIRST=1, 2216 BRANCH_SECOND=2 2217 };"; 2218 $HEADER2 .= " 2219 $DECL_SPEC int enumMemberRename(enum EnumMemberRename param);"; 2220 $SOURCE2 .= " 2221 int enumMemberRename(enum EnumMemberRename param) { return 0; }"; 2222 2223 # Field_Type_And_Size 2224 $HEADER1 .= " 2225 struct $DECL_SPEC FieldTypeAndSize 2226 { 2227 int method(FieldTypeAndSize param); 2228 int i; 2229 long j; 2230 double k; 2231 FieldTypeAndSize* p; 2232 };"; 2233 $SOURCE1 .= " 2234 int FieldTypeAndSize::method(FieldTypeAndSize param) { return 0; }"; 2235 2236 $HEADER2 .= " 2237 struct $DECL_SPEC FieldTypeAndSize 2238 { 2239 int method(FieldTypeAndSize param); 2240 long long i; 2241 long j; 2242 double k; 2243 FieldTypeAndSize* p; 2244 };"; 2245 $SOURCE2 .= " 2246 int FieldTypeAndSize::method(FieldTypeAndSize param) { return 0; }"; 2247 2248 # Member_Type 2249 $HEADER1 .= " 2250 struct $DECL_SPEC MemberType 2251 { 2252 int method(MemberType param); 2253 int i; 2254 long j; 2255 double k; 2256 MemberType* p; 2257 };"; 2258 $SOURCE1 .= " 2259 int MemberType::method(MemberType param) { return 0; }"; 2260 2261 $HEADER2 .= " 2262 struct $DECL_SPEC MemberType 2263 { 2264 int method(MemberType param); 2265 float i; 2266 long j; 2267 double k; 2268 MemberType* p; 2269 };"; 2270 $SOURCE2 .= " 2271 int MemberType::method(MemberType param) { return 0; }"; 2272 2273 # Field_BaseType 2274 $HEADER1 .= " 2275 struct $DECL_SPEC FieldBaseType 2276 { 2277 int method(FieldBaseType param); 2278 int *i; 2279 long j; 2280 double k; 2281 FieldBaseType* p; 2282 };"; 2283 $SOURCE1 .= " 2284 int FieldBaseType::method(FieldBaseType param) { return 0; }"; 2285 2286 $HEADER2 .= " 2287 struct $DECL_SPEC FieldBaseType 2288 { 2289 int method(FieldBaseType param); 2290 long long *i; 2291 long j; 2292 double k; 2293 FieldBaseType* p; 2294 };"; 2295 $SOURCE2 .= " 2296 int FieldBaseType::method(FieldBaseType param) { return 0; }"; 2297 2298 # Field_PointerLevel_Increased (and size) 2299 $HEADER1 .= " 2300 struct $DECL_SPEC FieldPointerLevelAndSize 2301 { 2302 int method(FieldPointerLevelAndSize param); 2303 long long i; 2304 long j; 2305 double k; 2306 FieldPointerLevelAndSize* p; 2307 };"; 2308 $SOURCE1 .= " 2309 int FieldPointerLevelAndSize::method(FieldPointerLevelAndSize param) { return 0; }"; 2310 2311 $HEADER2 .= " 2312 struct $DECL_SPEC FieldPointerLevelAndSize 2313 { 2314 int method(FieldPointerLevelAndSize param); 2315 long long *i; 2316 long j; 2317 double k; 2318 FieldPointerLevelAndSize* p; 2319 };"; 2320 $SOURCE2 .= " 2321 int FieldPointerLevelAndSize::method(FieldPointerLevelAndSize param) { return 0; }"; 2322 2323 # Field_PointerLevel 2324 $HEADER1 .= " 2325 struct $DECL_SPEC FieldPointerLevel 2326 { 2327 int method(FieldPointerLevel param); 2328 int **i; 2329 long j; 2330 double k; 2331 FieldPointerLevel* p; 2332 };"; 2333 $SOURCE1 .= " 2334 int FieldPointerLevel::method(FieldPointerLevel param) { return 0; }"; 2335 2336 $HEADER2 .= " 2337 struct $DECL_SPEC FieldPointerLevel 2338 { 2339 int method(FieldPointerLevel param); 2340 int *i; 2341 long j; 2342 double k; 2343 FieldPointerLevel* p; 2344 };"; 2345 $SOURCE2 .= " 2346 int FieldPointerLevel::method(FieldPointerLevel param) { return 0; }"; 2347 2348 # Added_Interface (method) 2349 $HEADER1 .= " 2350 struct $DECL_SPEC AddedInterface 2351 { 2352 int method(AddedInterface param); 2353 int i; 2354 long j; 2355 double k; 2356 AddedInterface* p; 2357 };"; 2358 $SOURCE1 .= " 2359 int AddedInterface::method(AddedInterface param) { return 0; }"; 2360 2361 $HEADER2 .= " 2362 struct $DECL_SPEC AddedInterface 2363 { 2364 int method(AddedInterface param); 2365 int added_func(AddedInterface param); 2366 int i; 2367 long j; 2368 double k; 2369 AddedInterface* p; 2370 };"; 2371 $SOURCE2 .= " 2372 int AddedInterface::method(AddedInterface param) { return 0; }"; 2373 $SOURCE2 .= " 2374 int AddedInterface::added_func(AddedInterface param) { return 0; }"; 2375 2376 # Added_Interface (function) 2377 $HEADER2 .= " 2378 $DECL_SPEC int addedFunc2(void *** param);"; 2379 $SOURCE2 .= " 2380 int addedFunc2(void *** param) { return 0; }"; 2381 2382 # Added_Interface (global variable) 2383 $HEADER1 .= " 2384 struct $DECL_SPEC AddedVariable 2385 { 2386 int method(AddedVariable param); 2387 int i1, i2; 2388 long j; 2389 double k; 2390 AddedVariable* p; 2391 };"; 2392 $SOURCE1 .= " 2393 int AddedVariable::method(AddedVariable param) { 2394 return i1; 2395 }"; 2396 2397 $HEADER2 .= " 2398 struct $DECL_SPEC AddedVariable 2399 { 2400 int method(AddedVariable param); 2401 static int i1; 2402 static int i2; 2403 long j; 2404 double k; 2405 AddedVariable* p; 2406 };"; 2407 $SOURCE2 .= " 2408 int AddedVariable::method(AddedVariable param) { return AddedVariable::i1; }"; 2409 $SOURCE2 .= " 2410 int AddedVariable::i1=0;"; 2411 $SOURCE2 .= " 2412 int AddedVariable::i2=0;"; 2413 2414 # Removed_Interface (method) 2415 $HEADER1 .= " 2416 struct $DECL_SPEC RemovedInterface 2417 { 2418 int method(RemovedInterface param); 2419 int removed_func(RemovedInterface param); 2420 int i; 2421 long j; 2422 double k; 2423 RemovedInterface* p; 2424 };"; 2425 $SOURCE1 .= " 2426 int RemovedInterface::method(RemovedInterface param) { return 0; }"; 2427 $SOURCE1 .= " 2428 int RemovedInterface::removed_func(RemovedInterface param) { return 0; }"; 2429 2430 $HEADER2 .= " 2431 struct $DECL_SPEC RemovedInterface 2432 { 2433 int method(RemovedInterface param); 2434 int i; 2435 long j; 2436 double k; 2437 RemovedInterface* p; 2438 };"; 2439 $SOURCE2 .= " 2440 int RemovedInterface::method(RemovedInterface param) { return 0; }"; 2441 2442 # Removed_Interface (function) 2443 $HEADER1 .= " 2444 $DECL_SPEC int removedFunc2(void *** param);"; 2445 $SOURCE1 .= " 2446 int removedFunc2(void *** param) { return 0; }"; 2447 2448 # Method_Became_Static 2449 $HEADER1 .= " 2450 struct $DECL_SPEC MethodBecameStatic 2451 { 2452 MethodBecameStatic becameStatic(MethodBecameStatic param); 2453 int **i; 2454 long j; 2455 double k; 2456 MethodBecameStatic* p; 2457 };"; 2458 $SOURCE1 .= " 2459 MethodBecameStatic MethodBecameStatic::becameStatic(MethodBecameStatic param) { return param; }"; 2460 2461 $HEADER2 .= " 2462 struct $DECL_SPEC MethodBecameStatic 2463 { 2464 static MethodBecameStatic becameStatic(MethodBecameStatic param); 2465 int **i; 2466 long j; 2467 double k; 2468 MethodBecameStatic* p; 2469 };"; 2470 $SOURCE2 .= " 2471 MethodBecameStatic MethodBecameStatic::becameStatic(MethodBecameStatic param) { return param; }"; 2472 2473 # Method_Became_Non_Static 2474 $HEADER1 .= " 2475 struct $DECL_SPEC MethodBecameNonStatic 2476 { 2477 static MethodBecameNonStatic becameNonStatic(MethodBecameNonStatic param); 2478 int **i; 2479 long j; 2480 double k; 2481 MethodBecameNonStatic* p; 2482 };"; 2483 $SOURCE1 .= " 2484 MethodBecameNonStatic MethodBecameNonStatic::becameNonStatic(MethodBecameNonStatic param) { return param; }"; 2485 2486 $HEADER2 .= " 2487 struct $DECL_SPEC MethodBecameNonStatic 2488 { 2489 MethodBecameNonStatic becameNonStatic(MethodBecameNonStatic param); 2490 int **i; 2491 long j; 2492 double k; 2493 MethodBecameNonStatic* p; 2494 };"; 2495 $SOURCE2 .= " 2496 MethodBecameNonStatic MethodBecameNonStatic::becameNonStatic(MethodBecameNonStatic param) { return param; }"; 2497 2498 # Parameter_Type_And_Size 2499 $HEADER1 .= " 2500 $DECL_SPEC int funcParameterTypeAndSize(int param, int other_param);"; 2501 $SOURCE1 .= " 2502 int funcParameterTypeAndSize(int param, int other_param) { return other_param; }"; 2503 2504 $HEADER2 .= " 2505 $DECL_SPEC int funcParameterTypeAndSize(long long param, int other_param);"; 2506 $SOURCE2 .= " 2507 int funcParameterTypeAndSize(long long param, int other_param) { return other_param; }"; 2508 2509 # Parameter_Type 2510 $HEADER1 .= " 2511 $DECL_SPEC int funcParameterType(int param, int other_param);"; 2512 $SOURCE1 .= " 2513 int funcParameterType(int param, int other_param) { return other_param; }"; 2514 2515 $HEADER2 .= " 2516 $DECL_SPEC int funcParameterType(float param, int other_param);"; 2517 $SOURCE2 .= " 2518 int funcParameterType(float param, int other_param) { return other_param; }"; 2519 2520 # Parameter_BaseType 2521 $HEADER1 .= " 2522 $DECL_SPEC int funcParameterBaseType(int *param);"; 2523 $SOURCE1 .= " 2524 int funcParameterBaseType(int *param) { return sizeof(*param); }"; 2525 2526 $HEADER2 .= " 2527 $DECL_SPEC int funcParameterBaseType(long long *param);"; 2528 $SOURCE2 .= " 2529 int funcParameterBaseType(long long *param) { return sizeof(*param); }"; 2530 2531 # Parameter_PointerLevel 2532 $HEADER1 .= " 2533 $DECL_SPEC long long funcParameterPointerLevelAndSize(long long param);"; 2534 $SOURCE1 .= " 2535 long long funcParameterPointerLevelAndSize(long long param) { return param; }"; 2536 2537 $HEADER2 .= " 2538 $DECL_SPEC long long funcParameterPointerLevelAndSize(long long *param);"; 2539 $SOURCE2 .= " 2540 long long funcParameterPointerLevelAndSize(long long *param) { return param[5]; }"; 2541 2542 # Parameter_PointerLevel 2543 $HEADER1 .= " 2544 $DECL_SPEC int funcParameterPointerLevel(int *param);"; 2545 $SOURCE1 .= " 2546 int funcParameterPointerLevel(int *param) { return param[5]; }"; 2547 2548 $HEADER2 .= " 2549 $DECL_SPEC int funcParameterPointerLevel(int **param);"; 2550 $SOURCE2 .= " 2551 int funcParameterPointerLevel(int **param) { return param[5][5]; }"; 2552 2553 # Return_Type_And_Size 2554 $HEADER1 .= " 2555 $DECL_SPEC int funcReturnTypeAndSize(int param);"; 2556 $SOURCE1 .= " 2557 int funcReturnTypeAndSize(int param) { return 0; }"; 2558 2559 $HEADER2 .= " 2560 $DECL_SPEC long long funcReturnTypeAndSize(int param);"; 2561 $SOURCE2 .= " 2562 long long funcReturnTypeAndSize(int param) { return 0; }"; 2563 2564 # Return_Type 2565 $HEADER1 .= " 2566 $DECL_SPEC int funcReturnType(int param);"; 2567 $SOURCE1 .= " 2568 int funcReturnType(int param) { return 0; }"; 2569 2570 $HEADER2 .= " 2571 $DECL_SPEC float funcReturnType(int param);"; 2572 $SOURCE2 .= " 2573 float funcReturnType(int param) { return 0.7; }"; 2574 2575 # Return_Type_Became_Void ("int" to "void") 2576 $HEADER1 .= " 2577 $DECL_SPEC int funcReturnTypeBecameVoid(int param);"; 2578 $SOURCE1 .= " 2579 int funcReturnTypeBecameVoid(int param) { return 0; }"; 2580 2581 $HEADER2 .= " 2582 $DECL_SPEC void funcReturnTypeBecameVoid(int param);"; 2583 $SOURCE2 .= " 2584 void funcReturnTypeBecameVoid(int param) { return; }"; 2585 2586 # Return_BaseType 2587 $HEADER1 .= " 2588 $DECL_SPEC int* funcReturnBaseType(int param);"; 2589 $SOURCE1 .= " 2590 int* funcReturnBaseType(int param) { 2591 int *x = new int[10]; 2592 return x; 2593 }"; 2594 2595 $HEADER2 .= " 2596 $DECL_SPEC long long* funcReturnBaseType(int param);"; 2597 $SOURCE2 .= " 2598 long long* funcReturnBaseType(int param) { 2599 long long *x = new long long[10]; 2600 return x; 2601 }"; 2602 2603 # Return_PointerLevel 2604 $HEADER1 .= " 2605 $DECL_SPEC long long funcReturnPointerLevelAndSize(int param);"; 2606 $SOURCE1 .= " 2607 long long funcReturnPointerLevelAndSize(int param) { return 0; }"; 2608 2609 $HEADER2 .= " 2610 $DECL_SPEC long long* funcReturnPointerLevelAndSize(int param);"; 2611 $SOURCE2 .= " 2612 long long* funcReturnPointerLevelAndSize(int param) { return new long long[10]; }"; 2613 2614 # Return_PointerLevel 2615 $HEADER1 .= " 2616 $DECL_SPEC int* funcReturnPointerLevel(int param);"; 2617 $SOURCE1 .= " 2618 int* funcReturnPointerLevel(int param) { return new int[10]; }"; 2619 2620 $HEADER2 .= " 2621 $DECL_SPEC int** funcReturnPointerLevel(int param);"; 2622 $SOURCE2 .= " 2623 int** funcReturnPointerLevel(int param) { return new int*[10]; }"; 2624 2625 # Size (anon type) 2626 $HEADER1 .= " 2627 typedef struct { 2628 int i; 2629 long j; 2630 double k; 2631 } AnonTypedef; 2632 $DECL_SPEC int funcAnonTypedef(AnonTypedef param);"; 2633 $SOURCE1 .= " 2634 int funcAnonTypedef(AnonTypedef param) { return 0; }"; 2635 2636 $HEADER2 .= " 2637 typedef struct { 2638 int i; 2639 long j; 2640 double k; 2641 union { 2642 int dummy[256]; 2643 struct { 2644 char q_skiptable[256]; 2645 const char *p; 2646 int l; 2647 } p; 2648 }; 2649 } AnonTypedef; 2650 $DECL_SPEC int funcAnonTypedef(AnonTypedef param);"; 2651 $SOURCE2 .= " 2652 int funcAnonTypedef(AnonTypedef param) { return 0; }"; 2653 2654 # Added_Field (safe: opaque) 2655 $HEADER1 .= " 2656 struct $DECL_SPEC OpaqueType 2657 { 2658 public: 2659 OpaqueType method(OpaqueType param); 2660 int i; 2661 long j; 2662 double k; 2663 OpaqueType* p; 2664 };"; 2665 $SOURCE1 .= " 2666 OpaqueType OpaqueType::method(OpaqueType param) { return param; }"; 2667 2668 $HEADER2 .= " 2669 struct $DECL_SPEC OpaqueType 2670 { 2671 public: 2672 OpaqueType method(OpaqueType param); 2673 int i; 2674 long j; 2675 double k; 2676 OpaqueType* p; 2677 int added_member; 2678 };"; 2679 $SOURCE2 .= " 2680 OpaqueType OpaqueType::method(OpaqueType param) { return param; }"; 2681 2682 # Added_Field (safe: internal) 2683 $HEADER1 .= " 2684 struct $DECL_SPEC InternalType { 2685 InternalType method(InternalType param); 2686 int i; 2687 long j; 2688 double k; 2689 InternalType* p; 2690 };"; 2691 $SOURCE1 .= " 2692 InternalType InternalType::method(InternalType param) { return param; }"; 2693 2694 $HEADER2 .= " 2695 struct $DECL_SPEC InternalType { 2696 InternalType method(InternalType param); 2697 int i; 2698 long j; 2699 double k; 2700 InternalType* p; 2701 int added_member; 2702 };"; 2703 $SOURCE2 .= " 2704 InternalType InternalType::method(InternalType param) { return param; }"; 2705 2706 # Size (unnamed struct/union fields within structs/unions) 2707 $HEADER1 .= " 2708 typedef struct { 2709 int a; 2710 struct { 2711 int u1; 2712 float u2; 2713 }; 2714 int d; 2715 } UnnamedTypeSize; 2716 $DECL_SPEC int unnamedTypeSize(UnnamedTypeSize param);"; 2717 $SOURCE1 .= " 2718 int unnamedTypeSize(UnnamedTypeSize param) { return 0; }"; 2719 2720 $HEADER2 .= " 2721 typedef struct { 2722 int a; 2723 struct { 2724 long double u1; 2725 float u2; 2726 }; 2727 int d; 2728 } UnnamedTypeSize; 2729 $DECL_SPEC int unnamedTypeSize(UnnamedTypeSize param);"; 2730 $SOURCE2 .= " 2731 int unnamedTypeSize(UnnamedTypeSize param) { return 0; }"; 2732 2733 # Changed_Constant 2734 $HEADER1 .= " 2735 #define PUBLIC_CONSTANT \"old_value\""; 2736 $HEADER2 .= " 2737 #define PUBLIC_CONSTANT \"new_value\""; 2738 2739 $HEADER1 .= " 2740 #define PUBLIC_VERSION \"1.2 (3.4)\""; 2741 $HEADER2 .= " 2742 #define PUBLIC_VERSION \"1.2 (3.5)\""; 2743 2744 $HEADER1 .= " 2745 #define PRIVATE_CONSTANT \"old_value\" 2746 #undef PRIVATE_CONSTANT"; 2747 $HEADER2 .= " 2748 #define PRIVATE_CONSTANT \"new_value\" 2749 #undef PRIVATE_CONSTANT"; 2750 2751 # Added_Field (union) 2752 $HEADER1 .= " 2753 union UnionAddedField { 2754 int a; 2755 struct { 2756 int b; 2757 float c; 2758 }; 2759 int d; 2760 }; 2761 $DECL_SPEC int unionAddedField(UnionAddedField param);"; 2762 $SOURCE1 .= " 2763 int unionAddedField(UnionAddedField param) { return 0; }"; 2764 2765 $HEADER2 .= " 2766 union UnionAddedField { 2767 int a; 2768 struct { 2769 long double x, y; 2770 } new_field; 2771 struct { 2772 int b; 2773 float c; 2774 }; 2775 int d; 2776 }; 2777 $DECL_SPEC int unionAddedField(UnionAddedField param);"; 2778 $SOURCE2 .= " 2779 int unionAddedField(UnionAddedField param) { return 0; }"; 2780 2781 # Removed_Field (union) 2782 $HEADER1 .= " 2783 union UnionRemovedField { 2784 int a; 2785 struct { 2786 long double x, y; 2787 } removed_field; 2788 struct { 2789 int b; 2790 float c; 2791 }; 2792 int d; 2793 }; 2794 $DECL_SPEC int unionRemovedField(UnionRemovedField param);"; 2795 $SOURCE1 .= " 2796 int unionRemovedField(UnionRemovedField param) { return 0; }"; 2797 2798 $HEADER2 .= " 2799 union UnionRemovedField { 2800 int a; 2801 struct { 2802 int b; 2803 float c; 2804 }; 2805 int d; 2806 }; 2807 $DECL_SPEC int unionRemovedField(UnionRemovedField param);"; 2808 $SOURCE2 .= " 2809 int unionRemovedField(UnionRemovedField param) { return 0; }"; 2810 2811 # Added (typedef change) 2812 $HEADER1 .= " 2813 typedef float TYPEDEF_TYPE; 2814 $DECL_SPEC int parameterTypedefChange(TYPEDEF_TYPE param);"; 2815 $SOURCE1 .= " 2816 int parameterTypedefChange(TYPEDEF_TYPE param) { return 1; }"; 2817 2818 $HEADER2 .= " 2819 typedef int TYPEDEF_TYPE; 2820 $DECL_SPEC int parameterTypedefChange(TYPEDEF_TYPE param);"; 2821 $SOURCE2 .= " 2822 int parameterTypedefChange(TYPEDEF_TYPE param) { return 1; }"; 2823 2824 # Parameter_Default_Value_Changed (safe) 2825 # Converted from void* to const char* 2826 $HEADER1 .= " 2827 $DECL_SPEC int paramDefaultValue_Converted(const char* arg = 0); "; 2828 $SOURCE1 .= " 2829 int paramDefaultValue_Converted(const char* arg) { return 0; }"; 2830 2831 $HEADER2 .= " 2832 $DECL_SPEC int paramDefaultValue_Converted(const char* arg = (const char*)((void*) 0)); "; 2833 $SOURCE2 .= " 2834 int paramDefaultValue_Converted(const char* arg) { return 0; }"; 2835 2836 # Parameter_Default_Value_Changed 2837 # Integer 2838 $HEADER1 .= " 2839 $DECL_SPEC int paramDefaultValueChanged_Integer(int param = 0xf00f); "; 2840 $SOURCE1 .= " 2841 int paramDefaultValueChanged_Integer(int param) { return param; }"; 2842 2843 $HEADER2 .= " 2844 $DECL_SPEC int paramDefaultValueChanged_Integer(int param = 0xf00b); "; 2845 $SOURCE2 .= " 2846 int paramDefaultValueChanged_Integer(int param) { return param; }"; 2847 2848 # Parameter_Default_Value_Changed 2849 # String 2850 $HEADER1 .= " 2851 $DECL_SPEC int paramDefaultValueChanged_String(char const* param = \" str 1 \"); "; 2852 $SOURCE1 .= " 2853 int paramDefaultValueChanged_String(char const* param) { return 0; }"; 2854 2855 $HEADER2 .= " 2856 $DECL_SPEC int paramDefaultValueChanged_String(char const* param = \" str 2 \"); "; 2857 $SOURCE2 .= " 2858 int paramDefaultValueChanged_String(char const* param) { return 0; }"; 2859 2860 # Parameter_Default_Value_Changed 2861 # Character 2862 $HEADER1 .= " 2863 $DECL_SPEC int paramDefaultValueChanged_Char(char param = \'A\'); "; 2864 $SOURCE1 .= " 2865 int paramDefaultValueChanged_Char(char param) { return 0; }"; 2866 2867 $HEADER2 .= " 2868 $DECL_SPEC int paramDefaultValueChanged_Char(char param = \'B\'); "; 2869 $SOURCE2 .= " 2870 int paramDefaultValueChanged_Char(char param) { return 0; }"; 2871 2872 # Parameter_Default_Value_Changed 2873 # Bool 2874 $HEADER1 .= " 2875 $DECL_SPEC int paramDefaultValueChanged_Bool(bool param = true); "; 2876 $SOURCE1 .= " 2877 int paramDefaultValueChanged_Bool(bool param) { return 0; }"; 2878 2879 $HEADER2 .= " 2880 $DECL_SPEC int paramDefaultValueChanged_Bool(bool param = false); "; 2881 $SOURCE2 .= " 2882 int paramDefaultValueChanged_Bool(bool param) { return 0; }"; 2883 2884 # Parameter_Default_Value_Removed 2885 $HEADER1 .= " 2886 $DECL_SPEC int parameterDefaultValueRemoved(int param = 15); 2887 "; 2888 $SOURCE1 .= " 2889 int parameterDefaultValueRemoved(int param) { return param; }"; 2890 2891 $HEADER2 .= " 2892 $DECL_SPEC int parameterDefaultValueRemoved(int param);"; 2893 $SOURCE2 .= " 2894 int parameterDefaultValueRemoved(int param) { return param; }"; 2895 2896 # Parameter_Default_Value_Added 2897 $HEADER1 .= " 2898 $DECL_SPEC int parameterDefaultValueAdded(int param); 2899 "; 2900 $SOURCE1 .= " 2901 int parameterDefaultValueAdded(int param) { return param; }"; 2902 2903 $HEADER2 .= " 2904 $DECL_SPEC int parameterDefaultValueAdded(int param = 15);"; 2905 $SOURCE2 .= " 2906 int parameterDefaultValueAdded(int param) { return param; }"; 2907 2908 # Field_Type (typedefs in member type) 2909 $HEADER1 .= " 2910 typedef float TYPEDEF_TYPE_2; 2911 struct $DECL_SPEC FieldTypedefChange{ 2912 public: 2913 TYPEDEF_TYPE_2 m; 2914 TYPEDEF_TYPE_2 n; 2915 }; 2916 $DECL_SPEC int fieldTypedefChange(FieldTypedefChange param);"; 2917 $SOURCE1 .= " 2918 int fieldTypedefChange(FieldTypedefChange param) { return 1; }"; 2919 2920 $HEADER2 .= " 2921 typedef int TYPEDEF_TYPE_2; 2922 struct $DECL_SPEC FieldTypedefChange{ 2923 public: 2924 TYPEDEF_TYPE_2 m; 2925 TYPEDEF_TYPE_2 n; 2926 }; 2927 $DECL_SPEC int fieldTypedefChange(FieldTypedefChange param);"; 2928 $SOURCE2 .= " 2929 int fieldTypedefChange(FieldTypedefChange param) { return 1; }"; 2930 2931 # Callback (testCallback symbol should be affected 2932 # instead of callback1 and callback2) 2933 $HEADER1 .= " 2934 class $DECL_SPEC Callback { 2935 public: 2936 virtual int callback1(int x, int y)=0; 2937 virtual int callback2(int x, int y)=0; 2938 }; 2939 $DECL_SPEC int testCallback(Callback* p);"; 2940 $SOURCE1 .= " 2941 int testCallback(Callback* p) { 2942 p->callback2(1, 2); 2943 return 0; 2944 }"; 2945 2946 $HEADER2 .= " 2947 class $DECL_SPEC Callback { 2948 public: 2949 virtual int callback1(int x, int y)=0; 2950 virtual int added_callback(int x, int y)=0; 2951 virtual int callback2(int x, int y)=0; 2952 }; 2953 $DECL_SPEC int testCallback(Callback* p);"; 2954 $SOURCE2 .= " 2955 int testCallback(Callback* p) { 2956 p->callback2(1, 2); 2957 return 0; 2958 }"; 2959 2960 # End namespace 2961 $HEADER1 .= "\n}\n"; 2962 $HEADER2 .= "\n}\n"; 2963 $SOURCE1 .= "\n}\n"; 2964 $SOURCE2 .= "\n}\n"; 2965 2966 runTests("libsample_cpp", "C++", $HEADER1, $SOURCE1, $HEADER2, $SOURCE2, "TestNS::OpaqueType", "_ZN6TestNS12InternalType6methodES0_"); 2967 } 2968 2969 sub testC() 2970 { 2971 printMsg("INFO", "\nverifying detectable C library changes"); 2972 my ($HEADER1, $SOURCE1, $HEADER2, $SOURCE2) = (); 2973 my $DECL_SPEC = ($OSgroup eq "windows")?"__declspec( dllexport )":""; 2974 my $EXTERN = ($OSgroup eq "windows")?"extern ":""; # add "extern" for CL compiler 2975 2976 # Struct to union 2977 $HEADER1 .= " 2978 typedef struct StructToUnion { 2979 unsigned char A[64]; 2980 } StructToUnion; 2981 2982 $DECL_SPEC int structToUnion(StructToUnion *p);"; 2983 $SOURCE1 .= " 2984 int structToUnion(StructToUnion *p) { return 0; }"; 2985 2986 $HEADER2 .= " 2987 typedef union StructToUnion { 2988 unsigned char A[64]; 2989 void *p; 2990 } StructToUnion; 2991 2992 $DECL_SPEC int structToUnion(StructToUnion *p);"; 2993 $SOURCE2 .= " 2994 int structToUnion(StructToUnion *p) { return 0; }"; 2995 2996 # Typedef to function 2997 $HEADER1 .= " 2998 typedef int(TypedefToFunction)(int pX); 2999 3000 $DECL_SPEC int typedefToFunction(TypedefToFunction* p);"; 3001 $SOURCE1 .= " 3002 int typedefToFunction(TypedefToFunction* p) { return 0; }"; 3003 3004 $HEADER2 .= " 3005 typedef int(TypedefToFunction)(int pX, int pY); 3006 3007 $DECL_SPEC int typedefToFunction(TypedefToFunction* p);"; 3008 $SOURCE2 .= " 3009 int typedefToFunction(TypedefToFunction* p) { return 0; }"; 3010 3011 # Used_Reserved 3012 $HEADER1 .= " 3013 typedef struct { 3014 int f; 3015 void* reserved0; 3016 void* reserved1; 3017 } UsedReserved; 3018 3019 $DECL_SPEC int usedReserved(UsedReserved p);"; 3020 $SOURCE1 .= " 3021 int usedReserved(UsedReserved p) { return 0; }"; 3022 3023 $HEADER2 .= " 3024 typedef struct { 3025 int f; 3026 void* f0; 3027 void* f1; 3028 } UsedReserved; 3029 3030 $DECL_SPEC int usedReserved(UsedReserved p);"; 3031 $SOURCE2 .= " 3032 int usedReserved(UsedReserved p) { return 0; }"; 3033 3034 # Parameter_Type_And_Register 3035 $HEADER1 .= " 3036 typedef struct { 3037 int a[4]; 3038 } ARRAY; 3039 $DECL_SPEC void callConv5 (ARRAY i, int j);"; 3040 $SOURCE1 .= " 3041 void callConv5 (ARRAY i, int j) { }"; 3042 3043 $HEADER2 .= " 3044 typedef struct { 3045 int a[4]; 3046 } ARRAY; 3047 $DECL_SPEC void callConv5 (ARRAY i, double j);"; 3048 $SOURCE2 .= " 3049 void callConv5 (ARRAY i, double j) { }"; 3050 3051 # Parameter_Type_And_Register 3052 $HEADER1 .= " 3053 typedef union { 3054 int a; 3055 double b; 3056 } UNION; 3057 $DECL_SPEC void callConv4 (UNION i, int j);"; 3058 $SOURCE1 .= " 3059 void callConv4 (UNION i, int j) { }"; 3060 3061 $HEADER2 .= " 3062 typedef union { 3063 int a; 3064 double b; 3065 } UNION; 3066 $DECL_SPEC void callConv4 (UNION i, double j);"; 3067 $SOURCE2 .= " 3068 void callConv4 (UNION i, double j) { }"; 3069 3070 # Parameter_Type_And_Register 3071 $HEADER1 .= " 3072 typedef struct { 3073 long a:4; 3074 long b:16; 3075 } POD2; 3076 $DECL_SPEC void callConv3 (POD2 i, int j);"; 3077 $SOURCE1 .= " 3078 void callConv3 (POD2 i, int j) { }"; 3079 3080 $HEADER2 .= " 3081 typedef struct { 3082 long a:4; 3083 long b:16; 3084 } POD2; 3085 $DECL_SPEC void callConv3 (POD2 i, double j);"; 3086 $SOURCE2 .= " 3087 void callConv3 (POD2 i, double j) { }"; 3088 3089 # Parameter_Type_And_Register 3090 $HEADER1 .= " 3091 typedef struct { 3092 short s:9; 3093 int j:9; 3094 char c; 3095 short t:9; 3096 short u:9; 3097 char d; 3098 } POD; 3099 $DECL_SPEC void callConv2 (POD i, int j);"; 3100 $SOURCE1 .= " 3101 void callConv2 (POD i, int j) { }"; 3102 3103 $HEADER2 .= " 3104 typedef struct { 3105 short s:9; 3106 int j:9; 3107 char c; 3108 short t:9; 3109 short u:9; 3110 char d; 3111 } POD; 3112 $DECL_SPEC void callConv2 (POD i, double j);"; 3113 $SOURCE2 .= " 3114 void callConv2 (POD i, double j) { }"; 3115 3116 # Parameter_Type_And_Register 3117 $HEADER1 .= " 3118 typedef struct { 3119 int a, b; 3120 double d; 3121 } POD1; 3122 $DECL_SPEC void callConv (int e, int f, POD1 s, int g, int h, long double ld, double m, double n, int i, int j, int k);"; 3123 $SOURCE1 .= " 3124 void callConv(int e, int f, POD1 s, int g, int h, long double ld, double m, double n, int i, int j, int k) { }"; 3125 3126 $HEADER2 .= " 3127 typedef struct { 3128 int a, b; 3129 double d; 3130 } POD1; 3131 $DECL_SPEC void callConv (int e, int f, POD1 s, int g, int h, long double ld, double m, double n, int i, int j, double k);"; 3132 $SOURCE2 .= " 3133 void callConv(int e, int f, POD1 s, int g, int h, long double ld, double m, double n, int i, int j, double k) { }"; 3134 3135 # Parameter_Type (int to "int const") 3136 $HEADER1 .= " 3137 $DECL_SPEC void parameterBecameConstInt(int arg);"; 3138 $SOURCE1 .= " 3139 void parameterBecameConstInt(int arg) { }"; 3140 3141 $HEADER2 .= " 3142 $DECL_SPEC void parameterBecameConstInt(const int arg);"; 3143 $SOURCE2 .= " 3144 void parameterBecameConstInt(const int arg) { }"; 3145 3146 # Parameter_Type ("int const" to int) 3147 $HEADER1 .= " 3148 $DECL_SPEC void parameterBecameNonConstInt(const int arg);"; 3149 $SOURCE1 .= " 3150 void parameterBecameNonConstInt(const int arg) { }"; 3151 3152 $HEADER2 .= " 3153 $DECL_SPEC void parameterBecameNonConstInt(int arg);"; 3154 $SOURCE2 .= " 3155 void parameterBecameNonConstInt(int arg) { }"; 3156 3157 # Parameter_Became_Register 3158 $HEADER1 .= " 3159 $DECL_SPEC void parameterBecameRegister(int arg);"; 3160 $SOURCE1 .= " 3161 void parameterBecameRegister(int arg) { }"; 3162 3163 $HEADER2 .= " 3164 $DECL_SPEC void parameterBecameRegister(register int arg);"; 3165 $SOURCE2 .= " 3166 void parameterBecameRegister(register int arg) { }"; 3167 3168 # Return_Type_Became_Const 3169 $HEADER1 .= " 3170 $DECL_SPEC char* returnTypeBecameConst(int param);"; 3171 $SOURCE1 .= " 3172 char* returnTypeBecameConst(int param) { return (char*)malloc(256); }"; 3173 3174 $HEADER2 .= " 3175 $DECL_SPEC const char* returnTypeBecameConst(int param);"; 3176 $SOURCE2 .= " 3177 const char* returnTypeBecameConst(int param) { return \"abc\"; }"; 3178 3179 # Return_Type_Became_Const (2) 3180 $HEADER1 .= " 3181 $DECL_SPEC char* returnTypeBecameConst2(int param);"; 3182 $SOURCE1 .= " 3183 char* returnTypeBecameConst2(int param) { return (char*)malloc(256); }"; 3184 3185 $HEADER2 .= " 3186 $DECL_SPEC char*const returnTypeBecameConst2(int param);"; 3187 $SOURCE2 .= " 3188 char*const returnTypeBecameConst2(int param) { return (char*const)malloc(256); }"; 3189 3190 # Return_Type_Became_Const (3) 3191 $HEADER1 .= " 3192 $DECL_SPEC char* returnTypeBecameConst3(int param);"; 3193 $SOURCE1 .= " 3194 char* returnTypeBecameConst3(int param) { return (char*)malloc(256); }"; 3195 3196 $HEADER2 .= " 3197 $DECL_SPEC char const*const returnTypeBecameConst3(int param);"; 3198 $SOURCE2 .= " 3199 char const*const returnTypeBecameConst3(int param) { return (char const*const)malloc(256); }"; 3200 3201 # Return_Type_Became_Volatile 3202 $HEADER1 .= " 3203 $DECL_SPEC char* returnTypeBecameVolatile(int param);"; 3204 $SOURCE1 .= " 3205 char* returnTypeBecameVolatile(int param) { return (char*)malloc(256); }"; 3206 3207 $HEADER2 .= " 3208 $DECL_SPEC volatile char* returnTypeBecameVolatile(int param);"; 3209 $SOURCE2 .= " 3210 volatile char* returnTypeBecameVolatile(int param) { return \"abc\"; }"; 3211 3212 # Added_Enum_Member 3213 $HEADER1 .= " 3214 enum AddedEnumMember { 3215 OldMember 3216 }; 3217 $DECL_SPEC int addedEnumMember(enum AddedEnumMember param);"; 3218 $SOURCE1 .= " 3219 int addedEnumMember(enum AddedEnumMember param) { return 0; }"; 3220 3221 $HEADER2 .= " 3222 enum AddedEnumMember { 3223 OldMember, 3224 NewMember 3225 }; 3226 $DECL_SPEC int addedEnumMember(enum AddedEnumMember param);"; 3227 $SOURCE2 .= " 3228 int addedEnumMember(enum AddedEnumMember param) { return 0; }"; 3229 3230 # Parameter_Type (Array) 3231 $HEADER1 .= " 3232 $DECL_SPEC int arrayParameterType(int param[5]);"; 3233 $SOURCE1 .= " 3234 int arrayParameterType(int param[5]) { return 0; }"; 3235 3236 $HEADER2 .= " 3237 $DECL_SPEC int arrayParameterType(int param[7]);"; 3238 $SOURCE2 .= " 3239 int arrayParameterType(int param[7]) { return 0; }"; 3240 3241 # Field_Type 3242 $HEADER1 .= " 3243 struct ArrayFieldType 3244 { 3245 int f; 3246 int i[1]; 3247 }; 3248 $DECL_SPEC int arrayFieldType(struct ArrayFieldType param);"; 3249 $SOURCE1 .= " 3250 int arrayFieldType(struct ArrayFieldType param) { return param.i[0]; }"; 3251 3252 $HEADER2 .= " 3253 struct ArrayFieldType 3254 { 3255 int f; 3256 int i[]; 3257 }; 3258 $DECL_SPEC int arrayFieldType(struct ArrayFieldType param);"; 3259 $SOURCE2 .= " 3260 int arrayFieldType(struct ArrayFieldType param) { return param.i[0]; }"; 3261 3262 # Field_Type_And_Size (Array) 3263 $HEADER1 .= " 3264 struct ArrayFieldSize 3265 { 3266 int i[5]; 3267 }; 3268 $DECL_SPEC int arrayFieldSize(struct ArrayFieldSize param);"; 3269 $SOURCE1 .= " 3270 int arrayFieldSize(struct ArrayFieldSize param) { return 0; }"; 3271 3272 $HEADER2 .= " 3273 struct ArrayFieldSize 3274 { 3275 int i[7]; 3276 }; 3277 $DECL_SPEC int arrayFieldSize(struct ArrayFieldSize param);"; 3278 $SOURCE2 .= " 3279 int arrayFieldSize(struct ArrayFieldSize param) { return 0; }"; 3280 3281 # Parameter_Became_Non_VaList 3282 $HEADER1 .= " 3283 $DECL_SPEC int parameterNonVaList(int param, ...);"; 3284 $SOURCE1 .= " 3285 int parameterNonVaList(int param, ...) { return param; }"; 3286 3287 $HEADER2 .= " 3288 $DECL_SPEC int parameterNonVaList(int param1, int param2);"; 3289 $SOURCE2 .= " 3290 int parameterNonVaList(int param1, int param2) { return param1; }"; 3291 3292 # Parameter_Became_VaList 3293 $HEADER1 .= " 3294 $DECL_SPEC int parameterVaList(int param1, int param2);"; 3295 $SOURCE1 .= " 3296 int parameterVaList(int param1, int param2) { return param1; }"; 3297 3298 $HEADER2 .= " 3299 $DECL_SPEC int parameterVaList(int param, ...);"; 3300 $SOURCE2 .= " 3301 int parameterVaList(int param, ...) { return param; }"; 3302 3303 # Field_Type_And_Size 3304 $HEADER1 .= " 3305 struct FieldSizePadded 3306 { 3307 int i; 3308 char changed_field; 3309 // padding (3 bytes) 3310 int j; 3311 }; 3312 $DECL_SPEC int fieldSizePadded(struct FieldSizePadded param);"; 3313 $SOURCE1 .= " 3314 int fieldSizePadded(struct FieldSizePadded param) { return 0; }"; 3315 3316 $HEADER2 .= " 3317 struct FieldSizePadded 3318 { 3319 int i; 3320 int changed_field; 3321 int j; 3322 }; 3323 $DECL_SPEC int fieldSizePadded(struct FieldSizePadded param);"; 3324 $SOURCE2 .= " 3325 int fieldSizePadded(struct FieldSizePadded param) { return 0; }"; 3326 3327 # Parameter_Type_Format 3328 $HEADER1 .= " 3329 struct DType1 3330 { 3331 int i; 3332 double j[7]; 3333 }; 3334 $DECL_SPEC int parameterTypeFormat(struct DType1 param);"; 3335 $SOURCE1 .= " 3336 int parameterTypeFormat(struct DType1 param) { return 0; }"; 3337 3338 $HEADER2 .= " 3339 struct DType2 3340 { 3341 double i[7]; 3342 int j; 3343 }; 3344 $DECL_SPEC int parameterTypeFormat(struct DType2 param);"; 3345 $SOURCE2 .= " 3346 int parameterTypeFormat(struct DType2 param) { return 0; }"; 3347 3348 # Field_Type_Format 3349 $HEADER1 .= " 3350 struct FieldTypeFormat 3351 { 3352 int i; 3353 struct DType1 j; 3354 }; 3355 $DECL_SPEC int fieldTypeFormat(struct FieldTypeFormat param);"; 3356 $SOURCE1 .= " 3357 int fieldTypeFormat(struct FieldTypeFormat param) { return 0; }"; 3358 3359 $HEADER2 .= " 3360 struct FieldTypeFormat 3361 { 3362 int i; 3363 struct DType2 j; 3364 }; 3365 $DECL_SPEC int fieldTypeFormat(struct FieldTypeFormat param);"; 3366 $SOURCE2 .= " 3367 int fieldTypeFormat(struct FieldTypeFormat param) { return 0; }"; 3368 3369 # Parameter_Type_Format (struct to union) 3370 $HEADER1 .= " 3371 struct DType 3372 { 3373 int i; 3374 double j; 3375 }; 3376 $DECL_SPEC int parameterTypeFormat2(struct DType param);"; 3377 $SOURCE1 .= " 3378 int parameterTypeFormat2(struct DType param) { return 0; }"; 3379 3380 $HEADER2 .= " 3381 union DType 3382 { 3383 int i; 3384 long double j; 3385 }; 3386 $DECL_SPEC int parameterTypeFormat2(union DType param);"; 3387 $SOURCE2 .= " 3388 int parameterTypeFormat2(union DType param) { return 0; }"; 3389 3390 # Global_Data_Size 3391 $HEADER1 .= " 3392 struct GlobalDataSize { 3393 int a; 3394 }; 3395 $EXTERN $DECL_SPEC struct GlobalDataSize globalDataSize;"; 3396 3397 $HEADER2 .= " 3398 struct GlobalDataSize { 3399 int a, b; 3400 }; 3401 $EXTERN $DECL_SPEC struct GlobalDataSize globalDataSize;"; 3402 3403 # Global_Data_Type 3404 $HEADER1 .= " 3405 $EXTERN $DECL_SPEC int globalDataType;"; 3406 3407 $HEADER2 .= " 3408 $EXTERN $DECL_SPEC float globalDataType;"; 3409 3410 # Global_Data_Type_And_Size 3411 $HEADER1 .= " 3412 $EXTERN $DECL_SPEC int globalDataTypeAndSize;"; 3413 3414 $HEADER2 .= " 3415 $EXTERN $DECL_SPEC short globalDataTypeAndSize;"; 3416 3417 # Global_Data_Value_Changed 3418 # Integer 3419 $HEADER1 .= " 3420 $EXTERN $DECL_SPEC const int globalDataValue_Integer = 10;"; 3421 3422 $HEADER2 .= " 3423 $EXTERN $DECL_SPEC const int globalDataValue_Integer = 15;"; 3424 3425 # Global_Data_Value_Changed 3426 # Character 3427 $HEADER1 .= " 3428 $EXTERN $DECL_SPEC const char globalDataValue_Char = \'o\';"; 3429 3430 $HEADER2 .= " 3431 $EXTERN $DECL_SPEC const char globalDataValue_Char = \'N\';"; 3432 3433 # Global_Data_Became_Non_Const 3434 $HEADER1 .= " 3435 $EXTERN $DECL_SPEC const int globalDataBecameNonConst = 10;"; 3436 3437 $HEADER2 .= " 3438 extern $DECL_SPEC int globalDataBecameNonConst;"; 3439 $SOURCE2 .= " 3440 int globalDataBecameNonConst = 15;"; 3441 3442 # Global_Data_Became_Non_Const 3443 # Typedef 3444 $HEADER1 .= " 3445 typedef const int CONST_INT; 3446 $EXTERN $DECL_SPEC CONST_INT globalDataBecameNonConst_Typedef = 10;"; 3447 3448 $HEADER2 .= " 3449 extern $DECL_SPEC int globalDataBecameNonConst_Typedef;"; 3450 $SOURCE2 .= " 3451 int globalDataBecameNonConst_Typedef = 15;"; 3452 3453 # Global_Data_Became_Const 3454 $HEADER1 .= " 3455 extern $DECL_SPEC int globalDataBecameConst;"; 3456 $SOURCE1 .= " 3457 int globalDataBecameConst = 10;"; 3458 3459 $HEADER2 .= " 3460 $EXTERN $DECL_SPEC const int globalDataBecameConst = 15;"; 3461 3462 # Global_Data_Became_Non_Const 3463 $HEADER1 .= " 3464 struct GlobalDataType{int a;int b;struct GlobalDataType* p;}; 3465 $EXTERN $DECL_SPEC const struct GlobalDataType globalStructDataBecameNonConst = { 1, 2, (struct GlobalDataType*)0 };"; 3466 3467 $HEADER2 .= " 3468 struct GlobalDataType{int a;int b;struct GlobalDataType* p;}; 3469 $EXTERN $DECL_SPEC struct GlobalDataType globalStructDataBecameNonConst = { 1, 2, (struct GlobalDataType*)0 };"; 3470 3471 # Removed_Parameter 3472 $HEADER1 .= " 3473 $DECL_SPEC int removedParameter(int param, int removed_param);"; 3474 $SOURCE1 .= " 3475 int removedParameter(int param, int removed_param) { return 0; }"; 3476 3477 $HEADER2 .= " 3478 $DECL_SPEC int removedParameter(int param);"; 3479 $SOURCE2 .= " 3480 int removedParameter(int param) { return 0; }"; 3481 3482 # Added_Parameter 3483 $HEADER1 .= " 3484 $DECL_SPEC int addedParameter(int param);"; 3485 $SOURCE1 .= " 3486 int addedParameter(int param) { return param; }"; 3487 3488 $HEADER2 .= " 3489 $DECL_SPEC int addedParameter(int param, int added_param, int added_param2);"; 3490 $SOURCE2 .= " 3491 int addedParameter(int param, int added_param, int added_param2) { return added_param2; }"; 3492 3493 # Added_Interface (typedef to funcptr parameter) 3494 $HEADER2 .= " 3495 typedef int (*FUNCPTR_TYPE)(int a, int b); 3496 $DECL_SPEC int addedFunc(FUNCPTR_TYPE*const** f);"; 3497 $SOURCE2 .= " 3498 int addedFunc(FUNCPTR_TYPE*const** f) { return 0; }"; 3499 3500 # Added_Interface (funcptr parameter) 3501 $HEADER2 .= " 3502 $DECL_SPEC int addedFunc2(int(*func)(int, int));"; 3503 $SOURCE2 .= " 3504 int addedFunc2(int(*func)(int, int)) { return 0; }"; 3505 3506 # Added_Interface (no limited parameters) 3507 $HEADER2 .= " 3508 $DECL_SPEC int addedFunc3(float p1, ...);"; 3509 $SOURCE2 .= " 3510 int addedFunc3(float p1, ...) { return 0; }"; 3511 3512 # Size 3513 $HEADER1 .= " 3514 struct TypeSize 3515 { 3516 long long i[5]; 3517 long j; 3518 double k; 3519 struct TypeSize* p; 3520 }; 3521 $DECL_SPEC int testSize(struct TypeSize param, int param_2);"; 3522 $SOURCE1 .= " 3523 int testSize(struct TypeSize param, int param_2) { return param_2; }"; 3524 3525 $HEADER2 .= " 3526 struct TypeSize 3527 { 3528 long long i[15]; 3529 long long j; 3530 double k; 3531 struct TypeSize* p; 3532 }; 3533 $DECL_SPEC int testSize(struct TypeSize param, int param_2);"; 3534 $SOURCE2 .= " 3535 int testSize(struct TypeSize param, int param_2) { return param_2; }"; 3536 3537 # Added_Field_And_Size 3538 $HEADER1 .= " 3539 struct AddedFieldAndSize 3540 { 3541 int i; 3542 long j; 3543 double k; 3544 struct AddedFieldAndSize* p; 3545 }; 3546 $DECL_SPEC int addedFieldAndSize(struct AddedFieldAndSize param, int param_2);"; 3547 $SOURCE1 .= " 3548 int addedFieldAndSize(struct AddedFieldAndSize param, int param_2) { return param_2; }"; 3549 3550 $HEADER2 .= " 3551 struct AddedFieldAndSize 3552 { 3553 int i; 3554 long j; 3555 double k; 3556 struct AddedFieldAndSize* p; 3557 int added_member1; 3558 int added_member2; 3559 }; 3560 $DECL_SPEC int addedFieldAndSize(struct AddedFieldAndSize param, int param_2);"; 3561 $SOURCE2 .= " 3562 int addedFieldAndSize(struct AddedFieldAndSize param, int param_2) { return param_2; }"; 3563 3564 # Added_Middle_Field_And_Size 3565 $HEADER1 .= " 3566 struct AddedMiddleFieldAndSize 3567 { 3568 int i; 3569 long j; 3570 double k; 3571 struct AddedMiddleFieldAndSize* p; 3572 }; 3573 $DECL_SPEC int addedMiddleFieldAndSize(struct AddedMiddleFieldAndSize param, int param_2);"; 3574 $SOURCE1 .= " 3575 int addedMiddleFieldAndSize(struct AddedMiddleFieldAndSize param, int param_2) { return param_2; }"; 3576 3577 $HEADER2 .= " 3578 struct AddedMiddleFieldAndSize 3579 { 3580 int i; 3581 int added_middle_member; 3582 long j; 3583 double k; 3584 struct AddedMiddleFieldAndSize* p; 3585 }; 3586 $DECL_SPEC int addedMiddleFieldAndSize(struct AddedMiddleFieldAndSize param, int param_2);"; 3587 $SOURCE2 .= " 3588 int addedMiddleFieldAndSize(struct AddedMiddleFieldAndSize param, int param_2) { return param_2; }"; 3589 3590 # Added_Middle_Field 3591 $HEADER1 .= " 3592 struct AddedMiddleField 3593 { 3594 unsigned char field1; 3595 unsigned short field2; 3596 }; 3597 $DECL_SPEC int addedMiddleField(struct AddedMiddleField param, int param_2);"; 3598 $SOURCE1 .= " 3599 int addedMiddleField(struct AddedMiddleField param, int param_2) { return param_2; }"; 3600 3601 $HEADER2 .= " 3602 struct AddedMiddleField 3603 { 3604 unsigned char field1; 3605 unsigned char added_field; 3606 unsigned short field2; 3607 }; 3608 $DECL_SPEC int addedMiddleField(struct AddedMiddleField param, int param_2);"; 3609 $SOURCE2 .= " 3610 int addedMiddleField(struct AddedMiddleField param, int param_2) { return param_2; }"; 3611 3612 # Renamed_Field 3613 $HEADER1 .= " 3614 struct RenamedField 3615 { 3616 long i; 3617 long j; 3618 double k; 3619 struct RenamedField* p; 3620 }; 3621 $DECL_SPEC int renamedField(struct RenamedField param, int param_2);"; 3622 $SOURCE1 .= " 3623 int renamedField(struct RenamedField param, int param_2) { return param_2; }"; 3624 3625 $HEADER2 .= " 3626 struct RenamedField 3627 { 3628 long renamed_member; 3629 long j; 3630 double k; 3631 struct RenamedField* p; 3632 }; 3633 $DECL_SPEC int renamedField(struct RenamedField param, int param_2);"; 3634 $SOURCE2 .= " 3635 int renamedField(struct RenamedField param, int param_2) { return param_2; }"; 3636 3637 # Renamed_Field 3638 $HEADER1 .= " 3639 union RenamedUnionField 3640 { 3641 int renamed_from; 3642 double j; 3643 }; 3644 $DECL_SPEC int renamedUnionField(union RenamedUnionField param);"; 3645 $SOURCE1 .= " 3646 int renamedUnionField(union RenamedUnionField param) { return 0; }"; 3647 3648 $HEADER2 .= " 3649 union RenamedUnionField 3650 { 3651 int renamed_to; 3652 double j; 3653 }; 3654 $DECL_SPEC int renamedUnionField(union RenamedUnionField param);"; 3655 $SOURCE2 .= " 3656 int renamedUnionField(union RenamedUnionField param) { return 0; }"; 3657 3658 # Removed_Field_And_Size 3659 $HEADER1 .= " 3660 struct RemovedFieldAndSize 3661 { 3662 int i; 3663 long j; 3664 double k; 3665 struct RemovedFieldAndSize* p; 3666 int removed_member1; 3667 int removed_member2; 3668 }; 3669 $DECL_SPEC int removedFieldAndSize(struct RemovedFieldAndSize param, int param_2);"; 3670 $SOURCE1 .= " 3671 int removedFieldAndSize(struct RemovedFieldAndSize param, int param_2) { return param_2; }"; 3672 3673 $HEADER2 .= " 3674 struct RemovedFieldAndSize 3675 { 3676 int i; 3677 long j; 3678 double k; 3679 struct RemovedFieldAndSize* p; 3680 }; 3681 $DECL_SPEC int removedFieldAndSize(struct RemovedFieldAndSize param, int param_2);"; 3682 $SOURCE2 .= " 3683 int removedFieldAndSize(struct RemovedFieldAndSize param, int param_2) { return param_2; }"; 3684 3685 # Removed_Middle_Field 3686 $HEADER1 .= " 3687 struct RemovedMiddleField 3688 { 3689 int i; 3690 int removed_middle_member; 3691 long j; 3692 double k; 3693 struct RemovedMiddleField* p; 3694 }; 3695 $DECL_SPEC int removedMiddleField(struct RemovedMiddleField param, int param_2);"; 3696 $SOURCE1 .= " 3697 int removedMiddleField(struct RemovedMiddleField param, int param_2) { return param_2; }"; 3698 3699 $HEADER2 .= " 3700 struct RemovedMiddleField 3701 { 3702 int i; 3703 long j; 3704 double k; 3705 struct RemovedMiddleField* p; 3706 }; 3707 $DECL_SPEC int removedMiddleField(struct RemovedMiddleField param, int param_2);"; 3708 $SOURCE2 .= " 3709 int removedMiddleField(struct RemovedMiddleField param, int param_2) { return param_2; }"; 3710 3711 # Enum_Member_Value 3712 $HEADER1 .= " 3713 enum EnumMemberValue 3714 { 3715 MEMBER1=1, 3716 MEMBER2=2 3717 }; 3718 $DECL_SPEC int enumMemberValue(enum EnumMemberValue param);"; 3719 $SOURCE1 .= " 3720 int enumMemberValue(enum EnumMemberValue param) { return 0; }"; 3721 3722 $HEADER2 .= " 3723 enum EnumMemberValue 3724 { 3725 MEMBER1=2, 3726 MEMBER2=1 3727 }; 3728 $DECL_SPEC int enumMemberValue(enum EnumMemberValue param);"; 3729 $SOURCE2 .= " 3730 int enumMemberValue(enum EnumMemberValue param) { return 0; }"; 3731 3732 # Enum_Member_Removed 3733 $HEADER1 .= " 3734 enum EnumMemberRemoved 3735 { 3736 MEMBER=1, 3737 MEMBER_REMOVED=2 3738 }; 3739 $DECL_SPEC int enumMemberRemoved(enum EnumMemberRemoved param);"; 3740 $SOURCE1 .= " 3741 int enumMemberRemoved(enum EnumMemberRemoved param) { return 0; }"; 3742 3743 $HEADER2 .= " 3744 enum EnumMemberRemoved 3745 { 3746 MEMBER=1 3747 }; 3748 $DECL_SPEC int enumMemberRemoved(enum EnumMemberRemoved param);"; 3749 $SOURCE2 .= " 3750 int enumMemberRemoved(enum EnumMemberRemoved param) { return 0; }"; 3751 3752 # Enum_Member_Removed (middle) 3753 $HEADER1 .= " 3754 enum EnumMiddleMemberRemoved 3755 { 3756 MEM_REMOVED, 3757 MEM1, 3758 MEM2 3759 }; 3760 $DECL_SPEC int enumMiddleMemberRemoved(enum EnumMiddleMemberRemoved param);"; 3761 $SOURCE1 .= " 3762 int enumMiddleMemberRemoved(enum EnumMiddleMemberRemoved param) { return 0; }"; 3763 3764 $HEADER2 .= " 3765 enum EnumMiddleMemberRemoved 3766 { 3767 MEM1, 3768 MEM2 3769 }; 3770 $DECL_SPEC int enumMiddleMemberRemoved(enum EnumMiddleMemberRemoved param);"; 3771 $SOURCE2 .= " 3772 int enumMiddleMemberRemoved(enum EnumMiddleMemberRemoved param) { return 0; }"; 3773 3774 # Enum_Member_Name 3775 $HEADER1 .= " 3776 enum EnumMemberName 3777 { 3778 BRANCH1=1, 3779 BRANCH2=2 3780 }; 3781 $DECL_SPEC int enumMemberName(enum EnumMemberName param);"; 3782 $SOURCE1 .= " 3783 int enumMemberName(enum EnumMemberName param) { return 0; }"; 3784 3785 $HEADER2 .= " 3786 enum EnumMemberName 3787 { 3788 BRANCH_FIRST=1, 3789 BRANCH_SECOND=2 3790 }; 3791 $DECL_SPEC int enumMemberName(enum EnumMemberName param);"; 3792 $SOURCE2 .= " 3793 int enumMemberName(enum EnumMemberName param) { return 0; }"; 3794 3795 # Field_Type_And_Size 3796 $HEADER1 .= " 3797 struct FieldTypeAndSize 3798 { 3799 int i; 3800 long j; 3801 double k; 3802 struct FieldTypeAndSize* p; 3803 }; 3804 $DECL_SPEC int fieldTypeAndSize(struct FieldTypeAndSize param, int param_2);"; 3805 $SOURCE1 .= " 3806 int fieldTypeAndSize(struct FieldTypeAndSize param, int param_2) { return param_2; }"; 3807 3808 $HEADER2 .= " 3809 struct FieldTypeAndSize 3810 { 3811 int i; 3812 long long j; 3813 double k; 3814 struct FieldTypeAndSize* p; 3815 }; 3816 $DECL_SPEC int fieldTypeAndSize(struct FieldTypeAndSize param, int param_2);"; 3817 $SOURCE2 .= " 3818 int fieldTypeAndSize(struct FieldTypeAndSize param, int param_2) { return param_2; }"; 3819 3820 # Field_Type 3821 $HEADER1 .= " 3822 struct FieldType 3823 { 3824 int i; 3825 long j; 3826 double k; 3827 struct FieldType* p; 3828 }; 3829 $DECL_SPEC int fieldType(struct FieldType param, int param_2);"; 3830 $SOURCE1 .= " 3831 int fieldType(struct FieldType param, int param_2) { return param_2; }"; 3832 3833 $HEADER2 .= " 3834 struct FieldType 3835 { 3836 float i; 3837 long j; 3838 double k; 3839 struct FieldType* p; 3840 }; 3841 $DECL_SPEC int fieldType(struct FieldType param, int param_2);"; 3842 $SOURCE2 .= " 3843 int fieldType(struct FieldType param, int param_2) { return param_2; }"; 3844 3845 # Field_BaseType 3846 $HEADER1 .= " 3847 struct FieldBaseType 3848 { 3849 int i; 3850 long *j; 3851 double k; 3852 struct FieldBaseType* p; 3853 }; 3854 $DECL_SPEC int fieldBaseType(struct FieldBaseType param, int param_2);"; 3855 $SOURCE1 .= " 3856 int fieldBaseType(struct FieldBaseType param, int param_2) { return param_2; }"; 3857 3858 $HEADER2 .= " 3859 struct FieldBaseType 3860 { 3861 int i; 3862 long long *j; 3863 double k; 3864 struct FieldBaseType* p; 3865 }; 3866 $DECL_SPEC int fieldBaseType(struct FieldBaseType param, int param_2);"; 3867 $SOURCE2 .= " 3868 int fieldBaseType(struct FieldBaseType param, int param_2) { return param_2; }"; 3869 3870 # Field_PointerLevel (and Size) 3871 $HEADER1 .= " 3872 struct FieldPointerLevelAndSize 3873 { 3874 int i; 3875 long long j; 3876 double k; 3877 struct FieldPointerLevelAndSize* p; 3878 }; 3879 $DECL_SPEC int fieldPointerLevelAndSize(struct FieldPointerLevelAndSize param, int param_2);"; 3880 $SOURCE1 .= " 3881 int fieldPointerLevelAndSize(struct FieldPointerLevelAndSize param, int param_2) { return param_2; }"; 3882 3883 $HEADER2 .= " 3884 struct FieldPointerLevelAndSize 3885 { 3886 int i; 3887 long long *j; 3888 double k; 3889 struct FieldPointerLevelAndSize* p; 3890 }; 3891 $DECL_SPEC int fieldPointerLevelAndSize(struct FieldPointerLevelAndSize param, int param_2);"; 3892 $SOURCE2 .= " 3893 int fieldPointerLevelAndSize(struct FieldPointerLevelAndSize param, int param_2) { return param_2; }"; 3894 3895 # Field_PointerLevel 3896 $HEADER1 .= " 3897 struct FieldPointerLevel 3898 { 3899 int i; 3900 long *j; 3901 double k; 3902 struct FieldPointerLevel* p; 3903 }; 3904 $DECL_SPEC int fieldPointerLevel(struct FieldPointerLevel param, int param_2);"; 3905 $SOURCE1 .= " 3906 int fieldPointerLevel(struct FieldPointerLevel param, int param_2) { return param_2; }"; 3907 3908 $HEADER2 .= " 3909 struct FieldPointerLevel 3910 { 3911 int i; 3912 long **j; 3913 double k; 3914 struct FieldPointerLevel* p; 3915 }; 3916 $DECL_SPEC int fieldPointerLevel(struct FieldPointerLevel param, int param_2);"; 3917 $SOURCE2 .= " 3918 int fieldPointerLevel(struct FieldPointerLevel param, int param_2) { return param_2; }"; 3919 3920 # Added_Interface 3921 $HEADER2 .= " 3922 $DECL_SPEC int addedFunc4(int param);"; 3923 $SOURCE2 .= " 3924 int addedFunc4(int param) { return param; }"; 3925 3926 # Removed_Interface 3927 $HEADER1 .= " 3928 $DECL_SPEC int removedFunc(int param);"; 3929 $SOURCE1 .= " 3930 int removedFunc(int param) { return param; }"; 3931 3932 # Parameter_Type_And_Size 3933 $HEADER1 .= " 3934 $DECL_SPEC int parameterTypeAndSize(int param, int other_param);"; 3935 $SOURCE1 .= " 3936 int parameterTypeAndSize(int param, int other_param) { return other_param; }"; 3937 3938 $HEADER2 .= " 3939 $DECL_SPEC int parameterTypeAndSize(long long param, int other_param);"; 3940 $SOURCE2 .= " 3941 int parameterTypeAndSize(long long param, int other_param) { return other_param; }"; 3942 3943 # Parameter_Type_And_Size + Parameter_Became_Non_Const 3944 $HEADER1 .= " 3945 $DECL_SPEC int parameterTypeAndSizeBecameNonConst(int* const param, int other_param);"; 3946 $SOURCE1 .= " 3947 int parameterTypeAndSizeBecameNonConst(int* const param, int other_param) { return other_param; }"; 3948 3949 $HEADER2 .= " 3950 $DECL_SPEC int parameterTypeAndSizeBecameNonConst(long double param, int other_param);"; 3951 $SOURCE2 .= " 3952 int parameterTypeAndSizeBecameNonConst(long double param, int other_param) { return other_param; }"; 3953 3954 # Parameter_Type_And_Size (test calling conventions) 3955 $HEADER1 .= " 3956 $DECL_SPEC int parameterCallingConvention(int p1, int p2, int p3);"; 3957 $SOURCE1 .= " 3958 int parameterCallingConvention(int p1, int p2, int p3) { return 0; }"; 3959 3960 $HEADER2 .= " 3961 $DECL_SPEC float parameterCallingConvention(char p1, int p2, int p3);"; 3962 $SOURCE2 .= " 3963 float parameterCallingConvention(char p1, int p2, int p3) { return 7.0f; }"; 3964 3965 # Parameter_Type 3966 $HEADER1 .= " 3967 $DECL_SPEC int parameterType(int param, int other_param);"; 3968 $SOURCE1 .= " 3969 int parameterType(int param, int other_param) { return other_param; }"; 3970 3971 $HEADER2 .= " 3972 $DECL_SPEC int parameterType(float param, int other_param);"; 3973 $SOURCE2 .= " 3974 int parameterType(float param, int other_param) { return other_param; }"; 3975 3976 # Parameter_Became_Non_Const 3977 $HEADER1 .= " 3978 $DECL_SPEC int parameterBecameNonConst(int const* param);"; 3979 $SOURCE1 .= " 3980 int parameterBecameNonConst(int const* param) { return *param; }"; 3981 3982 $HEADER2 .= " 3983 $DECL_SPEC int parameterBecameNonConst(int* param);"; 3984 $SOURCE2 .= " 3985 int parameterBecameNonConst(int* param) { 3986 *param=10; 3987 return *param; 3988 }"; 3989 3990 # Parameter_Became_Non_Const + Parameter_Became_Non_Volatile 3991 $HEADER1 .= " 3992 $DECL_SPEC int parameterBecameNonConstNonVolatile(int const volatile* param);"; 3993 $SOURCE1 .= " 3994 int parameterBecameNonConstNonVolatile(int const volatile* param) { return *param; }"; 3995 3996 $HEADER2 .= " 3997 $DECL_SPEC int parameterBecameNonConstNonVolatile(int* param);"; 3998 $SOURCE2 .= " 3999 int parameterBecameNonConstNonVolatile(int* param) { 4000 *param=10; 4001 return *param; 4002 }"; 4003 4004 # Parameter_BaseType (Typedef) 4005 $HEADER1 .= " 4006 typedef int* PARAM_TYPEDEF; 4007 $DECL_SPEC int parameterBaseTypedefChange(PARAM_TYPEDEF param);"; 4008 $SOURCE1 .= " 4009 int parameterBaseTypedefChange(PARAM_TYPEDEF param) { return 0; }"; 4010 4011 $HEADER2 .= " 4012 typedef const int* PARAM_TYPEDEF; 4013 $DECL_SPEC int parameterBaseTypedefChange(PARAM_TYPEDEF param);"; 4014 $SOURCE2 .= " 4015 int parameterBaseTypedefChange(PARAM_TYPEDEF param) { return 0; }"; 4016 4017 # Parameter_BaseType 4018 $HEADER1 .= " 4019 $DECL_SPEC int parameterBaseTypeChange(int *param);"; 4020 $SOURCE1 .= " 4021 int parameterBaseTypeChange(int *param) { return sizeof(*param); }"; 4022 4023 $HEADER2 .= " 4024 $DECL_SPEC int parameterBaseTypeChange(long long *param);"; 4025 $SOURCE2 .= " 4026 int parameterBaseTypeChange(long long *param) { return sizeof(*param); }"; 4027 4028 # Parameter_PointerLevel 4029 $HEADER1 .= " 4030 $DECL_SPEC long long parameterPointerLevelAndSize(long long param);"; 4031 $SOURCE1 .= " 4032 long long parameterPointerLevelAndSize(long long param) { return param; }"; 4033 4034 $HEADER2 .= " 4035 $DECL_SPEC long long parameterPointerLevelAndSize(long long *param);"; 4036 $SOURCE2 .= " 4037 long long parameterPointerLevelAndSize(long long *param) { return param[5]; }"; 4038 4039 # Parameter_PointerLevel 4040 $HEADER1 .= " 4041 $DECL_SPEC int parameterPointerLevel(int *param);"; 4042 $SOURCE1 .= " 4043 int parameterPointerLevel(int *param) { return param[5]; }"; 4044 4045 $HEADER2 .= " 4046 $DECL_SPEC int parameterPointerLevel(int **param);"; 4047 $SOURCE2 .= " 4048 int parameterPointerLevel(int **param) { return param[5][5]; }"; 4049 4050 # Return_Type_And_Size 4051 $HEADER1 .= " 4052 $DECL_SPEC int returnTypeAndSize(int param);"; 4053 $SOURCE1 .= " 4054 int returnTypeAndSize(int param) { return 0; }"; 4055 4056 $HEADER2 .= " 4057 $DECL_SPEC long long returnTypeAndSize(int param);"; 4058 $SOURCE2 .= " 4059 long long returnTypeAndSize(int param) { return 0; }"; 4060 4061 # Return_Type 4062 $HEADER1 .= " 4063 $DECL_SPEC int returnType(int param);"; 4064 $SOURCE1 .= " 4065 int returnType(int param) { return 1; }"; 4066 4067 $HEADER2 .= " 4068 $DECL_SPEC float returnType(int param);"; 4069 $SOURCE2 .= " 4070 float returnType(int param) { return 1; }"; 4071 4072 # Return_Type_Became_Void ("int" to "void") 4073 $HEADER1 .= " 4074 $DECL_SPEC int returnTypeChangeToVoid(int param);"; 4075 $SOURCE1 .= " 4076 int returnTypeChangeToVoid(int param) { return 0; }"; 4077 4078 $HEADER2 .= " 4079 $DECL_SPEC void returnTypeChangeToVoid(int param);"; 4080 $SOURCE2 .= " 4081 void returnTypeChangeToVoid(int param) { return; }"; 4082 4083 # Return_Type ("struct" to "void*") 4084 $HEADER1 .= " 4085 struct SomeStruct { 4086 int a; 4087 double b, c, d; 4088 }; 4089 $DECL_SPEC struct SomeStruct* returnTypeChangeToVoidPtr(int param);"; 4090 $SOURCE1 .= " 4091 struct SomeStruct* returnTypeChangeToVoidPtr(int param) { return (struct SomeStruct*)0; }"; 4092 4093 $HEADER2 .= " 4094 struct SomeStruct { 4095 int a; 4096 double b, c, d; 4097 }; 4098 $DECL_SPEC void* returnTypeChangeToVoidPtr(int param);"; 4099 $SOURCE2 .= " 4100 void* returnTypeChangeToVoidPtr(int param) { return (void*)0; }"; 4101 4102 # Return_Type (structure change) 4103 $HEADER1 .= " 4104 struct SomeStruct2 { 4105 int a; 4106 int b; 4107 }; 4108 $DECL_SPEC struct SomeStruct2 returnType2(int param);"; 4109 $SOURCE1 .= " 4110 struct SomeStruct2 returnType2(int param) { struct SomeStruct2 r = {1, 2};return r; }"; 4111 4112 $HEADER2 .= " 4113 struct SomeStruct2 { 4114 int a; 4115 }; 4116 $DECL_SPEC struct SomeStruct2 returnType2(int param);"; 4117 $SOURCE2 .= " 4118 struct SomeStruct2 returnType2(int param) { struct SomeStruct2 r = {1};return r; }"; 4119 4120 # Return_Type (structure change) 4121 $HEADER1 .= " 4122 struct SomeStruct3 { 4123 int a; 4124 int b; 4125 }; 4126 $DECL_SPEC struct SomeStruct3 returnType3(int param);"; 4127 $SOURCE1 .= " 4128 struct SomeStruct3 returnType3(int param) { struct SomeStruct3 r = {1, 2};return r; }"; 4129 4130 $HEADER2 .= " 4131 struct SomeStruct3 { 4132 int a; 4133 long double b; 4134 }; 4135 $DECL_SPEC struct SomeStruct3 returnType3(int param);"; 4136 $SOURCE2 .= " 4137 struct SomeStruct3 returnType3(int param) { struct SomeStruct3 r = {1, 2.0L};return r; }"; 4138 4139 # Return_Type_From_Void_And_Stack_Layout ("void" to "struct") 4140 $HEADER1 .= " 4141 $DECL_SPEC void returnTypeChangeFromVoidToStruct(int param);"; 4142 $SOURCE1 .= " 4143 void returnTypeChangeFromVoidToStruct(int param) { return; }"; 4144 4145 $HEADER2 .= " 4146 $DECL_SPEC struct SomeStruct returnTypeChangeFromVoidToStruct(int param);"; 4147 $SOURCE2 .= " 4148 struct SomeStruct returnTypeChangeFromVoidToStruct(int param) { 4149 struct SomeStruct obj = {1,2}; 4150 return obj; 4151 }"; 4152 4153 # Return_Type_Became_Void_And_Stack_Layout ("struct" to "void") 4154 $HEADER1 .= " 4155 $DECL_SPEC struct SomeStruct returnTypeChangeFromStructToVoid(int param);"; 4156 $SOURCE1 .= " 4157 struct SomeStruct returnTypeChangeFromStructToVoid(int param) { 4158 struct SomeStruct obj = {1,2}; 4159 return obj; 4160 }"; 4161 4162 $HEADER2 .= " 4163 $DECL_SPEC void returnTypeChangeFromStructToVoid(int param);"; 4164 $SOURCE2 .= " 4165 void returnTypeChangeFromStructToVoid(int param) { return; }"; 4166 4167 # Return_Type_From_Void_And_Stack_Layout (safe, "void" to "long") 4168 $HEADER1 .= " 4169 $DECL_SPEC void returnTypeChangeFromVoidToLong(int param);"; 4170 $SOURCE1 .= " 4171 void returnTypeChangeFromVoidToLong(int param) { return; }"; 4172 4173 $HEADER2 .= " 4174 $DECL_SPEC long returnTypeChangeFromVoidToLong(int param);"; 4175 $SOURCE2 .= " 4176 long returnTypeChangeFromVoidToLong(int param) { return 0; }"; 4177 4178 # Return_Type_From_Void_And_Stack_Layout (safe, "void" to "void*") 4179 $HEADER1 .= " 4180 $DECL_SPEC void returnTypeChangeFromVoidToVoidPtr(int param);"; 4181 $SOURCE1 .= " 4182 void returnTypeChangeFromVoidToVoidPtr(int param) { return; }"; 4183 4184 $HEADER2 .= " 4185 $DECL_SPEC void* returnTypeChangeFromVoidToVoidPtr(int param);"; 4186 $SOURCE2 .= " 4187 void* returnTypeChangeFromVoidToVoidPtr(int param) { return 0; }"; 4188 4189 # Return_Type_From_Register_To_Stack ("int" to "struct") 4190 $HEADER1 .= " 4191 $DECL_SPEC int returnTypeChangeFromIntToStruct(int param);"; 4192 $SOURCE1 .= " 4193 int returnTypeChangeFromIntToStruct(int param) { return param; }"; 4194 4195 $HEADER2 .= " 4196 $DECL_SPEC struct SomeStruct returnTypeChangeFromIntToStruct(int param);"; 4197 $SOURCE2 .= " 4198 struct SomeStruct returnTypeChangeFromIntToStruct(int param) { 4199 struct SomeStruct obj = {1,2}; 4200 return obj; 4201 }"; 4202 4203 # Return_Type_From_Stack_To_Register (from struct to int) 4204 $HEADER1 .= " 4205 $DECL_SPEC struct SomeStruct returnTypeChangeFromStructToInt(int param);"; 4206 $SOURCE1 .= " 4207 struct SomeStruct returnTypeChangeFromStructToInt(int param) { 4208 struct SomeStruct obj = {1,2}; 4209 return obj; 4210 }"; 4211 4212 $HEADER2 .= " 4213 $DECL_SPEC int returnTypeChangeFromStructToInt(int param);"; 4214 $SOURCE2 .= " 4215 int returnTypeChangeFromStructToInt(int param) { return param; }"; 4216 4217 # Return_Type_From_Stack_To_Register (from struct to int, without parameters) 4218 $HEADER1 .= " 4219 $DECL_SPEC struct SomeStruct returnTypeChangeFromStructToIntWithNoParams();"; 4220 $SOURCE1 .= " 4221 struct SomeStruct returnTypeChangeFromStructToIntWithNoParams() { 4222 struct SomeStruct obj = {1,2}; 4223 return obj; 4224 }"; 4225 4226 $HEADER2 .= " 4227 $DECL_SPEC int returnTypeChangeFromStructToIntWithNoParams();"; 4228 $SOURCE2 .= " 4229 int returnTypeChangeFromStructToIntWithNoParams() { return 0; }"; 4230 4231 # Return_BaseType 4232 $HEADER1 .= " 4233 $DECL_SPEC int *returnBaseTypeChange(int param);"; 4234 $SOURCE1 .= " 4235 int *returnBaseTypeChange(int param) { return (int*)0; }"; 4236 4237 $HEADER2 .= " 4238 $DECL_SPEC long long *returnBaseTypeChange(int param);"; 4239 $SOURCE2 .= " 4240 long long *returnBaseTypeChange(int param) { return (long long*)0; }"; 4241 4242 # Return_PointerLevel 4243 $HEADER1 .= " 4244 $DECL_SPEC long long returnPointerLevelAndSize(int param);"; 4245 $SOURCE1 .= " 4246 long long returnPointerLevelAndSize(int param) { return 100; }"; 4247 4248 $HEADER2 .= " 4249 $DECL_SPEC long long *returnPointerLevelAndSize(int param);"; 4250 $SOURCE2 .= " 4251 long long *returnPointerLevelAndSize(int param) { return (long long *)0; }"; 4252 4253 # Return_PointerLevel 4254 $HEADER1 .= " 4255 $DECL_SPEC long long *returnPointerLevel(int param);"; 4256 $SOURCE1 .= " 4257 long long *returnPointerLevel(int param) { return (long long *)0; }"; 4258 4259 $HEADER2 .= " 4260 $DECL_SPEC long long **returnPointerLevel(int param);"; 4261 $SOURCE2 .= " 4262 long long **returnPointerLevel(int param) { return (long long **)0; }"; 4263 4264 # Size (typedef to anon structure) 4265 $HEADER1 .= " 4266 typedef struct 4267 { 4268 int i; 4269 long j; 4270 double k; 4271 } AnonTypedef; 4272 $DECL_SPEC int anonTypedef(AnonTypedef param);"; 4273 $SOURCE1 .= " 4274 int anonTypedef(AnonTypedef param) { return 0; }"; 4275 4276 $HEADER2 .= " 4277 typedef struct 4278 { 4279 int i; 4280 long j; 4281 double k; 4282 union { 4283 int dummy[256]; 4284 struct { 4285 char q_skiptable[256]; 4286 const char *p; 4287 int l; 4288 } p; 4289 }; 4290 } AnonTypedef; 4291 $DECL_SPEC int anonTypedef(AnonTypedef param);"; 4292 $SOURCE2 .= " 4293 int anonTypedef(AnonTypedef param) { return 0; }"; 4294 4295 # Size (safe: opaque) 4296 $HEADER1 .= " 4297 struct OpaqueType 4298 { 4299 long long i[5]; 4300 long j; 4301 double k; 4302 struct OpaqueType* p; 4303 }; 4304 $DECL_SPEC int opaqueTypeUse(struct OpaqueType param, int param_2);"; 4305 $SOURCE1 .= " 4306 int opaqueTypeUse(struct OpaqueType param, int param_2) { return param_2; }"; 4307 4308 $HEADER2 .= " 4309 struct OpaqueType 4310 { 4311 long long i[5]; 4312 long long j; 4313 double k; 4314 struct OpaqueType* p; 4315 }; 4316 $DECL_SPEC int opaqueTypeUse(struct OpaqueType param, int param_2);"; 4317 $SOURCE2 .= " 4318 int opaqueTypeUse(struct OpaqueType param, int param_2) { return param_2; }"; 4319 4320 # Size (safe: internal) 4321 $HEADER1 .= " 4322 struct InternalType 4323 { 4324 long long i[5]; 4325 long j; 4326 double k; 4327 struct InternalType* p; 4328 }; 4329 $DECL_SPEC int internalTypeUse(struct InternalType param, int param_2);"; 4330 $SOURCE1 .= " 4331 int internalTypeUse(struct InternalType param, int param_2) { return param_2; }"; 4332 4333 $HEADER2 .= " 4334 struct InternalType 4335 { 4336 long long i[5]; 4337 long long j; 4338 double k; 4339 struct InternalType* p; 4340 }; 4341 $DECL_SPEC int internalTypeUse(struct InternalType param, int param_2);"; 4342 $SOURCE2 .= " 4343 int internalTypeUse(struct InternalType param, int param_2) { return param_2; }"; 4344 4345 if($OSgroup eq "linux") 4346 { 4347 # Changed version 4348 $HEADER1 .= " 4349 $DECL_SPEC int changedVersion(int param); 4350 $DECL_SPEC int changedDefaultVersion(int param);"; 4351 $SOURCE1 .= " 4352 int changedVersion(int param) { return 0; } 4353 __asm__(\".symver changedVersion,changedVersion\@VERSION_2.0\"); 4354 int changedDefaultVersion(int param) { return 0; }"; 4355 4356 $HEADER2 .= " 4357 $DECL_SPEC int changedVersion(int param); 4358 $DECL_SPEC int changedDefaultVersion(long param);"; 4359 $SOURCE2 .= " 4360 int changedVersion(int param) { return 0; } 4361 __asm__(\".symver changedVersion,changedVersion\@VERSION_3.0\"); 4362 int changedDefaultVersion(long param) { return 0; }"; 4363 4364 # Unchanged version 4365 $HEADER1 .= " 4366 $DECL_SPEC int unchangedVersion(int param); 4367 $DECL_SPEC int unchangedDefaultVersion(int param);"; 4368 $SOURCE1 .= " 4369 int unchangedVersion(int param) { return 0; } 4370 __asm__(\".symver unchangedVersion,unchangedVersion\@VERSION_1.0\"); 4371 int unchangedDefaultVersion(int param) { return 0; }"; 4372 4373 $HEADER2 .= " 4374 $DECL_SPEC int unchangedVersion(int param); 4375 $DECL_SPEC int unchangedDefaultVersion(int param);"; 4376 $SOURCE2 .= " 4377 int unchangedVersion(int param) { return 0; } 4378 __asm__(\".symver unchangedVersion,unchangedVersion\@VERSION_1.0\"); 4379 int unchangedDefaultVersion(int param) { return 0; }"; 4380 4381 # Non-Default to Default 4382 $HEADER1 .= " 4383 $DECL_SPEC int changedVersionToDefault(int param);"; 4384 $SOURCE1 .= " 4385 int changedVersionToDefault(int param) { return 0; } 4386 __asm__(\".symver changedVersionToDefault,changedVersionToDefault\@VERSION_1.0\");"; 4387 4388 $HEADER2 .= " 4389 $DECL_SPEC int changedVersionToDefault(long param);"; 4390 $SOURCE2 .= " 4391 int changedVersionToDefault(long param) { return 0; }"; 4392 4393 # Default to Non-Default 4394 $HEADER1 .= " 4395 $DECL_SPEC int changedVersionToNonDefault(int param);"; 4396 $SOURCE1 .= " 4397 int changedVersionToNonDefault(int param) { return 0; }"; 4398 4399 $HEADER2 .= " 4400 $DECL_SPEC int changedVersionToNonDefault(long param);"; 4401 $SOURCE2 .= " 4402 int changedVersionToNonDefault(long param) { return 0; } 4403 __asm__(\".symver changedVersionToNonDefault,changedVersionToNonDefault\@VERSION_3.0\");"; 4404 4405 # Added version 4406 $HEADER1 .= " 4407 $DECL_SPEC int addedVersion(int param); 4408 $DECL_SPEC int addedDefaultVersion(int param);"; 4409 $SOURCE1 .= " 4410 int addedVersion(int param) { return 0; } 4411 int addedDefaultVersion(int param) { return 0; }"; 4412 4413 $HEADER2 .= " 4414 $DECL_SPEC int addedVersion(int param); 4415 $DECL_SPEC int addedDefaultVersion(int param);"; 4416 $SOURCE2 .= " 4417 int addedVersion(int param) { return 0; } 4418 __asm__(\".symver addedVersion,addedVersion\@VERSION_2.0\"); 4419 int addedDefaultVersion(int param) { return 0; }"; 4420 4421 # Removed version 4422 $HEADER1 .= " 4423 $DECL_SPEC int removedVersion(int param); 4424 $DECL_SPEC int removedVersion2(int param); 4425 $DECL_SPEC int removedDefaultVersion(int param);"; 4426 $SOURCE1 .= " 4427 int removedVersion(int param) { return 0; } 4428 __asm__(\".symver removedVersion,removedVersion\@VERSION_1.0\"); 4429 int removedVersion2(int param) { return 0; } 4430 __asm__(\".symver removedVersion2,removedVersion\@VERSION_3.0\"); 4431 int removedDefaultVersion(int param) { return 0; }"; 4432 4433 $HEADER2 .= " 4434 $DECL_SPEC int removedVersion(int param); 4435 $DECL_SPEC int removedVersion2(int param); 4436 $DECL_SPEC int removedDefaultVersion(int param);"; 4437 $SOURCE2 .= " 4438 int removedVersion(int param) { return 0; } 4439 int removedVersion2(int param) { return 0; } 4440 __asm__(\".symver removedVersion2,removedVersion\@VERSION_3.0\"); 4441 int removedDefaultVersion(int param) { return 0; }"; 4442 4443 # Return_Type (good versioning) 4444 $HEADER1 .= " 4445 $DECL_SPEC int goodVersioning(int param);"; 4446 $SOURCE1 .= " 4447 int goodVersioning(int param) { return 0; } 4448 __asm__(\".symver goodVersioning,goodVersioning\@VERSION_1.0\");"; 4449 4450 $HEADER2 .= " 4451 $DECL_SPEC int goodVersioningOld(int param);"; 4452 $SOURCE2 .= " 4453 int goodVersioningOld(int param) { return 0; } 4454 __asm__(\".symver goodVersioningOld,goodVersioning\@VERSION_1.0\");"; 4455 4456 $HEADER2 .= " 4457 $DECL_SPEC float goodVersioning(int param);"; 4458 $SOURCE2 .= " 4459 float goodVersioning(int param) { return 0.7; } 4460 __asm__(\".symver goodVersioning,goodVersioning\@VERSION_2.0\");"; 4461 4462 # Return_Type (bad versioning) 4463 $HEADER1 .= " 4464 $DECL_SPEC int badVersioning(int param);"; 4465 $SOURCE1 .= " 4466 int badVersioning(int param) { return 0; } 4467 __asm__(\".symver badVersioning,badVersioning\@VERSION_1.0\");"; 4468 4469 $HEADER2 .= " 4470 $DECL_SPEC float badVersioningOld(int param);"; 4471 $SOURCE2 .= " 4472 float badVersioningOld(int param) { return 0.7; } 4473 __asm__(\".symver badVersioningOld,badVersioning\@VERSION_1.0\");"; 4474 4475 $HEADER2 .= " 4476 $DECL_SPEC float badVersioning(int param);"; 4477 $SOURCE2 .= " 4478 float badVersioning(int param) { return 0.7; } 4479 __asm__(\".symver badVersioning,badVersioning\@VERSION_2.0\");"; 4480 } 4481 # unnamed struct/union fields within structs/unions 4482 $HEADER1 .= " 4483 typedef struct 4484 { 4485 int a; 4486 union { 4487 int b; 4488 float c; 4489 }; 4490 int d; 4491 } UnnamedTypeSize; 4492 $DECL_SPEC int unnamedTypeSize(UnnamedTypeSize param);"; 4493 $SOURCE1 .= " 4494 int unnamedTypeSize(UnnamedTypeSize param) { return 0; }"; 4495 4496 $HEADER2 .= " 4497 typedef struct 4498 { 4499 int a; 4500 union { 4501 long double b; 4502 float c; 4503 }; 4504 int d; 4505 } UnnamedTypeSize; 4506 $DECL_SPEC int unnamedTypeSize(UnnamedTypeSize param);"; 4507 $SOURCE2 .= " 4508 int unnamedTypeSize(UnnamedTypeSize param) { return 0; }"; 4509 4510 # Changed_Constant (#define) 4511 $HEADER1 .= " 4512 #define PUBLIC_CONSTANT \"old_value\""; 4513 $HEADER2 .= " 4514 #define PUBLIC_CONSTANT \"new_value\""; 4515 4516 # Changed_Constant (Safe) 4517 $HEADER1 .= " 4518 #define INTEGER_CONSTANT 0x01"; 4519 $HEADER2 .= " 4520 #define INTEGER_CONSTANT 1"; 4521 4522 # Changed_Constant (Safe) 4523 $HEADER1 .= " 4524 #define PRIVATE_CONSTANT \"old_value\" 4525 #undef PRIVATE_CONSTANT"; 4526 $HEADER2 .= " 4527 #define PRIVATE_CONSTANT \"new_value\" 4528 #undef PRIVATE_CONSTANT"; 4529 4530 # Changed_Constant (enum) 4531 $HEADER1 .= " 4532 enum { 4533 SOME_CONSTANT=0x1 4534 };"; 4535 $HEADER2 .= " 4536 enum { 4537 SOME_CONSTANT=0x2 4538 };"; 4539 4540 # Added_Constant (#define) 4541 $HEADER2 .= " 4542 #define ADDED_CNST \"value\""; 4543 4544 # Added_Constant (enum) 4545 $HEADER1 .= " 4546 enum { 4547 CONSTANT1 4548 };"; 4549 $HEADER2 .= " 4550 enum { 4551 CONSTANT1, 4552 ADDED_CONSTANT 4553 };"; 4554 4555 # Removed_Constant (#define) 4556 $HEADER1 .= " 4557 #define REMOVED_CNST \"value\""; 4558 4559 # Removed_Constant (enum) 4560 $HEADER1 .= " 4561 enum { 4562 CONSTANT2, 4563 REMOVED_CONSTANT 4564 };"; 4565 $HEADER2 .= " 4566 enum { 4567 CONSTANT2 4568 };"; 4569 4570 # Added_Field (union) 4571 $HEADER1 .= " 4572 union UnionTypeAddedField 4573 { 4574 int a; 4575 struct { 4576 int b; 4577 float c; 4578 }; 4579 int d; 4580 }; 4581 $DECL_SPEC int unionTypeAddedField(union UnionTypeAddedField param);"; 4582 $SOURCE1 .= " 4583 int unionTypeAddedField(union UnionTypeAddedField param) { return 0; }"; 4584 4585 $HEADER2 .= " 4586 union UnionTypeAddedField 4587 { 4588 int a; 4589 struct { 4590 long double x, y; 4591 } new_field; 4592 struct { 4593 int b; 4594 float c; 4595 }; 4596 int d; 4597 }; 4598 $DECL_SPEC int unionTypeAddedField(union UnionTypeAddedField param);"; 4599 $SOURCE2 .= " 4600 int unionTypeAddedField(union UnionTypeAddedField param) { return 0; }"; 4601 4602 # Prameter_BaseType (typedef) 4603 $HEADER1 .= " 4604 typedef float TYPEDEF_TYPE; 4605 $DECL_SPEC int parameterTypedefChange(TYPEDEF_TYPE param);"; 4606 $SOURCE1 .= " 4607 int parameterTypedefChange(TYPEDEF_TYPE param) { return 1.0; }"; 4608 4609 $HEADER2 .= " 4610 typedef int TYPEDEF_TYPE; 4611 $DECL_SPEC int parameterTypedefChange(TYPEDEF_TYPE param);"; 4612 $SOURCE2 .= " 4613 int parameterTypedefChange(TYPEDEF_TYPE param) { return 1; }"; 4614 4615 # Field_BaseType (typedef in member type) 4616 $HEADER1 .= " 4617 typedef float TYPEDEF_TYPE_2; 4618 struct FieldBaseTypedefChange { 4619 TYPEDEF_TYPE_2 m; 4620 }; 4621 $DECL_SPEC int fieldBaseTypedefChange(struct FieldBaseTypedefChange param);"; 4622 $SOURCE1 .= " 4623 int fieldBaseTypedefChange(struct FieldBaseTypedefChange param) { return 1; }"; 4624 4625 $HEADER2 .= " 4626 typedef int TYPEDEF_TYPE_2; 4627 struct FieldBaseTypedefChange { 4628 TYPEDEF_TYPE_2 m; 4629 }; 4630 $DECL_SPEC int fieldBaseTypedefChange(struct FieldBaseTypedefChange param);"; 4631 $SOURCE2 .= " 4632 int fieldBaseTypedefChange(struct FieldBaseTypedefChange param) { return 1; }"; 4633 4634 # C++ keywords in C code 4635 $HEADER1 .= " 4636 $DECL_SPEC int testCppKeywords1(int class, int virtual, int (*new)(int));"; 4637 $SOURCE1 .= " 4638 $DECL_SPEC int testCppKeywords1(int class, int virtual, int (*new)(int)) { return 0; }"; 4639 4640 $HEADER2 .= " 4641 $DECL_SPEC int testCppKeywords1(int class, int virtual); 4642 $DECL_SPEC int testCppKeywords2(int operator, int other); 4643 $DECL_SPEC int testCppKeywords3(int operator); 4644 $DECL_SPEC int operator(int class, int this); 4645 $DECL_SPEC int delete(int virtual, int* this); 4646 struct CppKeywords { 4647 int bool: 8; 4648 //int*this; 4649 }; 4650 #ifdef __cplusplus 4651 class TestCppKeywords { 4652 void operator delete(void*); 4653 void operator ()(int); 4654 void operator,(int); 4655 void delete() { 4656 delete this; 4657 }; 4658 }; 4659 #endif"; 4660 $SOURCE2 .= " 4661 $DECL_SPEC int testCppKeywords1(int class, int virtual) { return 0; }"; 4662 4663 # Regression 4664 $HEADER1 .= " 4665 $DECL_SPEC int* testRegression(int *pointer, char const *name, ...);"; 4666 $SOURCE1 .= " 4667 int* testRegression(int *pointer, char const *name, ...) { return 0; }"; 4668 4669 $HEADER2 .= " 4670 $DECL_SPEC int* testRegression(int *pointer, char const *name, ...);"; 4671 $SOURCE2 .= " 4672 int* testRegression(int *pointer, char const *name, ...) { return 0; }"; 4673 4674 runTests("libsample_c", "C", $HEADER1, $SOURCE1, $HEADER2, $SOURCE2, "struct OpaqueType", "internalTypeUse"); 4675 } 4676 4677 sub runTests($$$$$$$$) 4678 { 4679 my ($LibName, $Lang, $HEADER1, $SOURCE1, $HEADER2, $SOURCE2, $Opaque, $Private) = @_; 4680 4681 my $SrcE = ($Lang eq "C++")?"cpp":"c"; 4682 rmtree($LibName); 4683 4684 my $ObjName = "libsample"; 4685 4686 # creating test suite 4687 my $Path_v1 = "$LibName/$ObjName.v1"; 4688 my $Path_v2 = "$LibName/$ObjName.v2"; 4689 mkpath($Path_v1); 4690 mkpath($Path_v2); 4691 writeFile("$Path_v1/$ObjName.h", $HEADER1."\n"); 4692 writeFile("$Path_v1/$ObjName.$SrcE", "#include \"$ObjName.h\"\n".$SOURCE1."\n"); 4693 writeFile("$LibName/v1.xml", " 4694 <version> 4695 1.0 4696 </version> 4697 4698 <headers> 4699 ".get_abs_path($Path_v1)." 4700 </headers> 4701 4702 <libs> 4703 ".get_abs_path($Path_v1)." 4704 </libs> 4705 4706 <skip_types> 4707 $Opaque 4708 </skip_types> 4709 4710 <skip_symbols> 4711 $Private 4712 </skip_symbols> 4713 4714 <include_paths> 4715 ".get_abs_path($Path_v1)." 4716 </include_paths>\n"); 4717 writeFile("$Path_v1/test.$SrcE", " 4718 #include \"$ObjName.h\" 4719 #include <stdio.h> 4720 ".($Lang eq "C++"?"using namespace TestNS;":"")." 4721 int main() 4722 { 4723 int ret = 0; 4724 printf(\"\%d\\n\", ret); 4725 return 0; 4726 }\n"); 4727 4728 writeFile("$Path_v2/$ObjName.h", $HEADER2."\n"); 4729 writeFile("$Path_v2/$ObjName.$SrcE", "#include \"$ObjName.h\"\n".$SOURCE2."\n"); 4730 writeFile("$LibName/v2.xml", " 4731 <version> 4732 2.0 4733 </version> 4734 4735 <headers> 4736 ".get_abs_path($Path_v2)." 4737 </headers> 4738 4739 <libs> 4740 ".get_abs_path($Path_v2)." 4741 </libs> 4742 4743 <skip_types> 4744 $Opaque 4745 </skip_types> 4746 4747 <skip_symbols> 4748 $Private 4749 </skip_symbols> 4750 4751 <include_paths> 4752 ".get_abs_path($Path_v2)." 4753 </include_paths>\n"); 4754 writeFile("$Path_v2/test.$SrcE", " 4755 #include \"$ObjName.h\" 4756 #include <stdio.h> 4757 ".($Lang eq "C++"?"using namespace TestNS;":"")." 4758 int main() 4759 { 4760 int ret = 0; 4761 printf(\"\%d\\n\", ret); 4762 return 0; 4763 }\n"); 4764 4765 my ($BuildCmd, $BuildCmd_Test) = ("", ""); 4766 if($OSgroup eq "windows") 4767 { 4768 check_win32_env(); # to run MS VC++ compiler 4769 my $CL = get_CmdPath("cl"); 4770 4771 if(not $CL) { 4772 exitStatus("Not_Found", "can't find \"cl\" compiler"); 4773 } 4774 $BuildCmd = "$CL /LD $ObjName.$SrcE >build_log.txt 2>&1"; 4775 $BuildCmd_Test = "$CL test.$SrcE $ObjName.$LIB_EXT"; 4776 } 4777 elsif($OSgroup eq "linux") 4778 { 4779 if($Lang eq "C") 4780 { # tests for symbol versioning 4781 writeFile("$Path_v1/version", " 4782 VERSION_1.0 { 4783 unchangedDefaultVersion; 4784 removedDefaultVersion; 4785 }; 4786 VERSION_2.0 { 4787 changedDefaultVersion; 4788 }; 4789 VERSION_3.0 { 4790 changedVersionToNonDefault; 4791 }; 4792 "); 4793 writeFile("$Path_v2/version", " 4794 VERSION_1.0 { 4795 unchangedDefaultVersion; 4796 changedVersionToDefault; 4797 }; 4798 VERSION_2.0 { 4799 addedDefaultVersion; 4800 }; 4801 VERSION_3.0 { 4802 changedDefaultVersion; 4803 }; 4804 "); 4805 $BuildCmd = $GCC_PATH." -Wl,--version-script version -shared $ObjName.$SrcE -o $ObjName.$LIB_EXT -g -Og"; 4806 $BuildCmd_Test = $GCC_PATH." -Wl,--version-script version test.$SrcE -Wl,$ObjName.$LIB_EXT -o test"; 4807 } 4808 else 4809 { 4810 $BuildCmd = $GCC_PATH." -shared -x c++ $ObjName.$SrcE -lstdc++ -o $ObjName.$LIB_EXT -g -Og"; 4811 $BuildCmd_Test = $GCC_PATH." -x c++ test.$SrcE -lstdc++ -Wl,$ObjName.$LIB_EXT -o test"; 4812 } 4813 if(getArch_GCC(1)=~/\A(arm|x86_64)\Z/i) 4814 { # relocation R_ARM_MOVW_ABS_NC against `a local symbol' can not be used when making a shared object; recompile with -fPIC 4815 $BuildCmd .= " -fPIC"; 4816 $BuildCmd_Test .= " -fPIC"; 4817 } 4818 } 4819 elsif($OSgroup eq "macos") 4820 { # using GCC -dynamiclib 4821 if($Lang eq "C") 4822 { 4823 $BuildCmd = $GCC_PATH." -dynamiclib $ObjName.$SrcE -o $ObjName.$LIB_EXT"; 4824 $BuildCmd_Test = $GCC_PATH." test.$SrcE $ObjName.$LIB_EXT -o test"; 4825 } 4826 else 4827 { # C++ 4828 $BuildCmd = $GCC_PATH." -dynamiclib -x c++ $ObjName.$SrcE -lstdc++ -o $ObjName.$LIB_EXT"; 4829 $BuildCmd_Test = $GCC_PATH." -x c++ test.$SrcE $ObjName.$LIB_EXT -o test"; 4830 } 4831 } 4832 else 4833 { # default unix-like 4834 # symbian target 4835 if($Lang eq "C") 4836 { 4837 $BuildCmd = $GCC_PATH." -shared $ObjName.$SrcE -o $ObjName.$LIB_EXT -g -Og"; 4838 $BuildCmd_Test = $GCC_PATH." test.$SrcE -Wl,$ObjName.$LIB_EXT -o test"; 4839 } 4840 else 4841 { # C++ 4842 $BuildCmd = $GCC_PATH." -shared -x c++ $ObjName.$SrcE -lstdc++ -o $ObjName.$LIB_EXT -g -Og"; 4843 $BuildCmd_Test = $GCC_PATH." -x c++ test.$SrcE -Wl,$ObjName.$LIB_EXT -o test"; 4844 } 4845 } 4846 4847 if(my $Opts = getGCC_Opts(1)) 4848 { # user-defined options 4849 $BuildCmd .= " ".$Opts; 4850 $BuildCmd_Test .= " ".$Opts; 4851 } 4852 4853 my $MkContent = "all:\n\t$BuildCmd\ntest:\n\t$BuildCmd_Test\n"; 4854 if($OSgroup eq "windows") { 4855 $MkContent .= "clean:\n\tdel test $ObjName.so\n"; 4856 } 4857 else { 4858 $MkContent .= "clean:\n\trm test $ObjName.so\n"; 4859 } 4860 writeFile("$Path_v1/Makefile", $MkContent); 4861 writeFile("$Path_v2/Makefile", $MkContent); 4862 system("cd $Path_v1 && $BuildCmd >build-log.txt 2>&1"); 4863 if($?) 4864 { 4865 my $Msg = "can't compile $LibName v.1: \'$Path_v1/build-log.txt\'"; 4866 if(readFile("$Path_v1/build-log.txt")=~/error trying to exec \W+cc1plus\W+/) { 4867 $Msg .= "\nDid you install G++?"; 4868 } 4869 exitStatus("Error", $Msg); 4870 } 4871 system("cd $Path_v2 && $BuildCmd >build-log.txt 2>&1"); 4872 if($?) { 4873 exitStatus("Error", "can't compile $LibName v.2: \'$Path_v2/build-log.txt\'"); 4874 } 4875 # executing the tool 4876 my @Cmd = ("perl", $0, "-l", $LibName); 4877 4878 if($TestABIDumper and $OSgroup eq "linux") 4879 { 4880 my @Cmd_d1 = ("abi-dumper", $Path_v1."/".$ObjName.".".$LIB_EXT, "-o", $LibName."/ABIv1.dump"); 4881 @Cmd_d1 = (@Cmd_d1, "-public-headers", $Path_v1, "-lver", "1.0"); 4882 if($Debug) 4883 { # debug mode 4884 printMsg("INFO", "executing @Cmd_d1"); 4885 } 4886 system(@Cmd_d1); 4887 printMsg("INFO", ""); 4888 4889 my @Cmd_d2 = ("abi-dumper", $Path_v2."/".$ObjName.".".$LIB_EXT, "-o", $LibName."/ABIv2.dump"); 4890 @Cmd_d2 = (@Cmd_d2, "-public-headers", $Path_v2, "-lver", "2.0"); 4891 if($Debug) 4892 { # debug mode 4893 printMsg("INFO", "executing @Cmd_d2"); 4894 } 4895 system(@Cmd_d2); 4896 printMsg("INFO", ""); 4897 4898 @Cmd = (@Cmd, "-old", $LibName."/ABIv1.dump", "-new", $LibName."/ABIv2.dump"); 4899 } 4900 else 4901 { 4902 @Cmd = (@Cmd, "-old", "$LibName/v1.xml", "-new", "$LibName/v2.xml"); 4903 } 4904 4905 if($Lang eq "C") { 4906 @Cmd = (@Cmd, "-cxx-incompatible"); 4907 } 4908 4909 if($TestDump) 4910 { 4911 @Cmd = (@Cmd, "-use-dumps"); 4912 if($SortDump) { 4913 @Cmd = (@Cmd, "-sort"); 4914 } 4915 } 4916 if($DumpFormat and $DumpFormat ne "perl") 4917 { # Perl Data::Dumper is default format 4918 @Cmd = (@Cmd, "-dump-format", $DumpFormat); 4919 } 4920 if($GCC_PATH ne "gcc") { 4921 @Cmd = (@Cmd, "-cross-gcc", $GCC_PATH); 4922 } 4923 if($Quiet) 4924 { # quiet mode 4925 @Cmd = (@Cmd, "-quiet"); 4926 @Cmd = (@Cmd, "-logging-mode", "a"); 4927 } 4928 elsif($LogMode and $LogMode ne "w") 4929 { # "w" is default 4930 @Cmd = (@Cmd, "-logging-mode", $LogMode); 4931 } 4932 if($ExtendedCheck) 4933 { # extended mode 4934 @Cmd = (@Cmd, "-extended"); 4935 if($Lang eq "C") { 4936 @Cmd = (@Cmd, "-lang", "C"); 4937 } 4938 } 4939 if($ReportFormat and $ReportFormat ne "html") 4940 { # HTML is default format 4941 @Cmd = (@Cmd, "-report-format", $ReportFormat); 4942 } 4943 if($CheckHeadersOnly) { 4944 @Cmd = (@Cmd, "-headers-only"); 4945 } 4946 if($OldStyle) { 4947 @Cmd = (@Cmd, "-old-style"); 4948 } 4949 if($Debug) 4950 { # debug mode 4951 @Cmd = (@Cmd, "-debug"); 4952 printMsg("INFO", "executing @Cmd"); 4953 } 4954 system(@Cmd); 4955 4956 my $ECode = $?>>8; 4957 4958 if($ECode!~/\A[0-1]\Z/) 4959 { # error 4960 exitStatus("Error", "analysis has failed"); 4961 } 4962 4963 my $RPath = "compat_reports/$LibName/1.0_to_2.0/compat_report.$ReportFormat"; 4964 my $NProblems = 0; 4965 if($ReportFormat eq "xml") 4966 { 4967 my $Content = readFile($RPath); 4968 # binary 4969 if(my $PSummary = parseTag(\$Content, "problem_summary")) 4970 { 4971 $NProblems += int(parseTag(\$PSummary, "removed_symbols")); 4972 if(my $TProblems = parseTag(\$PSummary, "problems_with_types")) 4973 { 4974 $NProblems += int(parseTag(\$TProblems, "high")); 4975 $NProblems += int(parseTag(\$TProblems, "medium")); 4976 } 4977 if(my $IProblems = parseTag(\$PSummary, "problems_with_symbols")) 4978 { 4979 $NProblems += int(parseTag(\$IProblems, "high")); 4980 $NProblems += int(parseTag(\$IProblems, "medium")); 4981 } 4982 } 4983 # source 4984 if(my $PSummary = parseTag(\$Content, "problem_summary")) 4985 { 4986 $NProblems += int(parseTag(\$PSummary, "removed_symbols")); 4987 if(my $TProblems = parseTag(\$PSummary, "problems_with_types")) 4988 { 4989 $NProblems += int(parseTag(\$TProblems, "high")); 4990 $NProblems += int(parseTag(\$TProblems, "medium")); 4991 } 4992 if(my $IProblems = parseTag(\$PSummary, "problems_with_symbols")) 4993 { 4994 $NProblems += int(parseTag(\$IProblems, "high")); 4995 $NProblems += int(parseTag(\$IProblems, "medium")); 4996 } 4997 } 4998 } 4999 else 5000 { 5001 my $BReport = readAttributes($RPath, 0); 5002 $NProblems += $BReport->{"removed"}; 5003 $NProblems += $BReport->{"type_problems_high"}+$BReport->{"type_problems_medium"}; 5004 $NProblems += $BReport->{"interface_problems_high"}+$BReport->{"interface_problems_medium"}; 5005 my $SReport = readAttributes($RPath, 1); 5006 $NProblems += $SReport->{"removed"}; 5007 $NProblems += $SReport->{"type_problems_high"}+$SReport->{"type_problems_medium"}; 5008 $NProblems += $SReport->{"interface_problems_high"}+$SReport->{"interface_problems_medium"}; 5009 } 5010 if(($LibName eq "libsample_c" and $NProblems>70) 5011 or ($LibName eq "libsample_cpp" and $NProblems>150)) { 5012 printMsg("INFO", "result: SUCCESS ($NProblems problems found)\n"); 5013 } 5014 else { 5015 printMsg("ERROR", "result: FAILED ($NProblems problems found)\n"); 5016 } 5017 } 5018 5019 return 1;