Commit Graph

110 Commits

Author SHA1 Message Date
hjk
7ab6783e24 Standardize on int for line and column values
Recently tons of warnings show up for presumably "problematic"
singned <-> unsigned and size conversions.

The Qt side uses 'int', and that's the biggest 'integration surface'
for us, so instead of establishing some internal boundary between
signed and unsigned areas, push that boundary out of creator core code,
and use 'int' everywhere.

Because it reduces friction further, also do it in libcplusplus.

Change-Id: I84f3b79852c8029713e7ea6f133ffb9ef7030a70
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2019-07-26 09:23:48 +00:00
Nikolai Kosjar
0d29fea0b3 C++: Fix parsing enum specifier III
This amends the obviously wrong
aac1bebace.

Fixes

  FAIL!  : tst_Semantic::q_enum_1() Compared values are not the same
  FAIL!  : tst_CheckSymbols::test_checksymbols(EnumerationUse) 'resultCount > 0' returned FALSE. ()
  FAIL!  : tst_CheckSymbols::test_checksymbols(VariableHasTheSameNameAsEnumUse) Compared values are not the same
  FAIL!  : tst_CheckSymbols::test_checksymbols(enum_inside_block_inside_function_QTCREATORBUG5456) Compared values are not the same
  FAIL!  : tst_CheckSymbols::test_checksymbols(enum_inside_function_QTCREATORBUG5456) Compared values are not the same

  FAIL!  : CppTools::Internal::CppToolsPlugin::test_completion(enum_inside_block_inside_function) Compared lists have different sizes.
  FAIL!  : CppTools::Internal::CppToolsPlugin::test_completion(enum_inside_block_inside_function_cxx11) Compared lists have different sizes.
  FAIL!  : CppTools::Internal::CppToolsPlugin::test_completion(enum_inside_function) Compared lists have different sizes.
  FAIL!  : CppTools::Internal::CppToolsPlugin::test_completion(enum_inside_function_cxx11) Compared lists have different sizes.
  FAIL!  : CppTools::Internal::CppToolsPlugin::test_completion(enum_inside_class) Compared lists have different sizes.
  FAIL!  : CppTools::Internal::CppToolsPlugin::test_completion(enum_inside_class_cxx11) Compared lists have different sizes.
  FAIL!  : CppTools::Internal::CppToolsPlugin::test_completion(enum_inside_namespace) Compared lists have different sizes.
  FAIL!  : CppTools::Internal::CppToolsPlugin::test_completion(enum_inside_namespace_cxx11) Compared lists have different sizes.
  FAIL!  : CppTools::Internal::CppToolsPlugin::test_completion(enum_inside_member_function) Compared lists have different sizes.
  FAIL!  : CppTools::Internal::CppToolsPlugin::test_completion(enum_inside_member_function_cxx11) Compared lists have different sizes.
  FAIL!  : CppTools::Internal::CppToolsPlugin::test_completion(enum_in_class_accessed_in_member_func_inline) Compared lists have different sizes.
  FAIL!  : CppTools::Internal::CppToolsPlugin::test_completion(enum_in_class_accessed_in_member_func) Compared lists have different sizes.
  FAIL!  : CppTools::Internal::CppToolsPlugin::test_cpplocatorfilters_CppLocatorFilter(CppLocatorFilter-filtered) Compared lists have different sizes.
  FAIL!  : CppTools::Internal::CppToolsPlugin::test_cpplocatorfilters_CppCurrentDocumentFilter() Compared lists have different sizes.
  FAIL!  : CppTools::Internal::CppToolsPlugin::test_builtinsymbolsearcher(BuiltinSymbolSearcher::AllTypes) Compared lists have different sizes.
  FAIL!  : CppTools::Internal::CppToolsPlugin::test_builtinsymbolsearcher(BuiltinSymbolSearcher::Enums) Compared lists have different sizes.

Task-number: QTCREATORBUG-21413
Change-Id: I71ace00091e37f0a148086e5047efaec08923b1a
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-11-01 14:29:52 +00:00
Nikolai Kosjar
aac1bebace C++: Fix parsing enum specifier II
This amends the obviously wrong
de975aca4f, which did not honored nameless
enum specifiers.

This fixes e.g. "Find Usages" for declarations following "enum {};".

Change-Id: Id98c074156f576b9a63e6c25dab38721ca34e496
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-10-24 12:47:03 +00:00
Nikolai Kosjar
de975aca4f C++: Fix parsing enum specifier
The enum name has to be an identifier. For the example in the referenced
report it was a destructor, which violated invariants in the lookup
code.

Fixes: QTCREATORBUG-20952
Change-Id: Ib8c9c23d6e001368c11c6a4b80c4295559786823
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-10-11 06:56:43 +00:00
Hugo Holgersson
86aab16ea4 TextEditor: Highlight punctuators as Text
This change limits the set of tokens that fall under
Token::isOperator(). That allows cpphighlighter.cpp to
distinguish operator tokens from punctuator tokens
(without changing any logic in cpphighlighter.cpp).

This change moves punctuators from "Operator"
to the "Text" style category where they belong.
Punctuators are not operators. Punctuators are
dumb text tokens.

Why don't we let the clang backend alone separate
these tokens for us?

1. Clang is slow on big files. Sometimes the
   highlighting dictated by clang is painted _seconds_
   after cpphighlighter.cpp runs. CppHighlighter is way
   faster so we use it to "prepaint" code while clang is
   busy in the background.

2. Secondly, clang cannot yet handle all operator types.
   In particular, none if its "operator cursors"
     CXCursor_UnaryOperator:
     CXCursor_BinaryOperator:
     CXCursor_CompoundAssignOperator:
     CXCursor_ConditionalOperator:
   includes the -> and . operators.
   We still need CppHighlighter to paint those tokens.

However, once clang has finished processing the file some
operator tokens will be repainted. We need clang to get
all operators' semantics. In particular, we need clang to
tell us if < is a "smaller than"-operator or part of a
template parameter like set<int>.

Task-number: QTCREATORBUG-19659
Change-Id: I952cb58f7c79134b3281e2a8221425cc1d0ad263
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-05-03 13:43:16 +00:00
Orgad Shaneh
eea6a7c3b3 Utils: Purge qtcfallthrough.h
No longer needed.

Change-Id: I9b0bee014df89d4c567f1d2431b5ff9404f5f925
Reviewed-by: hjk <hjk@qt.io>
2018-04-09 09:04:13 +00:00
Colin Duquesnoy
2a016d05b2 Add support for nested namespaces (C++17)
Task-number: QTCREATORBUG-16774
Change-Id: I3de3ac65810213e21c9a3bafef2474d252e191f7
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2018-02-09 17:54:30 +00:00
Friedemann Kleint
f482270432 Introduce Q_FALLTHROUGH()
Silence g++ 7.X warnings.

Change-Id: I9d06d04b496c9ec060e13e1be6f43d8fbadb1f3b
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2018-01-24 14:50:43 +00:00
Christian Kandeler
be2b3c91ae Add Q_FALLTHROUGH for Qt < 5.8
... and make use of it.
With gcc 7, the new option -Wimplicit-fallthrough is introduced and
added to the -Wextra set, triggering dozens of warnings in our sources.
Therefore, we annotate all obviously intended fall-throughs. The ones
that are still left are unclear and need to be checked by the respective
maintainer.

Change-Id: I44ead33cd42a4b41c28ee5fcb5a31db272710bbc
Reviewed-by: Nikita Baryshnikov <nib952051@gmail.com>
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2017-07-17 07:51:23 +00:00
Orgad Shaneh
e1660a18cf Remove workarounds for unsupported compilers
Change-Id: Ie28ff761b0bae13c6ebdf7dd649cfbba28e0fc2c
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2017-04-26 08:27:31 +00:00
Nikolai Kosjar
474b8ec5c0 C++: Fix expensive parsing of declarations
...which can occurr for e.g. files with a high difference of opening and
closing curly braces and many structs.

