summaryrefslogtreecommitdiffstats
path: root/languages/cpp/compiler/gccoptions/gccoptionsplugin.cpp
blob: 23e8a551315a356afe53ff5c44b0d2198c97b134 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
/***************************************************************************
*   Copyright (C) 2000-2001 by Bernd Gehrmann                             *
*   [email protected]                                                    *
*                                                                         *
*   This program is free software; you can redistribute it and/or modify  *
*   it under the terms of the GNU General Public License as published by  *
*   the Free Software Foundation; either version 2 of the License, or     *
*   (at your option) any later version.                                   *
*                                                                         *
***************************************************************************/

#include <tqapplication.h>
#include <tqlabel.h>
#include <tqvbuttongroup.h>
#include <tqradiobutton.h>
#include <tqvaluelist.h>
#include <tqtabwidget.h>
#include <tqlayout.h>
#include <tqvbox.h>
#include <kdialog.h>
#include <tdelocale.h>
#include <kgenericfactory.h>

#include "flagboxes.h"
#include "gccoptionsplugin.h"

K_EXPORT_COMPONENT_FACTORY( libkdevgccoptions, KGenericFactory<GccOptionsPlugin>( "kdevgccoptions" ) )

class GeneralTab : public TQWidget
{
public:
	GeneralTab( GccOptionsPlugin::Type type, TQWidget *parent = 0, const char *name = 0 );
	~GeneralTab();

	void readFlags( TQStringList *str );
	void writeFlags( TQStringList *str );

private:
	FlagCheckBoxController *controller;
};


class OptimizationTab : public TQWidget
{
public:
	OptimizationTab( GccOptionsPlugin::Type type, TQWidget *parent = 0, const char *name = 0 );
	~OptimizationTab();

	void readFlags( TQStringList *str );
	void writeFlags( TQStringList *str );

private:
	TQRadioButton *Odefault, *O0, *O1, *O2;
	FlagListBox *optBox;
};


class G77Tab : public TQWidget
{
public:
	G77Tab( TQWidget *parent = 0, const char *name = 0 );
	~G77Tab();

	void readFlags( TQStringList *str );
	void writeFlags( TQStringList *str );

private:
	FlagCheckBoxController *controller;
};


class Warnings1Tab : public TQWidget
{
public:
	Warnings1Tab( GccOptionsPlugin::Type type, TQWidget *parent = 0, const char *name = 0 );
	~Warnings1Tab();

	void readFlags( TQStringList *str );
	void writeFlags( TQStringList *str );

private:
	FlagCheckBoxController *controller;
	FlagListBox *wallBox;
};


class Warnings2Tab : public TQWidget
{
public:
	Warnings2Tab( GccOptionsPlugin::Type type, TQWidget *parent = 0, const char *name = 0 );
	~Warnings2Tab();

	void readFlags( TQStringList *str );
	void writeFlags( TQStringList *str );

private:
	FlagListBox *wrestBox;
};


GeneralTab::GeneralTab( GccOptionsPlugin::Type type, TQWidget *parent, const char *name )
		: TQWidget( parent, name ), controller( new FlagCheckBoxController )
{
	TQBoxLayout * layout = new TQVBoxLayout( this, KDialog::marginHint(), KDialog::spacingHint() );
	layout->setAutoAdd( true );
	layout->addSpacing( 10 );

	TQVButtonGroup *output_group = new TQVButtonGroup( i18n( "Output" ), this );
	new FlagCheckBox( output_group, controller,
	                  "-fsyntax-only", i18n( "Only check the code for syntax errors, do not produce object code" ) );
	new FlagCheckBox( output_group, controller,
	                  "-pg", i18n( "Generate extra code to write profile information for gprof" ) );
	new FlagCheckBox( output_group, controller,
	                  "-save-temps", i18n( "Do not delete intermediate output like assembler files" ) );

	TQApplication::sendPostedEvents( this, TQEvent::ChildInserted );
	layout->addSpacing( 10 );

	TQVButtonGroup *codegen_group = new TQVButtonGroup( i18n( "Code Generation" ), this );
	if ( type != GccOptionsPlugin::GPP )
	{
		new FlagCheckBox( codegen_group, controller,
		                  "-fexceptions", i18n( "Enable exception handling" ),
		                  "-fno-exception" );
	}
	else
	{
		new FlagCheckBox( codegen_group, controller,
		                  "-fno-exceptions", i18n( "Disable exception handling" ),
		                  "-fexception" );
	}
	// The following two are somehow mutually exclusive, but the default is
	// platform-dependent, so if we would leave out one of them, we wouldn't
	// know how to set the remaining one.
	new FlagCheckBox( codegen_group, controller,
	                  "-fpcc-struct-return", i18n( "Return certain struct and union values in memory rather than in registers" ) );
	new FlagCheckBox( codegen_group, controller,
	                  "-freg-struct-return", i18n( "Return certain struct and union values in registers when possible" ) );
	new FlagCheckBox( codegen_group, controller,
	                  "-short-enums", i18n( "For an enum, choose the smallest possible integer type" ) );
	new FlagCheckBox( codegen_group, controller,
	                  "-short-double", i18n( "Make 'double' the same as 'float'" ) );

	TQApplication::sendPostedEvents( this, TQEvent::ChildInserted );
	layout->addStretch();
}


