Skip to content

Validate conflicting declaration specifiers (e.g. long short int) - #111

Merged
praeclarum merged 2 commits into
masterfrom
copilot/fix-conflicting-declaration-specifiers
Mar 31, 2026
Merged

Validate conflicting declaration specifiers (e.g. long short int)#111
praeclarum merged 2 commits into
masterfrom
copilot/fix-conflicting-declaration-specifiers

Conversation

Copilot AI commented Mar 31, 2026

Copy link
Copy Markdown
Contributor

MakeCType() silently concatenated size specifiers ("long" + "short""long short"), and CIntType accepted the garbage string without complaint.

Changes

  • EmitContext.cs: After collecting size specifiers, validate the result is one of "", "short", "long", "long long". Also reject size modifiers on float/bool, and short double (while allowing long double). Reports error 2078.

  • DeclarationTests.cs: 10 new tests covering invalid combos (long short int, short float, short double, long bool, etc.) and valid edge cases (long double, long long int).

long short int x = 0;  // now error C2078: Invalid combination of type specifiers
long double y = 1.0;   // still valid

… int)

Validate size specifier combinations in EmitContext.MakeCType():
- Reject invalid combinations like "long short", "short short"
- Reject size modifiers with float and bool types
- Reject "short" with double (only "long double" is valid)
- Report error 2078 for invalid combinations

Add tests for all invalid combinations and valid edge cases.

Agent-Logs-Url: https://github.com/praeclarum/CLanguage/sessions/89ed26c4-8632-4e43-a058-f53924ce4c90

Co-authored-by: praeclarum <323548+praeclarum@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix validation of conflicting declaration specifiers Validate conflicting declaration specifiers (e.g. long short int) Mar 31, 2026
Copilot AI requested a review from praeclarum March 31, 2026 20:12
@praeclarum
praeclarum marked this pull request as ready for review March 31, 2026 20:25
@praeclarum
praeclarum merged commit 2085e51 into master Mar 31, 2026
1 check passed
@praeclarum
praeclarum deleted the copilot/fix-conflicting-declaration-specifiers branch March 31, 2026 20:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

No validation of conflicting declaration specifiers (e.g. long short int)

2 participants