Skip to content

Commit 9d23714

Browse files
committed
Added support for C functions with no parameter info
1 parent c429d67 commit 9d23714

File tree

7 files changed

+27
-1
lines changed

7 files changed

+27
-1
lines changed

src/c/ast/mod.rs

+6
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,12 @@ pub struct DeclarationSpecifiers {
321321
pub source: Source,
322322
}
323323

324+
impl DeclarationSpecifiers {
325+
pub fn is_empty(&self) -> bool {
326+
self.specifiers.is_empty() && self.attributes.is_empty()
327+
}
328+
}
329+
324330
impl From<&SpecifierQualifierList> for DeclarationSpecifiers {
325331
fn from(value: &SpecifierQualifierList) -> Self {
326332
let specifiers = value

src/c/translate/parameters.rs

+7
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@ pub fn has_parameters(parameter_type_list: &ParameterTypeList) -> bool {
1616
{
1717
return false; // Function has parameters `(void)`, which means no parameters
1818
}
19+
20+
if param.core.is_nothing()
21+
&& param.attributes.is_empty()
22+
&& param.declaration_specifiers.is_empty()
23+
{
24+
return false; // Treat function with `()` parameters as not having any parameters
25+
}
1926
}
2027

2128
!parameter_type_list.parameter_declarations.is_empty()

src/workspace/compile/module.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ pub fn compile_module_file<'a>(
5656

5757
let Some(settings) = settings else {
5858
return Err(Box::new(ErrorDiagnostic::new(
59-
"Module file is missing pragma section",
59+
"Module file is missing pragma section, consider adding `pragma => adept(\"3.0\")` at the top of your file",
6060
Source {
6161
key,
6262
location: Location { line: 1, column: 1 },

tests/c/0001/_.adept

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2+
pragma => adept("3.0")
3+

tests/c/0001/main.c

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
int main(void) {
3+
return 21;
4+
}

tests/c/0002/_.adept

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2+
pragma => adept("3.0")

tests/c/0002/main.c

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
int main() {
3+
return 21;
4+
}

0 commit comments

Comments
 (0)