Make use of the ASTCache for parseSimpleDeclaration() and
parseMemberSpecification(). Those two were the most recurring calls for
the code provided in the bug report.

Task-number: QTCREATORBUG-16049
Change-Id: I13cc7fba2fb6c3be863690a222c8bbfeacbddc05
Reviewed-by: Erik Verbruggen <erik.verbruggen@theqtcompany.com>
2016-04-20 12:58:39 +00:00
Lassi Hämäläinen
10e947f65f C++: Fix crashes with the pattern "enum class operator A"
Parser parsed the pattern as an enum declaration the name of
which is a conversion operator. Add check to disallow keywords
after enum-key (enum, enum class, enum struct).
Add tests tst_AST::enumDeclaration and
invalidEnumClassDeclaration.

Task-number: QTCREATORBUG-15341
Change-Id: Ia037f00184c1d7e5b0374f39331bb6748f8d90b1
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
2015-11-18 15:09:40 +00:00
Claus Steuer
158b07c9c8 C++: Support noexcept operator
The code model failed to parse the noexcept operator which is often
used in noexcept specifiers, e.g.: "void f() noexcept(noexcept(g()));"
Consequently some c++11 headers such as unordered_map, array
and unordered_set could not be parsed and no code completition was
available. I have created the NoExceptOperatorExpressionAST class
which is created whenever a noexcept token is found in an
expression with operator precedence. The noExcept test case
in the cplusplus/cxx11 test now contains a function that
uses the noexcept operator.

Fixed noexcept operator parsing

Added the test requested by Sergey Shambir, which then revealed that
i had not implemeneted the noexpect operator parsing according to the
c++ specification.
As stated here http://cpp0x.centaur.ath.cx/expr.unary.noexcept.html
the noexcept operator is a unary-expression that contains an
expression (and not a constant-expression). This should now be fixed.

Change-Id: Id4a99a43b660bd83e7680274491d99a698b57094
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
2015-10-03 17:24:45 +00:00
Nikolai Kosjar
9d5c85a635 C++: Limit parsing of initializer clauses II
This completes

    commit e69d20e10b
    C++: Limit parsing of initializer clauses

by handling the following code path:

    -------- parseExpressionStatement
    --------- parseExpression
    ---------- parseCastExpression
    ----------- parseUnaryExpression
    ------------ parsePostfixExpression
    ------------- parseCorePostfixExpression
    -------------- parsePrimaryExpression
    --------------- parseNumericLiteral
    ---------- parseExpressionWithOperatorPrecedence
    ----------- parseInitializerClause0x
    ------------ parseAssignmentExpression
    ------------- parseCastExpression
    -------------- parseUnaryExpression
    --------------- parsePostfixExpression
    ---------------- parseCorePostfixExpression
    ----------------- parsePrimaryExpression
    ------------------ parseNumericLiteral
    ------------- parseExpressionWithOperatorPrecedence
    ----------- parseInitializerClause0x
    ------------ parseAssignmentExpression
    ------------- parseCastExpression
    -------------- parseUnaryExpression
    --------------- parsePostfixExpression
    ---------------- parseCorePostfixExpression
    ----------------- parsePrimaryExpression
    ------------------ parseNumericLiteral
    ------------- parseExpressionWithOperatorPrecedence
    ----------- parseInitializerClause0x
    ...

Task-number: QTCREATORBUG-14645
Change-Id: I8a71fd687e15a3a4ae26e7b9830276464e3fa76e
Reviewed-by: Erik Verbruggen <erik.verbruggen@theqtcompany.com>
2015-07-06 12:11:43 +00:00
Nikolai Kosjar
17a4e76c50 C++: Use MAX_EXPRESSION_DEPTH and increase to 1000
We do not want different depths for different ASTs.

