Skip to contentSkip to conversation

Remove redundant YYLOC global declaration

PATCH Applied Dirk Mueller 2 participants 2 messages Jan 14, 2020 – Jan 16, 2020 1 message not in the archive

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Remove redundant YYLOC global declaration

gcc 10 will default to -fno-common, which causes this error at link time:

(.text+0x0): multiple definition of `yylloc'; dtc-lexer.lex.o (symbol from plugin):(.text+0x0): first defined here

This is because both dtc-lexer as well as dtc-parser define the same global symbol yyloc. Before with -fcommon those were merged into one defintion. The proper solution would be to to mark this as "extern", however that leads to:

dtc-lexer.l:26:16: error: redundant redeclaration of 'yylloc' [-Werror=redundant-decls]

   26 | extern YYLTYPE yylloc;
      |                ^~~~~~
In file included from dtc-lexer.l:24:
dtc-parser.tab.h:127:16: note: previous declaration of 'yylloc' was here
  127 | extern YYLTYPE yylloc;
      |                ^~~~~~

cc1: all warnings being treated as errors

which means the declaration is completely redundant and can just be dropped.

---
 dtc-lexer.l | 1 -
 1 file changed, 1 deletion(-)
dtc-lexer.l +0 -1
index 5c6c3fd..b3b7270 100644
@@ -23,7 +23,6 @@ LINECOMMENT	"//".*\n
 #include "srcpos.h"
 #include "dtc-parser.tab.h"
 
-YYLTYPE yylloc;
 extern bool treesource_error;
 
 /* CAUTION: this will stop working if we ever use yyless() or yyunput() */
Signature · 1 line
2.24.1

A message that is not in the archive (sent off-list or not yet received): 20200114175341.2994-1-dmueller-IBi9RG/[email protected]

Applied
#2 lore raw
Quoted 17 lines · Dirk Mueller

gcc 10 will default to -fno-common, which causes this error at link time:

(.text+0x0): multiple definition of `yylloc'; dtc-lexer.lex.o (symbol from plugin):(.text+0x0): first defined here

This is because both dtc-lexer as well as dtc-parser define the same global symbol yyloc. Before with -fcommon those were merged into one defintion. The proper solution would be to to mark this as "extern", however that leads to:

dtc-lexer.l:26:16: error: redundant redeclaration of 'yylloc' [-Werror=redundant-decls]

   26 | extern YYLTYPE yylloc;
      |                ^~~~~~
In file included from dtc-lexer.l:24:
dtc-parser.tab.h:127:16: note: previous declaration of 'yylloc' was here
  127 | extern YYLTYPE yylloc;
      |                ^~~~~~
Quoted 6 lines

cc1: all warnings being treated as errors

which means the declaration is completely redundant and can just be dropped.

Applied, thanks.

Quoted 16 lines
---
 dtc-lexer.l | 1 -
 1 file changed, 1 deletion(-)
dtc-lexer.l +0 -1
index 5c6c3fd..b3b7270 100644
@@ -23,7 +23,6 @@ LINECOMMENT	"//".*\n
 #include "srcpos.h"
 #include "dtc-parser.tab.h"
 
-YYLTYPE yylloc;
 extern bool treesource_error;
 
 /* CAUTION: this will stop working if we ever use yyless() or yyunput() */
Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson