mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-23 17:05:26 +02:00
Bug 464624 - C++ Parser fails with Syntax error on function declaration with __declspec and non-native type
Allow __declspec after identifier in decl-specifier. See https://docs.microsoft.com/en-us/cpp/cpp/declspec Change-Id: Ifdaeb649abcfa1b7391e2799072b1afbc07a16a1 Signed-off-by: Marc-Andre Laperle <malaperle@gmail.com>
This commit is contained in:
parent
3b8fcb62e7
commit
1278baf052
3 changed files with 15 additions and 4 deletions
|
@ -5433,6 +5433,17 @@ public class AST2Tests extends AST2TestBase {
|
||||||
parseAndCheckBindings(getAboveComment(), CPP, true);
|
parseAndCheckBindings(getAboveComment(), CPP, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//typedef struct _MyStruct {
|
||||||
|
//} MyStruct;
|
||||||
|
//
|
||||||
|
//MyStruct __declspec(dllexport) foo;
|
||||||
|
//MyStruct __declspec(dllexport) __declspec(deprecated) bar;
|
||||||
|
public void testDeclspecAfterDeclSpecifierIdentifier_464624() throws Exception {
|
||||||
|
for (ParserLanguage lang : ParserLanguage.values()) {
|
||||||
|
parseAndCheckBindings(getAboveComment(), lang, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// struct Outer {
|
// struct Outer {
|
||||||
// struct {int a1;};
|
// struct {int a1;};
|
||||||
// struct {int a2;} a3;
|
// struct {int a2;} a3;
|
||||||
|
|
|
@ -1162,8 +1162,8 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
throwBacktrack(LA(1));
|
throwBacktrack(LA(1));
|
||||||
attributes = CollectionUtils.merge(attributes, __attribute_decl_seq(true, false));
|
attributes = CollectionUtils.merge(attributes, __attribute_decl_seq(true, false));
|
||||||
break;
|
break;
|
||||||
case IGCCToken.t__declspec: // __declspec precedes the identifier
|
case IGCCToken.t__declspec:
|
||||||
if (identifier != null || !supportDeclspecSpecifiers)
|
if (!supportDeclspecSpecifiers)
|
||||||
throwBacktrack(LA(1));
|
throwBacktrack(LA(1));
|
||||||
__attribute_decl_seq(false, true);
|
__attribute_decl_seq(false, true);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -3579,8 +3579,8 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
throwBacktrack(LA(1));
|
throwBacktrack(LA(1));
|
||||||
attributes = CollectionUtils.merge(attributes, __attribute_decl_seq(true, false));
|
attributes = CollectionUtils.merge(attributes, __attribute_decl_seq(true, false));
|
||||||
break;
|
break;
|
||||||
case IGCCToken.t__declspec: // __declspec precedes the identifier
|
case IGCCToken.t__declspec:
|
||||||
if (identifier != null || !supportDeclspecSpecifiers)
|
if (!supportDeclspecSpecifiers)
|
||||||
throwBacktrack(LA(1));
|
throwBacktrack(LA(1));
|
||||||
attributes = CollectionUtils.merge(attributes, __attribute_decl_seq(false, true));
|
attributes = CollectionUtils.merge(attributes, __attribute_decl_seq(false, true));
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Add table
Reference in a new issue