Change-Id: Idc4aff226b20dbc5c14a77ef729b16044b55b837
Reviewed-by: Marco Bubke <marco.bubke@theqtcompany.com>
Reviewed-by: Erik Verbruggen <erik.verbruggen@theqtcompany.com>
2015-07-06 12:11:25 +00:00
Nikolai Kosjar
c9588aa877 C++: Add missing DEBUG_THIS_RULE() for Parser::parse*
Change-Id: Ic4d3ccd72618c512567140ea5af39ca0799cde3a
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2015-07-06 09:25:23 +00:00
Johannes Lorenz
2a966a8917 C++: Support ellipsis on variadic inheritance parsing
Change-Id: I571aefdb1f2aba88ba0c7710f16b6d8ad2e8f5a8
Reviewed-by: André Hartmann <aha_1980@gmx.de>
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
2015-06-02 08:24:17 +00:00
Nikolai Kosjar
e69d20e10b C++: Limit parsing of initializer clauses
...to prevent out of memory crash for generated tables.

Change-Id: I8f9f51829fcce5bccfe0dba8852023f8dd7d6e37
Task-number: QTCREATORBUG-14390
Reviewed-by: Eike Ziller <eike.ziller@theqtcompany.com>
Reviewed-by: Erik Verbruggen <erik.verbruggen@theqtcompany.com>
2015-05-13 08:26:07 +00:00
Francois Ferrand
1336502f58 C++: fix parsing nested C99 designated initializers.
Change-Id: Iaa0e7550abf6be77601b1852652bb3d0731d0323
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
2015-02-27 14:49:55 +00:00
Adam Strzelecki
425811291d C++: Basic support for C++11 user-defined literals
1. Extends lexer so digit or string can be followed by underscore '_' and
   alphanumeric defining literal.

2. Extends parser so it accepts operator"" _abc(...) user-defined literal
   definition.

3. Adds Token::Flags.userDefinedLiteral bool flag field representing if token
   carries user-defined literal.

4. Adds C++11 auto tests case with: 12_km, 0.5_Pa, 'c'_X, "abd"_L, u"xyz"_M

5. All optional suffix scanning methods now return boolean if the suffix was
   found.

6. Adds C++ Lexer tests for user-defined literals with C++11 feature enabled.

This change however does not make QtCreator understand user-defined literal
semantics, e.g. properly resolve type when applying custom literal operator.

Change-Id: I30e62f025ec9fb11c39261985ea4d772b1a80949
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
2015-02-17 09:45:34 +00:00
Nikolai Kosjar
921ec6da5a C++: Cache parsing of template ids
...in order to stop memory intensive parsing for invalid code.

Parsing the test data/snippet "hard" led to a memory consumption of
about 5.5MB and this could easily get up to hundreds/gigabytes by adding
some more "if_<bool_<true>,\n" lines. With the caching, we are at about
1.0MB, even if more lines are added.

The "memory consumption" was measured with valgrind-massif. The stated
numbers are the reported peaks.

Task-number: QTCREATORBUG-12890
Change-Id: Ie7eb00cfc7915552d29bb27410a6b13a486f486e
Reviewed-by: Erik Verbruggen <erik.verbruggen@theqtcompany.com>
2015-02-12 10:40:14 +00:00
Nikolai Kosjar
ae3aa07c4d C++: Remove workaround for crashing if parsing invalid code
This reverts the changes

    commit beac7b9539
    C++: Fix highlighting after "invalid code"

    commit 78ab287fc6
    C++: Stop parsing a declaration after two tries

which were a work around for QTCREATORBUG-12890.

A follow-up patch provides a proper fix.

Task-number: QTCREATORBUG-12890
Change-Id: I2650a8e41c8ff1180cad9f069e463fc51bd2f1b1
Reviewed-by: Erik Verbruggen <erik.verbruggen@theqtcompany.com>
2015-02-12 10:39:51 +00:00
Nikolai Kosjar
beac7b9539 C++: Fix highlighting after "invalid code"
For the semantic info document we do not expand function like macros and
because of that certain macro invocations lead to invalid code that we
need to handle, e.g.:

	Q_GLOBAL_STATIC(CppTools::SymbolFinder, symbolFinder)
	class Foo {};

