~ubuntu-branches/debian/sid/kdevelop/sid

« back to all changes in this revision

Viewing changes to languages/cpp/compiler/gccoptions/gccoptionsplugin.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jeremy Lainé
  • Date: 2010-05-05 07:21:55 UTC
  • mfrom: (1.2.3 upstream) (5.1.2 squeeze)
  • Revision ID: james.westby@ubuntu.com-20100505072155-h78lx19pu04sbhtn
Tags: 4:4.0.0-2
* Upload to unstable (Closes: #579947, #481832).
* Acknowledge obsolete NMU fixes (Closes: #562410, #546961).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/***************************************************************************
2
 
*   Copyright (C) 2000-2001 by Bernd Gehrmann                             *
3
 
*   bernd@kdevelop.org                                                    *
4
 
*                                                                         *
5
 
*   This program is free software; you can redistribute it and/or modify  *
6
 
*   it under the terms of the GNU General Public License as published by  *
7
 
*   the Free Software Foundation; either version 2 of the License, or     *
8
 
*   (at your option) any later version.                                   *
9
 
*                                                                         *
10
 
***************************************************************************/
11
 
 
12
 
#include <qapplication.h>
13
 
#include <qlabel.h>
14
 
#include <qvbuttongroup.h>
15
 
#include <qradiobutton.h>
16
 
#include <qvaluelist.h>
17
 
#include <qtabwidget.h>
18
 
#include <qlayout.h>
19
 
#include <qvbox.h>
20
 
#include <kdialog.h>
21
 
#include <klocale.h>
22
 
#include <kgenericfactory.h>
23
 
 
24
 
#include "flagboxes.h"
25
 
#include "gccoptionsplugin.h"
26
 
 
27
 
K_EXPORT_COMPONENT_FACTORY( libkdevgccoptions, KGenericFactory<GccOptionsPlugin>( "kdevgccoptions" ) )
28
 
 
29
 
class GeneralTab : public QWidget
30
 
{
31
 
public:
32
 
        GeneralTab( GccOptionsPlugin::Type type, QWidget *parent = 0, const char *name = 0 );
33
 
        ~GeneralTab();
34
 
 
35
 
        void readFlags( QStringList *str );
36
 
        void writeFlags( QStringList *str );
37
 
 
38
 
private:
39
 
        FlagCheckBoxController *controller;
40
 
};
41
 
 
42
 
 
43
 
class OptimizationTab : public QWidget
44
 
{
45
 
public:
46
 
        OptimizationTab( GccOptionsPlugin::Type type, QWidget *parent = 0, const char *name = 0 );
47
 
        ~OptimizationTab();
48
 
 
49
 
        void readFlags( QStringList *str );
50
 
        void writeFlags( QStringList *str );
51
 
 
52
 
private:
53
 
        QRadioButton *Odefault, *O0, *O1, *O2;
54
 
        FlagListBox *optBox;
55
 
};
56
 
 
57
 
 
58
 
class G77Tab : public QWidget
59
 
{
60
 
public:
61
 
        G77Tab( QWidget *parent = 0, const char *name = 0 );
62
 
        ~G77Tab();
63
 
 
64
 
        void readFlags( QStringList *str );
65
 
        void writeFlags( QStringList *str );
66
 
 
67
 
private:
68
 
        FlagCheckBoxController *controller;
69
 
};
70
 
 
71
 
 
72
 
class Warnings1Tab : public QWidget
73
 
{
74
 
public:
75
 
        Warnings1Tab( GccOptionsPlugin::Type type, QWidget *parent = 0, const char *name = 0 );
76
 
        ~Warnings1Tab();
77
 
 
78
 
        void readFlags( QStringList *str );
79
 
        void writeFlags( QStringList *str );
80
 
 
81
 
private:
82
 
        FlagCheckBoxController *controller;
83
 
        FlagListBox *wallBox;
84
 
};
85
 
 
86
 
 
87
 
class Warnings2Tab : public QWidget
88
 
{
89
 
public:
90
 
        Warnings2Tab( GccOptionsPlugin::Type type, QWidget *parent = 0, const char *name = 0 );
91
 
        ~Warnings2Tab();
92
 
 
93
 
        void readFlags( QStringList *str );
94
 
        void writeFlags( QStringList *str );
95
 
 
96
 
private:
97
 
        FlagListBox *wrestBox;
98
 
};
99
 
 
100
 
 
101
 
GeneralTab::GeneralTab( GccOptionsPlugin::Type type, QWidget *parent, const char *name )
102
 
                : QWidget( parent, name ), controller( new FlagCheckBoxController )
103
 
{
104
 
        QBoxLayout * layout = new QVBoxLayout( this, KDialog::marginHint(), KDialog::spacingHint() );
105
 
        layout->setAutoAdd( true );
106
 
        layout->addSpacing( 10 );
107
 
 
108
 
        QVButtonGroup *output_group = new QVButtonGroup( i18n( "Output" ), this );
109
 
        new FlagCheckBox( output_group, controller,
110
 
                          "-fsyntax-only", i18n( "Only check the code for syntax errors, do not produce object code" ) );
111
 
        new FlagCheckBox( output_group, controller,
112
 
                          "-pg", i18n( "Generate extra code to write profile information for gprof" ) );
113
 
        new FlagCheckBox( output_group, controller,
114
 
                          "-save-temps", i18n( "Do not delete intermediate output like assembler files" ) );
115
 
 
116
 
        QApplication::sendPostedEvents( this, QEvent::ChildInserted );
117
 
        layout->addSpacing( 10 );
118
 
 
119
 
        QVButtonGroup *codegen_group = new QVButtonGroup( i18n( "Code Generation" ), this );
120
 
        if ( type != GccOptionsPlugin::GPP )
121
 
        {
122
 
                new FlagCheckBox( codegen_group, controller,
123
 
                                  "-fexceptions", i18n( "Enable exception handling" ),
124
 
                                  "-fno-exception" );
125
 
        }
126
 
        else
127
 
        {
128
 
                new FlagCheckBox( codegen_group, controller,
129
 
                                  "-fno-exceptions", i18n( "Disable exception handling" ),
130
 
                                  "-fexception" );
131
 
        }
132
 
        // The following two are somehow mutually exclusive, but the default is
133
 
        // platform-dependent, so if we would leave out one of them, we wouldn't
134
 
        // know how to set the remaining one.
135
 
        new FlagCheckBox( codegen_group, controller,
136
 
                          "-fpcc-struct-return", i18n( "Return certain struct and union values in memory rather than in registers" ) );
137
 
        new FlagCheckBox( codegen_group, controller,
138
 
                          "-freg-struct-return", i18n( "Return certain struct and union values in registers when possible" ) );
139
 
        new FlagCheckBox( codegen_group, controller,
140
 
                          "-short-enums", i18n( "For an enum, choose the smallest possible integer type" ) );
141
 
        new FlagCheckBox( codegen_group, controller,
142
 
                          "-short-double", i18n( "Make 'double' the same as 'float'" ) );
143
 
 
144
 
        QApplication::sendPostedEvents( this, QEvent::ChildInserted );
145
 
        layout->addStretch();
146
 
}
147
 
 
148
 
 
149
 
GeneralTab::~GeneralTab()
150
 
{
151
 
        delete controller;
152
 
}
153
 
 
154
 
 
155
 
void GeneralTab::readFlags( QStringList *list )
156
 
{
157
 
        controller->readFlags( list );
158
 
}
159
 
 
160
 
 
161
 
void GeneralTab::writeFlags( QStringList *list )
162
 
{
163
 
        controller->writeFlags( list );
164
 
}
165
 
 
166
 
 
167
 
OptimizationTab::OptimizationTab( GccOptionsPlugin::Type type, QWidget *parent, const char *name )
168
 
                : QWidget( parent, name )
169
 
{
170
 
        QBoxLayout * layout = new QVBoxLayout( this, KDialog::marginHint(), KDialog::spacingHint() );
171
 
        layout->setAutoAdd( true );
172
 
 
173
 
        QVButtonGroup *group = new QVButtonGroup( i18n( "Optimization Level" ), this );
174
 
        Odefault = new QRadioButton( i18n( "Default" ), group );
175
 
        Odefault->setChecked( true );
176
 
        O0 = new QRadioButton( i18n( "No optimization" ), group );
177
 
        O1 = new QRadioButton( i18n( "Level 1" ), group );
178
 
        O2 = new QRadioButton( i18n( "Level 2" ), group );
179
 
 
180
 
        optBox = new FlagListBox( this );
181
 
 
182
 
        new FlagListItem( optBox,
183
 
                          "-ffloat-store", i18n( "<qt>Do not store floating point variables in registers</qt>" ),
184
 
                          "-fno-float-store" );
185
 
        new FlagListItem( optBox,
186
 
                          "-fno-defer-pop", i18n( "<qt>Pop the arguments to each function call directly "
187
 
                                                  "after the function returns</qt>" ),
188
 
                          "-fdefer-pop" );
189
 
        new FlagListItem( optBox,
190
 
                          "-fforce-mem", i18n( "<qt>Force memory operands to be copied into registers before "
191
 
                                               "doing arithmetic on them</qt>" ),
192
 
                          "-fno-force-mem" );
193
 
        new FlagListItem( optBox,
194
 
                          "-fforce-addr", i18n( "<qt>Force memory address constants to be copied into registers before "
195
 
                                                "doing arithmetic on them</qt>" ),
196
 
                          "-fno-force-addr" );
197
 
        new FlagListItem( optBox,
198
 
                          "-fomit-frame-pointer", i18n( "<qt>Do not keep the frame pointer in a register for functions that "
199
 
                                                       "do not need one</qt>" ),
200
 
                          "-fno-omit-frame-pointer" );
201
 
        new FlagListItem( optBox,
202
 
                          "-fno-inline", i18n( "<qt>Ignore the <i>inline</i> keyword</qt>" ),
203
 
                          "-finline" );
204
 
 
205
 
        if ( type == GccOptionsPlugin::GPP )
206
 
        {
207
 
                new FlagListItem( optBox,
208
 
                                  "-fno-default-inline", i18n( "<qt>Do not make member functions inline merely because they "
209
 
                                                               "are defined inside the class scope</qt>" ),
210
 
                                  "-fdefault-inline" );
211
 
        }
212
 
 
213
 
        QApplication::sendPostedEvents( this, QEvent::ChildInserted );
214
 
        layout->addStretch();
215
 
}
216
 
 
217
 
 
218
 
OptimizationTab::~OptimizationTab()
219
 
{}
220
 
 
221
 
 
222
 
void OptimizationTab::readFlags( QStringList *list )
223
 
{
224
 
        optBox->readFlags( list );
225
 
 
226
 
        QStringList::Iterator sli;
227
 
        sli = list->find( "-O0" );
228
 
        if ( sli != list->end() )
229
 
        {
230
 
                O0->setChecked( true );
231
 
                list->remove
232
 
                ( sli );
233
 
        }
234
 
        sli = list->find( "-O1" );
235
 
        if ( sli != list->end() )
236
 
        {
237
 
                O1->setChecked( true );
238
 
                list->remove
239
 
                ( sli );
240
 
        }
241
 
        sli = list->find( "-O2" );
242
 
        if ( sli != list->end() )
243
 
        {
244
 
                O2->setChecked( true );
245
 
                list->remove
246
 
                ( sli );
247
 
        }
248
 
}
249
 
 
250
 
 
251
 
void OptimizationTab::writeFlags( QStringList *list )
252
 
{
253
 
        optBox->writeFlags( list );
254
 
 
255
 
        if ( O0->isChecked() )
256
 
                ( *list ) << "-O0";
257
 
        else if ( O1->isChecked() )
258
 
                ( *list ) << "-O1";
259
 
        else if ( O2->isChecked() )
260
 
                ( *list ) << "-O2";
261
 
}
262
 
 
263
 
 
264
 
G77Tab::G77Tab( QWidget *parent, const char *name )
265
 
                : QWidget( parent, name ), controller( new FlagCheckBoxController )
266
 
{
267
 
        QBoxLayout * layout = new QVBoxLayout( this, KDialog::marginHint(), KDialog::spacingHint() );
268
 
        layout->setAutoAdd( true );
269
 
        layout->addSpacing( 10 );
270
 
 
271
 
        QVButtonGroup *dialect_group = new QVButtonGroup( i18n( "Dialect" ), this );
272
 
        new FlagCheckBox( dialect_group, controller,
273
 
                          "-ffree-form", i18n( "Interpret source code as Fortran 90 free form" ),
274
 
                          "-fno-exception" );
275
 
        new FlagCheckBox( dialect_group, controller,
276
 
                          "-ff90", i18n( "Allow certain Fortran 90 constructs" ) );
277
 
        new FlagCheckBox( dialect_group, controller,
278
 
                          "-fdollar-ok", i18n( "Allow '$' in symbol names" ) );
279
 
        new FlagCheckBox( dialect_group, controller,
280
 
                          "-fbackslash", i18n( "Allow '\' in character constants to escape special characters" ),
281
 
                          "-fno-backslah" );
282
 
        new FlagCheckBox( dialect_group, controller,
283
 
                          "-fonetrip", i18n( "DO loops are executed at least once" ) );
284
 
 
285
 
        QApplication::sendPostedEvents( this, QEvent::ChildInserted );
286
 
        layout->addSpacing( 10 );
287
 
 
288
 
        QVButtonGroup *codegen_group = new QVButtonGroup( i18n( "Code Generation" ), this );
289
 
        new FlagCheckBox( codegen_group, controller,
290
 
                          "-fno-automatic", i18n( "Treat local variables as if SAVE statement had been specified" ) );
291
 
        new FlagCheckBox( codegen_group, controller,
292
 
                          "-finit-local-zero", i18n( "Init local variables to zero" ) );
293
 
        new FlagCheckBox( codegen_group, controller,
294
 
                          "-fbounds-check", i18n( "Generate run-time checks for array subscripts" ) );
295
 
 
296
 
        QApplication::sendPostedEvents( this, QEvent::ChildInserted );
297
 
        layout->addStretch();
298
 
}
299
 
 
300
 
 
301
 
G77Tab::~G77Tab()
302
 
{
303
 
        delete controller;
304
 
}
305
 
 
306
 
 
307
 
void G77Tab::readFlags( QStringList *list )
308
 
{
309
 
        controller->readFlags( list );
310
 
}
311
 
 
312
 
 
313
 
void G77Tab::writeFlags( QStringList *list )
314
 
{
315
 
        controller->writeFlags( list );
316
 
}
317
 
 
318
 
 
319
 
Warnings1Tab::Warnings1Tab( GccOptionsPlugin::Type type, QWidget *parent, const char *name )
320
 
                : QWidget( parent, name ), controller( new FlagCheckBoxController )
321
 
{
322
 
        QBoxLayout * layout = new QVBoxLayout( this, KDialog::marginHint(), KDialog::spacingHint() );
323
 
        layout->setAutoAdd( true );
324
 
 
325
 
        new FlagCheckBox( this, controller,
326
 
                          "-w", i18n( "Inhibit all warnings" ) );
327
 
        new FlagCheckBox( this, controller,
328
 
                          "-Wno-import", i18n( "Inhibit warnings about the use of #import" ) );
329
 
        new FlagCheckBox( this, controller,
330
 
                          "-Werror", i18n( "Make all warnings into errors" ) );
331
 
        new FlagCheckBox( this, controller,
332
 
                          "-pedantic", i18n( "Issue all warnings demanded by strict ANSI C or ISO C++" ) );
333
 
        new FlagCheckBox( this, controller,
334
 
                          "-pedantic-errors", i18n( "Like -pedantic, but errors are produced instead of warnings" ) );
335
 
        new FlagCheckBox( this, controller,
336
 
                          "-Wall", i18n( "All warnings below, combined (-Wall):" ) );
337
 
 
338
 
        wallBox = new FlagListBox( this );
339
 
 
340
 
        new FlagListItem( wallBox,
341
 
                          "-Wchar-subscripts", i18n( "<qt>Warn if an array subscript has type <i>char</i></qt>" ) );
342
 
        new FlagListItem( wallBox,
343
 
                          "-Wcomment", i18n( "<qt>Warn when a comment-start sequence /* appears inside a comment</qt>" ) );
344
 
        new FlagListItem( wallBox,
345
 
                          "-Wformat", i18n( "<qt>Check calls to <i>printf()</i>, <i>scanf()</i> etc\n"
346
 
                                            "to make sure that the arguments supplied have types appropriate\n"
347
 
                                            "to the format string specified, and that the conversions specified\n"
348
 
                                            "in the format string make sense</qt>" ) );
349
 
        new FlagListItem( wallBox,
350
 
                          "-Wformat=2", i18n( "<qt>Enable -Wformat plus format checks not \n"
351
 
                                              "included in -Wformat. Currently equivalent to \n"
352
 
                                              "`-Wformat -Wformat-nonliteral -Wformat-security \n"
353
 
                                              "-Wformat-y2k'.</qt>" ) );
354
 
        new FlagListItem( wallBox,
355
 
                          "-Wimplicit-int", i18n( "<qt>Warn when a declaration does not specify a type</qt>" ) );
356
 
        new FlagListItem( wallBox,
357
 
                          "-Wimplicit-funtion-declaration",
358
 
                          i18n( "<qt>Issue a warning when a non-declared function is used</qt>" ) );
359
 
        new FlagListItem( wallBox,
360
 
                          "-Werror-implicit-function-declaration",
361
 
                          i18n( "<qt>Issue an error when a non-declared function is used</qt>" ) );
362
 
        new FlagListItem( wallBox,
363
 
                          "-Wmain", i18n( "<qt>Warn if the type of <i>main()</i> is suspicious</qt>" ) );
364
 
        new FlagListItem( wallBox,
365
 
                          "-Wmultichar", i18n( "<qt>Warn when multicharacter constants are encountered</qt>" ) );
366
 
        new FlagListItem( wallBox,
367
 
                          "-Wmissing-braces", i18n( "<qt>Warn if an aggregate or union initializer is not fully bracketed</qt>" ) );
368
 
        new FlagListItem( wallBox,
369
 
                          "-Wparentheses", i18n( "<qt>Warn when parentheses are omitted in certain contexts</qt>" ) );
370
 
        new FlagListItem( wallBox,
371
 
                          "-Wsequence-point", i18n( "<qt>Warn about code that may have undefined semantics because of\n"
372
 
                                                    "violations of sequence point rules in the C standard</qt>" ) );
373
 
        new FlagListItem( wallBox,
374
 
                          "-Wreturn-type", i18n( "<qt>Warn when a function without explicit return type is defined</qt>" ) );
375
 
        new FlagListItem( wallBox,
376
 
                          "-Wswitch", i18n( "<qt>Warn whenever a <i>switch</i> statement has an index of enumeral type\n"
377
 
                                            "and lacks a <i>case</i> for one or more of the named codes of that enumeration</qt>" ) );
378
 
        new FlagListItem( wallBox,
379
 
                          "-Wtrigraphs", i18n( "<qt>Warn when trigraphs are encountered</qt>" ) );
380
 
        new FlagListItem( wallBox,
381
 
                          "-Wunused", i18n( "<qt>Warn when a variable is declared but not used</qt>" ) );
382
 
        new FlagListItem( wallBox,
383
 
                          "-Wuninitialized", i18n( "<qt>Warn when a variable is used without being initialized first</qt>" ) );
384
 
        new FlagListItem( wallBox,
385
 
                          "-Wunknown-pragmas", i18n( "<qt>Warn when an unknown #pragma statement is encountered</qt>" ) );
386
 
        new FlagListItem( wallBox,
387
 
                          "-Wdiv-by-zero", i18n( "<qt>Warn when a division by zero occurs.</qt>" ) );
388
 
        if ( type == GccOptionsPlugin::GPP )
389
 
        {
390
 
                new FlagListItem( wallBox,
391
 
                                  "-Wreorder", i18n( "<qt>Warn when the order of member initializers is different from\n"
392
 
                                                     "the order in the class declaration</qt>" ) );
393
 
        }
394
 
}
395
 
 
396
 
 
397
 
Warnings1Tab::~Warnings1Tab()
398
 
{
399
 
        delete controller;
400
 
}
401
 
 
402
 
 
403
 
void Warnings1Tab::readFlags( QStringList *list )
404
 
{
405
 
        controller->readFlags( list );
406
 
        wallBox->readFlags( list );
407
 
}
408
 
 
409
 
 
410
 
void Warnings1Tab::writeFlags( QStringList *list )
411
 
{
412
 
        controller->writeFlags( list );
413
 
        wallBox->writeFlags( list );
414
 
}
415
 
 
416
 
 
417
 
Warnings2Tab::Warnings2Tab( GccOptionsPlugin::Type type, QWidget *parent, const char *name )
418
 
                : QWidget( parent, name )
419
 
{
420
 
        QBoxLayout * layout = new QVBoxLayout( this, KDialog::marginHint(), KDialog::spacingHint() );
421
 
        layout->setAutoAdd( true );
422
 
 
423
 
        wrestBox = new FlagListBox( this );
424
 
 
425
 
        new FlagListItem( wrestBox,
426
 
                          "-W", i18n( "<qt>Set options not included in -Wall which are very specific</qt>" ) );
427
 
        new FlagListItem( wrestBox,
428
 
                          "-Wfloat-equal", i18n( "<qt>Warn if floating point values are used in equality comparisons</qt>" ) );
429
 
        new FlagListItem( wrestBox,
430
 
                          "-Wundef", i18n( "<qt>Warn if an undefined identifier is evaluated in an <i>#if</i> directive</qt>" ) );
431
 
        new FlagListItem( wrestBox,
432
 
                          "-Wshadow", i18n( "<qt>Warn whenever a local variable shadows another local variable</qt>" ) );
433
 
        new FlagListItem( wrestBox,
434
 
                          "-Wpointer-arith", i18n( "<qt>Warn about anything that depends on the <i>sizeof</i> a\n"
435
 
                                                   "function type or of <i>void</i></qt>" ) );
436
 
        new FlagListItem( wrestBox,
437
 
                          "-Wcast-qual", i18n( "<qt>Warn whenever a pointer is cast so as to remove a type\n"
438
 
                                               "qualifier from the target type</qt>" ) );
439
 
        new FlagListItem( wrestBox,
440
 
                          "-Wcast-align", i18n( "<qt>Warn whenever a pointer is cast such that the required\n"
441
 
                                                "alignment of the target is increased</qt>" ) );
442
 
        new FlagListItem( wrestBox,
443
 
                          "-Wwrite-strings", i18n( "<qt>Warn when the address of a string constant is cast\n"
444
 
                                                   "into a non-const <i>char *</i> pointer</qt>" ) );
445
 
        new FlagListItem( wrestBox,
446
 
                          "-Wconversion", i18n( "<qt>Warn if a prototype causes a type conversion that is different\n"
447
 
                                                "from what would happen to the same argument in the absence\n"
448
 
                                                "of a prototype</qt>" ) );
449
 
        new FlagListItem( wrestBox,
450
 
                          "-Wsign-compare", i18n( "<qt>Warn when a comparison between signed and unsigned values\n"
451
 
                                                  "could produce an incorrect result when the signed value\n"
452
 
                                                  "is converted to unsigned</qt>" ) );
453
 
        new FlagListItem( wrestBox,
454
 
                          "-Wmissing-noreturn", i18n( "<qt>Warn about functions which might be candidates for attribute 'noreturn'</qt>" ) );
455
 
        new FlagListItem( wrestBox,
456
 
                          "-Waggregate-return", i18n( "<qt>Warn if any functions that return structures or unions are\n"
457
 
                                                      "defined or called</qt>" ) );
458
 
        new FlagListItem( wrestBox,
459
 
                          "-Wmissing-declarations", i18n( "<qt>Warn if a global function is defined without a previous declaration</qt>" ) );
460
 
        new FlagListItem( wrestBox,
461
 
                          "-Wno-deprecated-declarations",
462
 
                          i18n( "<qt>Do not warn about uses of functions, variables, and types marked as\n"
463
 
                                "deprecated by using the 'deprecated' attribute</qt>" ) );
464
 
        new FlagListItem( wrestBox,
465
 
                          "-Wpacked", i18n( "<qt>Warn if a structure is given the packed attribute, but the packed\n"
466
 
                                            "attribute has no effect on the layout or size of the structure</qt>" ) );
467
 
        new FlagListItem( wrestBox,
468
 
                          "-Wpadded", i18n( "<qt>Warn if padding is included in a structure, either to align an\n"
469
 
                                            "element of the structure or to align the whole structure</qt>" ) );
470
 
        new FlagListItem( wrestBox,
471
 
                          "-Wredundant-decls", i18n( "<qt>Warn if anything is declared more than once in the same scope</qt>" ) );
472
 
        new FlagListItem( wrestBox,
473
 
                          "-Wunreachable-code", i18n( "<qt>Warn if the compiler detects that code will never be executed</qt>" ) );
474
 
        new FlagListItem( wrestBox,
475
 
                          "-Winline", i18n( "<qt>Warn if an <i>inline</i> function cannot be inlined</qt>" ) );
476
 
        new FlagListItem( wrestBox,
477
 
                          "-Wlong-long", i18n( "<qt>Warn if the <i>long long</i> type is used</qt>" ) );
478
 
        new FlagListItem( wrestBox,
479
 
                          "-Wdisabled-optimization", i18n( "<qt>Warn if a requested optimization pass is disabled</qt>" ) );
480
 
        new FlagListItem( wrestBox,
481
 
                          "-Wno-div-by-zero", i18n( "<qt>Do not warn if there is a division by zero</qt>" ) );
482
 
 
483
 
        if ( type == GccOptionsPlugin::GCC )
484
 
        {
485
 
                new FlagListItem( wrestBox,
486
 
                                  "-Wtraditional", i18n( "<qt>Warn about certain constructs that behave differently\n"
487
 
                                                         "in traditional and ANSI C</qt>" ) );
488
 
                new FlagListItem( wrestBox,
489
 
                                  "-Wbad-function-cast", i18n( "<qt>Warn whenever a function call is cast to a non-matching type</qt>" ) );
490
 
                new FlagListItem( wrestBox,
491
 
                                  "-Wstrict-prototypes", i18n( "<qt>Warn if a function is declared or defined without specifying\n"
492
 
                                                               "the argument types</qt>" ) );
493
 
                new FlagListItem( wrestBox,
494
 
                                  "-Wmissing-prototypes", i18n( "<qt>Warn if a global function is defined without a previous prototype declaration</qt>" ) );
495
 
                new FlagListItem( wrestBox,
496
 
                                  "-Wnested-externs", i18n( "<qt>Warn if an <i>extern</i> declaration is encountered within a function</qt>" ) );
497
 
        }
498
 
 
499
 
 
500
 
        if ( type == GccOptionsPlugin::GPP )
501
 
        {
502
 
                new FlagListItem( wrestBox,
503
 
                                  "-Woverloaded-virtual", i18n( "<qt>Warn when a function declaration hides virtual\n"
504
 
                                                                "functions from a base class</qt>" ) );
505
 
                new FlagListItem( wrestBox,
506
 
                                  "-Wsynth", i18n( "<qt>Warn when g++'s synthesis behavior does\n"
507
 
                                                   "not match that of cfront</qt>" ) );
508
 
                new FlagListItem( wrestBox,
509
 
                                  "-Wctor-dtor-privacy", i18n( "<qt>Warn when a class seems unusable, because all the constructors or\n"
510
 
                                                               "destructors in a class are private and the class has no friends or\n"
511
 
                                                               "public static member functions</qt>" ) );
512
 
                new FlagListItem( wrestBox,
513
 
                                  "-Wnon-virtual-dtor", i18n( "<qt>Warn when a class declares a non-virtual destructor that should\n"
514
 
                                                              "probably be virtual, because it looks like the class will be used\n"
515
 
                                                              "polymorphically</qt>" ) );
516
 
                new FlagListItem( wrestBox,
517
 
                                  "-Wsign-promo", i18n( "<qt>Warn when overload resolution chooses a promotion from unsigned or\n"
518
 
                                                        "enumeral type to a signed type over a conversion to an unsigned\n"
519
 
                                                        "type of the same size. Previous versions of G++ would try to\n"
520
 
                                                        "preserve unsignedness, but the standard mandates the current behavior</qt>" ) );
521
 
                new FlagListItem( wrestBox,
522
 
                                  "-Wabi", i18n( "<qt>Warn when G++ generates code that is probably not compatible with\n"
523
 
                                                 "the vendor-neutral C++ ABI</qt>" ) );
524
 
                /*    new FlagListItem(wrestBox,
525
 
                                     "-Wreorder",             i18n("<qt>Warn when the order of member initializers given in the code does\n"
526
 
                                                                   "not match the order in which they must be executed.</qt>"));*/
527
 
                new FlagListItem( wrestBox,
528
 
                                  "-Weffc++", i18n( "<qt>Warn about violations of the following style guidelines from Scott\n"
529
 
                                                    "Meyers' 'Effective C++' book:\n"
530
 
                                                    "* Item 11:  Define a copy constructor and an assignment\n"
531
 
                                                    "  operator for classes with dynamically allocated memory;\n"
532
 
                                                    "* Item 12:  Prefer initialization to assignment in constructors;\n"
533
 
                                                    "* Item 14:  Make destructors virtual in base classes;\n"
534
 
                                                    "* Item 15:  Have `operator=' return a reference to `*this';\n"
535
 
                                                    "* Item 23:  Do not try to return a reference when you must\n"
536
 
                                                    "  return an object\n"
537
 
                                                    "\n"
538
 
                                                    "and about violations of the following style guidelines from Scott\n"
539
 
                                                    "Meyers' 'More Effective C++' book:\n"
540
 
                                                    "* Item 6:  Distinguish between prefix and postfix forms of\n"
541
 
                                                    "  increment and decrement operators;\n"
542
 
                                                    "* Item 7:  Never overload '&&', '||', or ','</qt>" ) );
543
 
                new FlagListItem( wrestBox,
544
 
                                  "-Wno-deprecated", i18n( "<qt>Do not warn about usage of deprecated features</qt>" ) );
545
 
                new FlagListItem( wrestBox,
546
 
                                  "-Wno-non-template-friend", i18n( "<qt>Disable warnings when non-templatized friend functions are declared\n"
547
 
                                                                    "within a template</qt>" ) );
548
 
                new FlagListItem( wrestBox,
549
 
                                  "-Wold-style-cast", i18n( "<qt>Warn if an old-style (C-style) cast to a non-void type is used\n"
550
 
                                                            "within a C++ program</qt>" ) );
551
 
                new FlagListItem( wrestBox,
552
 
                                  "-Wno-pmf-conversions", i18n( "<qt>Disable the diagnostic for converting a bound pointer to member\n"
553
 
                                                                "function to a plain pointer</qt>" ) );
554
 
        }
555
 
}
556
 
 
557
 
 
558
 
Warnings2Tab::~Warnings2Tab()
559
 
{}
560
 
 
561
 
 
562
 
void Warnings2Tab::readFlags( QStringList *list )
563
 
{
564
 
        wrestBox->readFlags( list );
565
 
}
566
 
 
567
 
 
568
 
void Warnings2Tab::writeFlags( QStringList *list )
569
 
{
570
 
        wrestBox->writeFlags( list );
571
 
}
572
 
 
573
 
 
574
 
// Last but not least... :-)
575
 
GccOptionsDialog::GccOptionsDialog( GccOptionsPlugin::Type type, QWidget *parent, const char *name )
576
 
                : KDialogBase( Tabbed, GccOptionsPlugin::captionForType( type ), Ok | Cancel, Ok, parent, name, true )
577
 
{
578
 
        QVBox * vbox;
579
 
 
580
 
        vbox = addVBoxPage( i18n( "General" ) );
581
 
        general = new GeneralTab( type, vbox, "general tab" );
582
 
 
583
 
        vbox = addVBoxPage( i18n( "Optimization" ) );
584
 
        optimization = new OptimizationTab( type, vbox, "optimization tab" );
585
 
 
586
 
        if ( type == GccOptionsPlugin::G77 )
587
 
        {
588
 
                vbox = addVBoxPage( i18n( "Fortran Specifics" ) );
589
 
                g77 = new G77Tab( vbox, "g77 tab" );
590
 
        }
591
 
        else
592
 
                g77 = 0;
593
 
 
594
 
        vbox = addVBoxPage( i18n( "Warnings (safe)" ) );
595
 
        warnings1 = new Warnings1Tab( type, vbox, "warnings1 tab" );
596
 
 
597
 
        vbox = addVBoxPage( i18n( "Warnings (unsafe)" ) );
598
 
        warnings2 = new Warnings2Tab( type, vbox, "warnings2 tab" );
599
 
}
600
 
 
601
 
 
602
 
GccOptionsDialog::~GccOptionsDialog()
603
 
{}
604
 
 
605
 
 
606
 
void GccOptionsDialog::setFlags( const QString &flags )
607
 
{
608
 
        QStringList flaglist = QStringList::split( " ", flags );
609
 
 
610
 
        // Hand them to 'general' at last, so it can make a line edit
611
 
        // with the unprocessed items
612
 
        if ( g77 )
613
 
                g77->readFlags( &flaglist );
614
 
        optimization->readFlags( &flaglist );
615
 
        warnings1->readFlags( &flaglist );
616
 
        warnings2->readFlags( &flaglist );
617
 
        general->readFlags( &flaglist );
618
 
        unrecognizedFlags = flaglist;
619
 
}
620
 
 
621
 
 
622
 
QString GccOptionsDialog::flags() const
623
 
{
624
 
        QStringList flaglist;
625
 
 
626
 
        if ( g77 )
627
 
                g77->writeFlags( &flaglist );
628
 
        optimization->writeFlags( &flaglist );
629
 
        warnings1->writeFlags( &flaglist );
630
 
        warnings2->writeFlags( &flaglist );
631
 
        general->writeFlags( &flaglist );
632
 
 
633
 
        QString flags;
634
 
        QStringList::ConstIterator li;
635
 
        for ( li = flaglist.begin(); li != flaglist.end(); ++li )
636
 
        {
637
 
                flags += ( *li );
638
 
                flags += " ";
639
 
        }
640
 
 
641
 
        for ( li = unrecognizedFlags.begin(); li != unrecognizedFlags.end(); ++li )
642
 
        {
643
 
                flags += ( *li );
644
 
                flags += " ";
645
 
        }
646
 
 
647
 
        flags.truncate( flags.length() - 1 );
648
 
        return flags;
649
 
}
650
 
 
651
 
 
652
 
GccOptionsPlugin::GccOptionsPlugin( QObject *parent, const char *name, const QStringList &args )
653
 
                : KDevCompilerOptions( parent, name )
654
 
{
655
 
        gcctype = Unknown;
656
 
 
657
 
        if ( args.count() == 0 )
658
 
                return ;
659
 
 
660
 
        QString typeStr = args[ 0 ];
661
 
 
662
 
        if ( typeStr == "gcc" )
663
 
                gcctype = GccOptionsPlugin::GCC;
664
 
        else if ( typeStr == "g++" )
665
 
                gcctype = GccOptionsPlugin::GPP;
666
 
        else if ( typeStr == "g77" )
667
 
                gcctype = GccOptionsPlugin::G77;
668
 
}
669
 
 
670
 
 
671
 
GccOptionsPlugin::~GccOptionsPlugin()
672
 
{}
673
 
 
674
 
 
675
 
QString GccOptionsPlugin::captionForType( Type type )
676
 
{
677
 
        switch ( type )
678
 
        {
679
 
        case GCC:
680
 
                return i18n( "GNU C Compiler Options" );
681
 
        case GPP:
682
 
                return i18n( "GNU C++ Compiler Options" );
683
 
        case G77:
684
 
                return i18n( "GNU Fortran 77 Compiler Options" );
685
 
        default:
686
 
                return QString::null;
687
 
        }
688
 
}
689
 
 
690
 
 
691
 
QString GccOptionsPlugin::exec( QWidget *parent, const QString &flags )
692
 
{
693
 
        if ( gcctype == Unknown )
694
 
                return QString::null;
695
 
        GccOptionsDialog *dlg = new GccOptionsDialog( gcctype, parent, "gcc options dialog" );
696
 
        QString newFlags = flags;
697
 
        dlg->setFlags( flags );
698
 
        if ( dlg->exec() == QDialog::Accepted )
699
 
                newFlags = dlg->flags();
700
 
        delete dlg;
701
 
        return newFlags;
702
 
}
703
 
 
704
 
#include "gccoptionsplugin.moc"
705
 
//kate: indent-mode csands; tab-width 4; space-indent off;