GeneralTab::~GeneralTab()
{
	delete controller;
}


void GeneralTab::readFlags( TQStringList *list )
{
	controller->readFlags( list );
}


void GeneralTab::writeFlags( TQStringList *list )
{
	controller->writeFlags( list );
}


OptimizationTab::OptimizationTab( GccOptionsPlugin::Type type, TQWidget *parent, const char *name )
		: TQWidget( parent, name )
{
	TQBoxLayout * layout = new TQVBoxLayout( this, KDialog::marginHint(), KDialog::spacingHint() );
	layout->setAutoAdd( true );

	TQVButtonGroup *group = new TQVButtonGroup( i18n( "Optimization Level" ), this );
	Odefault = new TQRadioButton( i18n( "Default" ), group );
	Odefault->setChecked( true );
	O0 = new TQRadioButton( i18n( "No optimization" ), group );
	O1 = new TQRadioButton( i18n( "Level 1" ), group );
	O2 = new TQRadioButton( i18n( "Level 2" ), group );

	optBox = new FlagListBox( this );

	new FlagListItem( optBox,
	                  "-ffloat-store", i18n( "<qt>Do not store floating point variables in registers</qt>" ),
	                  "-fno-float-store" );
	new FlagListItem( optBox,
	                  "-fno-defer-pop", i18n( "<qt>Pop the arguments to each function call directly "
	                                          "after the function returns</qt>" ),
	                  "-fdefer-pop" );
	new FlagListItem( optBox,
	                  "-fforce-mem", i18n( "<qt>Force memory operands to be copied into registers before "
	                                       "doing arithmetic on them</qt>" ),
	                  "-fno-force-mem" );
	new FlagListItem( optBox,
	                  "-fforce-addr", i18n( "<qt>Force memory address constants to be copied into registers before "
	                                        "doing arithmetic on them</qt>" ),
	                  "-fno-force-addr" );
	new FlagListItem( optBox,
	                  "-fomit-frame-pointer", i18n( "<qt>Do not keep the frame pointer in a register for functions that "
	                                               "do not need one</qt>" ),
	                  "-fno-omit-frame-pointer" );
	new FlagListItem( optBox,
	                  "-fno-inline", i18n( "<qt>Ignore the <i>inline</i> keyword</qt>" ),
	                  "-finline" );

	if ( type == GccOptionsPlugin::GPP )
	{
		new FlagListItem( optBox,
		                  "-fno-default-inline", i18n( "<qt>Do not make member functions inline merely because they "
		                                               "are defined inside the class scope</qt>" ),
		                  "-fdefault-inline" );
	}

	TQApplication::sendPostedEvents( this, TQEvent::ChildInserted );
	layout->addStretch();
}


OptimizationTab::~OptimizationTab()
{}


void OptimizationTab::readFlags( TQStringList *list )
{
	optBox->readFlags( list );

	TQStringList::Iterator sli;
	sli = list->find( "-O0" );
	if ( sli != list->end() )
	{
		O0->setChecked( true );
		list->remove
		( sli );
	}
	sli = list->find( "-O1" );
	if ( sli != list->end() )
	{
		O1->setChecked( true );
		list->remove
		( sli );
	}
	sli = list->find( "-O2" );
	if ( sli != list->end() )
	{
		O2->setChecked( true );
		list->remove
		( sli );
	}
}


