diff options
-rw-r--r-- | qmake/generators/makefiledeps.cpp | 27 | ||||
-rw-r--r-- | tests/auto/tools/qmake/testdata/findDeps/findDeps.pro | 2 | ||||
-rw-r--r-- | tests/auto/tools/qmake/testdata/findDeps/main.cpp | 9 | ||||
-rw-r--r-- | tests/auto/tools/qmake/testdata/findDeps/needed.cpp | 1 |
4 files changed, 22 insertions, 17 deletions
diff --git a/qmake/generators/makefiledeps.cpp b/qmake/generators/makefiledeps.cpp index 8c51a20aa6..535f0561cc 100644 --- a/qmake/generators/makefiledeps.cpp +++ b/qmake/generators/makefiledeps.cpp @@ -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; } } } diff --git a/tests/auto/tools/qmake/testdata/findDeps/findDeps.pro b/tests/auto/tools/qmake/testdata/findDeps/findDeps.pro index 442c9c767f..2713296f5b 100644 --- a/tests/auto/tools/qmake/testdata/findDeps/findDeps.pro +++ b/tests/auto/tools/qmake/testdata/findDeps/findDeps.pro @@ -9,4 +9,4 @@ HEADERS += object1.h \ object7.h \ object8.h \ object9.h -SOURCES += main.cpp +SOURCES += main.cpp needed.cpp diff --git a/tests/auto/tools/qmake/testdata/findDeps/main.cpp b/tests/auto/tools/qmake/testdata/findDeps/main.cpp index e4aa5c6251..0df3f9b7c3 100644 --- a/tests/auto/tools/qmake/testdata/findDeps/main.cpp +++ b/tests/auto/tools/qmake/testdata/findDeps/main.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(); +} diff --git a/tests/auto/tools/qmake/testdata/findDeps/needed.cpp b/tests/auto/tools/qmake/testdata/findDeps/needed.cpp new file mode 100644 index 0000000000..698d0aaa12 --- /dev/null +++ b/tests/auto/tools/qmake/testdata/findDeps/needed.cpp @@ -0,0 +1 @@ +extern int needed(void) { return 1; } |