Skip to content

Commit

Permalink
warning for meaningless class combinations
Browse files Browse the repository at this point in the history
1. Adds a generic new warning which is triggered when meaningless combination of class specifiers are used.

2. This commit adds code to trigger a warning for the following two cases:
- constant reference
- - not meaningful as as references always point to cells in PAWN (unlike C++ where it would help costly copies while guaranteeing to not modify the object) which makes const reference is as good as pass-by-value
- constant variable arguments
- - for similar reasons as in the previous case
  • Loading branch information
YashasSamaga committed Jan 7, 2018
1 parent 97586a7 commit 2a16a6d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 4 additions & 0 deletions source/compiler/sc1.c
Original file line number Diff line number Diff line change
Expand Up @@ -3868,6 +3868,8 @@ static int declargs(symbol *sym,int chkshadow)
case '&':
if (ident!=iVARIABLE || numtags>0)
error(1,"-identifier-","&");
if (fconst)
error(238, "const reference"); /* meaningless combination of class specifiers */
ident=iREFERENCE;
break;
case tCONST:
Expand Down Expand Up @@ -3942,6 +3944,8 @@ static int declargs(symbol *sym,int chkshadow)
case tELLIPS:
if (ident!=iVARIABLE)
error(10); /* illegal function or declaration */
if (fconst)
error(238, "const variable arguments"); /* meaningless combination of class specifiers */
if (numtags==0)
tags[numtags++]=0; /* default tag */
if ((sym->usage & uPROTOTYPED)==0) {
Expand Down
3 changes: 2 additions & 1 deletion source/compiler/sc5.c
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,8 @@ static char *warnmsg[] = {
/*234*/ "function is deprecated (symbol \"%s\") %s\n",
/*235*/ "public function lacks forward declaration (symbol \"%s\")\n",
/*236*/ "unknown parameter in substitution (incorrect #define pattern)\n",
/*237*/ "user warning: %s\n"
/*237*/ "user warning: %s\n",
/*238*/ "meaningless combination of class specifiers (%s)\n"
};

#define NUM_WARNINGS (sizeof warnmsg / sizeof warnmsg[0])
Expand Down

0 comments on commit 2a16a6d

Please sign in to comment.