void OptimizationTab::writeFlags( TQStringList *list )
{
	optBox->writeFlags( list );

	if ( O0->isChecked() )
		( *list ) << "-O0";
	else if ( O1->isChecked() )
		( *list ) << "-O1";
	else if ( O2->isChecked() )
		( *list ) << "-O2";
}


G77Tab::G77Tab( TQWidget *parent, const char *name )
		: TQWidget( parent, name ), controller( new FlagCheckBoxController )
{
	TQBoxLayout * layout = new TQVBoxLayout( this, KDialog::marginHint(), KDialog::spacingHint() );
	layout->setAutoAdd( true );
	layout->addSpacing( 10 );

	TQVButtonGroup *dialect_group = new TQVButtonGroup( i18n( "Dialect" ), this );
	new FlagCheckBox( dialect_group, controller,
	                  "-ffree-form", i18n( "Interpret source code as Fortran 90 free form" ),
	                  "-fno-exception" );
	new FlagCheckBox( dialect_group, controller,
	                  "-ff90", i18n( "Allow certain Fortran 90 constructs" ) );
	new FlagCheckBox( dialect_group, controller,
	                  "-fdollar-ok", i18n( "Allow '$' in symbol names" ) );
	new FlagCheckBox( dialect_group, controller,
	                  "-fbackslash", i18n( "Allow '\' in character constants to escape special characters" ),
	                  "-fno-backslah" );
	new FlagCheckBox( dialect_group, controller,
	                  "-fonetrip", i18n( "DO loops are executed at least once" ) );

	TQApplication::sendPostedEvents( this, TQEvent::ChildInserted );
	layout->addSpacing( 10 );

	TQVButtonGroup *codegen_group = new TQVButtonGroup( i18n( "Code Generation" ), this );
	new FlagCheckBox( codegen_group, controller,
	                  "-fno-automatic", i18n( "Treat local variables as if SAVE statement had been specified" ) );
	new FlagCheckBox( codegen_group, controller,
	                  "-finit-local-zero", i18n( "Init local variables to zero" ) );
	new FlagCheckBox( codegen_group, controller,
	                  "-fbounds-check", i18n( "Generate run-time checks for array subscripts" ) );

	TQApplication::sendPostedEvents( this, TQEvent::ChildInserted );
	layout->addStretch();
}


G77Tab::~G77Tab()
{
	delete controller;
}


void G77Tab::readFlags( TQStringList *list )
{
	controller->readFlags( list );
}


void G77Tab::writeFlags( TQStringList *list )
{
	controller->writeFlags( list );
}