This change makes parsing Foo in the semantic info document successfully
again, which affects highlighting of that class.

Change-Id: I389265ac64d3f0b8b8f406d38fa58d78820b14ba
Reviewed-by: Erik Verbruggen <erik.verbruggen@theqtcompany.com>
2014-11-19 16:10:56 +01:00
Nikolai Kosjar
78ab287fc6 C++: Stop parsing a declaration after two tries
If we fail to parse a declaration, we rewind, eat the token and look for the
next token that might be a good candidate for a declaration start (e.g. an
identifier). This becomes cpu and memory expensive with super long and invalid
expressions like

    typedef b::m::if_< b::m::bool_<
	(sizeof(fun((Dummy *) 0, (ThisT *) 0, (b::m::int_<70> *) 0)) ==
	 sizeof(defined_)) >, b::m::if_< b::m::bool_<
	(sizeof(fun((Dummy *) 0, (ThisT *) 0, (b::m::int_<71> *) 0)) ==
	 sizeof(defined_)) >, b::m::if_< b::m::bool_<
	(sizeof(fun((Dummy *) 0, (ThisT *) 0, (b::m::int_<72> *) 0)) ==
	 sizeof(defined_)) >, b::m::if_< b::m::bool_<
	(sizeof(fun((Dummy *) 0, (ThisT *) 0, (b::m::int_<73> *) 0)) ==
	 sizeof(defined_)) >, b::m::if_< b::m::bool_<
	(sizeof(fun((Dummy *) 0, (ThisT *) 0, (b::m::int_<74> *) 0)) ==
	 sizeof(defined_)) >, b::m::if_< b::m::bool_<
	(sizeof(fun((Dummy *) 0, (ThisT *) 0, (b::m::int_<75> *) 0)) ==
	 sizeof(defined_)) >, b::m::if_< b::m::bool_<
	// ...some more crazy lines like this

Therefore, stop trying after two failures by looking for the next semicolon or
closing curly brace.

Task-number: QTCREATORBUG-12890
Change-Id: I6637daeb840dd549d669080775228fa91fc932eb
Reviewed-by: Erik Verbruggen <erik.verbruggen@theqtcompany.com>
2014-11-18 13:46:34 +01:00
Nikolai Kosjar
390b4f0e0b C++: Fix parsing of "Foo *foo = new Foo()"
It should be parsed as an DeclarationStatement, but instead it was
parsed as an ExpressionStatement.

Regression introduced with

    commit d3c5fff66d.
    C++: Fix expensive parsing of expressions

The introduced ASTCache did not save the correct return value of a
parse* function. Because of that, the first return in
Parser::parseExpressionList returned false on the second invocation
(cache hit), instead of true, which resulted in an ExpressionStatement.

Task-number: QTCREATORBUG-13122
Change-Id: I8dbd8852b0909edddcd3195b484f4cea92328cc5
Reviewed-by: Fawzi Mohamed <fawzi.mohamed@digia.com>
2014-10-15 10:08:19 +02:00
Erik Verbruggen
4cfb7a62b7 C++: remove dead store.
Pointed out by the clang static analyzer.

Change-Id: I2d73d4c9ef2511c5697a4e4da89b61efb1149a3f
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2014-09-12 11:31:51 +02:00
Oswald Buddenhagen
f3a61e8bf7 Merge remote-tracking branch 'origin/3.2'
Conflicts:
	qtcreator.pri
	qtcreator.qbs
	src/plugins/android/androidglobal.h

Change-Id: I3367bf2ea47c088989175dddeed2210294346f4c
2014-08-05 14:24:23 +02:00
Tobias Hunger
c4eb09e9fb CppCheck: Fix fprintf format code to match unsigned type
Change-Id: Id4527ab5582294791b8db0c7ce9240e031a38bd7
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2014-08-05 10:52:17 +02:00
Nikolai Kosjar
d3c5fff66d C++: Fix expensive parsing of expressions
For expression statements like "(g(g(g(...(g(0))...))))" we reparsed
quite much again and again for nothing. The high-level trace for this
expression looks like this:

    parseCastExpression
      parseTypeId
        parseAbstractDeclarator
          parseAbstractCoreDeclarator
          parseParameterDeclarationClause (--> DEEP)
            ...

      parseUnaryExpression
        ...
        parseCorePostfixExpression
          parseTypeId (--> DEEP)
          parsePrimaryExpression (--> DEEP)

Especially parseTypeId is expensive in this case and it's called two
times, both from the same token (index).

With this patch, we remember for certain ASTs the parse results and
re-use them when needed.

Change-Id: I013d1c064c655636bc94db408097863b5e183fc2
Task-number: QTCREATORBUG-12252
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2014-07-24 12:06:50 +02:00
Nikolai Kosjar
20108a3d88 C++: Remove superfluous declarations in Parser
Change-Id: I6bf729a999494a84eb235a891ea14bbccd44aeb8
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2014-07-24 12:06:17 +02:00
Erik Verbruggen
45b1169d06 C++: Support alignas in C++11 mode.
Change-Id: Ifa81a481bf92b5b71495a105ae292f3e9895f704
Task-number: QTCREATORBUG-9279
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2014-07-22 16:43:51 +02:00
Eike Ziller
0374a9782e Merge remote-tracking branch 'origin/3.2' into HEAD
Change-Id: I257bb9310bb3bde493aff4cd43091ec63fcb5203
2014-07-22 16:11:40 +02:00
Erik Verbruggen
5d45e0b69a C++: block recursion when parsing subsequent case statements.
A case or a default statement must be followed by another statement.
When a such a case (or default) statement is followed immediately by
another case (or default) statement, then this would create a linked
list, and the parser will recurse to parse such input.

In order to prevent the parser running out of stack space while
recursing, parse this corner case by blocking parsing a labeled
statement as the first statement after a labeled statement.

The advantage is that these statements do not form a linked list, so any
subsequent visitation of the AST won't run out of stack space either.

Change-Id: Id2111a49509132997f5fbe4bb12c92c729ec2522
Task-number: QTCREATORBUG-12673
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2014-07-22 15:45:02 +02:00
Nikolai Kosjar
45fa5f9ccb C++: Add a clarifying comment and TODO
Change-Id: If6e6db7c4ca011159e78a27755ff9f665b179300
Reviewed-by: Wang Hoi <wanghoi@126.com>
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2014-07-04 12:16:38 +02:00
Orgad Shaneh
ea4b4bff40 C++: Split designator AST
Change-Id: I9bfed2023624c818c0f35f24476693cffeaf2bbc
Reviewed-by: Wang Hoi <wanghoi@126.com>
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2014-06-24 16:16:58 +02:00
Nikolai Kosjar
38b8940bd4 C++: Fix parsing designators vs lambdas
The introduction of C99 designators led to parsing problems with lambdas
that were passed in as a function arguments.

Fixed by prefering to parse without designators first. This will be
cleaner/clearer once the appropriate "LanguageFeatures" from the Project
Parts will be passed in.

Change-Id: Ia9cb7c4a4c9345e729cf2044e1e5411fe63e33ec
Reviewed-by: Wang Hoi <wanghoi@126.com>
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2014-06-24 16:14:40 +02:00
Wang Hoi
c56b999fff C: Parser: Support parsing of c99 designated initializers
In case:

    int a[6] = { [4] = 29, [2] = 15 };
    struct point { int x, y; };
    struct point p = { .y = 3, .x = 2 };

Grammar change when c99 language feature is enabled:
old grammar:

    braced-init-list :: '{' initializer-list '}'

new grammar:

    braced-init-list :: '{' designated-initializer-list '}'
    designated-initializer-list :: designated-initializer (',' designated-initializer )*
    designated-initializer :: designator* initializer-clause
    designator :: '.' identifier
                | '[' constant-expression ']'

