Avoid having division caught up in parsing of comments.
A loop to skip space and comments was meant to break on anything else but would have not broken on a division operator (where it should) due to it getting caught in the check for a comment-start, without falling back suitably when it didn't complete that check. Managed to contrive a suitably twisted change to findDeps test to reveal the bug; broken previously, now fixed. Not ideal, as it relied on another bug to fail previously - backslash-newline shouldn't end a preprocessing directive line - but it should still pass once that's fixed, too. Exercising a bug in qmake usually involves code that won't compile anyway, making it tricky to write a test that reveals the bug but that passes once it's fixed. Change-Id: I08a1d7cc5e3d7fd1ac0a48e5c09dfdfbb7580b11 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
This commit is contained in:
parent
f1d5641d49
commit
00a855d643
@ -509,22 +509,21 @@ bool QMakeSourceFileInfo::findDeps(SourceFile *file)
|
||||
for(; x < buffer_len; ++x) {
|
||||
if (buffer[x] == ' ' || buffer[x] == '\t') {
|
||||
// keep going
|
||||
} else if (buffer[x] == '/') {
|
||||
} else if (buffer[x] == '/' && x + 1 < buffer_len &&
|
||||
(buffer[x + 1] == '/' || buffer[x + 1] == '*')) {
|
||||
++x;
|
||||
if(buffer_len >= x) {
|
||||
if (buffer[x] == '/') { // C++-style comment
|
||||
for (; x < buffer_len && !qmake_endOfLine(buffer[x]); ++x) {} // skip
|
||||
beginning = 1;
|
||||
} else if (buffer[x] == '*') { // C-style comment
|
||||
for(++x; x < buffer_len; ++x) {
|
||||
if (buffer[x] == '*') {
|
||||
if (x + 1 < buffer_len && buffer[x + 1] == '/') {
|
||||
++x;
|
||||
break;
|
||||
}
|
||||
} else if (qmake_endOfLine(buffer[x])) {
|
||||
++line_count;
|
||||
if (buffer[x] == '/') { // C++-style comment
|
||||
for (; x < buffer_len && !qmake_endOfLine(buffer[x]); ++x) {} // skip
|
||||
beginning = 1;
|
||||
} else { // C-style comment
|
||||
while (++x < buffer_len) {
|
||||
if (buffer[x] == '*') {
|
||||
if (x + 1 < buffer_len && buffer[x + 1] == '/') {
|
||||
++x; // skip '*'; for loop skips '/'.
|
||||
break;
|
||||
}
|
||||
} else if (qmake_endOfLine(buffer[x])) {
|
||||
++line_count;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -9,4 +9,4 @@ HEADERS += object1.h \
|
||||
object7.h \
|
||||
object8.h \
|
||||
object9.h
|
||||
SOURCES += main.cpp
|
||||
SOURCES += main.cpp needed.cpp
|
||||
|
@ -31,6 +31,9 @@
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#define spurious \
|
||||
/ #include "needed.cpp"
|
||||
// if not ignored, symbol needed() won't be available ...
|
||||
|
||||
#include <moc_object1.cpp>
|
||||
/**/ #include <moc_object2.cpp>
|
||||
@ -49,5 +52,7 @@ static void function2(); /**/
|
||||
static void function3(); //
|
||||
#include <moc_object9.cpp>
|
||||
|
||||
int main () {}
|
||||
|
||||
int main () {
|
||||
extern int needed(void);
|
||||
return needed();
|
||||
}
|
||||
|
1
tests/auto/tools/qmake/testdata/findDeps/needed.cpp
vendored
Normal file
1
tests/auto/tools/qmake/testdata/findDeps/needed.cpp
vendored
Normal file
@ -0,0 +1 @@
|
||||
extern int needed(void) { return 1; }
|
Loading…
x
Reference in New Issue
Block a user