Warnings1Tab::Warnings1Tab( GccOptionsPlugin::Type type, TQWidget *parent, const char *name )
		: TQWidget( parent, name ), controller( new FlagCheckBoxController )
{
	TQBoxLayout * layout = new TQVBoxLayout( this, KDialog::marginHint(), KDialog::spacingHint() );
	layout->setAutoAdd( true );

	new FlagCheckBox( this, controller,
	                  "-w", i18n( "Inhibit all warnings" ) );
	new FlagCheckBox( this, controller,
	                  "-Wno-import", i18n( "Inhibit warnings about the use of #import" ) );
	new FlagCheckBox( this, controller,
	                  "-Werror", i18n( "Make all warnings into errors" ) );
	new FlagCheckBox( this, controller,
	                  "-pedantic", i18n( "Issue all warnings demanded by strict ANSI C or ISO C++" ) );
	new FlagCheckBox( this, controller,
	                  "-pedantic-errors", i18n( "Like -pedantic, but errors are produced instead of warnings" ) );
	new FlagCheckBox( this, controller,
	                  "-Wall", i18n( "All warnings below, combined (-Wall):" ) );

	wallBox = new FlagListBox( this );

	new FlagListItem( wallBox,
	                  "-Wchar-subscripts", i18n( "<qt>Warn if an array subscript has type <i>char</i></qt>" ) );
	new FlagListItem( wallBox,
	                  "-Wcomment", i18n( "<qt>Warn when a comment-start sequence /* appears inside a comment</qt>" ) );
	new FlagListItem( wallBox,
	                  "-Wformat", i18n( "<qt>Check calls to <i>printf()</i>, <i>scanf()</i> etc\n"
	                                    "to make sure that the arguments supplied have types appropriate\n"
	                                    "to the format string specified, and that the conversions specified\n"
	                                    "in the format string make sense</qt>" ) );
	new FlagListItem( wallBox,
	                  "-Wformat=2", i18n( "<qt>Enable -Wformat plus format checks not \n"
				              "included in -Wformat. Currently equivalent to \n"
					      "`-Wformat -Wformat-nonliteral -Wformat-security \n"
					      "-Wformat-y2k'.</qt>" ) );
	new FlagListItem( wallBox,
	                  "-Wimplicit-int", i18n( "<qt>Warn when a declaration does not specify a type</qt>" ) );
	new FlagListItem( wallBox,
	                  "-Wimplicit-funtion-declaration",
	                  i18n( "<qt>Issue a warning when a non-declared function is used</qt>" ) );
	new FlagListItem( wallBox,
	                  "-Werror-implicit-function-declaration",
	                  i18n( "<qt>Issue an error when a non-declared function is used</qt>" ) );
	new FlagListItem( wallBox,
	                  "-Wmain", i18n( "<qt>Warn if the type of <i>main()</i> is suspicious</qt>" ) );
	new FlagListItem( wallBox,
	                  "-Wmultichar", i18n( "<qt>Warn when multicharacter constants are encountered</qt>" ) );
	new FlagListItem( wallBox,
	                  "-Wmissing-braces", i18n( "<qt>Warn if an aggregate or union initializer is not fully bracketed</qt>" ) );
	new FlagListItem( wallBox,
	                  "-Wparentheses", i18n( "<qt>Warn when parentheses are omitted in certain contexts</qt>" ) );
	new FlagListItem( wallBox,
	                  "-Wsequence-point", i18n( "<qt>Warn about code that may have undefined semantics because of\n"
	                                            "violations of sequence point rules in the C standard</qt>" ) );
	new FlagListItem( wallBox,
	                  "-Wreturn-type", i18n( "<qt>Warn when a function without explicit return type is defined</qt>" ) );
	new FlagListItem( wallBox,
	                  "-Wswitch", i18n( "<qt>Warn whenever a <i>switch</i> statement has an index of enumeral type\n"
	                                    "and lacks a <i>case</i> for one or more of the named codes of that enumeration</qt>" ) );
	new FlagListItem( wallBox,
	                  "-Wtrigraphs", i18n( "<qt>Warn when trigraphs are encountered</qt>" ) );
	new FlagListItem( wallBox,
	                  "-Wunused", i18n( "<qt>Warn when a variable is declared but not used</qt>" ) );
	new FlagListItem( wallBox,
	                  "-Wuninitialized", i18n( "<qt>Warn when a variable is used without being initialized first</qt>" ) );
	new FlagListItem( wallBox,
	                  "-Wunknown-pragmas", i18n( "<qt>Warn when an unknown #pragma statement is encountered</qt>" ) );
	new FlagListItem( wallBox,
	                  "-Wdiv-by-zero", i18n( "<qt>Warn when a division by zero occurs.</qt>" ) );
	if ( type == GccOptionsPlugin::GPP )
	{
		new FlagListItem( wallBox,
		                  "-Wreorder", i18n( "<qt>Warn when the order of member initializers is different from\n"
		                                     "the order in the class declaration</qt>" ) );
	}
}


Warnings1Tab::~Warnings1Tab()
{
	delete controller;
}


void Warnings1Tab::readFlags( TQStringList *list )
{
	controller->readFlags( list );
	wallBox->readFlags( list );
}


void Warnings1Tab::writeFlags( TQStringList *list )
{
	controller->writeFlags( list );
	wallBox->writeFlags( list );
}