Task-number: QTCREATORBUG-1902
Change-Id: Ib99d6f553f8d0f50ba3eff86f3a2e86d73372426
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2014-06-17 16:23:23 +02:00
Christian Kamm
e85c6f4b38 C++11: Fix parsing of expressions like vector<int>{1}.
The parser considers '{' an operator and thus thought
"template-id {" couldn't possibly be valid. This patch adds
'{' as an exception to the rule.

Change-Id: I40730fcdc5cade48566b4c8b6fde390f455bbdba
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2014-06-16 20:06:58 +02:00
Eike Ziller
2786250c17 Merge remote-tracking branch 'origin/3.1'
Conflicts:
	qtcreator.pri
	qtcreator.qbs
	src/shared/qbs

Change-Id: Iba59e41db72e2afdf594f1f7003215d7d8d1e6d3
2014-06-13 10:51:51 +02:00
Orgad Shaneh
d0f00cc29d C++: Whitespace fixes in parser
Change-Id: I409699225b5f42db7ecb6c2dc8d150c1a66ee23c
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2014-06-12 16:04:38 +02:00
Przemyslaw Gorszkowski
b90452e309 C++: fix nested anonymous with __attribute__
Task-number: QTCREATORBUG-12345
Change-Id: Ib2316ebdc81393b38185b9cb659fb85b78753e7b
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
Reviewed-by: Eike Ziller <eike.ziller@digia.com>
2014-06-06 15:38:02 +02:00
Christian Kamm
eee94667e6 C++11: Fix parsing of trailing-type-specifier.
In particular "auto foo() -> typename Foo<T>::X;" didn't parse.

Change-Id: I7665c9b387e222e4107f053a529d502813ebf617
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2014-06-04 09:17:56 +02:00
Nikolai Kosjar
349de9331c C++: Fix weird logic in usage of TopLevelDeclarationProcessor::processDeclaration
As the name function name suggests, true should be returned if the
declaration should be processed. Otherwise false.

Change-Id: I8d266d99c579b331fee8772bde47aa1a466dae9c
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2014-03-13 15:41:01 +01:00
Povilas Kanapickas
9528230bd3 C++: Remove dead code in the parser
CPlusPlus::Parser::parseAccessSpecifier() is not used anywhere
throughout the QtCreator codebase.

Change-Id: I062a4ae257b9c61f02bf85079feb6d48bd07c49e
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2014-01-20 16:30:06 +01:00
Povilas Kanapickas
3dbb1a9275 C++: Fix a typo in template declaration parser function
This is an obvious typo considering the checks at the beginning of the function.

Change-Id: I11b784153b650b02bba7bb942ca1131447a3da4a
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2014-01-20 16:29:46 +01:00
Orgad Shaneh
eac518aee6 C++: Support __thread and thread_local
Task-number: QTCREATORBUG-7679
Change-Id: I794f52b2bcfb6c78ceef86ec53b6ed32b3d53d9f
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2013-11-26 09:46:10 +01:00
Yuchen Deng
ef1645f43f Avoid warning when compilation with MSVC2013
warning: C4005: 'va_copy' : macro redefinition

Change-Id: Ib2bfd2229cb3ae00e084dd6df7a4558a5a766d55
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2013-11-12 08:39:38 +01:00
hjk
2b532c73ee CPlusPlus: Make (sub-)languague selection more generic
Change-Id: I4e2df6992b446adec662ab07671acd41715e41fd
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2013-10-15 16:22:28 +02:00
Nikolai Kosjar
0e4deaba23 C++: Parse MEMBER in Q_PROPERTY()
MEMBER was added in Qt5.

Task-number: QTCREATORBUG-10068

Change-Id: Ic6c15a0e5ee8981ab98e4c12fc1521dc281b731f
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2013-10-09 15:13:31 +02:00
Erik Verbruggen
c2d2173934 C++: Add parser support for @throw statements.
Change-Id: I366733ec821ee264f182f4d4a3cf69cdada20cfc
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2013-08-21 15:33:39 +02:00