Warnings2Tab::Warnings2Tab( GccOptionsPlugin::Type type, TQWidget *parent, const char *name )
		: TQWidget( parent, name )
{
	TQBoxLayout * layout = new TQVBoxLayout( this, KDialog::marginHint(), KDialog::spacingHint() );
	layout->setAutoAdd( true );

	wrestBox = new FlagListBox( this );

	new FlagListItem( wrestBox,
	                  "-W", i18n( "<qt>Set options not included in -Wall which are very specific</qt>" ) );
	new FlagListItem( wrestBox,
	                  "-Wfloat-equal", i18n( "<qt>Warn if floating point values are used in equality comparisons</qt>" ) );
	new FlagListItem( wrestBox,
	                  "-Wundef", i18n( "<qt>Warn if an undefined identifier is evaluated in an <i>#if</i> directive</qt>" ) );
	new FlagListItem( wrestBox,
	                  "-Wshadow", i18n( "<qt>Warn whenever a local variable shadows another local variable</qt>" ) );
	new FlagListItem( wrestBox,
	                  "-Wpointer-arith", i18n( "<qt>Warn about anything that depends on the <i>sizeof</i> a\n"
	                                           "function type or of <i>void</i></qt>" ) );
	new FlagListItem( wrestBox,
	                  "-Wcast-qual", i18n( "<qt>Warn whenever a pointer is cast so as to remove a type\n"
	                                       "qualifier from the target type</qt>" ) );
	new FlagListItem( wrestBox,
	                  "-Wcast-align", i18n( "<qt>Warn whenever a pointer is cast such that the required\n"
	                                        "alignment of the target is increased</qt>" ) );
	new FlagListItem( wrestBox,
	                  "-Wwrite-strings", i18n( "<qt>Warn when the address of a string constant is cast\n"
	                                           "into a non-const <i>char *</i> pointer</qt>" ) );
	new FlagListItem( wrestBox,
	                  "-Wconversion", i18n( "<qt>Warn if a prototype causes a type conversion that is different\n"
	                                        "from what would happen to the same argument in the absence\n"
	                                        "of a prototype</qt>" ) );
	new FlagListItem( wrestBox,
	                  "-Wsign-compare", i18n( "<qt>Warn when a comparison between signed and unsigned values\n"
	                                          "could produce an incorrect result when the signed value\n"
	                                          "is converted to unsigned</qt>" ) );
	new FlagListItem( wrestBox,
	                  "-Wmissing-noreturn", i18n( "<qt>Warn about functions which might be candidates for attribute 'noreturn'</qt>" ) );
	new FlagListItem( wrestBox,
	                  "-Waggregate-return", i18n( "<qt>Warn if any functions that return structures or unions are\n"
	                                              "defined or called</qt>" ) );
	new FlagListItem( wrestBox,
	                  "-Wmissing-declarations", i18n( "<qt>Warn if a global function is defined without a previous declaration</qt>" ) );
	new FlagListItem( wrestBox,
	                  "-Wno-deprecated-declarations",
	                  i18n( "<qt>Do not warn about uses of functions, variables, and types marked as\n"
	                        "deprecated by using the 'deprecated' attribute</qt>" ) );
	new FlagListItem( wrestBox,
	                  "-Wpacked", i18n( "<qt>Warn if a structure is given the packed attribute, but the packed\n"
	                                    "attribute has no effect on the layout or size of the structure</qt>" ) );
	new FlagListItem( wrestBox,
	                  "-Wpadded", i18n( "<qt>Warn if padding is included in a structure, either to align an\n"
	                                    "element of the structure or to align the whole structure</qt>" ) );
	new FlagListItem( wrestBox,
	                  "-Wredundant-decls", i18n( "<qt>Warn if anything is declared more than once in the same scope</qt>" ) );
	new FlagListItem( wrestBox,
	                  "-Wunreachable-code", i18n( "<qt>Warn if the compiler detects that code will never be executed</qt>" ) );
	new FlagListItem( wrestBox,
	                  "-Winline", i18n( "<qt>Warn if an <i>inline</i> function cannot be inlined</qt>" ) );
	new FlagListItem( wrestBox,
	                  "-Wlong-long", i18n( "<qt>Warn if the <i>long long</i> type is used</qt>" ) );
	new FlagListItem( wrestBox,
	                  "-Wdisabled-optimization", i18n( "<qt>Warn if a requested optimization pass is disabled</qt>" ) );
	new FlagListItem( wrestBox,
	                  "-Wno-div-by-zero", i18n( "<qt>Do not warn if there is a division by zero</qt>" ) );

	if ( type == GccOptionsPlugin::GCC )
	{
		new FlagListItem( wrestBox,
		                  "-Wtraditional", i18n( "<qt>Warn about certain constructs that behave differently\n"
		                                         "in traditional and ANSI C</qt>" ) );
		new FlagListItem( wrestBox,
		                  "-Wbad-function-cast", i18n( "<qt>Warn whenever a function call is cast to a non-matching type</qt>" ) );
		new FlagListItem( wrestBox,
		                  "-Wstrict-prototypes", i18n( "<qt>Warn if a function is declared or defined without specifying\n"
		                                               "the argument types</qt>" ) );
		new FlagListItem( wrestBox,
		                  "-Wmissing-prototypes", i18n( "<qt>Warn if a global function is defined without a previous prototype declaration</qt>" ) );
		new FlagListItem( wrestBox,
		                  "-Wnested-externs", i18n( "<qt>Warn if an <i>extern</i> declaration is encountered within a function</qt>" ) );
	}


	if ( type == GccOptionsPlugin::GPP )
	{
		new FlagListItem( wrestBox,
		                  "-Woverloaded-virtual", i18n( "<qt>Warn when a function declaration hides virtual\n"
		                                                "functions from a base class</qt>" ) );
		new FlagListItem( wrestBox,
		                  "-Wsynth", i18n( "<qt>Warn when g++'s synthesis behavior does\n"
		                                   "not match that of cfront</qt>" ) );
		new FlagListItem( wrestBox,
		                  "-Wctor-dtor-privacy", i18n( "<qt>Warn when a class seems unusable, because all the constructors or\n"
		                                               "destructors in a class are private and the class has no friends or\n"
		                                               "public static member functions</qt>" ) );
		new FlagListItem( wrestBox,
		                  "-Wnon-virtual-dtor", i18n( "<qt>Warn when a class declares a non-virtual destructor that should\n"
		                                              "probably be virtual, because it looks like the class will be used\n"
		                                              "polymorphically</qt>" ) );
		new FlagListItem( wrestBox,
		                  "-Wsign-promo", i18n( "<qt>Warn when overload resolution chooses a promotion from unsigned or\n"
		                                        "enumeral type to a signed type over a conversion to an unsigned\n"
		                                        "type of the same size. Previous versions of G++ would try to\n"
		                                        "preserve unsignedness, but the standard mandates the current behavior</qt>" ) );
		new FlagListItem( wrestBox,
		                  "-Wabi", i18n( "<qt>Warn when G++ generates code that is probably not compatible with\n"
		                                 "the vendor-neutral C++ ABI</qt>" ) );
		/*    new FlagListItem(wrestBox,
		                     "-Wreorder",             i18n("<qt>Warn when the order of member initializers given in the code does\n"
		                                                   "not match the order in which they must be executed.</qt>"));*/
		new FlagListItem( wrestBox,
		                  "-Weffc++", i18n( "<qt>Warn about violations of the following style guidelines from Scott\n"
		                                    "Meyers' 'Effective C++' book:\n"
		                                    "* Item 11:  Define a copy constructor and an assignment\n"
		                                    "  operator for classes with dynamically allocated memory;\n"
		                                    "* Item 12:  Prefer initialization to assignment in constructors;\n"
		                                    "* Item 14:  Make destructors virtual in base classes;\n"
		                                    "* Item 15:  Have `operator=' return a reference to `*this';\n"
		                                    "* Item 23:  Do not try to return a reference when you must\n"
		                                    "  return an object\n"
		                                    "\n"
		                                    "and about violations of the following style guidelines from Scott\n"
		                                    "Meyers' 'More Effective C++' book:\n"
		                                    "* Item 6:  Distinguish between prefix and postfix forms of\n"
		                                    "  increment and decrement operators;\n"
		                                    "* Item 7:  Never overload '&&', '||', or ','</qt>" ) );
		new FlagListItem( wrestBox,
		                  "-Wno-deprecated", i18n( "<qt>Do not warn about usage of deprecated features</qt>" ) );
		new FlagListItem( wrestBox,
		                  "-Wno-non-template-friend", i18n( "<qt>Disable warnings when non-templatized friend functions are declared\n"
		                                                    "within a template</qt>" ) );
		new FlagListItem( wrestBox,
		                  "-Wold-style-cast", i18n( "<qt>Warn if an old-style (C-style) cast to a non-void type is used\n"
		                                            "within a C++ program</qt>" ) );
		new FlagListItem( wrestBox,
		                  "-Wno-pmf-conversions", i18n( "<qt>Disable the diagnostic for converting a bound pointer to member\n"
		                                                "function to a plain pointer</qt>" ) );
	}
}


Warnings2Tab::~Warnings2Tab()
{}


void Warnings2Tab::readFlags( TQStringList *list )
{
	wrestBox->readFlags( list );
}


void Warnings2Tab::writeFlags( TQStringList *list )
{
	wrestBox->writeFlags( list );
}


// Last but not least... :-)
GccOptionsDialog::GccOptionsDialog( GccOptionsPlugin::Type type, TQWidget *parent, const char *name )
		: KDialogBase( Tabbed, GccOptionsPlugin::captionForType( type ), Ok | Cancel, Ok, parent, name, true )
{
	TQVBox * vbox;

	vbox = addVBoxPage( i18n( "General" ) );
	general = new GeneralTab( type, vbox, "general tab" );

	vbox = addVBoxPage( i18n( "Optimization" ) );
	optimization = new OptimizationTab( type, vbox, "optimization tab" );

	if ( type == GccOptionsPlugin::G77 )
	{
		vbox = addVBoxPage( i18n( "Fortran Specifics" ) );
		g77 = new G77Tab( vbox, "g77 tab" );
	}
	else
		g77 = 0;

	vbox = addVBoxPage( i18n( "Warnings (safe)" ) );
	warnings1 = new Warnings1Tab( type, vbox, "warnings1 tab" );

	vbox = addVBoxPage( i18n( "Warnings (unsafe)" ) );
	warnings2 = new Warnings2Tab( type, vbox, "warnings2 tab" );
}


GccOptionsDialog::~GccOptionsDialog()
{}


void GccOptionsDialog::setFlags( const TQString &flags )
{
	TQStringList flaglist = TQStringList::split( " ", flags );

	// Hand them to 'general' at last, so it can make a line edit
	// with the unprocessed items
	if ( g77 )
		g77->readFlags( &flaglist );
	optimization->readFlags( &flaglist );
	warnings1->readFlags( &flaglist );
	warnings2->readFlags( &flaglist );
	general->readFlags( &flaglist );
	unrecognizedFlags = flaglist;
}


TQString GccOptionsDialog::flags() const
{
	TQStringList flaglist;

	if ( g77 )
		g77->writeFlags( &flaglist );
	optimization->writeFlags( &flaglist );
	warnings1->writeFlags( &flaglist );
	warnings2->writeFlags( &flaglist );
	general->writeFlags( &flaglist );

	TQString flags;
	TQStringList::ConstIterator li;
	for ( li = flaglist.begin(); li != flaglist.end(); ++li )
	{
		flags += ( *li );
		flags += " ";
	}

	for ( li = unrecognizedFlags.begin(); li != unrecognizedFlags.end(); ++li )
	{
		flags += ( *li );
		flags += " ";
	}

	flags.truncate( flags.length() - 1 );
	return flags;
}


GccOptionsPlugin::GccOptionsPlugin( TQObject *parent, const char *name, const TQStringList &args )
		: KDevCompilerOptions( parent, name )
{
	gcctype = Unknown;

	if ( args.count() == 0 )
		return ;

	TQString typeStr = args[ 0 ];

	if ( typeStr == "gcc" )
		gcctype = GccOptionsPlugin::GCC;
	else if ( typeStr == "g++" )
		gcctype = GccOptionsPlugin::GPP;
	else if ( typeStr == "g77" )
		gcctype = GccOptionsPlugin::G77;
}


GccOptionsPlugin::~GccOptionsPlugin()
{}


TQString GccOptionsPlugin::captionForType( Type type )
{
	switch ( type )
	{
	case GCC:
		return i18n( "GNU C Compiler Options" );
	case GPP:
		return i18n( "GNU C++ Compiler Options" );
	case G77:
		return i18n( "GNU Fortran 77 Compiler Options" );
	default:
		return TQString();
	}
}


TQString GccOptionsPlugin::exec( TQWidget *parent, const TQString &flags )
{
	if ( gcctype == Unknown )
		return TQString();
	GccOptionsDialog *dlg = new GccOptionsDialog( gcctype, parent, "gcc options dialog" );
	TQString newFlags = flags;
	dlg->setFlags( flags );
	if ( dlg->exec() == TQDialog::Accepted )
		newFlags = dlg->flags();
	delete dlg;
	return newFlags;
}

#include "gccoptionsplugin.moc"
//kate: indent-mode csands; tab-width 4; space-indent off;